visual-studio Visual C++ 2008 'Release' 版本包含调试信息

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/218226/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 09:47:53  来源:igfitidea点击:

Visual C++ 2008 'Release' build contains debug information

c++visual-studiodebugging

提问by Rob

I've noticed that when generating a new C++ project using MS Visual Studio 2008, the Releasebuild contains debugging symbols - specifically the following settings are enabled:

我注意到在使用 MS Visual Studio 2008 生成新的 C++ 项目时,发布版本包含调试符号 - 特别是启用了以下设置:

  • The C++/General/Debug Information Format is set to Program Database.
  • The Linker/Debugging/Generate Debug Info setting is set to Yes.
  • C++/General/Debug Information Format 设置为Program Database
  • Linker/Debugging/Generate Debug Info 设置设置为Yes

I have never noticed this on earlier releases of Visual Studio.

我从未在 Visual Studio 的早期版本中注意到这一点。

So, other than generating a larger EXE file, is there any downside to leaving these settings enabled?

那么,除了生成更大的 EXE 文件之外,启用这些设置还有什么缺点吗?

回答by Karim

We have turned on those settings in our commercial releases for years now with no apparent downside. The upsides are enormous,though.

多年来,我们一直在商业版本中启用这些设置,没有明显的缺点。不过,好处是巨大的。

We have integrated a crash dump packager that packages the dump along with some other information and emails it (with the user's consent) to a company inbox. This has helped us find problems that would have taken us foreverto reproduce and find otherwise.

我们已经集成了一个故障转储打包程序,它将转储与一些其他信息一起打包,并通过电子邮件(在用户同意的情况下)发送到公司收件箱。这帮助我们找到了需要我们永远重现和发现其他问题的问题。

Although it's slightly off topic, here's a link to an excellent contribution someone made that gives you an easy way to include a crash reporter to a C++/Windows app: http://www.codeproject.com/KB/debug/crash_report.aspx

虽然它有点偏离主题,但这里有一个链接,指向某人所做的出色贡献,它为您提供了一种将崩溃报告器包含到 C++/Windows 应用程序的简单方法:http: //www.codeproject.com/KB/debug/crash_report.aspx

Note: It would be wise, though, not to include the PDB file with your release. That said, you must keep the PDB file that matches your released version so that you can correctly debug the problem in the future. If a PDB file is used that wasn't built with the same code that built the exe, the stack you see when you try to debug the dmp will be wrong.

注意:不过,最好不要在您的版本中包含 PDB 文件。也就是说,您必须保留与您发布的版本匹配的 PDB 文件,以便您将来可以正确调试问题。如果使用的 PDB 文件不是使用构建 exe 的相同代码构建的,则您在尝试调试 dmp 时看到的堆栈将是错误的。

回答by Jay Bazuzi

They're turned on by default because:

默认情况下它们是打开的,因为:

  1. If you don't create them now, you can't create them later.
  2. You need them.
  1. 如果您现在不创建它们,以后就无法创建它们。
  2. 你需要他们。

Enabling debug info in Visual C++ causes a small entry to be added to the binary header, identifying the PDB for this binary. It's too small to be of any size concern, and doesn't contain any useful secrets that you might be concerned about sharing.

在 Visual C++ 中启用调试信息会导致向二进制标头添加一个小条目,标识此二进制文件的 PDB。它太小了,不会有任何大小问题,并且不包含任何您可能会担心共享的有用秘密。

(The header entry is labeled RSDS: who can guess why?)

(标题条目标有 RSDS:谁能猜到原因?)

Of course, those PDBs will use more disk space on your build machine / in your backups. Deal with it. You need those PDBs when it comes time to debug something.

当然,这些 PDB 将在您的构建机器上/在您的备份中使用更多的磁盘空间。处理它。当需要调试某些东西时,您需要这些 PDB。

回答by Sam

Well, you might deliver this debug information and someone might use it to disassemble your code. For some fearful people this alone might be a reason not to leave it this way.

好吧,您可能会提供此调试信息,而有人可能会使用它来反汇编您的代码。对于一些害怕的人来说,仅此一点可能就是不这样做的原因。

Personally, I think sometimes it's helpful to have debug information available for the release version - this way it is far easier to analyse a crashdump, that will be stored by Dr. Watson in case of application crashes.
I did find some really obscure bugs this way.

就我个人而言,我认为有时为发布版本提供调试信息会很有帮助——这样分析故障转储要容易得多,在应用程序崩溃的情况下,将由 Dr. Watson 存储。
我确实通过这种方式发现了一些非常晦涩的错误。

回答by Dave Van den Eynde

Having these options on do not necessarily make your executables bigger. Debug information is stored in a separate file, with the extension PDB. Having debug information available is never a bad idea, unless you're really really short on free storage space.

启用这些选项并不一定会使您的可执行文件更大。调试信息存储在一个单独的文件中,扩展名为 PDB。提供调试信息从来都不是一个坏主意,除非您真的很缺乏可用存储空间。

Perhaps that's why they're on by default: they don't harm your executables. Release builds do use optimizations such as function inlining and generating optimized code, which makes it harder to step through, while Debug builds have these options turned off.

也许这就是它们默认开启的原因:它们不会损害您的可执行文件。发布版本确实使用了诸如函数内联和生成优化代码之类的优化,这使得单步执行变得更加困难,而调试版本则关闭了这些选项。

No downside here.

这里没有缺点。

Dave

戴夫

回答by Dave Van den Eynde

Add the /Zi switch does make a larger .exe file in addition to the PDB. However you can seperately link with /OPT:REF to keep the .exe file size to a minimum.

除了 PDB 之外,添加 /Zi 开关确实会生成更大的 .exe 文件。但是,您可以单独链接 /OPT:REF 以将 .exe 文件大小保持在最小。

回答by MSN

The .exe will be slightly larger due to a reference to the .pdb file (i.e., an extra path). That's about it.

由于引用了 .pdb 文件(即额外的路径),.exe 会稍大一些。就是这样。