Debugging a Routine in Direct Mode

Creating and Displaying M Routines
Executing M Routines Interactively
Processing with Run-time and Syntax Errors
Correcting Errors
Stepping Through a Routine
Continuing Execution From a Breakpoint
Interrupting Execution
Using the Invocation Stack in Debugging
Transferring Routine Control
Displaying Source Code
Correcting Errors in an M Routine
Relinking the Edited Routine
Re-executing the Routine
Using Spawned Processes

To begin a debugging session on a specific routine, type the following command at the GTM prompt:

        GTM>DO ^routinename
      

You can also begin a debugging session by pressing <CTRL-C> after running an M application packaged as an executable image from DCL. To invoke Direct Mode by pressing <CTRL-C>, process must have the Principal Device in the CENABLE state and not have the device set to CTRAP=$C(3).

When GT.M receives a <CTRL-C> command from the principal device, it invokes Direct Mode at the next opportunity, (usually at a point corresponding to the beginning of the next source line). GT.M can also interrupt at a FOR loop iteration or during a command of indeterminate duration such as JOB, LOCK, OPEN or READ. The GT.M USE command enables/disables the <CTRL-C> interrupt with the [NO]CENABLE deviceparameter. The default setting for <CTRL-C> handling is controlled by GTM$DEFAULTS.M64 and is enabled in the distribution version of that file.

GT.M displays the GTM> prompt on the principal device. Direct Mode accepts commands from, and reports errors to, the principal device. GT.M uses the current device for all other I/O. If the current device does not match the principal device when GT.M enters Direct Mode, GT.M issues a warning message on the principal device. A USE command changes the current device. For more information on the USE command, refer to the "Input/Output Processing" chapter.

The default "compile-as-written" mode of the GT.M compiler lets you run a program with errors as part of the debugging cycle. The object code produced includes all lines that are correct and all commands on a line with an error, up to the error. When GT.M encounters an error, it XECUTEs non empty values of $ETRAP or $ZTRAP. By default $ZTRAP contains a BREAK command, so GT.M enters Direct Mode.

The rest of the chapter illustrates the debugging capabilities of GT.M by taking a sample routine, dmex, through the debugging process. dmex is intended to read and edit a name, print the last and first name, and terminate if the name is an upper-case or lower-case "Q".

Each of the remaining sections of the chapter uses dmex to illustrate an aspect of the debugging process in GT.M.