gpt4 book ai didi

c++ - 调试当前项目启动的进程

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:55:34 25 4
gpt4 key购买 nike

我的 Visual Studio 解决方案包含两个 C++ 控制台项目,“A”和“B”,其中“A”以编程方式启动 B(使用 CreateProcess())。

如果我在创建“B”之后开始单步执行“A”,我如何才能检测到“B”项目中的断点并将其停止?

目前我只是在“B”中的特定点粘贴“DebugBreak()”,但这很烦人,因为弹出该窗口通常需要一段时间才能让您使用 VS 实例调试应用程序,而且它通常不会显示当前实例,因此我必须启动另一个需要更长时间的实例。

我无法使用附加到进程,因为“B”启动、执行其操作然后关闭得太快。

是否有标记项目自动附加的功能,例如让我在 main 的开头有一个断点(类似于 main 开头的 DebugBreak)?

最佳答案

我在 MSDN 上找到了这条注释:

The debugger does not automatically attach to a child process that is started by a debugged process, even if the child project is in the same solution. To debug a child process:

  • Attach to the child process after it has been started.
  • -or-
  • Configure Windows to automatically start the child process in a new instance of the debugger.

后者显然可以通过一些注册表干预来实现: Automatically start a process in the debugger

关于c++ - 调试当前项目启动的进程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19878227/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com