The Watch window provides a means to evaluate expressions and to display the results of those expressions. Typically, expressions are just the name of a variable to be displayed, but they can be considerably more complex; see Debug expressions. Note: expressions are always evaluated when your program stops, so the expression you are watching is the one that is in scope of the stopped program position.
The Watch window is divided into a toolbar and the main data display.
|Displays the selected item in binary.|
|Displays the selected item in octal.|
|Displays the selected item in decimal.|
|Displays the selected item in hexadecimal.|
|Displays the selected item as a signed decimal.|
|Displays the selected item as a character or Unicode character.|
|Sets the range displayed in the active memory window to the address where the selected item is stored.|
|Sorts the watch items alphabetically by name.|
|Sorts the watch items numerically by address or register number (default).|
|Remove the selected watch item.|
|Remove all the watches.|
Right-clicking a watch item shows a shortcut menu with commands that are not available from the toolbar.
|View pointer or array as a null-terminated string.|
|View pointer or array as an array.|
|View pointer value.|
|Set watch value to zero.|
|Set watch value to one.|
|Increment watched variable by one.|
|Decrement watched variable by one.|
|Negated watched variable.|
|Invert watched variable.|
|View the properties of the watch value.|
You can view details of the watch item using the Properties window.
Each expression appears as a row in the display. Each row contains the expression and its value. If the value of an expression is structured (for example, an array), you can open the structure to see its contents.
The display updates each time the debugger locates to source code. So it will update each time your program stops on a breakpoint, or single steps, and whenever you traverse the call stack. Items that have changed since they were previously displayed are highlighted in red.
You can show other Watch windows similarly.
You can add a new expression to be watched by clicking and typing into the last entry in the Watch window. You can change an expression by clicking its entry and editing its contents.
When you select a variable in the main part of the display, the display format button highlighted on the Watch window toolbar changes to show the item's display format.
The selected display format will then be used for all subsequent displays and will be preserved after the debug session stops.
For C programs, the interpretation of pointer types can be changed by right-clicking and selecting from the shortcut menu. A pointer can be interpreted as: