Using Programming Language Constructs
You can also use programming language constructs in an evalpoint. For example, here’s a trivial example of code that can execute:
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 in the Create Evaluation Point dialog on the left in Figure 41. The results are printed in the shell in which TotalView is running, displayed on the right.
Figure 41, 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 returns a zero.
The code within an evalpoint 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 cannot 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.