About Expressions
Either directly or indirectly, accessing and manipulating data requires an evaluation system. When your program (and TotalView, of course) accesses data, it must determine where this data resides. The simplest data lookups involve two operations: looking up an address in your program’s symbol table and interpreting the information located at this address based on a variable’s datatype. For simple variables such as an integer or a floating-point number, this is straightforward.
Looking up array data is slightly more complicated. For example, if the program wants my_var[9], it looks up the array’s starting address, then applies an offset to locate the array’s 10th element. In this case, if each array element uses 32 bits, my_var[9] is located 9 times 32 bits away.
In a similar fashion, your program obtains information about variables stored in structures and arrays of structures.
Structures complicate matters slightly. For example ptr->my_var requires three operations: extract the data contained within address of the my_var variable, use this information to access the data at the address being pointed to, then display the data according to the variable’s datatype.
Accessing an array element such as my_var[9] where the array index is an integer constant is rare in most programs. In most cases, your program uses variables or expressions as array indices; for example, my_var[cntr] or my_var[cntr+3]. In the latter case, TotalView must determine the value of cntr+3 before it can access an array element.
Here is an illustration showing TotalView accessing the my_var array in the three ways discussed in this section:
Figure 47, Data View: Accessing Array Elements