TotalView User Guide : Part II: Debugging Tools and Tasks : Evaluating Expressions : Why is There an Expression System? : Expressions in Eval Points and the Evaluate Window
Expressions in Eval Points and the Evaluate Window
Expression evaluation is not limited to a Variable Window or an Expression List Window. You can use expressions within eval points and in the Tools > Evaluate Window. The expressions you type here also let you use programming language constructs. For example, here’s a trivial example of code that can execute within the Evaluate Window:
int i, j, k;
j = k = 10;
for (i=0; i< 20; i++)
{
j = j + access_func(i, k);
}
j;
This code fragment declares a couple of variables, runs them through a for loop, then displays the value of j. In all cases, the programming language constructs being interpreted or compiled within TotalView are based on code within TotalView. TotalView is not using the compiler you used to create your program or any other compiler or interpreter on your system.
Notice the last statement inFigure 162. TotalView displays the value returned by the last statement. This value is displayed. (See Displaying the Value of the Last Statement”.)
Figure 162: Displaying the Value of the Last Statement
TotalView assumes that there is always a return value, even if it’s evaluating a loop or the results of a subroutine returning a void. The results are, of course, not well-defined. If the value returned is not well-defined, TotalView displays a zero in the Result area.
The code within eval points and the Evaluate Window does not run in the same address space as that in which your program runs. Because TotalView is a debugger, it knows how to reach into your program’s address space. The reverse isn’t true: your program can’t reach into the TotalView address space. This forces some limitations upon what you can do. In particular, you can not enter anything that directly or indirectly needs to pass an address of a variable defined within the TotalView expression into your program. Similarly, invoking a function that expects a pointer to a value and whose value is created within TotalView can’t work. However, you can invoke a function whose parameter is an address and you name something within that program’s address space. For example, you could say something like adder(an_array) if an_array is contained within your program.