我是否应该将调试信息编译为“完整”版本?或“仅限 pdb”?
在 Visual Studio for a C# 项目中,如果转到“项目属性”>“构建>高级>调试信息您有三个选项:none
、full
或 pdb-only
。
哪种设置最适合发布版本?
那么,full
和 pdb-only
之间有什么区别?
如果我使用 full
会对性能产生影响吗?如果我使用 pdb-only
调试生产问题会更困难吗?
In Visual Studio for a C# project, if you go to Project Properties > Build > Advanced > Debug Info you have three options: none
, full
, or pdb-only
.
Which setting is the most appropriate for a release build?
So, what are the differences between full
and pdb-only
?
If I use full
will there be performance ramifications? If I use pdb-only
will it be harder to debug production issues?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我将使用
pdb-only
进行构建。您将无法将调试器附加到已发布的产品,但如果您收到故障转储,您可以使用 Visual Studio 或 WinDBG 检查崩溃时的堆栈跟踪和内存转储。如果您使用
full
而不是pdb-only
,您将获得相同的好处,只不过可执行文件可以直接附加到调试器。您需要根据您的产品和需求确定这是否合理。顾客。请务必将 PDB 文件保存在某个位置,以便在收到崩溃报告时可以引用它们。如果您可以设置 符号服务器 来存储这些调试符号,那就更好了。
如果您选择使用
none
进行构建,那么当现场发生崩溃时您将无法追索。您将无法对事故进行任何形式的事后检查,这可能会严重妨碍您追踪问题的能力。关于性能的说明:
两者John Robbins< /a> 和 Eric Lippert 撰写了有关
/debug
标志的博客文章,它们都表明此设置对性能的影响为零。有一个单独的/optimize
标志指示编译器是否应该执行优化。I would build with
pdb-only
. You will not be able to attach a debugger to the released product, but if you get a crash dump, you can use Visual Studio or WinDBG to examine the stack traces and memory dumps at the time of the crash.If you go with
full
rather thanpdb-only
, you'll get the same benefits, except that the executable can be attached directly to a debugger. You'll need to determine if this is reasonable given your product & customers.Be sure to save the PDB files somewhere so that you can reference them when a crash report comes in. If you can set up a symbol server to store those debugging symbols, so much the better.
If you opt to build with
none
, you will have no recourse when there's a crash in the field. You won't be able to do any sort of after-the-fact examination of the crash, which could severely hamper your ability to track down the problem.A note about performance:
Both John Robbins and Eric Lippert have written blog posts about the
/debug
flag, and they both indicate that this setting has zero performance impact. There is a separate/optimize
flag which dictates whether the compiler should perform optimizations.警告
/debug 开关的 MSDN 文档(在 Visual Studio 中是调试信息)似乎已经过时了!这就是它的内容不正确
那么,现在的情况又是怎样呢?
如果它们完全相同,为什么我们有这些选项? John Robbins(Windows 调试之神)发现这些是由于历史原因。
然后他继续证明这一点。
现在,优化是单独开关
/optimize
的一部分(在 Visual Studio 中称为优化代码
)。简而言之,无论 DebugInfo 设置 pdb-only 还是 full,我们都会得到相同的结果。建议避免无,因为它会使您无法分析已发布产品或附加调试器的故障转储。
WARNING
MSDN documentation for /debug switch (In Visual Studio it is Debug Info) seems to be out-of-date! This is what it has which is incorrect
Then, what is true now?
If they are exactly same, why do we have these options? John Robbins (windows debugging god) found out these are there for historical reasons.
then he goes on to prove it.
Now the optimization is part of a separate switch
/optimize
(in visual studio it is calledOptimize code
).In short, irrespective of DebugInfo setting pdb-only or full, we will have same results. The recommendation is to avoid None since it would deprive you of being able to analyze the crash dumps from released product or attaching debugger.
您只需要 PDB,但不想将 PDB 文件提供给用户。不过,将它们与二进制文件一起使用,可以让您将故障转储加载到 WinDbg 等调试器中,并查看程序实际失败的位置。当您的代码在您无权访问的计算机上崩溃时,这可能非常有用。
完全调试将 [Debuggable] 属性添加到您的代码中。这对速度有很大影响。例如,可以禁用某些循环优化以使单步执行更容易。此外,它对 JIT 流程的影响很小,因为它打开了跟踪。
You'll want PDB only, but you won't want to give the PDB files to users. Having them for yourself though, alongside your binaries, gives you the ability to load crash dumps into a debugger like WinDbg and see where your program actually failed. This can be rather useful when your code is crashing on a machine you don't have access to.
Full debug adds the [Debuggable] attribute to your code. This has a huge impact on speed. For example, some loop optimizations may be disabled to make single stepping easier. In addition, it has a small effect on the JIT process, as it turns on tracking.
我正在编写未处理的异常处理程序,并且堆栈跟踪包含仅使用 pdb 时的行号,否则当我选择“无”时,我只会获取子/函数的名称。
如果我不分发 .pdb,即使使用仅 pdb 构建,我也不会在堆栈跟踪中获得行号。
因此,我将 pdb 与 VB 应用程序中的 exe 一起分发(XCOPY 部署在 LAN 上)。
I'm in the process of writing a unhandled exception handler and the stack trace includes the line number when pdb-only is used, otherwise I just get the name of the Sub/Function when I choose None.
If I don't distribute the .pdb I don't get the line number in the stack trace even with the pdb-only build.
So, I'm distributing (XCOPY deploy on a LAN) the pdb along with the exe from my VB app.