GDB cheat sheet AsktheNerds

GDB cheat sheet

How to run GDB

gdb prog core $ gdb wc
GDB is free software and you are welcome to 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.
GDB 4.16 (alpha-dec-osf4.0), Copyright 1996 Free Software Foundation, Inc...
(gdb)

The basic commands

definition command examples
run programrun args (gdb) run -l split.c
debug running process attach pid (gdb) attach 1219
set breakpoint break location (gdb) b wc.c:112
(gdb) b main
view all breakpoints info breakpoints (gdb) i b
delete breakpoint delete breakpoint-num (gdb) d 1
single step a line of codestep (gdb) s
single step (skip funcs) next (gdb) n
run till a breakpoint is hit continue (gdb) c
display variable print expr (gdb) p argv[0]
(gdb) p &total_lines
display code list location (gdb) l main.c:80
show stacktrace backtrace (gdb) bt
change variableset var=value (gdb) set x=4
1

Hosted by www.Geocities.ws