Watch expressions

Watch expressions, or watches for short, are expressions that the debugger evaluates and prints the result of every time the program is stopped; for example, after every single-step through the program.

List watched expressions

  1. From the main menu, select View ▸ Watches to open the Watches window.

Like local variables, all watch expressions are displayed in a tree with children used to represent structure or array members.

Variable

The name of the variable or the expression.

Value

The variable or expression value.

Type

The type of the variable or of the expression result.

Update watches

Watch expressions can be updated automatically as soon as the program is stopped or on user request.

To set a watch expression to update automatically:

  1. In the Watches window, select the watch you want to update automatically. Right-click and check that Automatic Update if checked. If not, select it.

To update a watch expression manually:

  1. In the Watches window, right click and select Update Watch to update the selected watch.

To update all watch expressions manually at once:

  1. In the Watches window, right click and select Update all to update all watches at the same time.

Add a watch on an expression

To add an expression to the watch list:

  1. From the main menu, select Debug ▸ Add Watch... or in the Watches window, right-click and select Add Watch....

  2. Enter the expression to watch. Check Automatic Update if you want the expression to be evaluated each time the program is stopped.

An expression can be evaluated and then added as a watch like this:

  1. From the main menu, select Debug ▸ Inspect/Evaluate or right click in the Editor window and select Inspect/Evaluate.

  2. Click on Add button to add this expression to the watches list.

Remove a watch

You can remove an expression from the watches list.

  1. In the Watches window, select the watch you want to remove, then right-click and select Remove Watch.

All watches can be removed at the same time.

  1. In the Watches window, right-click and select Remove all.

Changing the value of a variable

If a watch expression corresponds to a variable, you can change its value.

  1. In the Watches window, select the variable you want to edit and double click in the Value column.

  2. Enter the new value.