Scoping and Symbol Names
TotalView assigns a unique name to every element in your program based on the scope in which the element exists. A scope defines the part of a program that knows about a symbol. For example, the scope of a variable that is defined at the beginning of a subroutine is all the statements in the subroutine. The variable’s scope does not extend outside of this subroutine. A program consists of multiple scopes. Of course, a block contained in the subroutine could have its own definition of the same variable. This would hide the definition in the enclosing scope.
All scopes are defined by your program’s structure. Except for the simplest of programs, scopes are embedded in other scopes. The only exception is the outermost scope, which is the one that contains main(), which is not embedded. Every element in a program is associated with a scope.
To see the scope in which a variable is valid, click the
More button in the Variable Window until the scope fields are visible. The Variable Window now includes additional information about your variable, as is shown in
Figure 148.
The Valid in Scope list indicates the scope in which the variable resides. That is, when this scope is active, the variable is defined. The Compiled in Scope list can differ if you modify the variable with an expression. It indicates where variables in this expression have meaning.
When you tell the CLI or the GUI to execute a command, TotalView consults the program’s symbol table to discover which object you are referring to—this process is known as symbol lookup. Symbol lookup is performed with respect to a particular context, and each context uniquely identifies the scope to which a symbol name refers.