Inspecting and Modifying Variable Values (Integrated Debugger)

When a thread has been suspended, the Debugger browser displays all running methods and the variables visible within them.

Select a method in the All Programs/Threads pane.  The Visible Variables pane shows the variables in use.  You can change which variables are shown by changing the selections in the Inspector menu.  Variables that themselves contain fields can be expanded to show the fields by clicking the plus symbol plus.gif (837 bytes) in the tree.

When you select a variable in the Visible Variables pane, its current value (at the exact point in the program where it was suspended) is shown in the Value pane.  If you select multiple variables, the values for each are shown in the Value pane.  To select multiple variables:

Opening an Inspector
To closely look at one variable that contains fields, select it in the Visible Variables pane and click the Inspect button inspect.gif (1041 bytes) in the toolbar.  An Inspector window will open, showing the variable's fields, and their values.  This information is the same as the information in the Debugger browser Visible Variables and Values panes, and you can select, view, and modify the contents in the same ways.

Modifying Variable Values While the Program is Running
The values of variables can be modified while the thread is suspended.  To modify a variable's value in the Value pane :

  1. Select the variable in an Inspector window or in the Visible Variables pane .
  2. Edit the value shown in the Value pane.
  3. Select Save from the Value pane's pop-up menu.

Alternatively, you can modify the value right in the source pane.  For example, if you have an integer variable called depth that has a current value of 4, and you want to change its value to 6, do the following steps:

  1. Anywhere in the source pane, type in depth=6.
  2. Highlight depth=6.
  3. Select Run from the Edit menu.  This evaluates the expression and changes the value of the variable.
  4. To see that the value has changed, find an occurrence of depth in the Source pane and hold the mouse pointer over it for about a second.  A pop-up lable will appear with the label "depth=(int) 6".
  5. Delete the fragment, depth=6.

The change in variable value is immediately available to the running program.   When you resume running, the new value is used.

Example: Modifying a Value While Running a Program

ngrelc.gif (533 bytes)
The Integrated Debugger

ngrelt.gif (466 bytes)
Debugging During the Development Cycle
Suspending, Resuming, and Terminating Threads
Stepping Through Methods
Modifying Code while Debugging
Evaluating Expressions in the Debugger