Sun Studio 12: Debugging a Program With dbx

when Command

The when command executes commands when a specified event occurs.

If dbx is in Java mode and you want to set a when breakpoint in native code, switch to Native mode using the joff command (see joff Command) or prefix the when command with native (see native Command).

If dbx is in JNI mode and you want to set a when breakpoint in Java code, prefix the when command with java (see java Command).

Syntax

The when command has the following general syntax:

when event_specification [modifier]{command; ... }

When the specified event occurs, the commands are executed. The following commands are forbidden in the when command:

A cont command with no options is ignored.

Native Mode Syntax

The following specific syntaxes are valid in native mode:

when at line_number { command; }

Execute command(s) when line_number is reached.

when in procedure { command; }

Execute command(s) when procedure is called.

where:

line_number is the number of a source code line.

command is the name of a command.

procedure is the name of a procedure.

Java Mode Syntax

The following specific syntaxes are valid in Java mode.

when at line_number

Execute command(s) when source line_number is reached.

when at file_name.line_number

Execute command(s) when file_name.line_number is reached.

when in class_name.method_name

Execute command(s) when class_name.method_name is called.

when in class_name.method_name([parameters])

Execute command(s) when class_name.method_name([parameters]) is called.

class_name is the name of a Java class, using either the package path (using period (.) as a qualifier; for example, test1.extra.T1.Inner) or the full path name (preceded by a pound sign (#) and using slash (/) and dollar sign ($) as qualifiers; for example, #test1/extra/T1$Inner). Enclose class_name in quotation marks if you use the $ qualifier.

file_name is the name of a file.

line_number is the number of a source code line.

method_name is the name of a Java method.

parameters are the method’s parameters.

For a list and the syntax of all events, see Setting Event Specifications.

See wheni Command for executing commands on given low-level event.