Question

When debugging in release, c++ code doesn't expand certain variables. What are the kind of variables that cant be expanded and why so? I can understand that a release dll has been packaged with extra optimizations but not quite sure if this is the only reason. Also is there anything that can be done to view those values

Was it helpful?

Solution

Even assuming that you have debug information in the build, debugging a release build (optimized) is hard in general. The optimizer can mangle the result of the code up to a point you might not recognize it.

It will remove variables altogether and hide them from the debugger (since the variable is not there, the debugger cannot show them). It might not remove it, but reuse the space for register spills temporarily and you will see the value of the memory where your variable is jumping to some random value. The flow might be reordered and the variable might be and have the right value once initialized, but initialization might have been pushed further down and not yet executed...

If you can reproduce the issue in a debug build, I'll start there. If not, good luck. Don't trust anything you see, but try to extract as much information as you can from the data points you have available.

OTHER TIPS

When you build in "Debug" mode, then the compiler (and linker) adds extra information about things like variables, their names, the source files used, line number information, etc. This is missing when compiling in "Release" mode. It can be added though, by changing it in the project settings.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top