Visualizing Data Programmatically
The
$visualize function supports data visualization from within eval points and the
Tools > Evaluate Window. Because you can enter more than one
$visualize function within an eval point or Evaluate Window, you can simultaneously visualize multiple variables.
If you enter the
$visualize function in an eval point, TotalView interprets rather than compiles the expression, which can greatly decrease performance. See
“Defining Eval Points and Conditional Breakpoints” for information about compiled and interpreted expressions.
Using the $visualize function in an eval point lets you animate the changes that occur in your data, because the Visualizer updates the array’s display every time TotalView reaches the eval point. Here is this function’s syntax:
$visualize ( array [, slice_string ])
The
array argument names the
dataset being visualized. The optional
slice_string argument is a quoted string that defines a constant slice expression that modifies the
array parameter’s dataset. In Fortran, you can use either a single (’) or double (") quotation mark. You must use a double quotation mark in C or C++.
The following examples show how you can use this function. Notice that the array’s dimension ordering differs between C/C++ and Fortran.
C and C++
$visualize(my_array);
$visualize (my_array,"[::2][10:15]");
$visualize (my_array,"[12][:]");
Fortran
$visualize (my_array)
$visualize (my_array,’(11:16,::2)’)
$visualize (my_array,’(:,13)’)
The first example in each programming language group visualizes the entire array. The second example selects every second element in the array’s major dimension; it also clips the minor dimension to all elements in the range. The third example reduces the dataset to a single dimension by selecting one subarray.
You may need to cast your data so that TotalView knows what the array’s dimensions are. For example, here is a C function that passes a two-dimensional array parameter that does not specify the major dimension’s extent.
void my_procedure (double my_array[][32])
{ /* procedure body */ }
You would need to cast this before TotalView can visualize it. For example:
$visualize (*(double[32][32]*)my_array);
Sometimes, it’s hard to know what to specify. You can quickly refine array and slice arguments, for example, by entering the $visualize function into the Tools > Evaluate Dialog Box. When you select the Evaluate button, you quickly see the result. You can even use this technique to display several arrays simultaneously.