Lab Midterm

Take-Home Midterm Due: Thursday, December 4, 1996, at 11:59 PM


This is a take-home midterm exam. All the usual rules of a midterm apply: it is open book, open notes, but closed neighbor, so it's not fair to work on this with anyone else.

The goal of this midterm is simple: to show you can do some basic debugging using gdb and can submit homework correctly. It is not meant to be hard; also, it is graded pass/fail.

In the CSIF directory for this class, ~cs40, is a directory called lab-midterm. It contains a program called parity.c. This program is supposed to load an array of 10 elements with alternating 1s and 0s, beginning with index #1, and to print each element when it is loaded.

But this program doesn't work right - it goes into an infinite loop. Your job: find the bug!

The Examination

Get the program. Use gdb to show what the bug is. You do not have to fix it, but you must clearly exhibit the bug using gdb (possibly annotating what you did), and say very clearly what caused it.

What to Turn In

Use the program script(1) to generate a typescript file called DEBUGGING showing your debugging session with gdb. Note you must do this, even if you did not use gdb to find the error. Step through the program at least once in such a way that you demonstrate exactly where the bug is, and then add a comment saying exactly what the bug is. Feel free to add comments to your gdb commands in the file to explain what you are doing.

How to Turn It In

Submit the midterm as though it were a homwork; the directory is labmid:

handin cs40r labmid DEBUGGING

You can also see this document as a RTF document, a Postscript document, or a plain ASCII text document.
Send email to

Department of Computer Science
University of California at Davis
Davis, CA 95616-8562

Page last modified on 12/2/97