2.4 Debugging in Immediate Mode
To debug in immediate mode, you insert STOP statements in
your program at the points where you wish to examine the
values of variables. When VAX BASIC encounters a STOP
statement, program execution is interrupted. You can use
immediate mode statements to display the values of variables
or to assign them new values. After changing or examin-
ing data, you can use the CONTINUE command to resume
program execution.
The following restrictions apply when you are debugging in
immediate mode:
.
You cannot continue execution if you change any pro-
gram code; for example, you cannot create new variables
after VAX BASIC encounters a STOP statement.
.
You can debug only one module at a time; BASIC lets
you examine and change variables only in the cur-
rent module (the most recently compiled module) of a
multiple-module program.
When you are debugging multiple program units in the
environment, follow these guidelines:
.
Use the OLD command to read in the source file for the
module you want to debug. This source file becomes the
current module-the one available for immediate mode
debugging.
.
Use the LOAD command to read in the object files for the
remaining program modules.
An object module is the file that results from compiling a
source file; its format is an intermediate step between a
source file and an executable image. The LOAD command
removes any previously loaded object modules, whether or
not the command specifies any object module files. Therefore,
you must use a single LOAD command to specify all the ob-
ject files you need. In addition, you must separate multiple
object modules with a plus sign (+).
The object files are not linked with the current program or
executed until you issue the RUN command. Therefore,
run-time errors in the loaded modules are not detected until
you execute the program.
When you want to run a program, you can load all the ob-
ject modules for that program and then execute the program
with the RUN command. If you want to debug a program,
use the OLD command for the module you want to de-
bug and then load the remaining program modules. The
module to be debugged can be either a main program or a
subprogram because, when you enter the RUN command,
BASIC transfers control to the main program, whether it is
in object-module format or source-program format.
For information about using the OpenVMS Debugger, see
Chapter 4.