Home TOC Previous Next


                   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)

Menu
command

 


Action

 

Go

 

Executes code from the current statement until a breakpoint or the end of the program is reached, or until the application pauses for user input. (Equivalent to the Go button on the toolbar.)

 

Step Into

 

Single-steps through instructions in the program, and enters each function call that is encountered.

 

Run to Cursor

 

Executes the program as far as the line that contains the insertion point. This is equivalent to setting a temporary breakpoint at the insertion point location.

 

Attach to Process

 

Attaches the debugger to a process that is running. Then you can break into the process and perform debugging operations like normal.

 

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

Debug menu
command

 


Action

 

Go

 

Executes code from the current statement until a breakpoint or the end of the program is reached, or until the application pauses for user input. (Equivalent to the Go button on the Standard toolbar.) When the Debug menu is not available, you can choose Go from the Start debugging submenu of the Build menu.

 

Stop Debugging

 

Terminates the debugging session, and returns to a normal editing session.

 

Break

 

Halts the program at its current location.

 

Step Into

 

Single-steps through instructions in the program, and enters each function call that is encountered. When the Debug menu is not available, you can choose Step Into from the Start debugging submenu of the Build menu.

 

Step Over

 

Single-steps through instructions in the program. If this command is used when you reach a function call, the function is executed without stepping through the function instructions.

 

Step Out

 

Executes the program out of a function call, and stops on the instruction immediately following the call to the function. Using this command, you can quickly finish executing the current function after determining that a bug is not present in the function.

 

Run to Cursor

 

Executes the program as far as the line that contains the insertion point. This command is equivalent to setting a temporary breakpoint at the insertion point location. When the Debug menu is not available, you can choose Run To Cursor from the Start debugging submenu of the Build menu.

 

The following additional commands appear on the Debug menu:

Show Next Statement

 

Shows the next statement in your program code. If source code is not available, displays the statement within the Disassembly window.

 

QuickWatch

 

Displays the Quick Watch window, where you can work with expressions.

 

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

Window

 

Displays

 

Output

 

Information about the build process, including any compiler, linker, or build-tool errors, and debugger output information.

 

Watch

 

Information about variables used in the variables local to the current function (in the Locals tab), and the object pointed to by this (in the This tab).and specify variables and expressions that you want to watch ( in the watch tab )

 

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.


Home TOC Previous Next

Copyright(c) 2003-2004 Magicunix,Inc.