The watch window provides a means to evaluate expressions and display the values of those expressions. Typically expressions are just the name of the variable to be displayed, but can be considerably more complex see debugger expressions. Note that the 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.
Watch window user interface
The Watch window is divided into a tool bar and the main data display.
Watch tool bar
Button | Description |
![]() |
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 displayed range in the active memory window to the 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 on a watch item shows a context menu that has some actions that are not available on the toolbar.
Watch menu
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 watch value by one. |
![]() |
Decrement watch value by one. |
![]() |
Negate the watch value. |
![]() |
Invert the watch value. |
![]() |
View the properties of the watch value. |
You can view details of the watch item using the properties window.
Watch Properties
- Filename
- The filename context of the watch item.
- Line number
- The line number context of the watch item.
- (Name)
- The name of the watch item.
- Address
- The address or register of the watch item.
- Expression
- The debug expression of the watch item.
- Previous Value
- The previous watch value.
- Size In Bytes
- The size of the watch item in bytes.
- Type
- The type of the watch item.
- Value
- The value of the watch item.
Using the Watch 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) then you can open the structure see its contents.
The display is updated each time the debugger locates to source code. So it will update each time your program stops on a breakpoint or single step and whenever you traverse the call stack. Items that have changed since they that were previously displayed are highlighted in red.
Showing the Watch window
To display watch window n if it is hidden, do one of the following:
- From the View menu, click Other Windows then Watch n .
—or—
- From the Debug menu, click Debug Windows then Watch n .
—or—
- Type Ctrl+T, W, n .
—or—
- Right click the tool bar area to display the View menu.
- From the popup menu, click Other Windows then Watch n .
Adding or changing items to watch
You can add a new expression to be watched by clicking and typing into the last entry in the watch window. You can change the expression that is watched by clicking the expression entry and editing its contents.
Changing display format
When you select a variable in the main part of the display, the display format button highlighted on the Watch window tool bar changes to show the item’s display format.
To change the display format of a local variable, do one of the following:
- Right click the item to change.
- From the popup menu, select the format to display the item in.
—or—
- Click the item to change.
- On the Watch window tool bar, select the format to display the item in.
The selected display format will then be used for all subsequent displays and will be recorded when the debug session stops.
For C programs the interpretation of pointer types can be changed by right clicking and selecting from the popup menu. A pointer can be interpreted as:
- a null terminated ASCII string.
- an array.
- an integer.
- dereferenced.
Modifying watched values
To modify the value of a local variable, do one of the following:
- Click the value of the local variable to modify.
- Enter the new value for the local variable. Prefix hexadecimal numbers with ‘0x’, binary numbers with ‘0b’, and octal numbers with ‘0’.
—or—
- Right click the value of the local variable to modify.
- From the popup menu, select one of the operations to modify the variable’s value