For future reference, and because I keep forgetting things, here is how I work on GDB:
- Check out a copy of the sources. Some of this is described on the branch management page of the GDB wiki:
mkdir /somewhere/to/work cd /somewhere/to/work git clone ssh://sourceware.org/git/archer.git src cd src git remote add gdb git://sourceware.org/git/gdb.git
- Point the
master
branch to the correct place. The real one is in the GDB repo, but there’s an old one in Archer that is no longer used. Open/somewhere/to/work/src/.git/config
in your favourite editor and changeremote = origin
toremote = gdb
in the[branch "master"]
section. Then probably do agit pull
to fetch the actual code you’ll be working on. - Create yourself a nice new branch to make your changes in:
- (make your changes here)
- Build it. I build out-of-tree, like this:
mkdir /somewhere/to/work/build cd /somewhere/to/work/build CFLAGS="-g -O0" ../src/configure --with-separate-debug-dir=/usr/lib/debug make
- Run the testsuite. I like to run the tests twice, once without and once with the changes, then I diff the results and pipe it through a script I wrote to hide the unimportant bits:
make check >& build-20110921-3.log diff -u baseline-20110919.log build-20110921-3.log | gdbtestdiff
- If a test fails, you’ll want to hook gdb into it. To do that you run the specific test to create a transcript:
cd /somewhere/to/work/build/gdb/testsuite runtest TRANSCRIPT=1 ../../../src/gdb/testsuite/gdb.opt/inline-cmds.exp gdb ../gdb
- Then you pipe the transcript into gdb:
set prompt (top-gdb) b internal_error r -nx <transcript.1
git branch --track archer-gbenson-lazy-skip-inline-frames gdb/master git checkout archer-gbenson-lazy-skip-inline-frames
Ok, I think that is enough for now.
i wish *every* developer would publish something like this. i’m sure it would increase the number of eyes. thanks!
Oh, there will be more! Putting the stuff in one place saves me hunting through my IRC logs every time I forget something :)
Hey Gary,
Great post :-). Sometimes I do some research on the internet to find different workflows, and maybe learn new things to increment my way of work.
I posted a “reply” in my (brand new) blog: http://www.sergiodj.net/blog/posts/2011/11/29/my-workflow-with-gdb-and-git-part-1/ .
See ya!
A fun/crazy/sometimes-not-working way to debug failures coming from the test suite:
cd build/gdb/testsuite/
gdb /bin/sh
set target-async on
set schedule-multiple on
set pagination off
set detach-on-fork off
set non-stop on
run /usr/bin/runtest whatever.exp
This works pretty good if you are just trying to see the point of the crash, not as well if you have more complicated things to do. But at least it relieves you of trying to deal with hacking up the transcript; at least for some tests (e.g., ones rebuilding the executable or whatever) this won’t have all the information…