Skip to main content

10. Conditional Commands

Conditional commands are used in breakpoints to control the execution of breakpoint commands. One or more conditions in sequence form a condition list. If a condition list is satisfied (evaluates to TRUE), the breakpoint command list immediately following it is executed. (See Breakpoints and Watchpoints, above, for a discussion of the logic flow in conditional/command lists.) Conditional commands perform tests on local breakpoint variables, and other locations. Each condition evaluates to either TRUE or FALSE. Figure 65 contains a summary of conditional commands:

 Command                       Description
-----------------------------+------------------------------------

CHANGED <loc> Determine if a location has changed
COMPARE <loc1> <mask> <loc2> Compare two locations, using a mask
COUNT_[EQ | GT | LT] <value> Compare the counter to a value
TEST <loc> <mask> <value> Compare a location to a value

Conditional Command Summary
Figure 65

The rules for forming and evaluating condition lists are:

  • consecutive conditions have an implicit logical AND between them. A sequence of such conditions is called an 'and_list'. and_lists are delimited by an OR command and by the end of the condition list.
  • the breakpoint OR command may be inserted between any pair of conditions
  • AND takes precedence over OR
  • nested condition lists are not supported. A condition list is simply one or more and_lists, separated by ORs.
  • the condition list is evaluated in sequence until either a TRUE and_list is found (condition list <- TRUE), or the end of the condition list is reached (condition list <- FALSE). An and_list is TRUE if all its conditions are TRUE.

The distillation of these rules into BNF is:

    <condition_list> :== <and_list>  [OR <and_list>]*
<and_list> :== <condition> [AND <condition>]*
<condition> :== CHANGED | COMPARE | COUNT | TEST

where: OR is a breakpoint command
AND is implicit for any pair of consecutive conditions

For example, the following condition list, with one command per line,

    COUNT_EQ 1
OR
COUNT_GT 10
COUNT_LT 20

evaluates to:

    (COUNT = 1) OR (COUNT > 10  AND COUNT < 20)

and will cause the command list that follows it to be executed if the counter is equal to one, or is between 10 and 20.

10.1 Condition Command Format​

Condition commands start with the standard four-octet command header. The high-order bit of the command type byte is used as a negate flag: if this bit is set, the boolean value of the condition is negated. This flag applies to one condition only, and not to other conditions in the condition list.

            0             0 0   1         1
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
+---------------+---------------+
0 | Command Length |
+---------------+---------------+
1 | CONDITION |N| Type |
+---------------+---------------+

Condition Command Header
Figure 66

10.2 COUNT Conditions​

The COUNT conditions (COUNT_EQ, COUNT_GT and COUNT_LT) are used to compare the breakpoint counter to a specified value. The counter is set to zero when the breakpoint is STARTed, and is incremented by the INC_COUNT breakpoint command. The format is the same for the COUNT_EQ, COUNT_GT and COUNT_LT conditions.

            0             0 0   1         1
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
+---------------+---------------+
0 | 8 |
+---------------+---------------+
1 | CONDITION |N| Type |
+---------------+---------------+
2 | |
+-- Value --+
3 | |
+---------------+---------------+

COUNT Condition Format
Figure 67

COUNT_* Condition FIELDS:

Type

One of COUNT_EQ, COUNT_LT and COUNT_GT. The condition is TRUE if the breakpoint counter is [EQ | LT | GT] the specified value.

Value

A 32-bit value to be compared to the counter.

10.3 CHANGED Condition​

The CHANGED condition is TRUE if the contents of the specified location have changed since the last time this breakpoint occurred. Only one location may be specified as the object of CHANGED conditions per breakpoint. The CHANGED condition is always FALSE the first time the breakpoint occurs.

            0             0 0   1         1
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
+---------------+---------------+
0 | 14 |
+---------------+---------------+
1 | CONDITION |N| CHANGED |
+---------------+---------------+
2 | |
+-- --+
3 | Address |
+-- --+
4 | |
+-- --+
5 | |
+-- --+
6 | |
+---------------+---------------+

CHANGED Condition
Figure 68

CHANGED FIELDS:

Address

The full 5-word address of the location to be tested by the CHANGED command.

10.4 COMPARE Condition​

The COMPARE condition compares two locations using a mask. The condition is TRUE if (<loc1> & <mask>) = (<loc2> & <mask>).

            0             0 0   1         1
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
+---------------+---------------+
0 | 28 |
+---------------+---------------+
1 | CONDITION |N| COMPARE |
+---------------+---------------+
2 | |
+-- --+
3 | Address 1 |
+-- --+
4 | |
+-- --+
5 | |
+-- --+
6 | |
+---------------+---------------+
7 | |
+-- Mask --+
8 | |
+-------------------------------+
9 | |
+-- --+
10| Address 2 |
+-- --+
11| |
+-- --+
12| |
+-- --+
13| |
+-------------------------------+

COMPARE Condition
Figure 69

COMPARE FIELDS:

Address 1 Address 2

The 5-word addresses of the locations to be compared.

Mask

A 32-bit mask specifying which bits in the locations should be compared.

10.5 TEST Condition​

The TEST condition is used to compare a location to a value, using a mask. The condition is TRUE if (<loc> & <mask>) = <value>.

            0             0 0   1         1
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
+---------------+---------------+
0 | 22 |
+---------------+---------------+
1 | CONDITION |N| TEST |
+---------------+---------------+
2 | |
+-- --+
3 | Address |
+-- --+
4 | |
+-- --+
5 | |
+-- --+
6 | |
+---------------+---------------+
7 | |
+-- Mask --+
8 | |
+-------------------------------+
9 | |
+-- Value --+
10| |
+-------------------------------+

TEST Condition
Figure 70

TEST FIELDS:

Address

The 5-word address of the location to be compared to the value.

Mask

A 32-bit mask specifying which bits in the location should be compared.

Value

A 32-bit value to compare to the masked location.