Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what's the difference between C# compilation setting "/debug:pdbonly" and "/debug:full"? [duplicate]

Tags:

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?

like image 523
RationalGeek Avatar asked Oct 10 '11 13:10

RationalGeek


People also ask

What's the difference between C C+ and C++?

Difference between C and C++. The main difference between both these languages is C is a procedural programming language and does not support classes and objects, while C++ is a combination of both procedural and object-oriented programming languages.

Is C or C+ Better?

C is still in use because it is slightly faster and smaller than C++. For most people, C++ is the better choice. It has more features and more applications, which allow you to explore various roles. For most people, learning C++ is also easier especially if you are familiar with object-oriented programming.

Is C+ a thing?

C+ (grade), an academic grade. C++, a programming language. C with Classes, predecessor to the C++ programming language. ANSI C, a programming language (as opposed to K&R C)

Is C++ better than C+?

The betterness depends on the purpose of the project. Q: Should I learn C, C++, or C#? A: Although C++ and C# are better than C, C forms the basis of both the languages, and most of the popular operating systems like UNIX, Windows, etc are still written in C. Thus C should be learned before C++ and C#.


2 Answers

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 than pdb-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.

like image 76
Matt Dillard Avatar answered Oct 12 '22 23:10

Matt Dillard


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

If you use /debug:full, be aware that there is some impact on the speed and size of JIT optimized code and a small impact on code quality with /debug:full. We recommend /debug:pdbonly or no PDB for generating release code.

One difference between /debug:pdbonly and /debug:full is that with /debug:full the compiler emits a DebuggableAttribute, which is used to tell the JIT compiler that debug information is available.

Then, what is true now?

  1. Pdb-only – Prior to .NET 2.0, it helped to investigate the crash dumps from released product (customer machines). But it didn't let attaching the debugger. This is not the case from .NET 2.0. It is exactly same as Full.
  2. Full – This helps us to investigate crash dumps, and also allows us to attach debugger to release build. But unlike MSDN mentions, it doesn't impact the performance (since .NET 2.0). It does exactly same as Pdb-only.

If they are exactly same, why do we have these options? John Robbins (windows debugging god) found out these are there for historical reasons.

Back in .NET 1.0 there were differences, but in .NET 2.0 there isn’t. It looks like .NET 4.0 will follow the same pattern. After double-checking with the CLR Debugging Team, there is no difference at all.

What controls whether the JITter does a debug build is the /optimize switch. <…>

The bottom line is that you want to build your release builds with /optimize+ and any of the /debug switches so you can debug with source code.

then he goes on to prove it.

Now the optimization is part of a separate switch /optimize (in visual studio it is called Optimize 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.

like image 38
rpattabi Avatar answered Oct 13 '22 00:10

rpattabi