Visual Studio 2008 Breakpoint will not be hit
I have a bug that only occurs in release mode, which is a problem because I am not able to regularly debug my code. The breakpoint says "The breakpoint will not currently be hit. No symbols have been loaded for this document." I have tried many of the other solutions people have posted about this problem, but none of them seem to work for release mode. Are there any suggesti开发者_高级运维ons on how to find a bug in release mode or how to regularly debug code in release mode?
You need to enable debug symbols in your project.
If this is a C++ Project, you need to do 2 things to get debug info:
1) In the "Project Settings" under "Configuration Properties" -> "C/C++" -> "General", you need to set "Debug Information Format" to "Program Database (/Zi)".
2) In the "Project Settings" under "Configuration Properties" -> "Linker" -> "Debugging" make sure you set the "Generate Debug Info" to "Yes (/DEBUG)".
Then, the build (compile and link) process will generate a PDB with debug info... typically next to your exe file but with a pdb extension.
Now when you run the project from Visual Studio, you should be able to debug and set breakpoints.
Other languages have similars settings although in slightly different locations.
By default, the release configuration does not build a .pdb file (which contains the symbols that cannot be loaded). You can enable this option in your project properties. Also be aware that your code will be optimized, by default. This can affect breakpoints, so often, when I am debugging release builds, I will create several breakpoints (Since your symbols cannot be loaded, this is not your problem... yet).
If you are running the on the same computer that built the program, then it will usually find the .pdb file and source code. If not, make sure that the .pdb file is in the same directory as your .exe so the runtime/debugger can find the symbols.
精彩评论