Data Display Debugger
DDD stands for 'Data Display Debugger'. It is a GUI front end of GDB, the GNU debugger. The main advantage of DDD over GDB is that DDD offers a GUI. In this tutorial, we will learn about
- setting and removing breakpoints
- tracing through programs
- examining data at various points in execution.
Since DDD is a graphical debugger, you will either need to SSH with X forwarding or use OnDemand.
SSH with X
If you want to debug from a dev node, first make sure that you SSH using the
-X option. You can then start DDD using
ddd which will open a DDD window on
1 2 3
If you would like to run your debugging job interactively on a compute node, please see the instructions for running an interactive graphical application.
You can also use DDD in your browser through OnDemand. Log in using your MSU credentials on the OnDemand site. Then from the Jobs menu, select Interactive Desktop. Once your job starts, you can open your Interactive Desktop and choose "Data Display Debugger" from the Applications menu under Programming.
The DDD interface
When you start DDD, you will see a DDD window like this:
The DDD window consists of 4 sections:
- data window
- source window
- machine code window
- GDB console
You can show/hide each of them in View menu.
You can customize the DDD environment in Edit → Preferences menu.
For example, to display line numbers in source window, under Edit → Preferences → Source, check 'Display Source Line Numbers'.
Opening a program
To use DDD, we need a program to debug. Let's use the following code.
1 2 3 4 5 6 7 8 9
First, you need to compile this code with
-g option to include the debug
symbols. Run this on the command line:
Now, to open this in DDD, you can either select it in the File → Open Program menu or you can run DDD with this executable from the command line like
Even though you open an executable such as
debug_ex, DDD will show the source
file name such as
Breakpoints stop your program in the middle of running to examine the current state of variables and data structures. You can continue from where you set the breakpoint to finish program execution.
To set a breakpoint, double click to the left of the source line in the source window. A STOP icon will appear next to it.
Click Run at the top of the window to start execution or type
run in the GDB
console. A green arrow will appear as soon as you hit the breakpoint.
The breakpoints you set can be deleted or disabled by right-clicking on the line with the breakpoint and choosing either the "Disable Breakpoint" or "Delete Breakpoint" options.
In order to set breakpoints in other files (i.e., not in the
function), choose the "Open Source" option from the File menu of DDD. The file
dialog should appear.
The example in the figure above has a breakpoint at line 6. The program runs to
the line number 5 and waits your input. You can run the code a line by line
with 'next' command (by either clicking the button at the top of the screen or
next into the GDB console).
To see a variable's value, type
print <variable_name> in the GDB console. For
print i will show the value of the variable
i. You can also right
click the variable in the source code choose
To go to the next break point, click Cont button or type
cont on GDB console.
When you find bugs, 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.
DDD offers command buttons, but you can also type commands directly on GDB console.
|help documentation for topics and commands
|Lists help information about breakpoints
|Sets breakpoint at a line number
|Sets breakpoint at the begining of function name
|Enable, disable, or delete one or more breakpoints.
|Disables breakpoint number 3
|Clears breakpoint at line_number
|Deletes breakpoint number 3
|Deletes all beakpoints
|Starts program running from the begining.
|Continues execution from the current line to the next breakpoint
|Execute next line(s) of program
|Executes one line of a program
|Executes next number of lines of program
|next (or n)
|Like step, but treats a function as a single line.
|Execute the next line
|Executes next number of lines of program
|Executes program until line number
|Lists program source code
|Display program values, results of expressions
|List type of an expression
|Shows data type of expression
|Shows local variables in current stack frame
|Shows the argument variable of current stack frame
|Change values of variables, memory, registers
set x = 123*y
x's value to
While the program is running, you may want to examine the contents of variables. You can do this by right-clicking on a variable name in the DDD window.
Upon right-clicking, select "Display". If you want to display the value of a pointer, use the "Display*" menu item.
Right-clicking on a variable name offers other capabilities such as Print, Lookup, What Is (showing the data type), Break, and Clear.
Instead of right-clicking, you can peek at memory contents also. To do that, click Data → Memory.