Conditional breakpoints

Optional breakpoint parameters are used to control the behavior of breakpoints.

Note: Not all breakpoints support conditions.

When you set a breakpoint, you can make it conditional by setting these parameters in the Optional parameters page of any breakpoint wizard:

Optional breakpoint parameter Description Type of breakpoint supported
Thread

Breakpoints can be thread-specific. You can specify whether the breakpoint applies to all threads (the default) or only to one (n=one) specific thread. To specify all threads, select Every. To specify an individual thread, choose the thread.

This parameter is supported by all breakpoint types.
Frequency Indicates when to stop on a breakpoint and when to skip it. The debugger keeps track of how many times each breakpoint is encountered. The fields in this section tell the debugger on which encounter of a breakpoint the debugger will first stop, how often it will stop, and on which encounter the debugger will no longer stop.

The following parameters are used to set the breakpoint frequency:

  • From: Enter the first breakpoint encounter you want the debugger to stop on. For example, if you want the debugger to skip over the breakpoint the first five times it is encountered, enter 6.
  • To: Enter the last breakpoint encounter you want the debugger to stop on. For example, if you want it to start ignoring the breakpoint after the 20th encounter, enter 20. To stop on every encounter, enter Infinity.
  • Every: Enter the frequency with which you want the debugger to stop on this breakpoint. For example, if you want it to stop on one out of every four encounters, enter 4.
This parameter is supported by all breakpoint types.
Expression You can enter an expression into this field. The execution of the program stops at the breakpoint only if the condition specified in this field tests true (any non-zero value is considered true).

For example, if you are debugging a C++ program you can type the following expression:

(i==1) || (j==k) && (k!=5)

A conditional expression is any valid expression in the language of the location of the breakpoint that evaluates to a number, and does not have side effects or involve calling a function. For C and C++, all assignment operators, and the increment and decrement operators (++ and --) are not permitted.

Attention: Even though an application does not appear to stop at a breakpoint whose condition has not been met, the debugger temporarily suspends the application while it evaluates the condition. For most purposes, this short pause is not significant. However, in a multithreaded application, a pause may cause the operating system to change the order in which threads are dispatched.
Line, Entry, Statement, Watch, and Address.
Action You can specify debug console commands in this field. Address, Entry, Statement, and Watch