Sun Studio 12: Debugging a Program With dbx

Stopping Execution When an Address Is Accessed

To stop execution when a memory address has been accessed, type:


(dbx) stop access mode address-expression [, byte-size-expression]

mode specifies how the memory was accessed. It can be composed of one or all of the letters:

r

The memory at the specified address has been read.

w

The memory has been written to.

x

The memory has been executed.

mode can also contain either of the following:

a

Stops the process after the access (default).

b

Stops the process before the access.

In both cases the program counter will point at the offending instruction. The “before” and “after” refer to the side effect.

address-expression is any expression that can be evaluated to produce an address. If you give a symbolic expression, the size of the region to be watched is automatically deduced; you can override it by specifying byte-size-expression. You can also use nonsymbolic, typeless address expressions; in which case, the size is mandatory.

In the following example, execution will stop execution after the memory address 0x4762 has been read


(dbx) stop access r 0x4762
:

In this example, execution will stop before the variable speed has be written to:


(dbx) stop access wb &speed

Keep these points in mind when using the stop access command:

For more information on specifying an access event, see access mode address-expression [, byte-size-expression] and stop Command.