Using the Evaluate Window
TotalView lets you open a window to evaluate expressions in the context of a particular process and evaluate them in C, Fortran, or assembler.
*Not all platforms let you use assembler constructs. See Architectures” in the TotalView Reference Guide for details.
You can use the Tools > Evaluate Dialog Box in many different ways. The following are two examples:
*Expressions can contain loops, so you can use a for loop to search an array of structures for an element set to a certain value. In this case, you use the loop index at which the value is found as the last expression in the expression field.
*Because you can call subroutines, you can test and debug a single routine in your program without building a test program to call it.
*Although the CLI does not have an evaluate command, the information in the following sections does apply to the expression argument of the dbreak, dbarrier, dprint, and dwatch commands.
To evaluate an expression: Display the Evaluate Dialog Box by selecting the Tools > Evaluate command.
An Evaluate Dialog Box appears. If your program hasn’t yet been created, you won’t be able to use any of the program’s variables or call any of its functions.
1 Select a button for the programming language you’re writing the expression in (if it isn’t already selected).
2 Move to the Expression field and enter a code fragment. For a description of the supported language constructs, see Using Built-in Variables and Statements”.
Below is a sample expression. The last statement in this example assigns the value of my_var1-3 back to my_var1. Because this is the last statement in the code fragment, the value placed in the Result field is the same as if you had just typed my_var1-3.
 
 
3 Click the Evaluate button.
If TotalView finds an error, it places the cursor on the incorrect line and displays an error message. Otherwise, it interprets (or on some platforms, compiles and executes) the code, and displays the value of the last expression in the Result field.
While the code is being executed, you can’t modify anything in the dialog box. TotalView might also display a message box that tells you that it is waiting for the command to complete, Figure 180.   
Figure 180: Waiting to Complete Message Box
If you click Cancel, TotalView stops execution.
Since TotalView evaluates code fragments in the context of the target process, it evaluates stack variables according to the current program counter. If you declare a variable, its scope is the block that contains the program counter unless, for example, you declare it in some other scope or declare it to be a static variable.
If the fragment reaches a breakpoint (or stops for any other reason), TotalView stops evaluating your expression. Assignment statements in an expression can affect the target process because they can change a variable’s value.
The controls at the top of the dialog box let you refine the scope at which TotalView evaluates the information you enter. For example, you can evaluate a function in more than one process. The following figure shows TotalView displaying the value of a variable in multiple processes, and then sending the value as it exists in each process to a function that runs on each of these processes.
 
Figure 181: Evaluating Information in Multiple Processes
See Chapter 21, “Group, Process, and Thread Control” for information on using the P/T set controls at the top of this window.