Debug & release mode
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 15

Thread: Debug & release mode

  1. #1
    Join Date
    Apr 2013
    Posts
    77

    Debug & release mode

    One of my win32 application working fine in debug mode.but malfunctioning in release mode.Can i do debug operation on release mode?I tryed to debug in release mode,But valuse showing is not correct.How to solve this problem?

  2. #2
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,415

    Re: Debug & release mode

    Quote Originally Posted by manjut19 View Post
    One of my win32 application working fine in debug mode.but malfunctioning in release mode.
    Well, you are not the first having such a problem. See Surviving the Release Version

    Quote Originally Posted by manjut19 View Post
    Can i do debug operation on release mode?
    Yes, you can. See How to: Debug a Release Build

    Quote Originally Posted by manjut19 View Post
    I tryed to debug in release mode,But valuse showing is not correct.How to solve this problem?
    Fix your bugs.
    Victor Nijegorodov

  3. #3
    Join Date
    Apr 2013
    Posts
    77

    Re: Debug & release mode

    Well, you are not the first
    Yes, you can. See How to: Debug a Release Build
    I made changes on Project property to debug my relaese build,But still i am not getting the correct values for the variable,
    Suppose i have written
    Code:
    int a=10;
    Add watch for a will show zero,Like that happening,Second thing,Now i canot debug my debug build one.What to do, i am entirely stucked.Please help me
    Last edited by manjut19; August 29th, 2013 at 12:40 AM.

  4. #4
    Join Date
    Apr 1999
    Posts
    27,429

    Re: Debug & release mode

    Quote Originally Posted by manjut19 View Post
    I made changes on Project property to debug my relaese build,But still i am not getting the correct values for the variable,
    Did you turn off optimizations? If you're debugging an optimized build, then the code that you're running is not going to match your source code.

    You need to disable optimizations and rebuild your application.

    Regards,

    Paul McKenzie

  5. #5
    Join Date
    Apr 2013
    Posts
    77

    Re: Debug & release mode

    Quote Originally Posted by Paul McKenzie View Post
    Did you turn off optimizations? If you're debugging an optimized build, then the code that you're running is not going to match your source code.

    You need to disable optimizations and rebuild your application.

    Regards,

    Paul McKenzie
    Now i disabled Optimization in my release version,So i can debug my release build,But then i have a doubt , what is the use of debug mode,if we can directly debug and trace the problem from release build?

  6. #6
    Join Date
    Apr 1999
    Posts
    27,429

    Re: Debug & release mode

    Quote Originally Posted by manjut19 View Post
    Now i disabled Optimization in my release version,So i can debug my release build,But then i have a doubt , what is the use of debug mode,if we can directly debug and trace the problem from release build?
    You are getting confused with what a "debug" build is.

    All you're doing when you turn on debugging is generating the necessary information to generate .PDB file. That PDB file is then matched with the source code. You can turn on debug symbols for any configuration, whether it is called "Release", "debug", "ReleaseWithMyOwnStuffAdded", etc. Similarly, you can turn off debugging when you choose the "Debug" configuration.

    Now, when the preprocessor symbol "DEBUG" is defined, it pulls in extra code that allows heap analysis, checking for invalid pointers etc. That's all -- nothing else. It doesn't turn on or off generating information necessary for the debugger to work. That is done in the Linker and Compiler options for Debugging.

    Regards,

    Paul McKenzie

  7. #7
    Join Date
    Apr 2013
    Posts
    77

    Re: Debug & release mode

    Ok.I didn't understand completely what is debugging,any how i got a brief idea.Now my application working fine with development system .But same application(Release build with optimization enabled/Disabled )running on other PC(other than developmentPC)misbehaving.Please give me some solution,What may be the reason for that?
    Last edited by manjut19; September 12th, 2013 at 01:18 AM.

  8. #8
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,415

    Re: Debug & release mode

    There may be a lot of...
    Different environments, working directories, and so on.
    Do you, for example, open some file using its relative or some hard coded path?
    In any case you have to check the return values of all the APIs you call and signal somehow if they failed...

    See more here
    Victor Nijegorodov

  9. #9
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    5,990

    Re: Debug & release mode

    Quote Originally Posted by manjut19 View Post
    Please give me some solution,What may be the reason for that?
    The only reason is: your code has a bug, or several ones.

    The only possible solution is: you identify your bugs and fix those.
    Best regards,
    Igor

  10. #10
    Join Date
    Apr 2013
    Posts
    77

    Re: Debug & release mode

    Quote Originally Posted by Igor Vartanov View Post
    The only reason is: your code has a bug, or several ones.

    The only possible solution is: you identify your bugs and fix those.

    Bug should show while debugging time right? iam not getting any bug in debugging time.(Release build)

  11. #11
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,415

    Re: Debug & release mode

    Quote Originally Posted by manjut19 View Post
    Bug should show while debugging time right? iam not getting any bug in debugging time.(Release build)
    The fact you are "not getting any bug in debugging time" does NOT mean "there is no any bug".
    It only means you have tested your code not good enough!
    Victor Nijegorodov

  12. #12
    Join Date
    Apr 2013
    Posts
    77

    Re: Debug & release mode

    Quote Originally Posted by VictorN View Post
    The fact you are "not getting any bug in debugging time" does NOT mean "there is no any bug".
    It only means you have tested your code not good enough!
    How to trace such bugs?

  13. #13
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,415

    Re: Debug & release mode

    At first you must locate it. Where in your code does it happen?
    What is the exact error message? Address?
    Sometimes you can finf this info in the Windows event viewer.
    Victor Nijegorodov

  14. #14
    Join Date
    Apr 1999
    Posts
    27,429

    Re: Debug & release mode

    Quote Originally Posted by manjut19 View Post
    Ok.I didn't understand completely what is debugging,any how i got a brief idea.Now my application working fine with development system .But same application(Release build with optimization enabled/Disabled )running on other PC(other than developmentPC)misbehaving.
    You have never heard of an application that works in the shop, but fails at a customer's site? You've never read the release notes of various applications, and find that they have fixed bugs (usually identified by other users)?

    Just because a program works on your PC means nothing except you have an expectation that it should work on another PC. But nothing guarantees it working -- that's why you see the cases I mentioned above.

    Unlike most other computer languages, when you make a mistake in a C++ program, there is no guarantee how your program will behave. For example, if you don't check the return values for functions and you expect the function to always work, what happens when that function returns a failure value? Since you didn't check the return value, your program then goes on the path that things are OK when they are not OK.

    What if you don't initialize your variables? What if that uninitialized variable just happens by luck be 0 every time you run it on your machine, and thus your program "works"? However on another machine that uninitialized variable value is -748932478. Then your program fails.

    These are just a few of the scenarios that cause applications to fail. There are many more, and you must have the expectations that these things will happen and be prepared to debug as best as possible these scenarios.

    Regards,

    Paul McKenzie

  15. #15
    Join Date
    Dec 2012
    Location
    England
    Posts
    2,450

    Re: Debug & release mode

    Quote Originally Posted by manjut19 View Post
    Ok.I didn't understand completely what is debugging,any how i got a brief idea.Now my application working fine with development system .But same application(Release build with optimization enabled/Disabled )running on other PC(other than developmentPC)misbehaving.Please give me some solution,What may be the reason for that?
    Does the program misbehave on all other pcs apart from your development system - or works on some pcs but not all?

    What do you mean by 'misbehave'?

    Apart from suggestions from Paul, Victor and Ignor, another possible reason could be buffer overflow, memory corruption etc from a bug in the program not picked up during debugging. Just because a program 'works' on one pc doesn't necessarily mean that the program will work on other pcs!
    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center