Visual Studio:发布版本中的调试信息 [英] Visual Studio: debug information in release build

查看:174
本文介绍了Visual Studio:发布版本中的调试信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将调试信息包含在我的发布版本中,出现在客户端。据我所知,二进制文件大小只有25%的增加。优点是可以立即获得可用的崩溃转储,更容易分析。
我愿意增加25%的生活。我有没有其他的缺点?



这是一个C项目,所有我想做的是链接/调试/生成调试信息

解决方案

可执行文件的大小应增加远远小于25%。我实际上有点惊讶,它增加了很多,但一些快速测试显示,至少有一个大型示例项目(ScummVM)从10,205,184增加了.exe字节到10,996,224字节,只需将 / DEBUG 选项添加到链接步骤(增加约8%)。使用IDE中的链接器|调试|生成调试信息选项指定 / DEBUG 请注意,这个设置应该对编译器生成的优化没有影响。



我知道指向.pdb文件的指针在可执行文件中,但没有太多的可执行文件。我尝试了一下,发现启用 / OPT:NOREF 链接器选项将大小差异更改为10,205,184与10,205,696。所以非 / DEBUG build保持不变,但是$ / DEBUG build只下降到512字节以上可以通过指向.pdb的指针来解释 - 可能链接器会回到512的一些倍数或某些东西)。增加不到1%。显然,添加 / DEBUG 会导致链接器保留未引用的对象,除非您还指定了 / OPT:NOREF 。 (IDE中的Linker | Optimization | References选项)



程序运行正常,没有。 pdb文件 - 如果要在客户站点提供更好的调试体验,您可以选择将其发送给客户。如果您只想获得体面的堆栈跟踪,则不需要在客户机上拥有.pdb文件 - 它们(或您提供的某些工具/功能)可以发送一个可以加载到您的站点上的调试器可以使用.pdb文件,并获得相同的堆栈跟踪信息port-mortem。



当然需要注意的一点是,您需要将.pdb文件与发行版一起存档。 调试工具Windows软件包(现在分布在Windows SDK中)提供了符号服务器工具,因此您可以存档.pdbs并轻松地检索它们进行调试。



我可以想到的分发.pdb文件的唯一缺点是,它可以使您的应用程序更容易逆向工程,如果这是您的关注。请注意,Microsoft为Windows分配符号(使用公共符号服务器以及某些特定版本的完整符号集的包)。然而,他们分发的符号可以通过消毒步骤来消除他们认为敏感的某些项目。您可以使用链接器的 / PDBSTRIPPED 选项(Linker | Debugging | Strip Private Symbols在IDE中)。有关该选项删除的详细信息,请参阅 MSDN文档。如果您要分发符号,则可能使用该选项。


I'm tempted to include debug information in my release builds that go out to customers. As far as I see the only down side is 25% increase in the binary file size. The advantage is that I can get an immediately usable crash dump, much easier to analyze. I'm willing to live with the 25% increase. Are there any other disadvantages I'm missing?

This is a C project and all I want to do is Linked/Debugging/Generate Debug Info

解决方案

The size of the executable should increase much less than 25%.

I'm actually a little surprised that it increases much at all, but some quick tests show that at least one large example project (ScummVM) increases the .exe from 10,205,184 bytes to 10,996,224 bytes just by adding the /DEBUG option to the link step (about an 8% increase). /DEBUG is specified using the "Linker | Debugging | Generate Debug Info" option in the IDE. Note that this settings should have no effect on the optimizations generated by the compiler.

I know that a pointer to the .pdb file is put in the executable, but there's not much to that. I experimented a bit and found that enabling the /OPT:NOREF linker option changed the size difference to 10,205,184 vs. 10,205,696. So the non /DEBUG build stayed the same size, but the /DEBUG build dropped to only 512 bytes larger (which could be accounted for by the pointer-to-.pdb - maybe the linker rounds to some multiple of 512 or something). Much less than 1% increase. Apparently, adding /DEBUG causes the linker to keep unreferenced objects unless you also specify /OPT:NOREF. ("Linker | Optimization | References" option in the IDE).

The program will run fine without the .pdb file - you can choose to send it to customers if you want to provide a better debugging experience at the customer site. If you just want to be able to get decent stack traces, you don't need to have the .pdb file on the customer machine - they (or some tool/functionality you provide) can send a dump file which can be loaded into a debugger at your site with the .pdb file available and get the same stack trace information port-mortem.

One thing to of course be aware of is that you'll need to archive the .pdb files along with your releases. The "Debugging Tools for Windows" package (which is now distributed in the Windows SDK) provides a symbol server tool so you can archive .pdbs and easily retrieve them for debugging.

The only drawback that I can think of to distributing .pdb files is that it can make reverse engineering your application easier, if that's a concern for you. Note that Microsoft distributes symbols for Windows (using a public symbol server - as well as packages of the full symbols sets for some specific releases). However, the symbols they distribute do get run through a sanitizing step that removes certain items they consider sensitive. You can do the same (or similar) using the linker's /PDBSTRIPPED option ("Linker | Debugging | Strip Private Symbols" in the IDE). See the MSDN docs for details on what the option removes. If you're going to distribute symbols, it's probably appropriate to use that option.

这篇关于Visual Studio:发布版本中的调试信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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