如何在发布模式下调试? [英] How to debug in release mode?

查看:18
本文介绍了如何在发布模式下调试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须调试一个 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".

  1. 单击 C/C++ 节点.将调试信息格式设置为 C7 兼容 (/Z7) 或程序数据库 (/Zi).

  1. 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).

Select the Optimization node. Set References to Yes (/OPT:REF).

如果指定了/OPT:REF,则/OPT:ICF 默认开启.

if /OPT:REF is specified, /OPT:ICF is on by default.

这是直接从微软的文档中撕下来的:

That's ripped directly from Microsoft's documentation:

我一直这样做,几乎不再在调试模式下调试了.如您所知,发布版本中发生的许多错误可能不会发生在调试版本中(几乎可以肯定是调用 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆