Variables Window
Home Page (Debugger) | Overview | How Do I... Topics
The Variables window provides quick access to variables that are important in the program’s current context. The window includes three tabs:
The Auto tab displays variables used in the current statement and in the previous statement. It also displays return values when you step over or out of a function.
The Locals tab displays the variables that are local to the current function.
The This tab displays the object pointed to by this.
Each tab contains a spreadsheet with fields for the variable name and value. The debugger automatically fills in these fields. If a value appears in red, it indicates that the value has recently changed. Only the last value to change appears in red.
You cannot add variables or expressions to the Variables window (you must use the Watch window — but you can expand or collapse the variables shown using the tree controls. You can expand an array, object, or structure variable in the Variables window if it has a plus sign (+) box in the Name field. If an array, object, or structure variable has a minus sign (–) box in the Name field, the variable is already fully expanded. To expand or collapse the variable, click the + or – box, as described in Spreadsheet Fields.
If the variable is an object, reference or a C++ pointer to an object, the Variables window automatically expands the variable to show the most important data at the top level. For example, suppose you had the following C++ object:
CString String = {...}
char * m_pchData =0x7ffdf000 "abc"
int m_nDataLength=4
int m_nAllocLength=1244628
The Variables window would display the following:
String = {"abc"}
If the variable is a reference or a C++ pointer to an object, the Variables window automatically downcasts the reference or pointer. The Variables window adds an extra member to the expanded object. This extra member, which looks like another base class, indicates the derived subclass. For example, if a variable declared as a C++ pointer to CObject really points to a CComboBox, the Variables window recognizes this fact and adds an extra member so that you can access the CComboBox members.
In addition to the tabs, the Variables window has a context box on the toolbar that contains a copy of the current call stack in a drop-down list box. Use this list to specify the current scope of the variables displayed. The Content box is part of a toolbar, which you can hide using the right mouse button.
Navigating from the Variables Window
You can navigate to a function’s source code or disassembled object code from the Context box in the Variables window. This procedure displays the function’s source code, if it is available, in a source window. If source code for the selected function is not available, it displays the function’s object code in the Disassembly window.
This procedure changes the view of the program displayed in the Variables window and other debugger windows, but does not change the next line of execution or the value stored in the program counter.