GNU debugger. Used to debug programs compiled by GCC, core files or processes.

From the gdb man page:

You can use GDB to debug programs written in C or C++.
Support for Modula-2 and Chill is partial.

I've seen some GUI frontends to GDB on Win32 platforms (Cygwin), and they all have a weird interface. Luckily there is a console mode.

Here's a basic overall explanation of how to use GDB:

GDB is source-level. So no assembler knowledge is required, as is with many debuggers I've seen.

First, to put your program's source and symbol information into your object files, run your compiler with the -g flag:

	gcc -g -c -Wall somefile.c
	g++ -g -c -Wall somefile.cxx
	etc..

Run GDB on your program like so:
$ gdb binary
To set a breakpoint, use the break command. You can specify a line number, a function, or * and an address.
To run your program, type:
(gdb) run [args]
To load another program or core file:
(gdb) file filename
To execute the current line and proceed to the next (which will not be executed), type "step". You can give it an argument of the number of times to do this.
To continue execution after a break:
(gdb) continue
To go up in the program's stack (to the function that called this one), type "up". "down" to go down.
For a stack trace, type "bt".
To output an expression:
(gdb) print expression (ex: print i-1, print *someptr)

If your gdb has been compiled with support for threads, you can output a list of currently running threads with:
(gdb) info threads
And switch to a thread with:
(gdb) thread number

Log in or register to write something here or to contact authors.