Visual Studio 调试器可扩展性 - 如何遵循 VS 调试器源文件路径重定向?
我正在写一个VS扩展,需要知道用户当前正在调试的文件的完整路径,并且想支持pdb中写入的源路径不正确的场景,提示用户查找在别处归档。
如果我执行以下操作:
1) 调试 PDB 指向位置 A 处的代码文件的 DLL
2) 将代码文件移动到不同位置 B
3) 当出现“打开文件”对话框提示时,指示调试器将代码定位到位置B
文件然后被打开,Visual Studio 似乎“记住”了这个重定向,并且即使在我重新启动它之后也会知道在位置 B 中查找该文件。
我的问题是, IDebugStackFrame2/EnvDTE.StackFrame 对象都为我提供了旧的、不正确的代码文件路径 - 我想要正确的路径,以便我可以从中读取源代码! Visual Studio 是否以任何方式公开此间接表?
如何获取源文件的文本?
PS 我尝试将 VsShellUtilities.OpenDocument 方法与旧的、不正确的路径一起使用,但它会抛出一个文件未找到的方法。
I'm writing a VS extension that needs to know the full path of the file the user is currently debugging, and I want to support the scenario where the source path written in the pdb is not correct, and the user is prompted to find the file elsewhere.
If I do the following:
1) Debug a DLL whose PDB points at code file at location A
2) Move the code file to different location, B
3) When prompted with the Open File dialog, direct the debugger to locate the code at location B
The file is then opened, and it seems Visual Studio "remembers" this redirection and will know to look for the file in location B even after I restart it.
My problem is, that the IDebugStackFrame2/EnvDTE.StackFrame objects both give me the old, incorrect path for the code file - and I want the correct one so I can read the source from it! Does Visual Studio expose this indirection table in any way?
How can I get the text of the source file?
P.S. I tried to use the VsShellUtilities.OpenDocument method with the old, incorrect path, but it throws a file not found method..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
从#2开始,你也重新编译吗? PDB 本身具有源代码的路径信息,您可以使用十六进制编辑器查看该信息。我认为一旦调试器掌握了 PDB 以及其中指定的任何路径,您就无法更改源文件的路径。
From #2, are you also recompiling? The PDB itself has the path info to the source, you can look at that with a hex editor. I don't think you can change the path to the source file, once the debugger has gotten a hold of the PDB and whatever path is specified there.
根本做不到......
Simply can't be done..........