DDD: The Data Display Debugger

Example: Lab2 using DDD

We'll use “part a” of Lab 2 as an example. First, copy the files into your home directory:

cp -r ~cs61c/files/lab/2 ~/lab2
cd ~/lab2

Then, compile the first example:

gcc -g list1.c main.c

Now, launch ddd:

ddd a.out

You should see something like this:

Click at the far left edge of the line “list = cons (line, list);”, and then click the “break” button on the toolbar.

You should see a stopsign appear next to the line where you set the breakpoint:

Now, run the program by choosing the “run” option from the “program” menu. You should see a dialog like this:

Click ok. You should see “string to add to front of list?” appear in the lower window; click there and type something:

After you press enter, the program will run and hit the breakpoint. Notice the text “Breakpoint 1” in the lower window, and the black arrow in the upper window:

Now, we'd like to inspect some data. From the Data menu, choose “Display Local Variables”. You should see this:

Now, from the Program menu, choose Next. The black arrow moves down one line, and you can see the changes to list reflected in the upper window:

Right-click on list, and choose the option “Display”.

You should now see the box-and-pointer diagram expand by one level to show the struct that list points to:

Here's a more complex diagram generated from the program in list3.c: