Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Session-4 CSIT 121 Spring 2006 Debugging Tips Lab Work.

Similar presentations


Presentation on theme: "1 Session-4 CSIT 121 Spring 2006 Debugging Tips Lab Work."— Presentation transcript:

1

2 1 Session-4 CSIT 121 Spring 2006 Debugging Tips Lab Work

3 2 Some Aspects of Visual Studio Your project can be set in “Debug” or “Release” configuration ( Build->Configuration Manager ) In “Debug” state, you can apply several debugging options. Debug is set by default You can start debugging by invoking the debugger

4 3 Debugging Tips Let us try a few simple steps Open a new Win32 console project and copy and paste the following program into the editor window The compiler gives an error message Click on the error message The system moves the pointer to the line where the error is, press F1 to learn more

5 4 Program With an Error #include using namespace std; void main() { double kpl,mpg, kpg; const double CF=1.6; cout<<"How many miles does your car cover in one gallon (MPG rating from the sticker)?"; cin>>mpg kpg = mpg*CF; cout<<"Your KPG rating is "<<kpg<<endl; kpl = kpg/3.78; cout<<"Your KPL rating is "<<kpl<<endl; }

6 5 Starting the Debugger Once you have compiled the project, you can start the debugger by first inserting breakpoints A Breakpoint is where the program execution will halt Thus you can see the values of variables at that point

7 6 Using the Debugger Inserting breakpoints is a convenient way of stopping at a suspected problem location and examining the values of variables (Click the gray panel to the left of the program to insert a breakpoint) Click on “Debug”  “Start” Look at the bottom of the screen. You will find “Autos” on the left and call stack on the right “Autos” represents the variables. Look at the values. Which one is not assigned a value yet? Choose “step over” from the icons to avoid stepping into system functions

8 7 Directories Choose Tools  Options  Environment and change the project directory You can browse the Buildlog.htm file in the Debug folder to appreciate the automation of the linker

9 8 Lab Work (Part-D Due 2/2) Part-A –Solve Prelab assignment on pages 31-32 of the lab course textbook. (Exercises 1,2,3,4,5) –Check the solution and make any corrections –The program source code is on the course website in the labs and lectures page Part-B –Carry out all the four exercises in lesson 2-2 on page 34 Part-C –Do exercises 1,2,3 in Lesson 2-3 (page 35) Part-D –Exercise 1 and 2 of Lesson 2-4 are due Thursday Feb 2


Download ppt "1 Session-4 CSIT 121 Spring 2006 Debugging Tips Lab Work."

Similar presentations


Ads by Google