Debugging with GDB (September 2007)

32 Debugging with GDB
parent The original process is debugged after a fork. The child pro c es s
runs unimpeded. This is the default.
child The new process is debugged after a fork. The parent process runs
unimpeded.
show follow-fork-mode
Display the current debugger response to a fork or vfork call.
If you ask to debug a child process and a vfork is followed by an exec, GDB executes
the new target up to the first breakpoint in the new target. If you have a breakpoint set on
main in your original program, the breakpoint will also be set on the child process’s main.
When a child process is spawned by vfork, you cannot debug the child or parent until
an exec call completes.
If you issue a run command to GDB after an exec call e xec utes, the new target restarts.
To restart the parent process, use the file command with the parent executable name as
its argument.
You can use the catch command to make GDB stop whenever a fork, vfork, or exec
call is made. See Section 5.1.2 [Setting catchpoints], page 37.