GDB (GNU Project Debugger) cheatsheet
- "set logging file mylog.txt" - logs to mylog.txt
- "set logging on thread apply all bt" - logs backtraces of all threads
- "vi ~/.gdbinit dir source_dir, br somefunction etc" - add frequently used commands to gdbinit
- "gdb -tui executable" - UI mode
- "finish" - finish execution of current function and print return value
- "until linenumber" - continue execution until line number
- "advance functionname" - continue till functionname is called
- "jump location"
- "watch i" - prints when value changes
- "rwatch i" - break when variable is read
- "awatch i" - break when variable is written to or read from
- "disp i" - keep printing value of i
- "undisplay i" - stop displaying
- "set variable expression" - sets variable's value to expression
- "x/13b 0x401820a8" - examine 13 bytes at the given address
- "layout next" - Display the next layout.
- "layout prev" - Display the previous layout.
- "layout src" - Display the source window only.
- "layout asm" - Display the assembly window only.
- "layout split" - Display the source and assembly window.
- "layout regs" - Display the register window together with the source or assembly window.
- "focus next | prev | src | asm | regs | split" - Set the focus to the named window. This command allows to change the active window so that scrolling keys can be affected to another window. e.g fs src
- "refresh" - Refresh the screen. This is similar to using C-L key.
- "update" - Update the source window and the current execution point.
- "winheight name +count" - Increase window height
- "winheight name -count e.g: wh src -20" - Decrease window height
- "set print array on" - Pretty print arrays.
- "set print pretty on" - GDB will print structures in an indented format with one member per line
- "break linespec thread threadno if cond" - breaks at given line for given thread if condition is met
- "ptype -v struct st_one" - Prints offsets in a structure
- "set $my_arg0=*($sp-0x64)" - defining convenience variables
No comments:
Post a Comment