Using gdb, the Gnu Debugger

Here are some more useful commands.

run
starts running the program. This will run to the first breakpoint. You can pass arguments to the run command; this passes arguments to your program. For example
r arg1 arg2
print
displays the value of a variable or expression
display
Display the value of a variable or expression at each step
step
steps through the program a line at a time, stepping into functions.
next
steps through the program a line at a time, stepping over functions
finish
run to the end of the current function (useful if you step into a function by mistake)
continue
runs to the next breakpoint
list
shows the source code
quit
terminates the debugger
help
gets more information