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.
Button | Description |
Display the selected item in binary. | |
Display the selected item in octal. | |
Display the selected item in decimal. | |
Display the selected item in hexadecimal. | |
Display the selected item as a signed decimal. | |
Display the selected item as a character or Unicode character. | |
Set the range displayed in the active Memory window to span the memory allocated to the selected item. | |
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.
Button | Description |
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 watched item using the Properties dialog.
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.
—or—
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:
—or—