A good starting place is Professor Johnson’s guide to GDB. This will give you a good run down on the basic commands.
We have a couple of commands that are useful to us that are not included in that guide.
The next
and step
commands only work when debugging data is included in the file and they operate on the level of lines of C code. nexti
and stepi
, on the other hand, work at the instruction level, allowing us to walk through the code one instruction at a time. As with next
and step
, nexti
will “step over” the call
instruction, while stepi
will follow the jump into the function.
disassemble function_name
is a good place to startcall
instructionsb function_name
will put a breakpoint at the start of the named functionb \* address
to set a breakpoint at a particular address (which you will find when you disassemble)d \i $pc
, to display the next instruction to be run after every call to nexti
or stepi
info reg
or use display
or print
to look at specific ones