30.01.2013 Views

TotalView Users Guide - CI Wiki

TotalView Users Guide - CI Wiki

TotalView Users Guide - CI Wiki

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Examining and Analyzing Arrays<br />

Displaying Array Slices<br />

<strong>TotalView</strong> lets you display array subsections by editing the Slice field in an<br />

array’s Variable Window. (An array subsection is called a slice.) The Slice field<br />

contains placeholders for all array dimensions. For example, the following<br />

is a C declaration for a three-dimensional array:<br />

integer an_array[10][20][5]<br />

Because this is a three-dimensional array, the initial slice definition is<br />

[:][:][:]. This lets you know that the array has three dimensions and that<br />

<strong>TotalView</strong> is displaying all array elements.<br />

The following is a deferred shape array definition for a two-dimensional<br />

array variable:<br />

integer, dimension (:,:) :: another_array<br />

The <strong>TotalView</strong> slice definition is (:,:).<br />

<strong>TotalView</strong> displays as many colons (:) as there are array dimensions. For<br />

example, the slice definition for a one-dimensional array (a vector) is [:] for<br />

C arrays and (:) for Fortran arrays.<br />

CLI: dprint -slice “\[n:m\]” an_array<br />

Using Slices and Strides<br />

A slice has the following form:<br />

lower_bound:upper_bound[:stride]<br />

The stride, which is optional, tells <strong>TotalView</strong> to skip over elements and not<br />

display them. Adding a stride to a slice tells the debugger to display every<br />

stride element of the array, starting at the lower_bound and continuing through<br />

the upper_bound, inclusive.<br />

For example, a slice of [0:9:9] used on a ten-element C array tells <strong>TotalView</strong><br />

to display the first element and last element, which is the ninth element<br />

beyond the lower bound.<br />

If the stride is negative and the lower bound is greater than the upper<br />

bound, <strong>TotalView</strong> displays a dimension with its indices reversed. That is,<br />

<strong>TotalView</strong> treats the slice as if it was defined as follows:<br />

[upperbound : lowerbound : stride]<br />

For example, the following definition tells <strong>TotalView</strong> to display an array<br />

beginning at its last value and moving to its first:<br />

[::-1]<br />

dprint -slice “(n:m,p:q)” an_array<br />

CLI: dprint an_array(n:m:p,q:r:s)<br />

334 Chapter 15: Examining Arrays

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!