Binary:
gdb binary
/gdb --args <args...>
set args <args...>
- set args if neededbreak <where>
- set breakpoints as necessaryr
- run
Core dumps:
gdb binary core-dump
directory <dir
/dir <dir>
- Add dir to the front of the source path
- Without dir argument resets path to
$cdir:$cwd
set directories <path-list>
- Set the source path to path-list.
$cdir:$cwd
added if missing.
- Set the source path to path-list.
set substitute-path <from> <to>
- Substitution rule for finding source files
- With arguments, all substitution rules are deleted.
set solib-search-path <dir>
- Specifies directories where GDB will search for shared libraries with symbols. Very useful when debugging with gdbserver.
set debug-file-directory <dir>
- Symbols files are loaded from dir as long as the binary supports debug-link and provides the names.
add-symbol-file filename address
- Parameter address is the address for
.text
section. - Can be retrieved with:
readelf -WS <filename> | grep .text | awk '{ print "0x"$5 }'
- Parameter address is the address for
bt
- backtrace: show stack functions and argsinfo
frame - show stack start/end/args/locals pointersx/100x $sp
- show stack memory