Make my release build a debug build
If you are in the process of development and then you notice a crash while testing release build and you don’t know where the crash is taking place, do the following…
- Enable debugging for your release builds
- Go to C-C++/Optimizations/ and select Disable(Debug). If you don’t enable this bit you will see weird behavior while debugging. For e.g. addresses show as NULL even for valid objects on stack. By the way this might even be the cause of those crashes so initially you can leave it as it is but watch out for weird behaviors, don’t be surprised.
- Go to C-C++/Debug Info/ and select Program Database, this will generate a pdb file.
- If the output for a particular project is of .lib type then this much will suffice.
- Now for dlls and exes, follow steps 1 - 3.
- Go to Link tab/section and enable “Generate debug info”, this will add further debugging information to your exe or dll. Will show real deep stack traces with values of passed in parameters.
Yup now your release exe/dll/lib is now in full fledged debugging form. An additional thing to note is that _DEBUG is not enabled so AfxTrace, TRACE, TRACE0, TRACE1, TRACE2, ASSERTs, and VERIFYs won’t work.