Skip to content

Instantly share code, notes, and snippets.

@soardex
Created May 31, 2015 14:51
Show Gist options
  • Save soardex/eb3fc9f6db6a75c06af8 to your computer and use it in GitHub Desktop.
Save soardex/eb3fc9f6db6a75c06af8 to your computer and use it in GitHub Desktop.
Useful commands for GDB
### going back the backtrace
backtrace
select-frame [frameno]
up
down
### reversing stepping in the code
target record-full
reverse-{next, continue, step}
note: target record-full must be set after run
?- ---------------------------------------------
?- run program
?- target record-full
?- ---------------------------------------------
### displaying variable in the scope
display [variable]
### setting breakpoints
break [filename:lineno]
break [...] if [condition]
### setting the commands to run after a breakpoint is hit
info break
commands [breakno]
### setting condition on breakpoint
condition [breakno] [condition]
### condition on string evaluate
condition [breakno] strcmp(variable, comparitive_word) == 0
### set the directory to search for source files
directory [path]
### setting hardware breakpoints
watch [variable]
### viewing local, global, and arguments
info locals
info all
info args
### the x command
x/[format] [optional address]
x/x is elements in hex
x/d is signed decimals
x/c is to display characters
x/i is to dissamble memory as instructions
x/s is to interpret memory to C strings
### get debugger settings
show
### setting alias
alias
### executing python commands
python
### common commands usually
next
continue
step
list
enable
disable
print
shell
make
restart
run
### automatic enable target recording
?- ---------------------------------------------
?- break
?- condition [breakno] [condition]
?- commands [breakno]
?- > target record-full
?- > end
?- ---------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment