Choose a design and let our professionals help you build a successful website   - ITAcumens

Main Menu

Debugging a Program

Started by sukishan, Aug 13, 2009, 12:52 PM

Previous topic - Next topic


There are many ways to debug a program. One of the simplest is to use cout to output the values of key variables at various places in the program. Another is to use the debugger. You can access it by selecting Build, Start Debug. This brings up the choices: Go (to execute until a breakpoint is reached), Step Into (to execute the program line by line), Run to Cursor (run to the current cursor location).

If you select Step Into or Run to Cursor, you should be given a debug toolbar that has other options such as Step Over (also for executing line by line but without going inside the code for any function that is called). This toolbar also allows you to restart the program, to end debugging, etc. If the debug toolbar isn't shown, look under Tools, Customize, Toolbars and see that the debug toolbar is checked.

When the debugger is running, one or more windows may be open for displaying values. The debug toolbar has buttons for toggling on/off a watch window, an auto variable display window etc. The former lets you enter the names of variables whose values you would like to see. The latter automatically shows the values of variables used in the line just executed.

Note that to add or remove breakpoints (probably done before you even start the debugger), you can right click at the desired location in the code and then click on Insert/Remove breakpoint. Doing the same thing again removes the breakpoint. The debugger has many more features which you can learn if you like. See the Debugger Lab for a practice exercise on using the debugger.
A good beginning makes a good ending

Quick Reply

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Note: this post will not display until it has been approved by a moderator.

Please leave this box empty:
Type the letters shown in the picture
Listen to the letters / Request another image

Type the letters shown in the picture:

Shortcuts: ALT+S post or ALT+P preview