|
 |
|
|
Evaluating Expressions
TotalView lets you open a window for evaluating expressions in the context of a particular process and evaluate expressions in C, Fortran, or assembler.
Note: Not all platforms let you use assembler constructs; see Architectures for details.
You can use the Tools > Evaluate dialog box in many different ways, but here are two examples:
- Expressions can contain loops, so you could 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.
To evaluate an expression:
- Tell TotalView to display the Evaluate dialog box by selecting the Tools > Evaluate command. An Evaluate dialog box appears. If your program has not yet been created, you will not be able to use any of the program's variables or call any of its functions.
- Select the button (if it is not already selected) for the language in which you will write the code.
- Move to the Expression field and enter a code fragment. For a description of the supported language constructs, see Writing Code Fragments.
TotalView returns the value of the last statement in the code fragment. This means that you do not have to assign the expression's return value to a variable.The following figure shows 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 would be the same if you had just typed my_var1-3.
Tools > Evaluate Dialog Box 
|
- Select 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 cannot modify anything in the dialog box. TotalView may also display a message box that tells you that it is waiting for the command to complete.
Waiting to Complete Message Box 
|
If you select Cancel, TotalView stops execution.
Since TotalView evaluates code fragments in the context of the target process, it evaluates stack variables according to the currently selected stack frame. If the fragment reaches a breakpoint (or stops for any other reason), TotalView stops evaluating your expression. Assignment statements within an expression can affect the target process because they can change a variable's value.
|
|
|
|
|