QuickWatch and Watches

While debugging you might want to track a value of a variable or an expression. To do so you can right click on the expression under the cursor and select Add a Watch or Quickwatch.

The QuickWatch dialog box lets you examine and evaluate variables and expressions. Because QuickWatch is a modal dialog box, you have to close it before you can continue to debug. You can also edit the value of a variable in QuickWatch. For more information on how to watch a variable, see Watch Window.

Some users might wonder why QuickWatch is useful. Why not add the variable or expression to the Watch window? That is possible, but if you just want to do a quick scratch calculation that involves one or more variables, you do not want to clutter the Watch window with such calculations. That is when the QuickWatch dialog box is especially useful.

Another feature of the QuickWatch dialog box is that it is resizeable. If you want to examine the members of a large object, it is frequently easier to expand and examine the tree QuickWatch than it is in the Watch, Locals, or Autos window.

The QuickWatch dialog box does not allow you to view more than one variable or expression at a time. Also, because QuickWatch is a modal dialog box, you cannot perform operations such as stepping through your code while QuickWatch is open. If you want to do these things, use the Watch window instead.

Some expressions have side effects that change the value of a variable or otherwise change the state of your program when they are executed. Evaluating an expression in the QuickWatch dialog box will have the same effect as executed the expression in your code. This can produce unexpected results if you do not consider the side effects of the expression.

Note: In Atmel Studio, you can view a variable's value by placing the cursor over the variable. A small box called a DataTip appears and shows the value.

To open the QuickWatch dialog box

While in break mode, choose QuickWatch on the Debug menu.

To open the QuickWatch dialog box with a variable added

While in break mode, right click a variable name in the source window name and choose QuickWatch. This automatically places the variable into the QuickWatch dialog box.

To add a QuickWatch expression to the Watch window

In the QuickWatch dialog box, click Add Watch.

Whatever expression that was displayed in the QuickWatch dialog box is added to the list of expressions in the Watch window. The expression will normally be added to the Watch1 window.