简体   繁体   English

如何在 C++ Builder 下调试外部进程?

[英]How to debug an external process under C++ Builder?

I have a DLL that is written in C++ Builder.我有一个用 C++ Builder 编写的 DLL。 The DLL is built with "debug info" on. DLL 内置“调试信息”。
I cannot run and debug this DLL from the IDE because it is loaded dynamically as a plugin in another process (main exe).我无法从 IDE 运行和调试此 DLL,因为它作为插件在另一个进程(主 exe)中动态加载。 My DLL needs to be copied into the main exe's folder first.我的 DLL 需要先复制到主 exe 的文件夹中。

So, I attached the IDE to that process but I don't know what to do from here.因此,我将 IDE 附加到该过程,但我不知道从这里做什么。

I know that if I click a button in the main process to load and use my DLL an AV is raised and a custom message is shown with some minor into about the error.我知道,如果我在主进程中单击一个按钮来加载和使用我的 DLL,则会引发 AV,并显示一条自定义消息,其中包含一些关于错误的小信息。 The debugger won't step in when the AV is raised.当 AV 被提升时,调试器不会介入。 Probably the error is caught at a higher level.错误可能在更高级别被捕获。

It would be nice if I could also attach the source-code of my DLL and put a breakpoint in it.如果我还可以附上我的 DLL 的源代码并在其中放置一个断点,那就太好了。

How do I get more info about that AV (its origins)?我如何获得有关该 AV(其起源)的更多信息?
(Basically any hint from those that did this type of debugging would be very helpful). (基本上,那些进行此类调试的人提供的任何提示都会非常有帮助)。

I have a DLL that is written in C++ Builder.我有一个用 C++ Builder 编写的 DLL。 The DLL is built with "debug info" on. DLL 内置“调试信息”。 I cannot run and debug this DLL from the IDE because it is loaded as a plugin in another process.我无法从 IDE 运行和调试此 DLL,因为它在另一个进程中作为插件加载。

Yes, you can.是的你可以。

Open the DLL project in the IDE, go into the project's Run parameters and set the desired EXE as the project's Host.打开IDE、go项目中的DLL项目进入项目的Run参数,设置所需的EXE为项目的Host。 This way, when you "run" the DLL project for debugging, the IDE will execute the Host instead and attach the debugger to that process.这样,当您“运行”DLL 项目进行调试时,IDE 将改为执行主机并将调试器附加到该进程。 When the Host process loads your DLL into memory, you can then step through and debug the DLL's code as needed.当主机进程将您的 DLL 加载到 memory 中时,您可以根据需要逐步调试 DLL 的代码。

If the Host process is already running before you start your debugging, you can simply Attach the debugger to the Host process manually before it loads your DLL, and then the debugger will still be able to step through the DLL's code once the Host loads the DLL into memory.如果在您开始调试之前主机进程已经在运行,您可以在加载 DLL 之前手动将调试器附加到主机进程,然后一旦主机加载 DLL,调试器仍然能够单步执行 DLL 的代码进入 memory。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM