Debugger
Pre-lab Exercises
Go through online videos, demonstrating the basic debugging techniques. Some useful links are given below:
Announcements
We will have a simple 5 minute quiz at the beginning of the lab on Blackboard. Please sign in to your Blackboard account and finish the quiz individually. To access the quiz, go to CS 141 course on Blackboard, and click on Lab Quizzes, there you can find Lab 9 Quiz. To access the quiz, you will need a password, which will be announced by the TA in the lab
The full version of lab assignment is on Blackboard, under the link "Lab Assignments" > "Lab 9 Programming Activity". To access the assignment, you need a password, which will be announced by the TA in the lab
You must work with a single partner, in a group of 2. You must take turns being the “driver” and the “navigator”. (If there are an odd-number of students in the class, your TA will make an adjustment.)
Bring your laptops to work with the IDE of your choice
There are 3 questions. The maximum score is 2, where each question is worth 1 point. Question 3 is extra credit. To get a grade, you must demonstrate the assignments to a TA, & submit the work onto Blackboard before your lab session ends. Late submission is not accepted. Once you finish your work, please raise your hand and show your work to the TA during the last 10 minutes of lab or whenever you finish, the earlier of the two.
Lab Activity
Lab 9 is designed to practice & gain some insight into program debugging.
Prior to this, most of you have been using printf (and similar display functions) for debugging your code to find issues/bugs. Writing code to debug issues in the code seems fine when the code size is limited to a hundred lines or so, but it becomes unusable when you need to write programs that are larger in scale. This is where a "Debugger" steps in. It gives you complete visibility over the execution of your program, where you can stop the program at any point you like, print the values, & go through the execution of the program step by step. Therefore, Lab 9 is designed to give you a hands-on experience of the powerful utility of debuggers.
1. (1 credit) Demonstrate the following, using any code segment
Set a breakpoint, and run the program until it stops there
Check the values of variable at that point
Single-stepping (step-in & step-over) through a program, starting from a breakpoint
2. (1 credit) Program1.c (attached below) has an evident bug. Run it, identify the bug, & fix it using the above-mentioned debugging techniques.
Hint: The output of the program might differ in separate runs & might be erroneous too. Expected output is: mouse
3. (Extra credit) Program2.c (attached below) has an infinite loop, due to erroneous code. Use debugging techniques to find the issue & fix it.