views:

406

answers:

3

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  A: 

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.

Simon Hughes
+1  A: 

Check out this answer

Igal Serban
+1  A: 

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.aspx

Hazy Joe Aardvark