Watching Data Values Update
As you run your program, any data added to the Data View displays updated values.
NOTE: This discussion assumes that you have set a breakpoint on line 15 in the
evaluate() function and that you have clicked
Go, as discussed in
Viewing Variables in the Local Variables View.
1. Add a Variable to the Data View
![*](p4-bullet.jpg)
From the Local Variables view, just drag a variable into the Data View.
![](../TotalView/images/basicdebugging-breakpoints-data-view-add.png)
Alternatively, right-click and select
Add to Data View:
![](../TotalView/images/basicdebugging-breakpoints-data-view-add-2.png)
Add a global variable by double clicking
Add New Expression in the Data View and manually entering it:
![](../TotalView/images/basicdebugging-data-add-global-variable-to-data-view.png)
Once entered, TotalView populates its type and value:
![](../TotalView/images/basicdebugging-data-add-global-variable-to-data-view-2.png)
2. View nested structures.
NOTE: You can also view compound structures in the Local Variables view.
The variable node is a compound type with several nested structures.
![*](p4-bullet.jpg)
To view any nested structure, click the right-arrow, which means that additional nested structures exist. Here, we’ve drilled into the node variable’s union
u to see that it contains a
left and
right struct, and a double
value.
![](../TotalView/images/basicdebugging-breakpoints-data-view-unfold-node-1.png)
![*](p4-bullet.jpg)
Re-enable the breakpoint at line 119 in the
readexpr() function by clicking on its checkbox in the Action Points view, or recreate it if necessary:
![](../TotalView/images/basicdebugging-breakpoints-data-view-unfold-note-reenable-breakpoint.png)
![*](p4-bullet.jpg)
Click
Go twice to run the program to the re-enabled breakpoint.
To see a variable’s value, drill further down into the left or right variable:
![](../TotalView/images/basicdebugging-breakpoints-data-view-unfold-node-2.png)
Remember that the data provided to the program consists of three simple expressions:
2+3
2*(4/5)
(1/2)-(3/4)
At this point in the program’s execution, the second expression is being read in. In the Data View, note that left has been assigned a value of 4. If you drill into right, it will have a value of 5, i.e. the input for the right side of the second expression.
3. View updated values.
![*](p4-bullet.jpg)
Click
Go several times to run the program to the two breakpoints.
As the program reads in the expressions and evaluates them, the values change in the Data View:
![](../TotalView/images/basicdebugging-data-watch-values-change.png)
4. View the output in the Input/Output view.
The output of the program goes to
stdout when
fflush() is called.
![](../TotalView/images/basicdebugging-data-view-output-fflush.png)
As each expression is evaluated and printed to
stdout, when the
stdout buffer is flushed, the Input/Output view shows the result of evaluating the expression. Run the program to the end to see the completed output.
![](../TotalView/images/basicdebugging-data-view-output.png)