GNU Debugger

infobox software

developer = GNU Project
released = 1986
latest_release_version = 6.8
latest_release_date = March 27, 2008
operating_system =
genre = Debugger
license = GPL
website = []

The GNU Debugger, usually called just GDB, is the standard debugger for the GNU software system. It is a portable debugger that runs on many Unix-like systems and works for many programming languages, including Ada, C, C++, FreeBASIC, and Fortran.


GDB was first written by Richard Stallman in 1986 as part of his GNU system, after his GNU Emacs was "reasonably stable". [cite web
title = Richard Stallman lecture at the Royal Institute of Technology, Sweden (1986-10-30)
url =
accessdate = 2006-09-21
quote = Then after GNU Emacs was reasonably stable, which took all in all about a year and a half, I started getting back to other parts of the system. I developed a debugger which I called GDB which is a symbolic debugger for C code, which recently entered distribution. Now this debugger is to a large extent in the spirit of DBX, which is a debugger that comes with Berkeley Unix.
] GDB is free software released under the GNU General Public License (GPL). It was modeled after the Dbx debugger, which came with Berkeley Unix distributions.

From 1990 to 1993 it was maintained by John Gilmore while he worked for Cygnus Solutions. Now it is maintained by GDB Steering Committee which is appointed by Free Software Foundation. [cite web
title=GDB Steering Committee
accessdate = 2008-05-11

Technical details


GDB offers extensive facilities for tracing and altering the execution of computer programs. The user can monitor and modify the values of programs' internal variables, and even call functions independently of the program's normal behavior.

GDB target processors (as of 2003) include:
Alpha, ARM, AVR, H8/300, System/370, System 390, X86 and X86-64, IA-64 "Itanium", Motorola 68000, MIPS, PA-RISC, PowerPC, SuperH, SPARC, and VAX.

Lesser-known target processors supported in the standard release have included A29K, ARC, CRIS, D10V, D30V, FR-30, FR-V, Intel i960, M32R, 68HC11, Motorola 88000, MCORE, MN10200, MN10300, NS32K, Stormy16, V850, and Z8000. (Newer releases will likely not support some of these.)

GDB has compiled-in simulators for target processors even for lesser-known target processors such like M32R or V850.

GDB is still actively developed. As of early 2007, the focus is on adding "reversible debugging" support [cite web
title = GDB and Reversible Debugging
url =
accessdate = 2007-03-01
quote = Reversible debugging (the ability to "step backwards" through a program) is an obviously powerful tool. GDB does not support it today, but the foundations have been laid, and the GDB maintainers are looking for contributors interested in expanding those foundations.
] — allowing a debugging session to step backwards, much like rewinding a crashed program to see what happened. Adding reversible debugging is one of the High Priority Free Software Projects.

Remote debugging

GDB offers a 'remote' mode often used when debugging embedded systems. Remote operation is when GDB runs on one machine and the program being debugged runs on another. GDB can communicate to the remote 'stub' which understands GDB protocol via Serial or TCP/IP.

The same mode is also used by KGDB for debugging a running Linux kernel on the source level with gdb. With kgdb, kernel developers can debug a kernel in much the same way as they debug application programs. It makes it possible to place breakpoints in kernel code, step through the code and observe variables. On architectures where hardware debugging registers are available, watchpoints can be set which trigger breakpoints when specified memory addresses are executed or accessed. kgdb requires an additional machine which is connected to the machine to be debugged using a serial cable or ethernet. On FreeBSD, it is also possible to debug using Firewire DMA.


The debugger does not contain its own graphical user interface, and defaults to a command-line interface. Several front-ends have been built for it, such as DDD, Eclipse CDT, KDbg, Xcode debugger, GDBtk/ [ Insight] and the "GUD mode" in GNU Emacs. These offer facilities similar to debuggers found in integrated development environments.

Some other debugging tools have been designed to work with GDB, such as memory leak detectors.

Examples of commands

An example session

This is an example GDB session on the example program in Stack trace:

GNU gdb Red Hat Linux ( 2004 Free Software Foundation, Inc.GDB is free software, covered by the GNU General Public License, and you arewelcome to change it and/or distribute copies of it under certain conditions.Type "show copying" to see the conditions.There is absolutely no warranty for GDB. Type "show warranty" for details.This GDB was configured as "i386-redhat-linux-gnu"...Using host libthread_db library "/lib/".

(gdb) runStarting program: /home/sam/programming/crashReading symbols from shared object read from target memory...done.Loaded system supplied DSO at 0xc11000This program will demonstrate gdb

Program received signal SIGSEGV, Segmentation fault.0x08048428 in function_2 (x=24) at crash.c:2222 return *y;(gdb) edit(gdb) shell gcc crash.c -o crash -gstabs+(gdb) runThe program being debugged has been started already.Start it from the beginning? (y or n) ywarning: cannot close "shared object read from target memory": File in wrong format`/home/sam/programming/crash' has changed; re-reading symbols.Starting program: /home/sam/programming/crashReading symbols from shared object read from target memory...done.Loaded system supplied DSO at 0xa3e000This program will demonstrate gdb24Program exited normally.(gdb) quit

The program is being run. After the cause of the segmentation fault is found, the program is edited to use the correct behavior. The corrected program is recompiled with GCC and then run.

See also

*Binary File Descriptor library (libbfd)
*dbx debugger


External links

* [ GDB homepage]
* [ kgdb, the gdb backend for debugging the Linux kernel]


* Richard M. Stallman, Roland Pesch, Stan Shebs, et al., [ "Debugging with GDB"] (Free Software Foundation, 2002) ISBN 1-882114-88-4
* [ GDB Internals]


* [ Peter Jay Salzman's GDB guide] : "Using GNU's GDB Debugger"

Wikimedia Foundation. 2010.

Look at other dictionaries:

  • GNU Debugger — Captura de pantalla …   Wikipedia Español

  • GNU-Debugger — GDB Bildschirmfoto des GNU Debuggers Basisdaten Entwickler: GNU Projekt Aktuelle Version …   Deutsch Wikipedia

  • GNU Debugger — GDB Bildschirmfoto des GNU Debuggers Basisdaten Entwickler GNU Projekt Aktuelle  …   Deutsch Wikipedia

  • GNU Debugger — Pour les articles homonymes, voir GDB. GNU Debugger …   Wikipédia en Français

  • GNU Debugger — GDB Тип …   Википедия

  • GNU Debugger — GDB o GNU Debugger es el depurador estándar para el sistema operativo GNU. Es un depurador portable que se puede utilizar en varias plataformas Unix y funciona para varios lenguajes de programación como C, C++ y Fortran. GDB fue escrito por… …   Enciclopedia Universal

  • GNU's Not Unix — GNU Die unter GNU verwendete Desktop Umgebung GNOME …   Deutsch Wikipedia

  • GNU-Manifest — GNU Die unter GNU verwendete Desktop Umgebung GNOME …   Deutsch Wikipedia

  • GNU HURD — GNU Die unter GNU verwendete Desktop Umgebung GNOME …   Deutsch Wikipedia

  • GNU Mach — GNU Die unter GNU verwendete Desktop Umgebung GNOME …   Deutsch Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”

We are using cookies for the best presentation of our site. Continuing to use this site, you agree with this.