4.9 QuickWatch, Watch, Locals, and Autos Windows
For displaying variable information while you are debugging, the Microchip Studio debugger provides several windows, collectively known as variable windows.
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 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.
When evaluating an expression in the Watch window, you might see a refresh icon, which indicates an error or out-of-date value.
If required, enter an expression for a value. The debugger will evaluate the expression and replace it with the resulting value. The debugger accepts the 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 may 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
- The debugger must be in break mode.
- 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.
- Double click the Value in the row to change.
- Type the new value.
- Press ENTER.
To Display a Variable Window
On the Debug menu, choose Windows and then 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. The debugger must be running or be in break mode to display these menu items.