www.gibmonks.com

Main Page




Previous Page
Next Page

[Page 1379 (continued)]

Summary

  • Most C++ compiler vendors provide software called a debugger, which allows you to monitor the execution of your programs to locate and remove logic errors.

  • Breakpoints are markers that can be set at any executable line of code. When program execution reaches a breakpoint, execution pauses.

  • The debugger is enabled by default. If it is not enabled, you have to change the settings of the Solution Configurations combo box.

  • To insert a breakpoint, either click inside the margin indicator bar next to the line of code or right click that line of code and select Insert Breakpoint. A solid maroon circle appears where you clicked, indicating that a breakpoint has been set.

  • When the program runs, it suspends execution at any line that contains a breakpoint. It is then said to be in break mode, and the title bar of the IDE will display [break].

  • A yellow arrow indicates that this line contains the next statement to execute.

  • When you place your mouse pointer over a variable name, the value that the variable stores is displayed in a Quick Info box.

  • To disable a breakpoint, right click a line of code on which a breakpoint has been set and select Disable Breakpoint. The disabled breakpoint is indicated by a hollow maroon circle.

  • To remove a breakpoint that you no longer need, right click a line of code on which a breakpoint has been set and select Remove Breakpoint. You also can remove a breakpoint by clicking the maroon circle in the margin indicator bar.

  • Once the program has entered break mode, you can explore the values of your variables using the debugger's Locals window. To view the Locals window, select Debug > Windows > Locals.

  • You can evaluate arithmetic and boolean expressions using one of the Watch windows. The first Watch window is displayed by selecting Debug > Windows > Watch > Watch 1.

  • Updated variables are displayed in red to indicate that they have been modified since the last breakpoint.

  • Clicking the plus box next to an object in the Name column of the Locals window allows you to view each of object's data member values individually.

  • You can click the Value field of a variable to change its value in the Locals window.

  • The Step Into command executes the next statement (the yellow highlighted line) in the program. If the next statement is to execute a function call and you select Step Into, control is transferred to the called function.

  • The Step Over command behaves like the Step Into command when the next statement to execute does not contain a function call. If the next statement to execute contains a function call, the called function executes in its entirety, and the yellow arrow advances to the next executable line in the current function.

  • Select Debug > Step Out to execute the remaining statements in the function and return control to the function call.

  • The Continue command will execute any statements between the next executable statement and the next breakpoint or the end of main, whichever comes first.


  • [Page 1380]
  • The Autos window allows you to view the contents of the variables used in the last statement that was executed. The Autos window also lists the values in the next statement to be executed.


Previous Page
Next Page