Question

  • Step 1: I build myProgram.exe and generate myProgram.pdb alongside it.
  • Step 2: I deliberately cause a crash in myProgram.exe.
  • Step 3: I get asked if I want to use Visual Studio as a debugger, and I do that.
  • Step 4: Visual Studio loads the symbols from myProgram.pdb.
  • Step 5: I check the call stack to identify the (known) place where the crash occurred.
  • Step 6: I don't frown or look perplexed, because this is how it should be.

However, if I rename myProgram.exe and myProgram.pdb to SomethingElse.exe and SomethingElse.pdb and repeat these steps, results are mixed from Step 4 onwards. As far as I can tell, on my build machine, VS will always load symbols successfully from the renamed PDB file. However, on my remote target machine, VS will never load symbols - it always tells me that the PDB file does not match the executable. Why not? Is there an obscure rule I am breaking? I am running Visual Studio 2005 everywhere in case that matters.

Was it helpful?

Solution

The simple subtle rule being broken here is that the PDB file name appears to be encoded into the EXE file, not derived from the EXE file name. So, for example, if you create "Copy of myProgram.exe" and "Copy of myProgram.pdb" by a simple copy-and-paste in Windows Explorer, it can appear that symbols are being loaded despite the name change. But this will only work so long as the original "myProgram.pdb" file is also present - if you remove "myProgram.pdb" and only have "Copy of myProgram.pdb", the symbols may be compatible, but Visual Studio will not even try to load them.

In a quick-and-dirty test on a remote machine in my office, all that changed was the file name, not the file version, whereas on the actual remote machine, both name and file version were different, so it was never possible for things to appear to work.

OTHER TIPS

Visual Studio 2013 Update 5 creates broken[1] PDBs for me if my intermediate directory is a subdirectory of the output directory. My diff to fix the issue

-    <IntDir>$(OutDir)/$(TargetName)/</IntDir>
+    <IntDir>$(OutDir)</IntDir>

[1] Verified mismatched with windbg's !itoldyouso

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top