How do I change the locations of source files in a symbols file (pdb)
Asked Answered
M

4

26

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)?

Mislike answered 26/8, 2008 at 12:58 Comment(0)
T
12

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.

Tyronetyrosinase answered 26/8, 2008 at 14:41 Comment(3)
Having the PDB indexed straight from source control is GOLD! I wish that all open source projects would start doing this.Mislike
That is mint. I wasn't aware of this feature! This article is also useful: entland.homelinux.com/blog/2006/07/06/…Trotskyism
The link in @Trotskyism comment above is now dead. Luckily there is web.archive.org/web/20150328011952/http://entland.homelinux.com/…Horne
M
9

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.

Montalvo answered 26/8, 2008 at 14:23 Comment(0)
J
3

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...:)

Juliettejulina answered 10/2, 2011 at 13:13 Comment(0)
F
1

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
Fsh answered 6/10, 2008 at 12:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.