CS 241 Data Organization using C
Lab 4: GDB
September 12, 2018
1 Lab Overview
In this lab, you will work on your debugging techniques using gdb. For more reference, see the slides.
Finding an intermediate value using gdb
For this part of the assignment, you will need to find intermediate values for the recursively defined fibonacci program using breakpoints, print statements, and other gdb commands. Be sure to compile your program with the -g flag.
How many times does this program calculate fib?
Turn in the answer to this and the gdb commands that you needed in a text file intermediatefib.txt.
Finding bugs using gdb
For this part of the assignment, you will need to debug this broken factorial program. First, compile and run the program. What is wrong? Then, use gdb to pinpoint which value of n causes the bug. (I suggest using watchpoints -- watch where you declare them! Variable scope matters.)
Turn in the value of n that causes the bug along with the gdb commands that you used and a proposed fix for the problem (no c code necessary). This should all be in a textfile bugfac.txt.
Files to submit
Submit your intermediatefib.txt and bugfac.txt in a zip file labeled with your cs username to the lab-04 folder in the course dropbox.