如何更改符号文件 (pdb) 中源文件的位置

发布于 2024-07-04 13:36:52 字数 155 浏览 12 评论 0原文

基本上我想要这样做:pdb 文件包含源文件的位置(例如 C:\dev\proj1\helloworld.cs)。 是否可以修改该 pdb 文件,使其包含不同的位置(例如 \more\ differenter\location\proj1\helloworld.cs)?

Basically what I want to do it this: a pdb file contains a location of source files (e.g. C:\dev\proj1\helloworld.cs). Is it possible to modify that pdb file so that it contains a different location (e.g. \more\differenter\location\proj1\helloworld.cs)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

苄①跕圉湢 2024-07-11 13:36:52

我想找到这个问题的答案,以便调试在我的计算机上未构建的可执行文件中发生的故障转储,因此 PDB 中引用的源代码的路径无效,PDB 的路径也是如此。可执行文件中引用。

在四处搜索并未能找到有效的东西后,我发现如果将可执行文件和 PDB 与故障转储文件放在一起(即在同一目录中),然后在 VS 中打开并运行故障转储,VS 将找到并使用 PDB /EXE 本地。 此外,当单击调用堆栈中的条目时,它还会提示源代码的位置:将其指向相关的源代码,一切都可以正常工作,这太棒了!

无论如何,希望这对其他人有帮助......:)

I wanted to find the answer to this in order to debug a crash dump that occurred in an executable that I did not build on my machine, therefore the path to the source code referenced in the PDB was invalid, as was the path to the PDB referenced in the executable.

After searching around and failing to find something that works, I discovered that if you place the executable and PDB alongside the crash dump file (i.e. in the same directory) then open and run the crash dump in VS, VS will find and use the PDB/EXE locally. Furthermore, it will also prompt for the location of the source code when clicking on an entry in the call stack: pointing it at whichever source code is relevant, it all works fine, which is great!

Anyway, hopefully this helps someone else...:)

岁月染过的梦 2024-07-11 13:36:52

您可以使用 Windows 调试工具的源索引功能,该功能将对源存储库中的文件的适当修订版的引用保存为 PDB 文件中的备用流。

You can use the source indexing feature of the Debugging Tools for Windows, which will save references to the appropriate revisions of the files in your source repository as an alternate stream in the PDB file.

七秒鱼° 2024-07-11 13:36:52

如果您希望更通用地了解 pdb 文件中嵌入的路径,可以首先使用 MS-DOS subst 命令将特定文件夹映射到驱动器号。

subst N: <MyRealPath>

然后打开相对于 N: 驱动器的项目并重建它。 您的 PDB 文件将引用 N: 上的源文件。 现在,将特定的源文件集放在哪里并不重要,只要您随后像构建根目录时那样调用根目录“N:”即可。

John Robbins 在他的优秀著作 调试 Microsoft .NET 和 Microsoft Windows 的应用程序中推荐了这种做法

If you're looking to be more generic about the paths embedded in a pdb file, you could first use the MS-DOS subst command to map a particular folder to a drive letter.

subst N: <MyRealPath>

Then open your project relative to the N: drive and rebuild it. Your PDB files will reference the source files on N:. Now it doesn't matter where you place that particular set of source files, so long as you subsequently call the root directory "N:" like you did when you built it.

This practice is recommended by John Robbins in his excellent book, Debugging Applications for Microsoft .NET and Microsoft Windows.

忆离笙 2024-07-11 13:36:52

正如弗罗因德已经指出的那样,这当然是可能的。
但如果只是为了在调试时定位并加载源代码,那么更好的方法是相应地设置源路径。 一旦在调试器中设置,它将抢占 PDB 内的所有硬编码路径。

在windbg中(例如):

.srcpath+ 源根路径

or this (in case you're debugging remotely):

.lsrcpath+ 源根路径

It is certainly possible, as On Freund has already pointed out.
But if it is only so that the sources can be located and loaded during debugging, then a better way would be to set the source path correspondingly. Once set in a debugger, it will preemt all hard coded paths inside PDBs.

In windbg (for instance):

.srcpath+ path_to_source_root

or this (in case you're debugging remotely):

.lsrcpath+ path_to_source_root

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文