Sunday, January 13, 2013

Loading Local Symbols (PDB) for .NET application using WinDbg

In order to use WinDbg we need to give it a symbol server for understanding what are the call stacks that is being used in the Windows OS world. If we are using a .NET application, this too is part of the Windows OS world. This we shall call as Microsoft Symbols. We also need to be able to load our assemblies and our call stacks this we call as Local Symbols.

We specify the loading of Symbols in the WinDbg as part of the initial setup.

To do this we first have to open WinDbg and File -> Symbol File Path

We then enter the following make sure that we have created the folder correctly.

srv*C:\Software\MicrosoftSymbols*http://msdl.microsoft.com/download/symbols;C:\Software\LocalSymbols

The first part is for loading the Microsoft Symbols we say if you don't find a Symbol you go to this location specified in the URL and download it.

The second part of this is load the local symbols. Since we didn't specify a URL, we need to place our PDB (Program Database) that comes with compiling the application both in Debug and Release Mode into this folder location. One should always expose the PDB in release mode to external use.

Please make sure that the same PDB is used at the time of compilation for a Software version. You could generate a PDB for the same version again  but not after the version has changed. So make sure that you copy the PDB files after you compile once you are ready to deploy your application so that this could be published for debugging purposes.

You could then save the workspace in WinDbg so that you dont need to re-type this information.

To verify that the local symbols are loaded you could do the following

Take a single assembly that is specific to your application and issue the following command

!chksym YourAssembly.dll

After a lot of verbose output you should get something like this

Loaded pdb is c:\share\YourAssembly.pdb


YourAssembly.pdb

pdb sig: 97489EA7-34EB-4861-A271-CB99337D21D9

age: 1
MATCH: YourAssembly.pdb and C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\AppFolder\7ecdb58d\fdf53a2\assembly\dl3\fde54ebd\000993fb_79b5cd01\YourAssembly.dll

No comments:

Post a Comment