gnu debugger gdb redirects here for other uses see gdb disambiguation the gnu debugger gdb is a portable debugger that runs on many unixlike systems and works for many programming languages including ada c c objectivec free pascal fortran go java history gdb was first written by richard stallman in 1986 as part of his gnu system after his gnu emacs was reasonably stable from 1990 to 1993 it was maintained by john gilmore technical details features 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 programs normal behavior gdb target processors as of 2003 include alpha arm avr h8300 altera niosnios ii system370 system 390 x86 and its 64bit extension x8664 ia64 itanium motorola 68000 mips parisc powerpc superh sparc and vax lesserknown target processors supported in the standard release have included a29k arc etrax cris d10v d30v fr30 frv intel i960 68hc11 motorola 88000 mcore mn10200 mn10300 ns32k stormy16 and z8000 newer releases will likely not support some of these gdb has compiledin simulators for even lesserknown target processors such like m32r or v850 gdb is still actively developed as of version 70 new features include support for python scripting 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 that understands gdb protocol through a serial device or tcpip alternatively gdbserver can be used to remotely debug the program without needing to change it in any way 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 direct memory access dma graphical user interface the debugger does not contain its own graphical user interface and defaults to a commandline interface several frontends have been built for it such as ultragdb xxgdb data display debugger ddd nemiver kdbg xcode debugger gdbtkinsight and the hp wildebeest debugger gui wdb gui ides such as codelite codeblocks devc geany gnat programming studio gps kdevelop qt creator lazarus monodevelop eclipse netbeans and visualstudio can interface with gdb gnu emacs has a gud mode and tools for vim exist eg clewn these offer facilities similar to debuggers found in ides some other debugging tools have been designed to work with gdb such as memory leak detectors examples of commands gdb program debug program from the shell run v run the loaded program with the parameters bt backtrace in case the program crashed info registers dump all registers disas pc32 pc32 disassemble an example session consider the following sourcecode written in c include stdioh include stdlibh include stringh sizet foolen const char s return strlen s int main int argc char argv const char a null printf size of a lun foolena exit 0 using the gcc compiler on linux the code above must be compiled using the g flag in order to include appropriate debug information on the binary generated thus making it possible to inspect it using gdb assuming that the file containing the code above is named examplec the command for the compilation could be gcc examplec og g o example and the binary can now be run example segmentation fault since the example code when executed generates a segmentation fault gdb can be used to inspect the problem gdb example gnu gdb gdb fedora 73502011072213fc16 copyright c 2011 free software foundation inc license gplv3 gnu gpl version 3 or later httpsgnuorglicensesgplhtml this is free software you are free to change and redistribute it there is no warranty to the extent permitted by law type show copying and show warranty for details this gdb was configured as x8664redhatlinuxgnu for bug reporting instructions please see httpswwwgnuorgsoftwaregdbbugs reading symbols from pathexampledone gdb run starting program pathexample program received signal sigsegv segmentation fault 0x0000000000400527 in foolen s0x0 at examplec8 8 return strlen s gdb print s 1 0x0 the problem is present in line 8 and occurs when calling the function strlen because its argument s is null depending on the implementation of strlen inline or not the output can be different eg gnu gdb gdb 731 copyright c 2011 free software foundation inc license gplv3 gnu gpl version 3 or later httpsgnuorglicensesgplhtml this is free software you are free to change and redistribute it there is no warranty to the extent permitted by law type show copying and show warranty for details this gdb was configured as i686pclinuxgnu for bug reporting instructions please see httpswwwgnuorgsoftwaregdbbugs reading symbols from tmpgdbexampledone gdb run starting program tmpgdbexample program received signal sigsegv segmentation fault 0xb7ee94f3 in strlen from libi686cmovlibcso6 gdb bt 0 0xb7ee94f3 in strlen from libi686cmovlibcso6 1 0x08048435 in foolen s0x0 at examplec8 2 0x0804845a in main argcoptimized out argvoptimized out at examplec16 to fix the problem the variable a in the function main must contain a valid string here is a fixed version of the code include stdioh include stdlibh include stringh sizet foolen const char s return strlens int main int argc char argv const char a this is a test string printf size of a lun foolena exit 0 recompiling and running the executable again inside gdb now gives a correct result gnu gdb gdb fedora 73502011072213fc16 copyright c 2011 free software foundation inc license gplv3 gnu gpl version 3 or later httpsgnuorglicensesgplhtml this is free software you are free to change and redistribute it there is no warranty to the extent permitted by law type show copying and show warranty for details this gdb was configured as x8664redhatlinuxgnu for bug reporting instructions please see httpswwwgnuorgsoftwaregdbbugs reading symbols from pathexampledone gdb run starting program pathexample size of a 21 gdb prints the output of printf in the screen and then informs the user that the program exited normally free software portal computer programming portal binary file descriptor library libbfd dbx ddd a gui for gdb and other debuggers gdbserver sysdig official website ultragdb visual cc debugging with gdb on windows and linux kgdb linux kernel source level debugger the website for mygdb gdb frontend in the korean language a visual studio plugin for debugging with gdb comparison of gdb frontends 2013 using eclipse as a frontend to the gdb debugger documentation richard m stallman roland pesch stan shebs et al debugging with gdb free software foundation 2011 isbn9780983159230 gdb internals tutorials rmss gdb tutorial ryan schmidt vtegnu projecthistory gnu manifesto free software foundation europe india latin america history of free software licenses gnu general public license gnu lesser general public license gnu affero general public license gnu free documentation license gpl linking exception software gnu variants hurd linuxlibre glibc bash coreutils findutils build system gcc binutils gdb grub gnome gnustep gimp gnu ring gnu emacs gnu texmacs gnu octave gnu r gsl gmp gnu electric gnu archimedes gnunet gnu privacy guard gnuzilla icecat gnu health gnumed gnu lilypond gnu go gnu chess gnash guix guix system distribution more publicspeakers alexandre oliva benjamin mako hill bradley m kuhn eben moglen federico heinz georg c f greve john sullivan loc dachary matt lee nagarjuna g ricardo galli richard stallman robert j chassell other topics gnulinux naming controversy revolution os free software foundation antiwindows campaigns defective by design 