Take the 2-minute tour ×

Basically what I want to do it this: a pdb file contains a location of source files (e.g. C:\dev\proj1\helloworld.cs). Is it possible to modify that pdb file so that it contains a different location (e.g. \more\differenter\location\proj1\helloworld.cs)?

share|improve this question
add comment

4 Answers

up vote 10 down vote accepted

You can use the source indexing feature of the Debugging Tools for Windows, which will save references to the appropriate revisions of the files in your source repository as an alternate stream in the PDB file.

share|improve this answer
Having the PDB indexed straight from source control is GOLD! I wish that all open source projects would start doing this. –  Trumpi Feb 11 '11 at 16:46
That is mint. I wasn't aware of this feature! This article is also useful: entland.homelinux.com/blog/2006/07/06/… –  Pete May 2 '12 at 7:44
add comment

If you're looking to be more generic about the paths embedded in a pdb file, you could first use the MS-DOS subst command to map a particular folder to a drive letter.

subst N: <MyRealPath>

Then open your project relative to the N: drive and rebuild it. Your PDB files will reference the source files on N:. Now it doesn't matter where you place that particular set of source files, so long as you subsequently call the root directory "N:" like you did when you built it.

This practice is recommended by John Robbins in his excellent book, Debugging Applications for Microsoft .NET and Microsoft Windows.

share|improve this answer
add comment

It is certainly possible, as On Freund has already pointed out. But if it is only so that the sources can be located and loaded during debugging, then a better way would be to set the source path correspondingly. Once set in a debugger, it will preemt all hard coded paths inside PDBs.

In windbg (for instance):

.srcpath+ path_to_source_root
or this (in case you're debugging remotely):
.lsrcpath+ path_to_source_root

share|improve this answer
add comment

I wanted to find the answer to this in order to debug a crash dump that occurred in an executable that I did not build on my machine, therefore the path to the source code referenced in the PDB was invalid, as was the path to the PDB referenced in the executable.

After searching around and failing to find something that works, I discovered that if you place the executable and PDB alongside the crash dump file (i.e. in the same directory) then open and run the crash dump in VS, VS will find and use the PDB/EXE locally. Furthermore, it will also prompt for the location of the source code when clicking on an entry in the call stack: pointing it at whichever source code is relevant, it all works fine, which is great!

Anyway, hopefully this helps someone else...:)

share|improve this answer
add comment

Your Answer


