We’ve covered many of the features of python-gdb:
- Writing new commands
- Convenience functions
- Auto-loading of Python code
- Scripting gdb from Python
- Bringing up a GUI
In fact, that is probably all of the user-visible things right now. There are classes and methods in the Python API to gdb that we have not covered, but you can read about those when you need to use them.
What next? There are a few things to do. There are probably bugs. As we saw in some earlier sections, support for I/O redirection is not there. We need better code for tracking the inferior’s state. Barring the unexpected, all this will be done in the coming months.
Now is an exciting time to be working on gdb. There are a number of very interesting projects underway:
- Reversible debugging is being developed. The idea here is that gdb can record what your program does, and then you can step backward in time to find the bug.
- Sérgio Durigan Júnior, at IBM, has been working on syscall tracing support. This will let us do strace-like tracing in gdb. What’s nice about this is that all the usual gdb facilities will also be available: think of it as a Python-enabled strace, with stack dump capability.
- The excellent folks at Code Sourcery (I would name names, but I’m afraid of leaving someone out) are working on multi-process support for gdb. This is the feature I am most looking forward to. In the foreseeable future, gdb will be able to trace both the parent and the child of a
fork. The particular “wow” use-case is something I read on the frysk web site: run “
make check” in gdb, and have the CLI fire up whenever any program SEGVs. No more futzing with setting up the debug environment! In fact, no more figuring out how to get past libtool wrapper scripts — we could add a little hack so that you can just run them in gdb and the right thing will happen.
Naturally, we’ll be wiring all this up to Python, one way or another.
I’ve also got some longer-term plans for the Python support. I’m very interested in extending gdb to debug interpreted languages. As with most computer problems, this means inserting a layer of indirection in a number of places: into expression parsing, into symbol lookup, into breakpoints, into watchpoints, etc. The goal here is to be able to write support for, say, debugging Python scripts, as a Python extension to gdb. Then, users could switch back and forth between “raw” (debugging the C implementation) and “cooked” (debugging their script) views easily.
I have two basic models I use when thinking about python-gdb: valgrind and emacs.
Emacs is a great example of managing the split between the core implementation and scripts. Emacs developers prefer to write in elisp when possible; the core exists, more or less, to make this possible for a wide range of uses. I’m trying to steer gdb in this direction. That is, push Python hooks into all the interesting places in gdb, and then start preferring Python over C. (Mozilla might have been another good example here — but I am more familiar with Emacs.)
Naturally, we’ll pursue this with extraordinary wisdom and care. Cough cough. Seriously, there are many areas of gdb which are not especially performance sensitive. For example, consider the new commands we wrote during this series. Even support for a new language would not require anything that could not be comfortably — and excellently — done in Python.
Valgrind taught me the Field of Dreams model: even a fairly esoteric area of programming can attract a development community, provided that you build the needed infrastructure. In other words, just look at all those cool valgrind skins. This library orientation, by the way, is something I would like to see GCC pursue more vigorously.
I’m very interested to hear your feedback. Feel free to post comments here, or drop us a line on the Archer list.
We’ve come to the end of this series of posts. I’m sad to see it end, but now it is time to stop writing about python-gdb features, and to go back to writing the features themselves. I’ll write more when there is more to be said.