Break When a Variable Changes Value

Data breakpoints can be set on a pre-determined memory variable to cause the debugger to halt execution at the line of code that has just caused the value of the variable to change. This can be useful when trying to track down the point at which a variable is modified during program execution, especially if it is not clear how program execution is affecting a particular object state.

Access     Analyzer | Locals: right-click on variable | Break When Variable is Modified, or
Analyzer | Watches: right-click on variable | Break When Variable is Modified

Topics

Topic

Detail

See also

Usage

In order to establish a data breakpoint you must first set a normal breakpoint at a point in the code that presents the required scope of local variables to choose from.

Execute the debugger (press F6); once the program has halted execution, right-click on the variable of interest and select the Break When Variable is Modified context menu option.

There is no breakpoint indicator in the code, but in the Breakpoints & Events window, the data breakpoint displays as a blue circle in the Enabled column.

The example below creates a notification on a variable from the Locals window; the item being watched is the Passengers integer member of the CTrain Class.
 

VEA-VariableNotification

 

Continue to execute the debugger; when the variable changes and the debugger halts, the line of code is highlighted in the Source Code Editor and the log in the Debug window prints a statement reporting the effect.

 

Setting Code Breakpoints

View the Local Variables

View Variables in Other Scopes

Notes

This feature is not presently supported by the Microsoft .NET platform

Learning Center topics

(Alt+F1) | Build and Debug | Debug | Add Data Breakpoint