From: R. B. <ro...@pa...> - 2004-05-22 14:07:06
|
I've patched GNU make 3.80 to add better tracing, error reporting and I have added a debugger. It is in http://bashdb.sourceforge.net/remake-3.80+dbg.tar.gz What I have here is very very preliminary; it there so one can get a feel for what a debugger for GNU Make might look like. I've only been able to compile this on GNU/Linux with RedHat 9.0 or Debian. Compilations on other OS's seem to give problems in places that as far as I can tell are not related to any of the changes I've made. For the debugger, you should have GNU readline installed. Okay, now some sample output. Here's a small test Makefile: 1: FOO=bar 2: all: foo 3: foo: 4: @echo hi > /dev/null 5: @fdafds To get trace output, I've added the -x (or --trace) option. So: ./make -x -f bug2 produces: bug2:2 all bug2:3 foo bug2:4 foo echo hi > /dev/null bug2:5 foo fdafds make: fdafds: Command not found bug2:3: *** [foo] Error 127 One small thing to note above is that when -x is in effect the @'s to turn off echoing are disregarded. So you see the "echo hi" and "fdafds" in the output. If you want a target backtrace on errors, add -E. For the above, this adds to the end: #0 foo at bug2:3 #1 all at bug2:2 I've also tried this the actual Makefile to the modified make. At present it still gives too much output, but boy is it much more comprehensible compared to what you get with "make -d" Okay, now on to the debugger! Just add -X (or --debugger) and you are put into the debugger. Although I have a small command set right now with few command formats or opitons, many of the most useful debugging commands are there. You can set/delete breakpoints at a target, step execution, restart or quit execution, turn on/off/toggle tracing, go up or down the target backtrack stack and look at variables, Actually, there are two kinds of print commands: "print" give a variable source/file location and the value in symbolic terms. For example when I run "p MAKE" inside the debugger (remake), I get: (remake) p MAKE (null):0 MAKE = $(MAKE_COMMAND) The (null):0 means this is a builtin definition. However there is another print which does full expansion of the variables. So if I run x (examine) instead I get: (null):0 MAKE = /src/local-cvs/remake/src/./make In fact, "examine" doesn't need a variable name, it will work with a string. So I could type "x This is $(MAKE)" or "x $(bin_PROGRAMS) $(noinst_PROGRAMS)". For the latter, I get make loadavg Note, no location identification is given here (since what I put in isn't a variable). For those of you like myself who live inside of GNU Emacs, included in the tarball is remake.el which uses on gud.el to provide running the debugger inside GNU Emacs just as the way you'd do with perl, gdb, my bash debugger. I also have a patched gud.el which contains the remake debugger support. For front-end support such as this, I added "up" and "down" debugger commands to postion you up or down in the Makefile source. Okay that's about it for now. I thought it would take a year or so to get something I'm happy with. I'm a little ahead of schedule (but not by much). I've been very pleased and surprised at how little work it took for the gains I've gotten so far. It's a real pity no one has undertaken this before, it hasn't been that hard. Some interesting issues down the line will be in adding a command to show dependency results or figuring out the right level of display on a trace. Maybe there would be several levels: one doesn't want to step through every file dependency of which most of them are satisfied. Right now I use the hueristic unless a breakpoint is set I stop at targets that are explicitly mentioned on the left-hand side. This is probably still too much. "phony targets" and targets with commands may be too little. |