A DDD Quick Start by Elena Jakubiak

  • DDD stands for Data Display Debugger
  • DDD is a visual interface for the GDB debugger
  • DDD is Available on the Halligan Sun Machines (similar debuggers are available for Windows & Linux)

Some Useful Resources

  • The official DDD Manual
  • A good debugging tutorial using DDD

The DDD Interface

Customizing the DDD Environment

  • Display Line Numbers

Use the Source menu: Source  Display Line Numbers

  • Editing & Compiling Code from within DDD

Source code can be edited and compiled from within DDD.

  • Customizing the display Editor window

Drag data around in the Display Editor window.

Double-click to collapse and expand data displays.

More advanced features include displaying all local variables and graphing data.

The Basic Steps

  1. Compile your program with debugging information by using the –g flag

% g++ -g sort.cpp –o sort.o

  1. Open your executable program in DDD

% ddd sort.o

  1. Set a breakpoint

Right-click on the left side of a line of code in the Source Windowand select Set Breakpointfrom the pop-up menu

  1. Run your program

Click on the Run button in the Command Toolor hit F2

Enter any required run-time inputs in theDebugger Console window

  1. When the program stops at the breakpoint, Inspect your variables’ values

Hover over a variable to see a pop-up of its value

Right-click a variable and select Display <myVariable>from the pop-up menu (this will open a new window for displaying variables’ and their values)

  1. Step through the code (watch how the variables’ values change)

Click Step to step to the next line of code and into a function call

Click Next to step to the next line of code and over a function call

  1. Find the bug, edit your code, and restart the debugging cycle

Edit your source code in your editor of choice and recompile the code.

Reload the new source code into DDD using the Source menu: Source  Reload Source

Being Smart about Debugging

  • “I just use print statements”

Using print statements is slower and less informative. Code has to be repeatedly recompiled and you can only see what you specifically ask to see.

  • The binary search principle

You don’t look up a word in the dictionary by starting at the first letter ‘A’ page and turning hundreds of pages until you find your word (especially if your word is zebra). Like searching the dictionary, put a breakpoint in the middle of your program and look at the values there. Is your bug before or after that point?