p3l6.dev|

GDB

<<Back to Index

RUNNING / SOURCES

Command Action
$ gdb [core dump] start gdb, optional core dump
$ gdb –args program start gdb and pass arguments
$ gdb –pid start gdb attached to process
set args set the arguments to be passed on run
run run the program
kill kill the running program
thread <thread #> choose thread to operate on
directory add directory to list searched for sources

BREAKPOINTS / WATCHPOINTS

Command Action
break [if ] set a new breakpoint
watch [if ] set a new breakpoint
delete <breakpoint/watchpoint #> remove a breakpoint or watchpoint
clear remove all breakpoints
enable <breakpoint/watchpoint #>  
disable <breakpoint/watchpoint #>  

< WHERE > / < CONDITION >

Command Action
function_name the named function
line_number the line number in current source file
file:line_number the line number in named source
almost any c expression evaluating to true/false
condition <breakpoint #> set or change condition for breakpoint

STEPPING / STACK / MANIPULATION

Command Action
step (stepi) go to next instruction/line, into functions
next (nexti) go to next instruction/line, skip over functions
finish continue until current function returns
continue continue normal execution
backtrace, where show call stack
backtrace full, where full show call stack with all local variables in each
thread apply all where show call stack for every thread
frame <frame #> select the frame to operate on
set var = change content of a variable to value
return force function to return now, passing value
handle how to handle signals: [no]print, [no]stop, [no]pass ( pass to program )

VARIABLES

Command Action  
print[/format] print variable or memory location or register  
display[/format] like print, but print after each step  
undisplay <display #>    
enable disable display <display #>  
x[/NumFormatUnit] print memory, num, format, unit(b byte, h halfword, w word, g giant word)  

< FORMAT > / < WHAT >

Command Action
a, d, o, u, x, t pointer, int, float, oct, unsigned int, hex, binary
c, s character, c string
expression any c, including functions(must cast return type)
file_name:variable_name content of a static variable in named file
function::variable_name content of variable in function on stack
{type}address content at address, interpreted as type
$register content of a named register( $esp $ebp $eip .. )

INFORMATION

Command Action
disassemble [] show disassembly current function or where
info args args of current stack frame
info breakpoints info about break and watchpoints
info display info about displays
info locals info about local vars
info signals info about how signals are handled
info threads list all threads
show directories list places gdb looks for sources
whatis print type of variable
list print out source lines