Displaying the value of a variable
After you are familiar with setting breakpoints and running through your program, you can begin displaying the value of a variable. The value of a variable can be displayed in one of the following ways:
- One-time display (in the Log window) is useful for quickly checking
the value of a variable.
For one-time display, enter the following command on the command line, where x is the name of the variable:
LIST (x)
The Log window shows a message in the following format:
LIST ( x ) ; x = 10
Alternatively, you can enter the
L
prefix command in the prefix area of the Source window. In the following line from the Source window, type inL2
in the prefix area, then press Enter to display the value of var2:200 var1 = var2 + var3;
z/OS® Debugger creates the command
LIST (var2)
, runs it, then displays the following message in the Log window:LIST ( VAR2 ) ; VAR2 = 50
You can use theL
prefix command only with programs assembled or compiled with the following assemblers or compilers:- Enterprise PL/I for z/OS, Version 3.6 or 3.7 with the PTF for APAR PK70606, or later
- Enterprise COBOL (compiled with the TEST compiler option)
- Assembler
- Disassembly
- Continuous display (in the Monitor window) is useful for observing
the value of a variable over time.
For continuous display, enter the following command on the command line, where x is the name of the variable:
MONITOR LIST ( x )
In the Monitor window, a line appears with the name of the variable and the current value of the variable next to it. If the value of the variable is undefined, the variable is not initialized, or the variable does not exist, a message appears underneath the variable name declaring the variable unusable.
Alternatively, you can enter the
M
prefix command in the prefix area of the Source window. In the following line from the Source window, type inM3
in the prefix area, then press Enter to add var3 to the Monitor window:200 var1 = var2 + var3;
z/OS Debugger creates the command
MONITOR LIST (var3)
, runs it, then adds var3 to the Monitor window.You can use theM
prefix command only with programs assembled or compiled with the following assemblers or compilers:- Enterprise PL/I for z/OS, Version 3.6 or 3.7 with the PTF for APAR PK70606, or later
- Enterprise COBOL (compiled with the TEST compiler option)
- Assembler
- Disassembly
- A
combination of one-time and continuous display, where the value of
variables coded in the current line are displayed, is useful for observing
the value of variables when the variables are used.
For a combination of one-time and continuous display, enter the following command on the command line:
SET AUTOMONITOR ON ;
After a line of code is run, the Monitor window displays the name and value of each variable on the line of code. The
SET AUTOMONITOR
command can be used only with specific programming languages, as described in IBM® z/OS Debugger Reference and Messages.
Refer to the following topics for more information related to the material discussed in this topic.
- Related tasks
- Displaying values of C and C++ variables or expressions
- Displaying values of COBOL variables
- Displaying and monitoring the value of a variable
- Related references
- Monitor window
- Description of the MONITOR COMMAND in IBM z/OS Debugger Reference and Messages
- Description of the SET AUTOMONITOR COMMAND in IBM z/OS Debugger Reference and Messages