
7.2 Overview |
Debugging is the process of correcting or modifying the code in your project so that your project can build, run smoothly, act as you expected, and be easy to maintain later. To this end, Magic C++ provides a variety of tools to help with the varied tasks of tracking down errors in the code and program components. The debugger interface provides special menus, windows, dialog boxes, and spreadsheet fields. Drag-and-drop functionality is available for moving debug information between components. Occasionally the debugger is paused in break mode, meaning the debugger is waiting for user input after completing a debugging command (like break at breakpoint, step into/over/out/to cursor, break after Break command |
||||||||||||||||||||||||||||||
7.2.1 Debugger Menu Items |
Commands for debugging can be found on the Build menu, the Debug menu, the View menu, and the Edit menu. The Build menu contains a command called Start debuggingging, which contains a subset of the commands on the full Debug menu. These commands start the debugging process (Go, Step Into, Run To Cursor and Attach to Process). The Debug menu appears in the menu bar while the debugger is running (even if it is stopped at a breakpoint). From the Debug menu, you can control program execution and access the QuickWatch window. When the debugger is not running, the Debug menu is replaced by the Build menu. The View menu contains commands that display the various debugger windows, such as the Variables window and the Call Stack window. From the Edit menu, you can access the Breakpoints dialog box, from which you can insert, remove, enable, or disable breakpoints. |
||||||||||||||||||||||||||||||
7.2.2 Debug Options on the Build/Debug Menu |
To start debuggingging, choose the Go, Step Into, Run To Cursor or Attach to Process command from the Start debugging submenu of the Build menu. The following table lists the Start debugging menu commands that may appear and their actions. Start debugging Commands (Build menu)
When you begin debugging, the Debug menu appears, replacing the Build menu on the menu bar. You can then control program execution using the commands listed in the following table. Debug Menu Commands that Control Program Execution
The following additional commands appear on the Debug menu:
|
||||||||||||||||||||||||||||||
7.2.3 Debugger Windows |
Several specialized windows display debugging information for your program. When you are debugging, you can access these windows using the View menu. (In addition to windows, the debugger also uses dialog boxes to display debugging information.) The following table lists the debugger windows and describes the information they display. Debugger Windows
Debugger windows can be docked or floating. For more information When a window is in floating mode, you can resize or minimize the window to increase the visibility of other windows. You can copy information from any debugger window. You can print information only from the Output window. |
||||||||||||||||||||||||||||||
7.2.4 Watch Window |
The Watch window contains Three tabs: Local, This, Watch.
The Watch window provides quick access to variables that are important in the programĄ¯s current context and specify variables and expressions that you want to watch. If you add an array, object, or structure variable to the Watch window, plus sign (+) or minus sign (¨C) boxes appear in the Name column. You can use these boxes to expand or collapse your view of the variable. If the value of a variable appears in red, it indicates that the value has recently changed. Only the last value to change appears in red. If the variable is an object, reference or a C++ pointer to an object, the Watch window automatically expands the variable to show the most important data at the top level. Tip The Watch window does not display variable type information. You can view information for a variable type by using typeinfo in the shortcut menu The Locals tab displays the variables that are local to the current function. The This tab displays the object pointed to by this. The Watch Tab to specify variables and expressions that you want to watch while debugging your program |
||||||||||||||||||||||||||||||
7.2.5 Debugger Dialog Boxes |
QuickWatch Dialog Box The QuickWatch dialog box contains a text box, where you can type an expression or variable name, and a spreadsheet field that displays the current value of the variable or expression that you specified. You can use QuickWatch to quickly examine the value of a variable or expression. You can also use QuickWatch to modify the value of a variable or to add a variable or expression to the Watch window.
Display of a Scalar Variable or Expression If you type a scalar variable or expression in the text box, QuickWatch displays the result on the first line of the spreadsheet. If you type an array, object, or structure variable, however, QuickWatch uses the spreadsheet to show additional detail. Plus sign (+) and minus sign (-) boxes appear. Click these boxes to expand or collapse your view of the variable. |
||||||||||||||||||||||||||||||
7.2.6 Drag and Drop Information |
The debugger interface supports intelligent drag-and-drop operations. The result of a drag-and-drop operation depends, in part, on the location where the drop takes place. For example, you can drag a variable from the Editor window to the Watch window. This action puts the variable information into the Watch window, where it is updated each time the Watch window is updated. If you drag the variable to a text window instead, the variable information is converted into text. |
