1 out of 3 rated this helpful - Rate this topic

/debug (C# Compiler Options)

The /debug option causes the compiler to generate debugging information and place it in the output file or files.

/debug[+ | -]
/debug:{full | pdbonly}
+ | -

Specifying +, or just /debug, causes the compiler to generate debugging information and place it in a program database (.pdb file). Specifying -, which is in effect if you do not specify /debug, causes no debug information to be created.

full | pdbonly

Specifies the type of debugging information generated by the compiler. The full argument, which is in effect if you do not specify /debug:pdbonly, enables attaching a debugger to the running program. Specifying pdbonly allows source code debugging when the program is started in the debugger but will only display assembler when the running program is attached to the debugger.

Use this option to create debug builds. If /debug, /debug+, or /debug:full is not specified, you will not be able to debug the output file of your program.

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.

Note Note

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. Therefore, you will get an error if your code contains the DebuggableAttribute set to false if you use /debug:full.

For more information on how to configure the debug performance of an application, see Making an Image Easier to Debug.

To change the location of the .pdb file, see /pdb (C# Compiler Options).

To set this compiler option in the Visual Studio development environment

  1. Open the project's Properties page.

  2. Click the Build property page.

  3. Click the Advanced button.

  4. Modify the Debug Info property.

For information on how to set this compiler option programmatically, see DebugSymbols.

Place debugging information in output file app.pdb:

csc /debug /pdb:app.pdb test.cs
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Truly a performance impact?
Based on what I've read elsewhere, I don't believe the following statement is true:
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.
Eric Lippert has a blog post about this, titled "What does the optimize switch do?": http://blogs.msdn.com/b/ericlippert/archive/2009/06/11/what-does-the-optimize-switch-do.aspx

John Robbins has a blog post about this, titled "Do PDB Files Affect Performance?": http://www.wintellect.com/CS/blogs/jrobbins/archive/2009/06/19/do-pdb-files-affect-performance.aspx

Both claim that "full" has no performance impact; to quote Mr. Lippert:
"Emitting debug information and optimizing the generated IL are orthogonal; they have no effect on each other at all"
John Robbins specifically mentions that this documentation is wrong in one of the comments on the reference blog post: http://www.wintellect.com/CS/blogs/jrobbins/archive/2009/06/19/do-pdb-files-affect-performance.aspx#9864

Can someone from Microsoft confirm this?