Comp 1672, Winter 2003
Lab 8

This lab gives you a chance to examine and debug code for a singly-linked list. Download the following file lab8.tar.gz to your cygwin directory. Unzip it and extract the files. Recall that to do this you type

% gunzip lab8.tar.gz
% tar -xvf lab8.tar

When you extract the files, you will have a new directory called lab8. Change your current working directory to that new directory.

Compile the program using the makefile given. The name of the executable is listtest.

Question: The make file has all compilations done with the -g flag. What is this flag for?

Run the program, and read the output. Carefully read the first three tests, and note that they give correct output. Read test 4 - it does not give correct output.

Question: How can you tell that test 4 failed? In other words, what is the symptom of the bug?

Your job is to debug the program, so that test 4 runs correctly. Begin by running the debugger

% gdb listtest

If you get the console-version of the debugger rather than the GUI (Graphical User Interface) version of the debugger, then type

% gdb -window listtest

Set a breakpoint at the point in the code where test 4 begins. Step through the code to see what is happening and what is going wrong.

Note that when you fix the problem, then a new problem crops up in test 5. Find and fix that bug for extra credit.

Turn in a printout of any functions in LinkedList.cpp that you changed.