Watchpoint Specification

Related Topics:

Event Specification

dbx provides two syntaxes for specifying watchpoints:

The Newer Syntax

This syntax lets you specify the kind of access to be watched for

stop|when|trace access mode <address-expression> [ , byte-size-expression ]

where:

mode specifies what kind of access is to be watched for:

r read, memory loads
w write, memory stores
x execute, execution of code

You must specify at least one of the above modes must be specified. Additionally you may specify one of the following:

b stop before the access
a stop after the access (default)

In both cases the program counter points to the relevant instruction. Before or after refers to the side-effect.

address-expression is any expression that can be evaluated to produce an address. If a symbolic expression is used the size of the region to be watched is automatically deduced, or you can override that with the `,' syntax.

You can also use non-symbolic, typeless address expressions in which case the size is mandatory; for example:

stop access w 0x5678, sizeof(Complex)

This mechanism is mostly implemented in the kernel (see the proc(4) man page under PCWATCH for more details) and offers the following advantages over the older mechanisms:

The mechanism has the limitation that no two watched regions may overlap.

The Older Syntax

stop|when|trace modify address-expression [ , byte-size-expression ]

This syntax is still accepted for backward compatibility and maps to the appropriate stop access command.

stop|when|trace cond condition-expression

stop|when|trace change variable

These automatically single-step through the program and check for the given condition or change. Because of the single-stepping they are very slow and do not apply to multi-threaded applications.