Inspecting variables

About this task

You can inspect variables in two ways: by moving the mouse over the name of a variable in the Debug editor window (hovering) or by using the Variables view. With hovering, the debugger displays the value of a variable in a tree structure in a small window that disappears when you move the mouse away from the name of the variable. While the debugger displays the window, you can expand and collapse the tree structure to view more information. You can also edit the value of a variable from the hovering window. The debugger Variables view provides easy access to the variables in your program and enables you to observe and edit variables.

When a thread suspends, the top stack frame of the thread is automatically selected. When a stack frame is selected, the visible variables in that stack frame are displayed in the Variables view. Complex variables can be expanded to show the elements that make up the variable.

Note: COBOL, PL/I, C and C++ support the aggregate display of arrays and structures as a string (where the top node displays the contents of the whole array or struct as an aggregate string). Use Show as String to see the aggregate display.

Procedure

  • Variable values can be changed in the hovering window by performing these steps:
    1. Select a variable or a field from the tree structure in the hovering window.
      The value of the selected element is displayed in the detail pane below the tree structure.
    2. Click inside the detail pane to edit the variable value.
      You can use Cut, Copy, Paste, or Select All actions when you edit the value in the detail pane.
    3. After you edit the variable value, click the Assign Value button below the detail pane to assign the new value to the variable.
  • Variable values can be changed in the Variables view by clicking the value of the variable in the Value column and changing the value inline or by performing these steps:
    1. Right-click the variable that you want to edit and select Change Value from the pop-up menu.
    2. In the resulting dialog, change the variable value.

Results

To indicate that the variable value has changed, its indicator will have a delta symbol next to it. All variables affected by the change will also have a delta symbol next to their indicators.

The Variables view displays all variables for a selected stack frame. If you are debugging C/C++, local variables, not global variables, are displayed. If you are debugging assembler, current line operands are displayed. The view dynamically shows the variables in the current scope and they will appear and disappear as the program is stepped through or resumed. As an alternative to the Variables view, you can monitor variables in the Monitors view. In the monitors view, the debugger always shows the value for a variable if it can be obtained. To view and inspect one or multiple variables at a time, right-click the variable or variables and select Monitor Local Variable from the pop-up menu to work with the variables in the Monitors view.

Depending on the language that you are debugging, you can filter the Variables view to display certain variables only. To do this, right-click in the Variables view and select an entry from the Filter Locals submenu as shown in the following image. The Filter Locals submenu contents vary based on the mode being used and language of the program being debugged.
filter locals sub-menu
Note: The filtering options and content available in the Filter Locals submenu depends on the language you are debugging.
From the variables view, you can set the value to be represented in either a decimal or hexadecimal (EBCDIC) format. To select the representation, highlight the variable, right-click, select Change representation and then the desired format:
Change representation

Viewing the value in EBCDIC internal display may be useful when debugging data exceptions.