Collection of GDB commands that I use
Tells where a function returned.
(gdb) record
(gdb) fin
(gdb) reverse-step
Sometimes my application keeps receiving this signal while I try to debug. Dont know why but this is my solution.
(gdb) handle SIGPIPE nostop noprint pass
You can save the breakpoints of a session to load them later!
(gdb) save breakpoints <filename>
Saved to file 'bp'.
After saving you can continue your debug session normally. In this example I used bp as filename. To load the breakpoints, even in another session use:
(gdb) source <filename>
Show objects and structures in a better way.
(gdb) set print pretty on
When you have a long string, the print command won't print all the characters. To solve this:
(gdb) set print elements 0
In Linux, I save what I always use to a file, so I don't need to type the same commands every time:
> cat ~/.gdbinit
set pretty print on
set print elements 0
Most of the time I use cgdb. The command set is the same as GDB, and you can see the source code while you debug.