Automatically attach vs2005 debugger to a child processes

二次信任 提交于 2020-01-01 10:08:23

问题


I have a main C++ app built in Visual Studio 2005, called A.exe. It spawns a child process, B.exe. I run process A in the debugger by hitting F5 -- the only way I know to hit breakpoints in process B is to wait for A to kick it off, then run Debug -> Attach to Process, and manually select B.exe. This doesn't work very well if I need to debug initialization code in process B -- I have to start putting in 10 second sleeps at the beginning.

Is there some trick in the vs2005 GUI that I'm missing?

I'm using native code, by the way.

Thanks, Nathan


回答1:


You can tell Windows to automatically attach the debugger when a certain process is started (by specifying the process name in a registry setting).

The details are here: http://msdn.microsoft.com/en-us/library/a329t4ed(v=vs.100).aspx




回答2:


You'd be hard pushed to make use of the debugbreak command in the child process as the debug process is not yet attached.

However, there is another that may be of use. Seeing as your creating the process, you'll have the handle to it. So give the DebugBreakProcess function a whirl.



来源:https://stackoverflow.com/questions/448154/automatically-attach-vs2005-debugger-to-a-child-processes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!