在 Visual C 中附加到外部可执行文件 2003年
我有一个可执行文件(由其他人编译),它在我的代码附近触发了断言。 我在 Visual C++ 2003 中处理代码,但我没有这个特定可执行文件的项目文件(该代码用于构建许多不同的工具)。 是否可以在 Visual C++ 的调试器中启动二进制文件并告诉它源代码在哪里? 我以前在 GDB 中做过这个,所以我知道它应该是可能的。
I have an executable (compiled by someone else) that is hitting an assertion near my code. I work on the code in Visual C++ 2003, but I don't have a project file for this particular executable (the code is used to build many different tools). Is it possible to launch the binary in Visual C++'s debugger and just tell it where the sources are? I've done this before in GDB, so I know it ought to be possible.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的,这是可能的。 只需设置一个空项目并指定所需的 .exe 文件作为调试目标即可。 我不记得具体是怎么做的,但我知道这是可行的,因为我在为 Winamp 开发插件时曾经将
winamp.exe
设置为调试目标。由于您没有源文件,因此它只会显示汇编代码,但这可能仍然有用,因为您还可以检查内存、寄存器等。
更新
如果您正在调试断言自己的程序,您应该能够很好地看到源代码,因为当您使用调试信息编译它时,源文件的路径存储在可执行文件中。
Yes, it's possible. Just set up an empty project and specify the desired
.exe
file as debug target. I don't remember exactly how, but I know it's doable, because I used to setwinamp.exe
as debug target when I developed plug-ins for Winamp.Since you don't have the source file it will only show the assembly code, but that might still be useful as you can also inspect memory, registers, etc.
Update
If you are debugging an assertion in your own program you should be able to see the source just fine, since the path to the source file is stored in the executable when you compile it with debug information.
如果没有该应用程序的 PDB 符号,您将很难弄清楚正在发生的事情和地点。 我认为任何源代码信息都只会存在于构建该应用程序时创建的 PDB 文件中。
这是假设 PDB 文件是为此应用程序创建的 - 我认为这不是发布模式 VC++ 项目的默认配置。 既然你断言,我猜这是一个调试配置?
Without the PDB symbols for that application you're going to have a tough time making heads or tails of what is going on and where. I think any source code information is going to be only in that PDB file that was created when whoever built that application.
This is assuming that the PDB file was EVER created for this application - which is not the default configuration for release mode VC++ projects I think. Since you're asserting, I guessing this is a debug configuration?
如果没有任何其他答案,我会尝试附加到 Visual Studio 中的可执行进程,在代码中设置断点,当您进入没有源代码的进程时,它应该要求提供源文件。
Short of any other answers, I would try attaching to the executable process in Visual Studio, setting a break point in your code and when you step into the process you don't have source to, it should ask for a source file.