What To Do When Your Program Loops
If, when your program is executing, it seems to be in a loop, you should
first verify that it is looping, and then interrupt its execution and
either (1) halt it entirely and return to the CKS environment or (2)
resume its execution at an address outside of the loop.
The first indication of a program loop may be either what seems to be
an unreasonably long processing time, or, if you have a blip character
defined, an inordinately large number of blips. You can verify a loop by checking the PSi frequently. If the last
word repeatedly contains the same address, it is a fairly good
indication that your program is in a loop. You can check the PSi by
using the Attention key to enter the CP environment. You are notified
by the message:
CP
that your virtual machine is in the CP environment. You can then use
the CP command DISPLAY to examine the PSi: cp display psw
and then enter the command BEGIN to resume program execution:
cp begin
If you are checking for a loop, you might enter both commands on the
sa.e line using the logical line end:
cp d plb When you have determined that your program is in a loop, you can halt
execution using the CMS Immediate command HX. To enter this command, you must press the Attention key once to interrupt program execution,
then enter:
hx
If you want your program to continue executing at an address past the
loop, you can use the CP command BEGIN to specify the address at which
you want to continue execution:
cp begin 20cdO Or, you could use the CP command STORE to change the instruction address
in the PSi before entering the BEGIN command:
cp store psw 0 20cdOIbegin Tracing Program Activity ihen your program is in a loop, or when you have a program that takes an
unexpected branch, you might need to trace the execution closely to
determine at what instruction the program goes astray. There are two
commands you can use to do this. The SVCTRACE command is a CKS command
which traces all SVCs (supervisor calls) in your program. The TRACE
command is a CP command which allows you to trace different kinds of
information, including supervisor call instructions.
216 IBM VM/370 eMS User's Guide
USING THE CP TRACE COMMAND you can trace the following kinds of activity in a program using the CP TRACE command: Instructions Branches Interrupts (including program, external, I/O and SVC interrupts) I/O and channel activity When the TRACE command executes, it traces all your virtual machine's
activity; when your program issues a supervisor call, or calls any CMS routine, the TRACE continues. You can make most efficient use of the TRACE command by starting the
trace at a specific instruction location. You should set an address
stop for the location. For example, if you are going to execute a
program and you want to trace all of the branches made, you would enter
the following sequence of commands to begin executing the program and
start the trace:
load progress
cp adstop 20004 start ADSTOP AT 20004 cp trace branch
cp begin NOW, whenever
inforlllation at
your program executes a branch instruction, the terminal that might look like this: 02001E BALR 05E6 ==) 020092 you receive
This line indicates that the instruction at address 2001E resulted in a
branch to the address 020092. When this information is displayed, your
virtual machine is placed in the CP environment, and you must use the
BEGIN command to continue execution:
cp begin When you locate the branch that caused the problem in your program, you
should terminate tracing activity by entering:
cp trace end
and then you can use CP commands to continue debugging or you can use
the EXTERNAL command to cause an external interruption that places your
virtual machine in the debug environment:
cp external You receive the message: DEBUG ENTERED. EXTERNAL INTERRUPT And you can use the DEBUG subcommands to investigate the status of your
program. Section 11. How VM/370 Can Help You Debug Your Programs 217
Previous Page Next Page