Besides things that have already been posted i also use:
- a .gdbinit file for STL containers
signal SIGNAL noprint nostopfor some custom signals that are of no real interest when debugging- C-Casts to dereference pointers
- catchpoints (catch throw, catch catch)
- condition for conditional break- and watchpoints
- rarely gdbserver for remote debugging
- gdb program coredump, for those embarassing segfaults ;)
PS: One reason i personally love gdb btw. is that it supports tab-completion for nearly everything (gdb commands, symbols in the symbol table, functions, memberfunctions etc.). This is a fairly good productivity boost in my opinion.
c++ - How do you use gdb? - Stack Overflow
C programming: How to use gdb with Makefile and command line arguments? - Stack Overflow
Properly Learning GDB
A quick intro to gdb.
Why do I need to compile my code with the -g flag to use GDB?
What is the difference between step and next in GDB?
My program crashed, can GDB help me figure out why?
Videos
GDB Quick Guide
I found out I didn't need cgdb by the way, it was better to just gdb -tui on Debian. Less modem noise in the form of uninterpreted escape sequences too.
So it paid up to do gdb -help.
The guide doesn't mention watch or watch -l but it points to Debugging with GDB where you can find everything.
It is a good quick start, with a couple of examples.
Besides things that have already been posted i also use:
- a .gdbinit file for STL containers
signal SIGNAL noprint nostopfor some custom signals that are of no real interest when debugging- C-Casts to dereference pointers
- catchpoints (catch throw, catch catch)
- condition for conditional break- and watchpoints
- rarely gdbserver for remote debugging
- gdb program coredump, for those embarassing segfaults ;)
PS: One reason i personally love gdb btw. is that it supports tab-completion for nearly everything (gdb commands, symbols in the symbol table, functions, memberfunctions etc.). This is a fairly good productivity boost in my opinion.
Scripting is a nice GDB feature.
- First you set a breakpoint, like: b someFunction\n.
- Then you run command: commands\n. GDB will ask for commands for that breakpoint.
- Common scenario is to print some value and then continue, so you will enter: p someVar\n continue\n.
- To end the script press: Ctrl-D
After running program you will see your script executed occasionally when the breakpoint occurs.
Hi all,
Anyone know of any courses for an intermediate-advanced C programmer to really learn GDB?
I've been using printf debugging for too long and only know the very basics of GDB debugging (taught alongside an O/S dev course I completed).
Courses would be my preferred method.