This is the first in what I hope will be a series on using the python-enabled gdb.
We’ll start at the very beginning: checking it out, building it, and then “hello, world”.
First, install the prerequisites — aside from the normal development stuff, you will need the python development packages. You will also need git. If you don’t have makeinfo installed, you will want that, too. On Fedora you can get these with:
$ sudo yum install python-devel git texinfo
That was easy! Now we will check out and build the gdb branch. I like to prepare for this by making a new directory where I will keep the source, build, and install trees:
$ mkdir -p ~/archer/build ~/archer/install $ cd ~/archer
“Archer” is the name of our project, in case you’re wondering. Note that the clone step will take a while — it is downloading the entire history of gdb. My source tree weighs in at about 50M.
$ git clone git://sourceware.org/git/archer.git $ cd archer $ git checkout --track -b python origin/archer-tromey-python
Now you have archer checked out and on the right branch. If you’re curious, other work is being done in the Archer repository. Currently each separate project has its own “topic branch”, but we’ll be merging them together for a release. You can see the different topics with:
$ git branch -r | grep archer
This repository is also periodically synced from gdb. For example you could look at the in-progress multi-process work — that is, patches to let gdb debug multiple processes at the same time — by checking out the branch gdb/multiprocess-20081120-branch.
Now build gdb. Depending on your machine, this might take a while.
$ cd ../build $ ../archer/configure --prefix=$(cd ../install && pwd) $ make all install
(As an aside: I have typed that goofy
--prefix line a million times. I wish configure would just do that for me.)
Now you are ready to try your python-enabled gdb. We’ll just add the right directory to your path and then do a smoke test for now; we’ll look at more functionality in the next installment.
$ PATH=~/archer/install/bin:$PATH $ gdb [...] (gdb) python print 23 23 (gdb) quit
Once you have this set up, future updates are even simpler — and faster. Just pull and rebuild:
$ cd ~/archer/archer $ git pull $ cd ../build $ make all install
We’re actively hacking on this branch, so you may like to do this regularly. If you find bugs, feel free to email the Archer list. (We’ll have bugzilla working “soon”, but for the time being just fire off a note.)
I think next time we will look at writing a new gdb command in Python. Also, we’ll try a couple of new commands, written this way, that are shipped with the Python-enabled gdb.
In the future, it will be much simpler to get this gdb. Like I said before, I want it to be in Fedora 11 (and yeah, making the feature page is on my to-do list; I’ll try to get to it next week). Also, I think Daniel is making a Debian experimental package for it.
Update: fixed a bug in the checkout command. Oops.