Linux-Software-Beschreibung: GNU-Debugger GdB
Überblicksinformationen
Kategorien:
Programmierung / Entwicklung
Aktuell verfügbare Version: 6.4.90 | Lizenztyp: GPL | Ansprechpartner: Fritz Wünsch
Beschreibung

GDB lets 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 lets you start your program, specify anything that might affect its behavior,
make it stop on specified conditions, examine what has happened when your program
has stopped, and change things in it, so you can experiment with correcting the
effects of one bug and go on to learn about another.
The program being debugged can be written in C, C++, Fortran, Java
(and many other languages). Those programs might be executing on the same machine
as GDB (native) or on another machine (remote).
Start der Anwendung
GdB muss über die Kommandozeile bedient werden (es gibt aber bei uns auch DDD -
The Data Display Debugger, ein recht populäres graphisches Front End zum GdB).
Hier der GdB in Reinform. Beispiel: C-Programm für die rekursiv definierte
Ackermann-Funktion:
/* Ackermann-Funktion */
#include <stdio.h>
int ackermann(int m,int n)
{
if ( m==0 )
return n+1;
if ( n==0 )
return ackermann(m-1,1);
return ackermann(m-1,ackermann(m,n-1));
}
int main(void)
{
printf("Ackermann A(3,3)=%d\n",ackermann(3,3));
return 0;
}
Es soll untersucht werden, mit welchen Wertepaaren (n,m) die Funktion ackermann jeweils sich selbst aufruft.
# Compiliere mit Debug-Info!
pc56770:~> gcc -ggdb acker.c
# Starte den gdb
pc51072:~> gdb a.out
GNU gdb 6.3-debian ....
# Setze Breakpoint beim Aufruf der Funktion
(gdb) break ackermann
Breakpoint 1 at 0x80483f6: file acker.c, line 7.
# Starte Programm (bis zum ersten Breakpoint)
(gdb) r
Starting program: /home/wuf04055/cprog/a.out
Breakpoint 1, ackermann (m=3, n=3) at acker.c:7
7 if ( m==0 )
# Setze Programm fort (wieder bis zum nächsten Breakpoint)
(gdb) c
Continuing.
Breakpoint 1, ackermann (m=3, n=2) at acker.c:7
7 if ( m==0 )
usw.
Breakpoint 1, ackermann (m=3, n=1) at acker.c:7
Breakpoint 1, ackermann (m=3, n=0) at acker.c:7
Breakpoint 1, ackermann (m=2, n=1) at acker.c:7
Weitere Informationen
Wikipedia-Artikel zu Gdb: http://en.wikipedia.org/wiki/Gdb
Komplette Online-Doku für die aktuelle zum Browsen:
http://sourceware.org/gdb/current/onlinedocs/gdb.html
Archiv mit aller Doku für die Version 6.6 zum Runterladen:
http://sourceware.org/gdb/onlinedocs/

