Debugging Aids

The numeric form of the TRACE instruction can be used to allow sections of the program to be executed without pause for debugging input. TRACE n (that is, a positive result) allows execution to continue, skipping the next n pauses (when interactive debugging is or becomes active). TRACE -n (that is, a negative result) allows execution to continue without pause and with tracing inhibited for n clauses that would otherwise be traced. The trace action a TRACE instruction selects is saved and restored across subroutine calls. This means that if you are stepping through a program (for example, after using TRACE ?R to trace results) and then enter a subroutine in which you have no interest, you can enter TRACE O to turn off tracing. No further instructions in the subroutine are traced, but on return to the caller, tracing is restored.

Similarly, if you are interested only in a subroutine, you can put a TRACE ?R instruction at its start. Having traced the routine, the original status of tracing is restored and, if tracing was off on entry to the subroutine, tracing and interactive debugging are turned off until the next entry to the subroutine.

Because any instructions can be executed in interactive debugging you have considerable control over the execution.

The following are some examples:

Say expr     /* displays the result of evaluating the         */
             /* expression                                    */

name=expr    /* alters the value of a variable                */

Trace O      /* (or Trace with no options) turns off          */
             /* interactive debugging and all tracing         */

Trace ?A     /* turns off interactive debugging but           */
             /* continues tracing all clauses                 */

exit         /* terminates execution of the program           */

do i=1 to 10; say stem.i; end
             /* displays ten elements of the array stem.      */

Exceptions: Some clauses cannot safely be reexecuted, and therefore the language processor does not pause after them, even if they are traced. These are:

A pause occurs after a REPLY instruction, but the REPLY instruction cannot be reexecuted.