Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

20080925

Debugging child processes

Problem:
Program A executes program B.
You want to debug program B.
B exits before you can attach your debugger.

Solution:
Insert an infinite loop in main() in program B:

while(1) {}

Run program A.
Attach debugger to program B.
Set the program counter to the next line:

In gdb, use the "jump" command.
In Visual Studio, use the "Set next statement" command on the context menu.