GDB, the GNU Project Debugger, is the standard interactive debugger of the free software world. It was written by Richard Stallman as part of the GNU Project in the mid 1980s and has been maintained since by the Free Software Foundation and a wide community of contributors. Its purpose, as the project’s documentation states, is to let a programmer see what is going on inside a program while it executes, or what a program was doing at the moment it crashed.
The official documentation hub at sourceware.org describes GDB as the GNU Project Debugger and links to the GDB User Manual in multiple formats. GDB supports a long list of source languages, including C, C++, Objective-C, Fortran, Go, Rust, and Ada, and it can debug programs compiled by GCC and other compilers that emit standard debugging information. A single GDB build can target many processor architectures, and through its remote serial protocol it can debug a program running on a separate machine, an embedded board, or a simulator while the debugger itself runs elsewhere.
The central tools GDB gives a programmer are described in its manual’s chapter on stopping and continuing. A breakpoint halts execution at a specified location, set by line number, function name, or exact address, optionally guarded by a condition. A watchpoint is a special kind of breakpoint that stops the program when the value of an expression changes, which is invaluable for catching the moment a variable is unexpectedly modified. Once stopped, the programmer can inspect the call stack, examine and alter variables and memory, evaluate expressions, and step through the code one line or one instruction at a time.
Beyond live debugging, GDB performs post-mortem analysis by loading a core dump together with the executable, reconstructing the stack and program state as they were at the instant of the crash. On modern Unix-like systems GDB controls the inferior process through the operating system’s process-tracing facilities, such as the ptrace system call on Linux, which let one process observe and control the execution of another and read or write its memory and registers.
As one of the earliest major pieces of GNU software, GDB has shaped expectations for what a debugger should do and remains a foundation of the toolchains built around GCC and, increasingly, LLVM. Its command language, scripting hooks, and machine interface have also made it the engine behind many graphical front ends and integrated development environments.