Debugging a Program With dbx

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, (exp3), specifies the length of the stride. The value of exp3 specifies the elements to print; the number of elements skipped is equal to exp3 -1. 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)

Graphic

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.

print arr

Prints entire array, default boundaries. 

print arr(:)

Prints entire array, default boundaries and default stride of 1. 

print arr(::exp3)

Prints the whole array with a stride of exp3.

For a one-dimensional array:

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:


print arr (:,::3)