What is a PDB file?
Asked Answered
T

5

341

What is a PDB file and how can I exclude it from the release folder when I rebuild my solution?

Titicaca answered 10/10, 2010 at 8:23 Comment(2)
pdb is a program database file and it is created on compile. This file holds debugging and project state information that allows incremental linking of a debug configuration of your program.Shaffer
@Shaffer are you sure C# compiler also does incremental linking? I've only heard about it in C++ world. In a C++ project you enable/disable incremental linking from project properties. Is there an option in C# project also?Saberhagen
V
317

A PDB file contains information for the debugger to work with. There's less information in a Release build than in a Debug build anyway. But if you want it to not be generated at all, go to your project's Build properties, select the Release configuration, click on "Advanced..." and under "Debug Info" pick "None".

Vanvanadate answered 10/10, 2010 at 8:27 Comment(10)
@Jon Does it help provide extra information to the user if the application crashes in use? (ie, does it help with the JIT window, rather than "This program needs to end, send a Windows Error Report")Muhammad
Bear in mind that you should probably keep these included in your debug releases, as it allows exceptions to be traced to a specific line in your code. Without the symbols in the pdb file, you will find it hard to pinpoint specific problems in order to solve them. You don't necessarily need to exclude them from release builds either, as sometimes the extra information in a big report can be very useful.Refractive
@Jared: Yes, it includes a stack trace of the exception, which will pinpoint to a specific function and line of code.Refractive
@Jared: What do you mean by "the JIT window"? It's unlikely to give much more information to the user, but it may let you attach a debugger to a release build if you need to. Typically you wouldn't include it for end-user applications though. Of course, just because it's copied to the Release folder doesn't mean you have to ship it in the installer...Vanvanadate
@Jon if I include PDF file with my software installer , does it make problem or does it make anyway for hacker ?Titicaca
@Ata: PDB, not PDF. Please separate the two in your mind - they're completely different file formats, for different purposes. Including a PDB wouldn't introduce a problem particularly; it may make a hacker's job slightly easier, but is that a particular concern for you? In general, .NET can be decompiled relatively easily in most cases - if you're worried about that, simply not shipping the PDB isn't a good solution.Vanvanadate
@Jon The JIT window I was talking about is the "just in time debugging" message window, like this oneMuhammad
@Jared: Right... to avoid confusion it's probably worth talking about the standard crash dialog, or something like that - as JIT normally just refers to the just-in-time compiler, not debugger.Vanvanadate
In VS2010, select the Release Configuration, click on Linker\Debugging and set 'Generate Debug Info' to 'No'.Overcompensation
Some of the info here is specific to PDBs for .Net (since this is tagged for C#). PDBs for native code can be different. For example, a native code PDB usually has more info for a release build than for a debug build.Faydra
B
203

I had originally asked myself the question "Do I need a PDB file deployed to my customer's machine?", and after reading this post, decided to exclude the file.

Everything worked fine, until today, when I was trying to figure out why a message box containing an Exception.StackTrace was missing the file and line number information - necessary for troubleshooting the exception. I re-read this post and found the key nugget of information: that although the PDB is not necessary for the app to run, it is necessary for the file and line numbers to be present in the StackTrace string. I included the PDB file in the executable folder and now all is fine.

Blockus answered 17/4, 2013 at 15:44 Comment(1)
This is a very important part to keep in mind which the accepted answer here doesn't mention.Crane
S
126

PDB is an abbreviation for Program-Debug Data Base. As the name suggests, it is a repository (persistent storage such as databases) to maintain information required to run your program in debug mode. It contains several vital information required for code debugging e.g. at what points you have put break points where you expect the debugger to break in Visual Studio (VS).

This is the reason why Visual Studio fails to hit the break points if you remove PDB files from the debug directory. Visual Studio debugger is capable of telling you the exact line number of code file at which any exception occurred along with its stacktrace. It is able to do so with the help of PDB files only. Thus PDB files are very helpful for debugging purposes.

In general, it is not recommended to exclude the generation of PDB files during build process. From production release stand-point, what you should be doing is create the PDB files but don't ship them to customer site in product installer. Preserve all the generated PDB files on a symbol server from where it can be used/referenced in future if required.

It is specially important in scenario where you debug process crash issues. While analysing the crash dump files, Visual Studio will not be able to make out the exact line of code where program is crashing if the original PDB files created during the build process were not preserved.

If you still want to disable generation of PDB files then follow below steps:

  1. Go to properties window of the project. To open properties window, select the project file in solution explorer and press Alt + Enter.
  2. Go to Build tab
  3. Click Advanced
  4. Choose none from Debug Info drop-down box
  5. Press OK as shown in the snapshot below:

None Debug Info setting for a C# Project

Note: This setting will have to be done separately for Debug and Release build configurations.

Saberhagen answered 29/8, 2014 at 5:41 Comment(1)
(Picture an older fellow stepping off his front porch:) Hello. After 9? years I'm here to set the record straight. I invented PDB files and implemented and owned them in MS C/C++7.0, VC++ 1.0, 2.0, and 4.0. Here PDB stands for Program Database. Period. The fact that some uninformed dev in the Windows shell team thought Program Debug Database or whatever was a cool idea, that doesn't change the fact that PDBs are Program Database files. Have a nice day.Amoral
C
19

A PDB file contains information used by the debugger. It is not required to run your application and it does not need to be included in your released version.

You can disable pdb files from being created in Visual Studio. If you are building from the command line or a script then omit the /Debug switch.

Crackerbarrel answered 10/10, 2010 at 8:26 Comment(4)
Release mode still builds PDBs by default, I believe. You can change the project properties to disable it though.Vanvanadate
Yup; it still comes with release with a default project.Larson
I just checked and I also get one by default if using Visual Studio.Crackerbarrel
Surprise! Somewhen in the last 11 years, that PDB link went stale. Here's the new link: wintellect.com/pdb-files-what-every-developer-must-knowNatasha
K
9

Program Debug Database file (pdb) is a file format by Microsoft for storing debugging information.

When you build a project using Visual Studio or command prompt the compiler creates these symbol files.

Check Microsoft Docs

Kazim answered 28/4, 2019 at 10:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.