Tracing with the Interactive Debug Facility
The interactive debug facility lets a user control the execution of a program. The language processor reads from the terminal, and writes output to the terminal.
Starting Interactive Debug
To start interactive debug, specify ? before the option of a TRACE instruction, for example: TRACE ?A . There can be no blank(s) between the question mark and the option. Interactive debug is not carried over into external routines that are called but is resumed when the routines return to the traced program .
Options in Interactive Debug
- A null line, which continues tracing. The language processor continues execution until the next pause or read from the input stream. Repeated input of a null line, therefore, steps from pause point to pause point until the program ends.
- An equal sign (=), which re-executes the last instruction traced. The language processor re-executes the previously traced instruction with values possibly modified by instructions read from the input stream. (The input can also be an assignment, which changes the value of a variable.)
- Additional instructions. This input can be any REXX instruction,
including a command or call to another
program
. This
input is processed before the next instruction in the program is
traced.
For example, the input could be a TRACE instruction that alters the
type of tracing:
TRACE L /* Makes the language processor pause at labels only */The input could be an assignment instruction. This could change the flow of a program , by changing the value of a variable to force the execution of a particular branch in an IF THEN ELSE instruction. In the following example, RC is set by a previous command.IF RC = 0 THEN DO instruction1 instruction2 END ELSE instructionAIf the command ends with a nonzero return code, the ELSE path is taken. To force taking the first path, the input during interactive debug could be:RC = 0
Ending Interactive Debug
- Use the TRACE OFF instruction as input. The TRACE OFF instruction
ends tracing, as stated in the message at the beginning of
interactive
debug:
+++ Interactive trace. TRACE OFF to end debug, ENTER to continue. +++ - Use the TRACE ? instruction as input
The question mark prefix before a TRACE option can end interactive debug as well as beginning it. The question mark reverses the previous setting (on or off) for interactive debug. Thus you can use TRACE ?R within a program to start interactive debug, and provide input of another TRACE instruction with ? before the option to end interactive debug but continue tracing with the specified option.
- Use TRACE with no options as input. If you specify TRACE with no options in the input stream, this turns off interactive debug but continues tracing with TRACE Normal in effect. (TRACE Normal traces only failing commands after execution.)
- Let the program run until it ends. Interactive debug automatically ends when the program that started tracing ends. You can end the program prematurely using as input an EXIT instruction. The EXIT instruction ends both the program and interactive debug.