QTAwk has added a facility for debugging utilities. This facility is activated through the built-in variable TRACE. QTAwk can trace the loop control statements:
In addition, built-in functions and user-defined functions are traced.
By default, TRACE is set to FALSE and no tracing is done.
The
variable may be set to any value, numeric, string or regular expression
and
the value will determine the statements traced. If TRACE has
a
nonzero numeric value then QTAwk will trace all statements of
the
type listed.
Selective Statement Tracing
If TRACE has a string value, then the string is compared against the keywords:
If an exact match (case is important) is found, then the statement
is
traced. If TRACE is set to a regular expression, then the
keywords
are matched against the regular expression. If a match is found, then
the
statement is traced.
Trace Output
In tracing a statement, QTAwk issues a message to the standard output file. The message issued will have the form:
Stmt Trace: stmt_str value_str
Action File line: xxxx
Scanning File: FILENAME
Line: xxxxx
Record: xxxxxx
where stmt_str is the appropriate keyword listed above for the statement traced and value_str is a value dependent upon the statement traced as listed below:
| keyword
|
|
value string
|
| if | ==> | 0/1 conditional expression TRUE/FALSE |
| while | ==> | 0/1 conditional expression TRUE/FALSE |
| do | ==> | 0/1 conditional expression TRUE/FALSE |
| for | ==> | 0/1 conditional expression TRUE/FALSE |
| for | ==> | subscript value |
| switch | ==> | switch expression value |
| function_b | ==> | function name |
| function_u | ==> | function name |
When a statement that can be traced is encountered, the value of the statement is determined, e.g., for an if statement, the value of the conditional is evaluated before issuing the trace statement.
The following TRACE values will trace the statements indicated: