Starting the debugger is almost exactly like running
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 -1 inputfile
where both getopt.awk and uniq.awk are in
(Experienced users of GDB or similar debuggers should note that
this syntax is slightly different from what you are used to.
gawk debugger, you give the arguments for running the program
in the command line to the debugger rather than as part of the
command at the debugger prompt.)
The -1 is an option to uniq.awk.
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:
from which we can issue commands to the debugger. At this point, no code has been executed.