Product SiteDocumentation Site

5.2.4. Forked Execution

Among the more challenging bugs that can confront programmers is where one program (the parent) makes an independent copy of itself (a fork) that creates a child process which, in turn, fails. Debugging the parent process may or may not be useful—the only way to get to the bug may be by debugging the child process, but doing a gdb child isn't always possible.
To address this, GDB allows programmers to continue following the parent process after a fork, or to follow a child process.

Note

This capability is not supported by all architectures for which GDB is built, but even under those circumstances using GDB to follow a fork can still be possible. In such architectures, GDB can attach itself to a process that is already running, allowing a second instance of GDB to attach to a forked child process.