Search code examples
.netvisual-studiodebuggingpdb-files

How is debugging possible without pdb files?


Situation:

  • project DEP is a .NET class library project, being developed using VS2015, targeting .NET 4.5
  • project A references DEP.dll (the dll, not the source code project itself)
  • project A and DEP are part of separate solutions

When I build DEP in debug mode, and then I debug project A, I can still step into code from DEP, even though I see no pdb files in DEP's output folder. I wonder how debugging DEP is possible. I thought that pdbs were always needed to be able to debug. Or do dlls built in debug mode contain enough debug information?


Solution

  • Every program is debuggable. A debugger's most fundamental ability is to single-step processor instructions, look at processor registers and inspect memory. Soul of the machine stuff. What you'll never get without a PDB is the ability to look at the source code, single step statements and inspect named variables. Actually fixing bugs without a PDB is drastically impractical.

    If you in fact see source code then that's not terribly surprising, the debugger is pretty good at locating a PDB. If you didn't copy it yourself then the debugger can find the one in its original location, where the compiler put it, in the project's obj\Debug directory. The path to that PDB is embedded in the executable file. You can find out how it found it, use Debug > Windows > Modules, right-click the DLL and select Symbol Load Information. It shows you everywhere the debugger looked for the PDB.