4.4.5 Monitoring Changes in Variables
The SET WATCH command lets you set watchpoints that
will be monitored continuously as your program executes.
If the program modifies the value of a watched variable, the
debugger suspends execution and displays the old and new
values.
DBG> SET WATCH TOTAL
Subsequently, every time the program modifies the value of
TOTAL, the watchpoint is triggered. The debugger monitors
watchpoints continuously during program execution.
The next example shows what happens when your program
modifies the contents of a watched variable:
DBG> SET WATCH TOTAL
DBG> GO
.
.
.
watch of SCREEN_IO\TOTAL\%LINE 13
13: TOTAL = TOTAL + 1
old value: 16
new value: 17
break at SCREEN_IO.%LINE 14
14: CALL Pop_rtn(TOTAL)
DBG>
In this example, a watchpoint is set on the variable TOTAL
and the GO command starts execution. When the value of
TOTAL changes, execution is suspended. The debugger an-
nounces the event (watch of . . . ), identifying where TOTAL
changed (line 13) and the associated source line. The de-
bugger then displays the old and new values and announces
that execution has been suspended at the start of the next line
(14). (The debugger reports break at . . . , but this is not a
breakpoint; it is still the effect of the watchpoint.) Finally, the
debugger prompts for another command.
When a change in a variable occurs at a point other than the
start of a source line, the debugger gives the line number plus
the byte offset from the start of the line.