The ddd debugging tool is actually just a graphical X11 "front end" to gdb, so it will be assumed here that you are already familiar with gdb. (If not, see my gdb mini-manual.)
To start ddd, type
ddd filenamewhere "filename" is your program's executable file. Several windows will then appear (from top to bottom):
This deals with files, lists of breakpoints and other miscellaneous aspects of the debugging process.
This shows the source code of your program. A green arrow points to the next line to be executed, and little Stop signs show breakpoints. There is a scrollbar on the right, which can be used to view different parts of the source code. To view another source file, click on File in the Control window.
Also appearing in the Source window are the Run window, a small window at the right in which you can start and stop execution of your program,and the
This allows you to give ordinary gdb commands directly to gdb (though usually you will use mouse clicks in other windows instead). Note: You need to click the left mouse button somewhere in this window first if you are going to type something in that window.
In some cases, you may wish to make this window bigger. To do this, go to Edit, then Preferences, then Startup, and change Window Layout to Separate Windows. You can then use your X11 window manager to resize the Debugger Console window.
Here is how you can execute various gdb commands conveniently via ddd:
In the case in which your operation itself is Run, you will be prompted for command-line arguments in the Debugger Console window the first time you run the program within this ddd session.
To re-run a program within this ddd session, click the left mouse button on Program in the Control window, and then on Run Again.
If you change and save the source file and re-run the program, gdb/ddd will notice and update accordingly. However, it may not update the breakpoint positions, so check these. (If you are using the vim editor and have set autowrite, running vim's Make command will automatically save the file.)
Later, to disable a breakpoint, click on the line and then on Clear. Or, if you wish to only temporarily disable the breakpoint, click the left mouse button on Source in the Control window, then on Edit Breakpoints, then on the breakpoint in question, and then on the desired operation listed at the right of the breakpoints menu.
Often one wishes to move a breakpoint; this can be done in a very handy way in ddd by simply using the mouse to drag the stop sign to the desired line.
To see the contents of a struct when you have a variable pointing to it, click the right mouse button on any mention of the pointer, and select "*Print()" in the resulting pull-down menu.
You can click the right mouse button as with "print" above, to continuously display the contents of a struct.
To delete a display, click on it and then click Undisplay.
This is especially useful when debugging threads-based programs.
Here are some tips for using ddd to debug threads-based programs. First, make sure to have a Backtrace window, as discussed earlier. Second, have a Threads window (click on Status, then Threads). The latter highlights whichever thread is currently active; clicking on another thread will make that one active, and the Backtrace window will be updated accordingly.