Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does Visual Studio know if the source file matches the original version?

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:
enter image description here

Where do I find the checksum for a source file referenced in a .pdb?

like image 481
Cameron Taggart Avatar asked Jun 15 '13 04:06

Cameron Taggart


People also ask

What are .pdb files Visual Studio?

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.

How do I create a .PDB file in Visual Studio?

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.


1 Answers

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:

enter image description here

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.

enter image description here

like image 102
Cameron Taggart Avatar answered Oct 10 '22 08:10

Cameron Taggart