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:

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
  3. The Properties for C/C++ - breakpoint dialog appears (Figure 1). The Common panel is shown by default.

  4. Enter an condition in the Condition text box
  5. When entering a condition use the format: Variable <operator> value. For example, iCount == 5.

  6. Enter an ignore count value in the Ignore count text box (optional)
  7. 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.

  8. Click OK
  9. 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
Related tasks
Related references