Before you can set a watch condition, your program must be stopped under debug, and the expression or variable you want to watch must be in scope:
You can set a watch condition by using:
If you use the WATCH command, it must be entered as a single command; no other debug commands are allowed on the same command line.
WATCH
on the debug command line, without any parameters.
Figure 39. Example of a Work with Watch Display
+--------------------------------------------------------------------------------+ | Work with Watch | | System: DEBUGGER | | Type options, press Enter. | | 4=Clear 5=Display | | Opt Num Variable Address Length | | - 1 KOUNT 080090506F027004 4 | | | | | | | | | | | | | | | | Bottom | | Command | | ===>____________________________________________________________________ | | F3=Exit F4=Prompt F5=Refresh F9=Retrieve F12=Cancel | +--------------------------------------------------------------------------------+
The Work with Watch display shows all watches currently active in the debug session. You can remove or display watches from this display. When you select Option 5 (Display), the Display Watch window shown in Figure 40 displays information about the currently active watch.
Figure 40. Example of a Display Watch Window
+--------------------------------------------------------------------------------+ | Work with Watch | | .......................................................... | | : Display Watch : DEBUGGER | | : : | | : Watch Number ....: 1 : | | : Address .........: 080090506F027004 : | | : Length ..........: 4 : | | : Number of Hits ..: 0 : | | : : | | : Scope when watch was set: : | | : Program/Library/Type: PAYROLL ABC *PGM : | | : : | | : Module...: PAYROLL : | | : Procedure: main : | | : Variable.: KOUNT : | | : : | | : F12=Cancel : | | : : | | .......................................................... | | Bottom | | Command | | ===>____________________________________________________________________ | | F3=Exit F4=Prompt F5=Refresh F9=Retrieve F12=Cancel | +--------------------------------------------------------------------------------+
WATCH SALARY
on the debug command line, where SALARY is a variable.
This command requests a breakpoint to be set if the value of SALARY is changed from its current value.
The scope of the expression variables in a watch is defined by the most recently issued QUAL command.
WATCH %SUBSTR(A 1 3)
where A is part of a substring expression. For more information about substrings, refer to Displaying a Substring of a Character String Variable.
WATCH expression : watch length
on a debug command line.
Each watch allows you to monitor and compare a maximum of 128 bytes of contiguous storage. If the maximum length of 128 bytes is exceeded, the watch condition will not be set, and the debugger issues an error message.
By default, the length of the expression type is also the length of the watch-comparison operation. The watch-length parameter overrides this default. It determines the number of bytes of an expression that should be compared to determine if a change in value has occurred.
For example, if a 4-byte binary integer is specified as the variable, without the watch-length parameter, the comparison length is four bytes. However, if the watch-length parameter is specified, it overrides the length of the expression in determining the watch length.
(C) Copyright IBM Corporation 1992, 2005. All Rights Reserved.