GNU Debugger

Start the gnu debugger from the command line with:

$ gdb foo

Commands

Press <RET> to simply repeat the previous command.

Running

start
step
next

Step steps into the current line of code, whilst next steps over it.

Breakpoints

info breakpoints
break main.cc:140

Variables

display foo

Core Dumps

Enable core dumps (if necessary) with:

$ ulimit -c unlimited

To see what is set:

$ ulimit -a

To disable core dumps:

$ ulimit -c 0

View Stack Trace

To see the stack trace for a core dump:

$ gdb ./src/executable /tmp/core
(gdb) where
(gdb) thread apply all bt

See http://publib.boulder.ibm.com/httpserv/ihsdiag/get_backtrace.html


-- Frank Dean - 10 Apr 2010

Related Topics: DebianTips, LinuxHintsAndTips