I decided to find out how our C/C+ *nix practitioners use the gdb debugger.
Here is what I typically use:
- b – break filename.c:line #, function, filename.cpp:function, className::Member
- n, c, s — next continue step
- gdb program name => set breakpoints ==> run [parameter list] (I do this to set break points before the program starts)
- l – to list the surrounding source code.
- attach processID
6 break [location] - gdb programName corefile.core (to examine why app crashed)
- I also sometimes set breakpoint at exit function (break exit) to examine program stacks
- info b to examine all the breakpoints
- clear [breakpoints list ]
How do you use it?
Most useful gdb commands in my opinion (aside from all already listed):
Finally, if debugging over a slow link, the text UI might be of use. To use it, start gdb with the
--tuicommand-line switch.