Share via


How to: Specify a Breakpoint Condition

This topic applies to:

Edition

Visual Basic

C#

C++

Web Developer

Express

Topic does not apply Topic does not apply Topic applies Topic does not apply

Standard

Topic applies

Topic applies

Topic applies

Topic applies

Pro and Team

Topic applies

Topic applies

Topic applies

Topic applies

Table legend:

Topic applies

Applies

Topic does not apply

Does not apply

Topic applies but command hidden by default

Command or commands hidden by default.

A breakpoint condition is an expression that the debugger evaluates when a breakpoint is reached. If the condition is satisfied, the debugger looks at the How to: Specify a Hit Count to determine whether to break (or execute another specified action).

The condition can be any valid expression recognized by the debugger. (See Expressions in the Debugger for details.)

If you set a breakpoint condition with invalid syntax, a warning message appears immediately. If you specify a breakpoint condition with valid syntax but invalid semantics, a warning message appears the first time the breakpoint is hit. In either case, the debugger breaks execution when the invalid breakpoint is hit. The breakpoint is skipped only if the condition is valid and evaluates to false.

Note

The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or edition. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see Visual Studio Settings.

To specify a breakpoint condition

  1. In the Breakpoints window, right-click the line containing a breakpoint glyph and choose Condition from the shortcut menu

    —or—

    In a source, Disassembly, or Call Stack, right-click a line containing a breakpoint glyph and choose Condition from Breakpoints in the shortcut menu.

  2. In the Breakpoint Condition dialog box, enter a valid expression in the Condition box.

  3. Choose is true if you want to break when the expression is satisfied or has changed if you want to break when the value of the expression has changed.

    Note

    The debugger does not evaluate the expression until the first time the breakpoint is reached. If you choose has changed, the debugger does not consider the first evaluation of the condition to be a change, so the breakpoint will not be hit on the first evaluation.

  4. Click OK.

See Also

Concepts

Breakpoints and Tracepoints