-
August 27th, 2013, 12:38 AM
#1
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?
-
August 27th, 2013, 02:52 AM
#2
Re: Debug & release mode
Originally Posted by manjut19
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
Originally Posted by manjut19
Can i do debug operation on release mode?
Yes, you can. See How to: Debug a Release Build
Originally Posted by manjut19
I tryed to debug in release mode,But valuse showing is not correct.How to solve this problem?
Fix your bugs.
Victor Nijegorodov
-
August 29th, 2013, 12:19 AM
#3
Re: Debug & release mode
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 writtenAdd 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.
-
August 29th, 2013, 01:26 PM
#4
Re: Debug & release mode
Originally Posted by manjut19
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
-
September 11th, 2013, 01:48 AM
#5
Re: Debug & release mode
Originally Posted by Paul McKenzie
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?
-
September 11th, 2013, 06:22 AM
#6
Re: Debug & release mode
Originally Posted by manjut19
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
-
September 12th, 2013, 01:10 AM
#7
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.
-
September 12th, 2013, 01:33 AM
#8
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
-
September 12th, 2013, 01:41 AM
#9
Re: Debug & release mode
Originally Posted by manjut19
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
-
September 12th, 2013, 01:57 AM
#10
Re: Debug & release mode
Originally Posted by Igor Vartanov
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)
-
September 12th, 2013, 02:54 AM
#11
Re: Debug & release mode
Originally Posted by manjut19
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
-
September 12th, 2013, 04:42 AM
#12
Re: Debug & release mode
Originally Posted by VictorN
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?
-
September 12th, 2013, 04:52 AM
#13
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
-
September 12th, 2013, 06:26 AM
#14
Re: Debug & release mode
Originally Posted by manjut19
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
-
September 12th, 2013, 06:33 AM
#15
Re: Debug & release mode
Originally Posted by manjut19
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. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|