When debugging crash dump files you need the .pdb for the .exe and .dll files that belong to the application you want to debug.
The pdb files are unique to every build you do, so you must keep all the *.pdb files for all the releases of your program. One way to keep track of that is to add the *.pdb files to a symbol server.
But you also want to have access to the source code so you can see where in your code the program crashed and since your code might be changing all the time you want to tie the pdb symbols to a specific version of your source file. And since you have your code in a source control system ( I hope you do) this can be done quite easy with some script that are included in Microsoft Windows Debugging tools.
I'm here going to assume that you are using subversion as source control. There are other indexing script available for SourceSafe/CVS and TS but I'm not going to include them here.
First you need to download and install some tools if you not already have them installed.
Windows Debugging Tools is needed to index symbols files and to add them to the symbol storage.
Perl is need to be able to do the source indexing
SubVerson is needed by the perl script and it is not enough to have the TortiosSVN shell extension install. You need the command line subversion tool. There is no problem having both of them installed.
1 - Install tools
After you installed Windows Debugging tools, Perl and Subversion command line client you need to make sure that they all are added to environment search path.
Open a new command prompt and see if perl.exe and svn.exe are accessible. Sometimes a reboot or re-login is required for the new search path to take effect. If after a reboot perl.exe and svn.exe is still not found then add the path for them to the system variables 'path' in environment variables.
Make sure you do not install a localized version of subversion. The perl script needs the output from subversion to be in English.
You also need to add the path to the srcsrv folder under the debugging tools. This path is never added automatically so you need to add this your self. As default the path is "C:\Program Files\Debugging Tools for Windows\srcsrv". If you have an old version of Windows Debugging Tools already installed this folder might be missing. Then reinstall a newer versions of Windows Debugging Tools.
2 - Index Symbols
Make sure all your code is commited and updated and after you built a release of your program it is a good practices to have all you pdb and exe/dll files copied using post build script to a publish folder. so they are all found at one place.
Now we want to index the pdb files in our publish folder with our source code.
Write a small bat file that your publish script can run or that you run manually after you built you release.
svnindex /debug /symbols="Publish\Win32" /Source="Source;Dll\Source"
The /debug parameter is not needed but i like to have it there so i can see what it happend. Without it you will not get any feedback.
/symbols parameter is the path to where the pdb files are located.
/Source is the path to where it should search for matching source files. You can have a ; seperated list with paths there if you got multiple source locations.
3 - Add Symbols to Symbol Storage
You now got pdb files that are indexed against your current source revision, and you now need to add the symbols to your symbol storage.
Example of a bat files that add the symbol the symbols store
SET SYMSTORE="\\SymServer\Symbols\MyProduct" SET PRODUCT=MyProduct SET PATH_SYMSTORE=C:\Program Files\Debugging Tools for Windows\ SET BUILDVERSION=%1 SET COMMENT=%2 if "" == "%1" ( echo Paramter Error goto end ) "%PATH_SYMSTORE%symstore" add /r /f Publish\Win32\*.* /s %SYMSTORE% /t "%PRODUCT%" /v "Build %BUILDVERSION%" /c "%COMMENT%"
Using the bat script
c:\Project\MyProduct\> AddSymbolToSymStore.bat "126.96.36.199" "Release Build"
4 - Using WinDbg
When using WinDbg to debug crash dump files you need to setup it so it will try to fetch symbols from your symbol server as well as symbols from microsoft symbol server. You also need to inform it that svn.exe is a trusted command or it will not be able to export the source file from subversion when debugging the code.
Create a debug folder. A folder from where you always will start the debuging of crash dump files. And in there we are going to create files that will help you in using Windbg.exe
First create a file named srcsrv.ini, It is for the source server and we need to specifiy what trusted command we want to allow here
[variables] [trusted commands] svn.exe svn.exe export [server errors]
Under variable you can add variables to change the source server name If you do not want the server specified in your indexed symbols.
Then create a bat file called CheckDump.bat (or whatever name you prefer) that will launch WinDbg with parameters to the symbol servers.
"C:\Program Files\Debugging Tools for Windows\WinDbg.exe" -y "srv*D:\Symbols*http://msdl.microsoft.com/download/symbols;\\SymServer\Symbols\MyProduct" -z %1
Use the CheckDump.bat with the path/filename of the dump file as parameter to start analyzing it.
c:\Project\MyProject\Dump\> CheckDump.bat Crash.dmp
Windbg will start and when you do "!analyze -v" it will now fetch symbols from Microsoft symbols server and from your own symbol server. If it wants to open a source file it will export that file from subversion using the revision that the symbols was indexed with, So you will always get the correct version.