views:

2763

answers:

4

I have heard using PDB files can help diagnose where a crash occurred.
My basic understanding is that you give Visual studio the source file, the pdb file and the crash information (from Dr Watson?)
Can someone please explain how it all works / what is involved? (Thank you!)

+5  A: 

PDB files map an assembly's MSIL to the original source lines. This means that if you put the PDB that was compiled with the assembly in the same directory as the assembly, your exception stack traces will have the names and lines of the positions in the original source files. Without the PDB file, you will only see the name of the class and method for each level of the stack trace.

Omer van Kloeten
+1: For the good description of what a "program database" (PDB) contains.
AMissico
+9  A: 

PDB files are generated when you build your project. They contain information reltating to the built binaries which visual studio can interept and is able to link the call stack back to source.

When a program crashes and it generates a crash report, and visual studio is able to take that report and link it back to source via the PDB files. The PDB files must be built from the same binary that generated the crash report!

There are some issues that we have encouted over time.

  • The machine that is debugging the crash report needs to have the source on the same path as the machine that built the binary.
  • Release builds often optimize to the extent where you cannot view the state of object member variables

If anyone knows how to defeat the former I would be grateful for some input.

roo
One way to help with the source file path: use SUBST to map a drive letter to a particular directory. http://technet.microsoft.com/en-us/library/bb491006.aspx
MarkJ
+4  A: 

You should look into setting up a symbol server and indexing the PDB files to your source code control system. I just recently went through this process for our product and it works very well. You don't have to be concerned about making PDB files available with the binaries, nor how to get the appropriate source code when debugging dump files.

This link I found to be a good starting point: http://entland.homelinux.com/blog/2006/07/06/setting-up-a-symbol-server/

Also, John Robbins' book: http://www.amazon.com/Debugging-Microsoft-NET-2-0-Applications/dp/0735622027/ref=pd_bbs_sr_1?ie=UTF8&s=books&qid=1222366012&sr=8-1

Look here for some sample code for generating minidumps (which don't have to be restricted to post-crash analysis -- you can generate them at any point in your code without crashing): http://www.codeproject.com/KB/debug/postmortemdebug_standalone1.aspx

Wayne
+2  A: 

As an addendum to Wayne's post, I also wanted to point out John Robbins' blog post entitled PDB Files: What Every Developer Must Know . It is an excellent jumping off point on this topic.

reshen