Visual Studio 如何知道源文件是否与原始版本匹配? [英] How does Visual Studio know if the source file matches the original version?

查看:38
本文介绍了Visual Studio 如何知道源文件是否与原始版本匹配?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我弄清楚了 .NET 程序集 .dll 文件如何使用 GUID 映射到 .pdb (博客).当我调试一个程序集并要求提供源代码时,如果我导航到一个文件,它可能会告诉我源代码与原始代码不同.它怎么知道这个?我期望 .pdb 文件包含每个文件的校验和,但似乎没有.我发现转储调试信息的最佳工具是 dia2dump.C++ .pdb 文件有 MD5 条目,但 C# .pdb 文件没有.

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++ 转储
dia2dump -f dia2dump.pdb > dia2dump.pdb.files.txt

C# 转储
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?

它必须使用校验和.如果我在 Module.cs 中更改单个字符,我会得到:

It has got to be using a checksum. If I change a single character in Module.cs, I get:

在哪里可以找到 .pdb 中引用的源文件的校验和?

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

推荐答案

MD5 校验和存储在每个源文件的 .pdb 文件中.如果您对上面的问题您是否希望调试器使用它?"回答否",它会打印出它正在寻找的校验和:

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:

使用十六进制编辑器,您可以看到它肯定在.pdb 中.我的下一个任务是弄清楚如何以编程方式访问它.对于 .pdb 文件,我希望它返回所有源文件名及其 MD5 校验和.

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.

这篇关于Visual Studio 如何知道源文件是否与原始版本匹配?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆