Setting Conditional Breakpoints

## Setting Conditional Breakpoints or Watchpoints

You create a conditional (temporary) breakpoint or watchpoint in the Properties for C/C++ breakpoint dialog. Right-click a breakpoint or watchpoint in the Breakpoints view, then select Properties from the context menu. A conditional breakpoint or watchpoint has an associated conditional expression. The debugger evaluates the expression to determine whether to halt program execution at that breakpoint.

A conditional breakpoint or watchpoint behaves in two different ways:

- If the expression evaluates to true (a non-zero value), the debugger halts program execution.
- If the expression evaluates to false (a zero value), program execution continues without stopping.

Figure 1 Properties for C/C++ - breakpoint window

#### To set a conditional breakpoint

1. Find the breakpoint or watchpoint in the Breakpoints view
   - If the breakpoint is already set, then continue
   - If the breakpoint is not set, set it in the source code now
2. Right-click the breakpoint and select Properties on the context menu

The Properties for C/C++ - breakpoint dialog appears (Figure 1). The Common panel is shown by default.

3. Enter an condition in the Condition text box

When entering a condition use the format: Variable <operator> value. For example, iCount == 5.

4. Enter an ignore count value in the Ignore count text box (optional)

The Ignore count specifies how many times the breakpoint or watchpoint hits the condition before execution stops. The default setting is zero, which means the first time the breakpoint is hit, execution halts. For example, to stop at the breakpoint on the second time it is hit, enter an Ignore count of 1.

5. Click OK

During subsequent debugging sessions, the debugger evaluates the expression to determine whether to halt program execution at the conditional breakpoint.

For more information on marker bar icons, see C/C++ Development User Guide > Concepts > Debug > Breakpoints.

##### Related concepts

- Breakpoints

##### Related tasks

- Setting Breakpoints
- Disabling Breakpoints
- Removing Breakpoints

##### Related references

- Breakpoints view