Setting Expression Watches

A watch enables you to monitor the changing values of variables or expressions as your program runs. After you enter a watch expression, the Watch window displays the current value of the expression. As your program runs, the value of the watch changes as your program updates the values of the variables in the watch expression.

A watch evaluates an expression according to the current context which is controlled by the selection in the Stack window. If you move to a new context, the expression is reevaluated for the new context. If the execution point moves to a location where any of the variables in the watch expression are undefined, the entire watch expression becomes undefined. If the execution point returns to a location where the watch expression can be evaluated, the Watches window again displays the value of the watch expression.

To open the Watches window:

To add a watch from the Source Editor:
  1. Select the expression you want to watch with your cursor.
  2. Right-click and choose Watch from the context menu to add the expression to the Watches window. A dialog appears with the expression.
  3. Edit the expression, if necessary.
  4. Click OK.

Or, add a watch in the following ways:

To edit a watch:

  1. Select the expression in the Watches window, then right-click and choose Edit Watch.
    The Edit Watch Expression dialog appears.
  2. Enter a new expression or modify the existing one and click OK.

To delete a watch:

Caution: You cannot restore a deleted watch.


Using the Debugger Windows
Setting Preferences for the Debugger Windows
Examining Program State in Debugger Windows
Using the Stack Window