GDB: The GNU Project Debugger

GDB: The GNU Project Debugger

What is GDB?

GDB, the GNU Project debugger, allows you to see what is going on `inside' another program while it executes -- or what another program was doing at the moment it crashed.

GDB can do four main kinds of things (plus other things in support of these) to help you catch bugs in the act:

Start your program, specifying anything that might affect its behavior.

Make your program stop on specified conditions.

Examine what has happened, when your program has stopped.

Change things in your program, so you can experiment with correcting the effects of one bug and go on to learn about another.

What Languages does GDB Support?

Ada

Assembly

C

C++

D

Fortran

Go

Objective-C

OpenCL

Modula-2

Pascal

Rust

GDB version 9.2

An errata list (PROBLEMS) and documentation are also available.

News

September 13th, 2020: GDB 10 branch created The GDB 10 branch ( gdb-10-branch ) has been created. To check out a copy of the branch use: git clone --branch gdb-10-branch git://sourceware.org/git/binutils-gdb.git May 23rd, 2020: GDB 9.2 Released! The latest version of GDB, version 9.2, is available for download. This is a minor corrective release over GDB 9.1, fixing the following issues: PR tui/25586 (Resizing the source/disassembly or command window produces corrupted display)

PR gdb/25650 (GDB can't 'printf' a convenience variable holding an inferior address)

PR build/25981 (Use of short i386 register names breaks compilation on recent Solaris 11.4)

PR symtab/26003 (infinite loop loading symbols from separate debug objfile)

PR build/26029 (GDB build failure on SPARC) February 8th, 2020: GDB 9.1 Released! The latest version of GDB, version 9.1, is available for download. This version of GDB includes the following changes and enhancements: Building GDB and GDBserver now requires GNU make >= 3.82.

If you choose to build GDB without using the GNU readline version bundled with the GDB sources, building GDB new requires GNU readline >= 7.0.

Removed targets and native configurations: GDB no longer supports debugging the Cell Broadband Engine; GDB no longer supports Solaris 10.

New TI PRU Simulator (pru-*-elf).

Python Enhancements: GDB can now be compiled with Python 3 on Windows; Various Python API enhancements;

Usability enhancements: [experimental] Multithreaded symbol loading for higher performance (turned off by default, use 'maint set worker-threads unlimited' to turn this feature on); Command names can now use the '.' character; GDB can now place breakpoints on nested functions and subroutines in Fortran; GDB now shows the Ada task names at more places, e.g. in task switching messages. Styling enhancements to various commands to improve readability. GDB now has a standard infrastructure to support dash-style command options ('-OPT'). One benefit is that commands that use it can easily support completion of command line arguments. Try "CMD -[TAB]" or "help CMD" to find options supported by a command. Over time, we intend to migrate most commands to this infrastructure.

Enhancements to existing commands: "printf" and "eval" can now print C-style and Ada-style strings without calling functions in the program; "info sources" has been enhance to allow only printing files whose name match a REGEXP; New value "presence" for the "set print frame-arguments" setting, to only indicate the presence of arguments with '...' instead of printing the argument names and values; The "focus", "winheight", "+", "-", ">", " New options support for the following commands that allow overriding a number of relevant global settings (as set by e.g. "set print [...]" commands): "print", "compile print", "backtrace", "frame apply", "tfaas", "faas"; "info types" support for "-q" to disable printing of some header information; In settings, "unlimited" can now be abbreviated with "u". New commands: "define-prefix" to define user-defined prefix commands; "|" or "pipe" to execute a command and send its output to a shell command. "with" to run a given command with a setting temporarily changed to a given value; "set may-call-functions" to control whether subprogram can be called from GDB; "set print finish [on|off]" to control whether the returned value should be printed when using the "finish" command; "set print max-depth" to simplify the printing of deeply nested structures; "set print raw-values [on|off]" to turn on and off pretty printers; "set logging debugredirect [on|off]" to control whether to redirect debug output to the log file; Various new "set style" commands; "set print frame-info [...]" to control what information to print when printing a frame. "set tui compact-source" to enable the "compact" mode for the TUI source window; "info modules [...]" to query information about Fortran modules; The "set/show print raw-frame-arguments" commands replace the "set/show print raw frame-arguments" (now with a dash instead of a space). The latter is now deprecated and may be removed in a future release.

New GDB/MI commands "-complete" to list possible completions; "-catch-throw", "-catch-rethrow", and "-catch-catch", the GDB/MI equivalent of the "catch throw", "catch rethrow", and "catch catch" commands (respectively); "-symbol-info-functions", "-symbol-info-types", and "-symbol-info-variables", the GDB/MI equivalent of the "info functions", "info types", and "info variables" commands (respectively); "-symbol-info-modules", "-symbol-info-module-functions", and "-symbol-info-module-variables", the GDB/MI equivalent of "info modules", "info module functions" and "info module variables".

Other MI changes The default version of the MI interpreter is now 3 (-i=mi3); The output of information about multi-location breakpoints (which is syntactically incorrect in MI 2) has changed in MI 3; Backtraces and frames include a new optional field "addr_flags".

Several new builtin convenience variables $_gdb_major and $_gdb_minor; $_gdb_setting, $_gdb_setting_str, $_gdb_maint_setting and $_gdb_maint_setting_str $_cimag and $_creal $_shell_exitcode and $_shell_exitsignal

Miscellaneous enhancements: Support for a new configure option "--with-system-gdbinit-dir", where system gdbinit files are to be loaded from at startup; 'thread-exited' event is now available in the annotations interface; The TUI SingleKey keymap is now named "SingleKey" (requires GNU readline >= 8.0).

See the NEWS file for a more complete and detailed list of what this release includes. Nov 28, 2006: Reversible Debugging The GDB maintainers are looking for contributors interested in reversible debugging.