Next: , Up: Sample Debugging Session


14.2.1 How to Start the Debugger

Starting the debugger is almost exactly like running awk, except you have to pass an additional option --debug or the corresponding short option -D. The file(s) containing the program and any supporting code are given on the command line as arguments to one or more -f options. (gawk is not designed to debug command-line programs, only programs contained in files.) In our case, we invoke the debugger like this:

     $ gawk -D -f getopt.awk -f join.awk -f uniq.awk inputfile

where both getopt.awk and uniq.awk are in $AWKPATH. (Experienced users of GDB or similar debuggers should note that this syntax is slightly different from what they are used to. With the gawk debugger, you give the arguments for running the program in the command line to the debugger rather than as part of the run command at the debugger prompt.)

Instead of immediately running the program on inputfile, as gawk would ordinarily do, the debugger merely loads all the program source files, compiles them internally, and then gives us a prompt:

     gawk>

from which we can issue commands to the debugger. At this point, no code has been executed.