User guide

Chapter 5. Debugging
58
1 breakpoint keep y 0x080483f5 in main at iterations.c:8
stop only if i == 8936
breakpoint already hit 1 time
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.
5.2.5. Threads
In most cases, a forked program immediately uses one of the variations of the exec function to start
a completely independent executable. In the same manner, threads use multiple paths of execution,
occurring simultaneously in the same executable. This can provide a whole new range of debugging
challenges, such as setting a breakpoint for a particular thread that won't interrupt the execution of any
other thread. GDB supports threaded debugging (but not in all architectures for which GDB can be
built).
5.2.6. GDB Variations and Environments
GDB normally uses a command-line interface, a CLI, but it also includes what's called a “machine
interface,” the MI. Internally, Eclipse invokes GDB using the MI but a number of other applications
similarly use MI to provide different user interfaces.
Emacs, oddly enough, also supports GDB. It offers a collection of major modes that provide an
interface to GDB. For more information on this, refer to info emacs; additional information on this is
also available from the following link:
http://www.gnu.org/software/emacs/manual/html_mono/emacs.html#GDB-Graphical-Interface
5.2.7. GDB Documentation
GDB is a very mature application, literally decades in the making, and is extremely well documented.
The most convenient way to access that documentation, and the way most likely to provide
documentation on the version of GDB actually installed, is through info gdb; this provides access
to the GDB info file included in the GDB installation. In addition, man gdb offers more concise GDB
information.
Red Hat also provides extensive GDB documentation on the following link:
http://sources.redhat.com/gdb/current/onlinedocs/gdb.html