简体   繁体   English

如何调试.exe在Delphi中由另一个.exe启动

[英]How to debug .exe started by another .exe in Delphi

I want to debug App2.exe, which is started by App1.exe. 我想调试由App1.exe启动的App2.exe。 If App2.exe were a dll I could specify a host application, but this doesn't seem to work with an .exe. 如果App2.exe是一个DLL我可以指定一个主机应用程序,但这似乎不适用于.exe。

I now use 'attach to process', but this is useless if App2.exe crashes before I do that. 我现在使用'attach to process',但如果在我这样做之前App2.exe崩溃,这是没用的。

Is there a way to do this with having to attach to the process manually? 是否有办法通过手动附加到流程来执行此操作?

Set the "debug spawned processes" debugging option. 设置“debug spawned processes”调试选项。 It is off by default. 它默认是关闭的。 When App1 starts the new process, the debugger will pause. 当App1启动新进程时,调试器将暂停。 If the debugger isn't already attached to the new process automatically, attach to it, and then resume running it. 如果调试器尚未自动附加到新进程,请附加到该进程,然后继续运行它。

No, but there might be a way to get it to attach properly. 不,但可能有办法让它正确附着。 Find something that you know will happen in App2 soon before the crash point, and have it pop up a modal dialog box at that point. 在碰撞点之前不久找到你知道会在App2中发生的事情,然后让它弹出一个模态对话框。 Then it won't continue until you dismiss it, giving you time to attach the debugger. 然后它将不会继续,直到你解雇它,给你时间来附加调试器。

我想你可以自己启动app2.exe并将任何必要的命令行参数传递给它。

If you're using windows, there is a built in support for it. 如果您使用的是Windows,则会内置支持。 basically, you can tell the windows loader to launch some other process whenever a specific process is launched. 基本上,无论何时启动特定进程,您都可以告诉Windows加载程序启动其他进程。 for example, you can tell windows to always launch winword.exe whenever you click on notepad.exe 例如,您可以告诉Windows在您单击notepad.exe时始终启动winword.exe

you can use this ability in order to automatically launch a debugger whenever you start your process (this is why this feature was originally introduced, however you are not restricted to launch only debuggers :)) 您可以使用此功能,以便在您启动进程时自动启动调试器(这就是最初引入此功能的原因,但您不限于仅启动调试器:))

You can read exactly how to do it here . 你可以在这里准确地阅读如何做到这一点 You can also download the debugging tools for windows package and use GFlags to do it for you. 您也可以下载Windows软件包的调试工具,并使用GFlags为您完成。

If both apps are yours and you have the code than I propose the following: 如果这两个应用程序都是您的,并且您拥有的代码超出了我的建议:

  1. Make a debug mode for both apps. 为两个应用程序制作调试模式。 Use external inc file for instance 例如,使用外部inc文件
  2. Start two IDEs and load each app in its own IDE. 启动两个IDE并在其自己的IDE中加载每个应用程序。 Build in debug mode 在调试模式下构建
  3. If done right you can now debug the internal communication between apps 如果完成,您现在可以调试应用程序之间的内部通信

I have a project where a server spawns multiple exe worker processes that host each its own dll module. 我有一个项目,服务器生成多个exe工作进程,托管每个自己的dll模块。 I have a debug mode in which I can specify which dll will be loaded and I can have both processes running and communicationt in between from IDEs. 我有一个调试模式,我可以在其中指定将加载哪个DLL,我可以让两个进程在IDE之间运行和通信。 It is the best way I have found so far. 这是迄今为止我发现的最好方法。

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

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