In the next posts, I'll share the configuration files of my development and debugging tool. I think having a nice dev environment is key to good quality programming. At least, it makes your experience better. It's also verrrry nice for the people that will have to interact with you and your code!
I'll start with my .gdbinit:
No window size, we can scroll:
set height 0 set width 0
Allow pending breakpoints, we know what we're doing:
(gdb) break foobar Function "foobar" not defined. Breakpoint 9 (foobar) pending.
means that there is no "foobar" currently loaded, but maybe you know it will appear later.
set breakpoint pending on
We're doing python development, so print the full stack trace when it crashes:
set python print-stack full
GDB, please don't complain, I know what I'm doing! ... but beware, you may loose your session if you enter start in the middle of your debugging
set confirm off
Structure easier to read:
set print pretty
Save history, up-arrow and ctrl-r can save a lot of time:
set history filename ~/.gdb_history set history save
We can also add a little bit of Python shortcut commands:
quickly print Python objects pp instead of py print:
class pp(gdb.Command): """Python print its arg""" def __init__(self): gdb.Command.__init__ (self, "pp", gdb.COMMAND_DATA, completer_class=gdb.COMPLETE_SYMBOL) def invoke (self, arg, from_tty): gdb.execute("python print %s" % arg) pp()
quickly list attributes of a Python object: ppd
class ppd(gdb.Command): """Python print dir() of its arg""" def __init__(self): gdb.Command.__init__ (self, "ppd", gdb.COMMAND_DATA, completer_class=gdb.COMPLETE_SYMBOL) def invoke (self, arg, from_tty): gdb.execute("python print dir(%s)" % arg) ppd()
(src/ls.c:1242 main gdb) $