Download TOTALVIEW USER GUIDE

Transcript
Viewing Variables in Different Scopes as Program
Executes
When TotalView displays a Variable Window, it understands the scope in which the
variable exists. As your program executes, this scope doesn’t change. In other
words, if you’re looking at variable my_var in one routine, and you then execute
your program until it is within a second subroutine that also has a my_var variable,
TotalView does not change the scope so that you are seeing the in scope variable.
If you would like TotalView to update a variable’s scope as your program executes,
select the View > Compilation Scope > Floating command. This tells TotalView
that, when execution stops, it should look for the variable in the current scope. If it
finds the variable, it displays the variable contained within the current scope.
Select the View > Compilation Scope > Fixed command to return TotalView to its
default behavior, which is not to change the scope.
Selecting floating scope can be very handy when you are debugging recursive routines or have routines with identical names. For example, i, j, and k are popular
names for counter variables.
Scoping Issues
When you dive into a variable from the Source Pane, the scope that TotalView uses
is that associated with the current frame’s PC; for example:
1: void f()
2: {
3:
int x;
4: }
5:
6: int main()
7: {
8:
int x;
9:}
If the PC is at line 3, which is in f(), and you dive on the x contained in main(),
TotalView displays the value for the x in f(), not the x in main(). In this example, the
difference is clear: TotalView chooses the PC’s scope instead of the scope at the
place where you dove. If you are working with templated and overloaded code,
determining the scope can be impossible, since the compiler does not retain sufficient information. In all cases, you can click the More button within the Variable
window to see more information about your variable. The Valid in Scope field can
help you determine which instance of a variable you have located.
You can use the View > Lookup Variable command to locate the instance you are
interested in.
Freezing Variable Window Data
Whenever execution stops, TotalView updates the contents of Variable Windows.
More precisely, TotalView reevaluates the data based on the Expression field. If you
do not want this reevaluation to occur, use the Variable Window’s View > Freeze
command. This tells TotalView that it should not change the information that is displaying.
After you select this command, TotalView adds a marker to the window indicating
that the data is frozen.
ROGUEWAVE.COM
Examining and Editing Data and Program Elements
209