8

I know PDBs are generated for managed projects in .NET by giving the compiler the /debug argument. Is there a way to specify this in the VS (2005) GUI?

The only way I could get it to generate PDBs in release mode so far is to manually modify the .csproj file and to add :

<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>

under the 'release' settings:

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">

Another thing: I learned from MSDN here that the possible values for the DebugType tag are:

  • full
  • pdbonly
  • none

How do these values affect the compiler's behaviour?

Cristian Diaconescu
  • 34,633
  • 32
  • 143
  • 233

3 Answers3

8

In DEBUG:

<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>

In RELEASE:

<DebugSymbols>true</DebugSymbols>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
7

In VS2008, you can set the property using the project properties -> Build -> Advanced... -> Debug Info.

Mehrdad Afshari
  • 414,610
  • 91
  • 852
  • 789
5

I found this MONO request that may shed some light on what's the difference between 'full' and 'pdbonly'.

csc has a "pdbonly" debugtype that generates pdbs, while producing runtime code, i.e. optimised, no debugger attributes, etc.

This is important for being able to obtain useful stack traces from release-quality code.

It seems to me that the existance of the 2 tags (DebugSymbols and DebugType) is redundant.

Cristian Diaconescu
  • 34,633
  • 32
  • 143
  • 233
  • 2
    "obtain useful stack traces" This is incorrect. You will always get useful stack traces in .NET code due to the presence of type metadata. The PDBs in release flavor IS important for single-stepping through production code but you may get errors in the debugger due to optimizations. – Daniel P. Bullington Apr 03 '09 at 16:31
  • 1
    @Daniel Bullington, You don't get line numbers and filenames without pdb files, which makes the stack traces at least "less useful" – tster Sep 06 '13 at 16:15
  • @tster yes I agree, but even without PDBs (and thus line numbers/file names), the stack traces are still useful to lesser degree :) – Daniel P. Bullington Sep 12 '13 at 04:13
  • 2
    If I was handed a release bug that didn't have line numbers or file names with stack traces, I would probably scream "this is useless!" – aaaaaa Aug 08 '17 at 22:06
  • I regularly have to hunt down bugs where all I have to refer to is a stacktrace with file names and method names, but no line numbers. The methods are typically hundreds of lines long, so I have to bisect my way to the problem by moving around a line that says `Console.WriteLine("got here");`. It's a nightmare. – Dave Yarwood Jan 24 '18 at 22:09