First page Back Continue Last page Overview Graphics
Gdb: Basic commands
run arg1 arg2 ...
- Usual way to pass args
- NB: gdb prog arg1 arg2 doesn't work
where/up/down
- Show the call stack and move about
print - Show variable value
list - list source
Break - Set breakpoint
Notes:
Annoyingly you can't just prepend gdb to the command line you run your program with.
So do: gdb seggy
and then at the gdb prompt type: run
(since we haven't got any arguments).
It will get a SEGV (i.e. It will segfault). Now type
'where'. Here you can see the call stack. You can use up repeatedly to move to the previous function. And you can print variables with print, and list source at that point.
Sometimes you suspect where it is going to fail and want to look at it first. So do: break func2
and : run
again. Look how it stops at the first call to func2.