Sun Studio 12 Update 1: Debugging a Program With dbx

Using Strides

When you instruct print to stride across a slice of an array, dbx evaluates certain elements in the slice only, skipping over a fixed number of elements between each one it evaluates.

The third expression in the array slicing syntax, stride-expression, specifies the length of the stride. The value of stride-expression specifies the elements to print. The default stride value is 1, meaning: evaluate all of the elements in the specified slices.

Here is the same array used in the previous example of a slice. This time the print command includes a stride of 2 for the slice in the second dimension.

print arr(201:203, 101:105:2)

As shown in the diagram, a stride of 2 prints every second element, skipping every other element.

Diagram of an array with columns 100 through 106 and
rows 200 through 205. Elements in columns 101, 103, and 105 of rows 201 through
203 are shaded.

For any expression you omit, print takes a default value equal to the declared size of the array. Here are examples showing how to use the shorthand syntax.

For a one-dimensional array, use the following commands:

print arr

Prints the entire array with default boundaries.

print arr(:)

Prints the entire array with default boundaries and default stride of 1.

print arr(::stride-expression)

Prints the entire array with a stride of stride-expression.

For a two-dimensional array, the following command prints the entire array.

print arr

To print every third element in the second dimension of a two-dimensional array, type:

print arr (:,::3)