GDB - Opty-Forks/SSof GitHub Wiki
Below is a simple list of basic GDB commands. They should get you going for most of our exercises
- To analyse a program with gdb type
gdb <file_to_analyse>
- To disassemble a function use:
disassemble <fn_name>
ordisassemble <memory_address>
- e.g.
disassemble main
ordisassemble 0x0804843b
. - in
gdp-peda
you can usepdisass <fn_name/address>
to do it with colours.
- e.g.
-
b <memory_address>
inserts a breakpoint at addressmemory_address
- eg
b *0x0804846a
orb *main+47
- eg
-
r
runs the current program -
c
continues execution until the next breakpoint -
n
executes the next instrution -
s
steps into functionfn
when the instruction is acall fn
-
p
prints the value of an expression-
p variable_name
prints the content of the variable (if the symbolvariable_name
is defined) -
p &variable_name
prints the address where the variable is in memory -
p *memory_address
prints the content in this address
-
-
bt
prints a backtrace of the entire stack, that is, shows how you got to the current frame -
info f
prints the information about the current frame. This is usefull whenever you need to know where the return address of the function is stored and/or the value contained there. -
stack n
shows then
registers of the stack afteresp
. -
x/nx $rsp
--- shows then
registers after the register$rsp
-
x/nx address
--- shows then
registers after the addressaddress