QuickWatch, Watch, Locals, and Autos Windows

The Atmel Studio debugger provides several windows, collectively known as variable windows, for displaying variable information while you are debugging.

Each variable window has a grid with three columns: Name, Value, and Type. The Name column shows the names of variables added automatically in the Auto and Locals windows.

In the Watch window, the Name column is where you can add your own variables or expressions. See how to watch an expression in the Debugger.

The Value and Type columns display the value and data type of the corresponding variable or expression result.

You can edit the value of a variable in the Value column.

The variable windows, Autos, Locals, and Watch display the values of certain variables during a debugging session. The QuickWatch dialog box can also display variables. When the debugger is in break mode, you can use the variable windows to edit the values of most variables that appear in these locations.

Note: Editing floating-point values can result in minor inaccuracies because of decimal-to-binary conversion of fractional components. Even a seemingly harmless edit can result in changes to some of the least significant bits in the floating-point variable.

When an expression is evaluated in the Watch window, you might see a refresh icon. This indicates an error or out-of-date value.

If you want to, you can enter an expression for a value. The debugger will evaluate the expression and replace it with the resulting value. The debugger accepts most valid language expressions in a Watch window. For more information, see Expression Formatting.

If you are programming in native code, you might sometimes have to qualify the context of a variable name or an expression that contains a variable name. The context means the function, source file, and module where a variable is located. If you have to do this, you can use the context operator syntax.

Evaluating some expressions can change the value of a variable or otherwise affect the state of your program. For example, evaluating the following expression changes the value of var1 and var2:

var1 = var2++
var1 = var2++

Expressions that change data are said to have side effects, which can produce unexpected results if you are not aware of them. Therefore, make sure you understand the effect of an expression before you execute it.

To edit a value in a variable window

  1. 1.The debugger must be in break mode.
  2. 2.If the variable is an array or an object, a tree control appears next to the name in the Name box. In the Name column, expand the variable, if necessary, to find the element whose value you want to edit.
  3. 3.In the row you want to change, double-click the Value column.
  4. 4.Type the new value.
  5. 5.Press ENTER.

To display a variable window

On the Debug menu, choose Windows, then choose the name of the variable window you want to display (Autos, Locals, Watch, or Watch1 through Watch4).

You cannot access these menu items or display these windows in design mode. To display these menu items, the debugger must be running or in break mode.