GDB Commands Jumpstart
This page was last modified 2009-12-15 21:13:27 by Puchu.Net user Choco. (Show history)


Flow Control

n execute next function
s step into function
si step instruction
fin step out of function
c continue
run ? start running program with arguments
bt print backtrace of stack frames
frame ?/up/down switch stack frames
thread ? inspect specified thread


break ? set breakpoint
dis break ? disable breakpoint
enable break ? enable disabled breakpoint
info break list breakpoints
delete break ? delete breakpoint

set value 0xd to a memory address replaces the instruction with a breakpoint.

Watch/Examine Variables

p ? print value of variable
whatis ? show type of variable
ptype ? print variable structure
set print pretty on print variables one per line, easier to read
display ? print value of variable automatically when a breakpoint is hit
dis display ? disable watching variable
enable display ? enable disabled variable watching
info display list variables being watched
delete display ? delete watched variable
x/? ? dump specified amount of memory at address
(gdb) x/16x 0xbfbf06ac
0xbfbf06ac:	0x08496b13	0x0963e848	0x00000000	0x088d5dcf
0xbfbf06bc:	0x0000008f	0x088d5d0c	0x088d5dcf	0x088b4401
0xbfbf06cc:	0x088d5d0c	0x097b5e38	0x082716b0	0xb34d94f8
0xbfbf06dc:	0xb7c1d3e1	0xbfbf0718	0xb7c214f0	0xb7cfe160
info reg dump register values
disas ? ? disassembles between address ranges

Other commands that may be useful: info args, info frame, info local, and info threads.

Access Memory

mem ? ? ro 32 define read-only memory region between two addresses using 32-bit memory access
dis mem ? disable memory region
enable mem ? enable disabled memory region
info mem list defined memory regions
delete mem ? delete defined memory region
dump ihex filename ? ? dump memory to file in Intel hex format
dump binary filename ? dump expression to file in binary format


  • To ignore SIGPIPE: handle SIGPIPE nostop noprint pass.
  • Remote debugging by executing gdbserver x.x.x.x:xxxx ..., and connect with command target remote x.x.x.x:xxxx. Since program is already running, use continue instead of run.
  • If library symbols are missing, use set solib-search-path ... or set solib-absolute-prefix ... to load symbols from target.
  • If backtrace isn't going back as far as you like, try set heuristic-fence-post 100000.
  • Older versions of gdb is useless when debugging multi-threaded application. 6.8 seems to work well?



Document is accessible from © 2002-2010 Sean Yang, Karen Yang, Don Yang and/or respective authors, all rights reserverd.

This material may contain (biased) opinions, inappropriate materials for numerous individuals, work of other authors from the internet, links that refer to other web documents and resources, or origial work that cannot be use for personal or commercial purposes. Please respect the work of original authors.

Creative Commons License
Powered By MediaWiki

© 2002-2010 Sean Yang, all rights reserved.