I figured out how a .NET assembly .dll file maps to a .pdb using a GUID (blog). When I debug into an assembly and it asks for the source code, if I navigate to a file, it may tell me that the source code is different from the original. How does it know this? I was expecting the .pdb file to contain a checksum for each file, but it doesn't appear to. The best tool I found to dump the debug information is dia2dump. The C++ .pdb files had MD5 entries, but the C# .pdb files did not.
C++ dump
dia2dump -f dia2dump.pdb > dia2dump.pdb.files.txt
C# dump
dia2dump -f Autofac.pdb > Autofac.pdb.files.txt
dia2dump -all Autofac.pdb > Autofac.pdb.all.txt
Is there something I missed in the "all" dump?
It has got to be using a checksum. If I change a single character in Module.cs, I get:
Where do I find the checksum for a source file referenced in a .pdb?
pdb file holds debugging and project state information that allows incremental linking of a Debug configuration of your app. The Visual Studio debugger uses . pdb files to determine two key pieces of information while debugging: The source file name and line number to display in the Visual Studio IDE.
In a developer command prompt, you can use the mspdbcmf.exe tool to generate a full PDB from this limited PDB. In Visual Studio, use the Project or Build menu items for generating a full PDB file to create a full PDB for the project or solution.
An MD5 checksum is stored in the .pdb file for each source file. If you answer "No" to the question above "Would you like the debugger to use it anyway?", it prints out the checksum it was looking for:
Using a hex editor, you can see it is definitely in the .pdb. My next task is to figure out how to get access to it programatically. For a .pdb file, I want it to return all source file names and their MD5 checksums.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With