Besides looking at the values of variables, there is often a need to get
other sorts of information about the state of your program and of the
debugging environment itself. The
gawk debugger has one command that
provides this information, appropriately called
is used with one of a number of arguments that tell it exactly what
you want to know:
The value for what should be one of the following:
List arguments of the selected frame.
List all currently set breakpoints.
List all items in the automatic display list.
Give a description of the selected stack frame.
List all function definitions including source file names and line numbers.
List local variables of the selected frame.
Print the name of the current source file. Each time the program stops, the current source file is the file containing the current instruction. When the debugger first starts, the current source file is the first file included via the -f option. The ‘list filename:lineno’ command can be used at any time to change the current source.
List all program sources.
List all global variables.
List all items in the watch list.
Additional commands give you control over the debugger, the ability to save the debugger’s state, and the ability to run debugger commands from a file. The commands are:
Without an argument, display the available debugger options and their current values. ‘option name’ shows the current value of the named option. ‘option name=value’ assigns a new value to the named option. The available options are:
Set the maximum number of lines to keep in the history file ./.gawk_history. The default is 100.
Specify the number of lines that
list prints. The default is 15.
gawk output to a file; debugger output still goes
to standard output. An empty string (
"") resets output to
Change the debugger prompt. The default is ‘gawk> ’.
Save command history to file ./.gawk_history.
The default is
Save current options to file ./.gawkrc upon exit.
The default is
Options are read back into the next session upon startup.
Turn instruction tracing on or off. The default is
Save the commands from the current session to the given file name,
so that they can be replayed using the
Run command(s) from a file; an error in any command does not
terminate execution of subsequent commands. Comments (lines starting
with ‘#’) are allowed in a command file.
Empty lines are ignored; they do not
repeat the last command.
You can’t restart the program by having more than one
command in the file. Also, the list of commands may include additional
source commands; however, the
gawk debugger will not source the
same file more than once in order to avoid infinite recursion.
In addition to, or instead of, the
source command, you can use
the -D file or --debug=file command-line
options to execute commands from a file non-interactively