Docsity

MS Visual C++ Debugger: A Guide for CS 1044 Students - Prof. Suqin Ge, Study notes of Computer Science

Toggle sidebar
bg1
CS 1044 Intro Programming in C++ Fall 2002 August 20, 2001
MS Visual C++ 6.0 Debugger 1
1
Intro to MS Visual C++ Debugging
Debugger Definition
A program used to control the execution of another program for diagnostic purposes.
Debugger Features / Operations
Single-Stepping
Executing a program one instruction at a time.
Variable Examination
Inspecting the changes in a variable's value during execution .
Breakpoints
Setting temporary halting places within a program.
Expression Evaluation
Determining the value of an arbitrary expression during debugging execution.
2
Integrated Debugger
MS Visual C++ GUI Debugger
Allows interactive debugging from within the Integrated
Development Environment (IDE) thru the editor window.
3
Debugger Access
Debugging Code Generation
First load the corrected workspace you created earlier,
(Day Of The Week), in the MS Visual C++ tutorial.
Debugging may require recompilation to generate the
debug trace data.
Be sure that the Debug toolbars are displayed. Select Tools menu
Customize… 4
Begin Debug Trace
Start Trace
To Start The debugger (pausing at / and highlighting the
first executable instruction): Choose Step Into (F11) from
the Debug menu. This should bring up a code window with
the first line of code pointed to:
pf3

Partial preview of the text

Download MS Visual C++ Debugger: A Guide for CS 1044 Students - Prof. Suqin Ge and more Study notes Computer Science in PDF only on Docsity!

August 20, 2001

1

Intro to MS Visual C++ Debugging

Debugger Definition

A program used to control the execution of another program for diagnostic purposes. Debugger Features / OperationsSingle-Stepping

Executing a program one instruction at a time. Variable Examination

Inspecting the changes in a variable's value during execution. Breakpoints

Setting temporary halting places within a program. Expression Evaluation

Determining the value of an arbitrary expression during debugging execution.

2

Integrated Debugger

MS Visual C++ GUI DebuggerAllows interactive debugging from within the IntegratedDevelopment Environment (IDE) thru the editor window.

3

Debugger Access

Debugging Code GenerationFirst load the corrected workspace you created earlier,(Day Of The Week), in the MS Visual C++ tutorial.Debugging may require recompilation to generate thedebug trace data. Be sure that the Debug toolbars are displayed. Select Tools menu 

Customize…

4

Begin Debug Trace

Start TraceTo Start The debugger (pausing at / and highlighting thefirst executable instruction): Choose Step Into (F11) fromthe Debug menu. This should bring up a code window withthe first line of code pointed to:

August 20, 2001

5

Trace Controls

Executing code with the debuggerRun to Cursor

Click somewhere lower in the code and choose Run to cursor(Ctrl+F10)

from the Debug menu (or floating toolbar).

This will cause the program to run until it reaches the line withthe code you clicked on.

Continue Trace

To continue single stepping instruction by instruction:Repeatedly hit F10 or the Step Over

button:

Each click causes one statement to be executed. When you getto the part of the code that needs keyboard input, you willneed to type a date in the execution window.The execution window is used for input and output. To switchto the execution window, look on the

menu bar

and click on the

tab with the

program name.

Halt Trace

To stop debugger execution of the program:

Choose Stop

Debugging from the Debug menu or hit Shift+F5 or the haltdebug button:

6

Variable Examination

Examination MethodsIf you pause the mouse over a variable name, its current value isshown in a popup box. Try this on a few variables.The locals (variables) pane (accessible via the Debug, Windows

Locals menu) displays variables and their values from the currentexpression (the auto tab), local to the current function (the localstab). The watch pane (accessible via the Debug, Windows

Watch

Watch1 menu) allows variables & expressions to be constantlyevaluated while single-stepping through the program. In thiswindow, type month and year. As you step through the program youshould notice the value of these variables being changed.

7

Breakpoints: setting

Setting Unconditional Breakpoints

To display the Breakpoint pane hit the break point buttonfrom the debug toolbar. To set an unconditionalbreakpoint, position the cursor at the point you wish tobreak execution. Now

right-click

and select Insert

Breakpoint from the popup menu. You should see a bigred dot appear to the left of the line you selected.

The previous debugging session may need to be stopped and restarted at this point in order to set breakpoints.

8

Breakpoints: executing

Execute To The Breakpoint

To execute the program to the breakpoint you just set,click on the continue button

or hit F5. This will

cause the program to run until it reaches the nextbreakpoint.Set another breakpoint further along in the code. Thenrepeat this procedure to get to the next breakpoint.Select one of the breakpoints then right-click and selectRemove Breakpoint

on the popup menu to delete

the breakpoint.