I've been doing a lot of debuging at work using GDB. There are a bunch of useful commands among GDB's huge command list. Here's a quick list of the one's I've found useful:
- make – run make. It can take arguments just like on the command line.
- enter – do the same command again.
- n (next) – move to the next source line in the file.
- s (step) – step into the function.
- finish – step out of the current function.
- break filename:line number – set a breakpoint at a particular line.
- clear – clear the breakpoint you are stopped on.
- bt (backtrace) – show the current stack.
- frame n – go to the nth stack frame.
- info threads – list the current threads.
- thread n – look at the nth thread.
- print something – print a variable's value, or evaluate something (such as print sizeof(foo)
- info locals – print all local variables.
- info args – print all of the arguments to the current function as they are now (as opposed to as they were at the top of the function).
- call function – call a function.
- whatis something – print the type of a thing.
- x – just look at help x. This does memory dumps in many formats.
