CSC 161 Grinnell College Spring, 2010
 
Imperative Problem Solving and Data Structures
 

Gnu's DDD Debugger

Goals

This laboratory exercise walks you through the DDD tutorial provided by Gnu. DDD is a graphical debugger DDD (Data Display Debugger), a helpful tool for debugging C programs in a Unix environment.

Index

Acknowledgement

This lab is an edited version of a DDD tutorial by Marge Coahran. Be sure you have reviewed today's reading before proceeding to the steps that follow.

Part A: Gnu's DDD Tutorial

In this exercise, I would like you to walk through the DDD tutorial provided by Gnu. Unfortunately, the sample code contains some C syntax that we have not studied yet, so you may not understand everything in the sample program. However, you will still learn a lot about the use of the debugger, and that is the point of this laboratory lesson.
  1. Follow the instructions in the sample tutorial, except for the exceptions listed below. Stop at the end of the tutorial (i.e., when you run into the sample source code again), which is way before the end of the web page.

  2. Return to the top of Gnu's tutorial, and scan through it again, this time making a crib sheet of the various DDD features you learned. I suggest recording how the various features are invoked and also brief descriptions of what they do. You may want to keep this crib sheet handy for future use!

Part B: Various Shorts

  1. Compile the program sample.c again, this time without using the option -g, and try to run it in DDD. (The purpose of this exercise is so that you may recognize the error it produces should you happen to see it again in the future.)

  2. Re-compile sample.c with the debugging information included. Run ddd again. Move the mouse over various icons on the toolbar, and press the F1 key over some of them to read about what they do.

  3. Try selecting What Now? from the Help menu (in the far upper-right corner of the DDD window). You may also want to try the Tip of the Day from the same menu.

Part C: A Debugging Exercise

  1. Copy or download the following bug-ridden C program: ~walker/c/debugger/debugme.c.

  2. Use what you have learned to track down and fix the bugs in this program with the help of DDD.

    You may find the Interrupt button on the DDD Command Tool useful for this exercise. It will suspend your program -- a useful feature for locating infinite loops.

    At some point during this exercise, try moving a breakpoint from one line to another by dragging the stop-sign icon.

For Those with Extra Time: Shell Sort

If you are interested in learning more about the Shell Sort algorithm used in Gnu's DDD tutorial, you can read about it on Wikipedia.

This document is available on the World Wide Web as

http://www.cs.grinnell.edu/~walker/courses/161.sp10/labs/lab-debugger.shtml

created February 2007 by Marge Coahran
restructured 4 May 2008 by Henry M. Walker
last revised 27 February 2010 by Henry M. Walker
Valid HTML 4.01! Valid CSS!
For more information, please contact Henry M. Walker at walker@cs.grinnell.edu.