如何在释放模式下调试? [英] How to debug in release mode?
问题描述
我必须调试一个c ++项目,但因为一个依赖项不编译在调试模式,我还没有能够解决这个问题,到目前为止,我想尝试调试项目在发布模式。
I have to debug a c++ project, but as one dependency doesn't compile in debug mode and I haven't been able to fix that issue so far, I'd like to try to debug the project in release mode.
目前应用程序由于空指针而崩溃,但我没有导致错误的代码。由于断点显然在发布模式中被忽略,我想知道什么是找到错误的最好方法。
Currently the application crashes due to a null pointer, but I haven't the code that's causing the error. As break points apparently are ignored in release-mode, I'd like to know what's the best way find the error.
推荐答案
在VS中,右键单击您的项目,选择属性。
In VS, right click your project, chose "Properties".
-
单击C / C ++节点。将调试信息格式设置为C7兼容(/ Z7)或程序数据库(/ Zi)。
Click the C/C++ node. Set Debug Information Format to C7 compatible (/Z7) or Program Database (/Zi).
展开链接器并单击常规节点。将启用增量链接设置为否(/ INCREMENTAL:NO)。
Expand Linker and click the General node. Set Enable Incremental Linking to No (/INCREMENTAL:NO).
选择调试节点。将生成调试信息设置为是(/ DEBUG)。
Select the Debugging node. Set Generate Debug Info to Yes (/DEBUG).
选择优化节点。
如果指定了/ OPT:REF,/ OPT:ICF默认打开。
if /OPT:REF is specified, /OPT:ICF is on by default.
直接从Microsoft的文档中撕下:
That's ripped directly from Microsoft's documentation:
- How to: Debug a Release Build
- OPT Optimizations
我所有的时间都这样做,几乎从不在调试模式下调试。如你所知,在调试版本中可能不会发生版本构建中发生的许多错误(几乎肯定是调用UB时产生的错误)。
I do this all of the time and pretty much never debug in debug mode anymore. As you know, many errors that occur in a release build may not occur in a debug build (almost certainly the errors that arise from invoking UB).
此外,我在一个项目中使用了大量的图像处理,并执行大量图像的大量压缩/解压缩。使用慢速调试版本是不切实际的。
Also, I work on a project which uses a ton of image processing and performs a lot of compression/decompression of large images. Using a slow debug build is simply impractical.
这篇关于如何在释放模式下调试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!