Node:Top, Next:, Up:DDD home page
DDD - The Data Display Debugger

Debugging with DDD

DDD is a graphical front-end for GDB and other command-line debuggers.

This is the First Edition of Debugging with DDD, 2000-01-03, for DDD Version 3.2.

Table of Contents

Copyright © 2000 Universität Passau
Lehrstuhl für Software-Systeme
Innstraße 33
D-94032 Passau
GERMANY

Distributed by
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307
USA

DDD and this manual are available via the DDD WWW page.

Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies.

Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided also that the sections entitled "Copying" and "GNU General Public License" (see License) are included exactly as in the original, and provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.

Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by the Free Software Foundation.

Send questions, comments, suggestions, etc. to ddd@gnu.org.
Send bug reports to bug-ddd@gnu.org.


Node:Summary, Next:, Previous:Top, Up:Top

Summary of DDD

The purpose of a debugger such as DDD is to allow you to see what is going on "inside" another program while it executes--or what another program was doing at the moment it crashed.

DDD can do four main kinds of things (plus other things in support of these) to help you catch bugs in the act:

Technically speaking, DDD is a front-end to a command-line debugger (called inferior debugger, because it lies at the layer beneath DDD). DDD supports the following inferior debuggers:

See Choosing an Inferior Debugger, for choosing the appropriate inferior debugger. See Sample Session, for getting a first impression of DDD.


Node:About this Manual, Next:, Up:Summary

About this Manual

This manual comes in several formats:

The manual itself is written in TeXinfo format; its source code ddd.texi is contained in the DDD source distribution ddd-3.2.tar.gz.

The picture sources come in a separate package ddd-3.2-pics.tar.gz; you need this package only if you want to re-create the PostScript, HTML, or PDF versions.


Node:Free Software, Next:, Previous:About this Manual, Up:Summary

Free software

DDD is free; this means that everyone is free to use it and free to redistribute it on a free basis. DDD is not in the public domain; it is copyrighted and there are restrictions on its distribution, but these restrictions are designed to permit everything that a good cooperating citizen would want to do. What is not allowed is to try to prevent others from further sharing any version of DDD that they might get from you. The precise conditions are found in the GNU General Public License that comes with DDD; See License, for details.

The easiest way to get a copy of DDD is from someone else who has it. You need not ask for permission to do so, or tell any one else; just copy it.


Node:Getting DDD, Next:, Previous:Free Software, Up:Summary

Getting DDD

If you have access to the Internet, you can get the latest version of DDD from the anonymous FTP server ftp.gnu.org in the directory /gnu/ddd. This should contain the following files:

ddd-version.tar.gz
The DDD source distribution. This should be all you need.
ddd-version-html-manual.tar.gz
The DDD manual in HTML format. You need this only if you want to install a local copy of the DDD manual in HTML format.
ddd-version-pics.tar.gz
Sources of images included in the DDD manual. You need this only if you want to recreate the DDD manual.

DDD can also be found at numerous other archive sites around the world; check the file ANNOUNCE in a DDD distribution for the latest known list.


Node:Contributors, Next:, Previous:Getting DDD, Up:Summary

Contributors to DDD

Dorothea Lütkehaus and Andreas Zeller were the original authors of DDD. Many others have contributed to its development. The files ChangeLog and THANKS in the DDD distribution approximates a blow-by-blow account.


Node:History, Previous:Contributors, Up:Summary

History of DDD

The history of DDD is a story of code recycling. The oldest parts of DDD were written in 1990, when Andreas Zeller designed VSL, a box-based visual structure language for visualizing data and program structures. The VSL interpreter and the Box library became part of Andreas' Diploma Thesis, a graphical syntax editor based on the Programming System Generator PSG.

In 1992, the VSL and Box libraries were recycled for the NORA project. For NORA, an experimental inference-based software development tool set, Andreas wrote a graph editor (based on VSL and the Box libraries) and facilities for inter-process knowledge exchange. Based on these tools, Dorothea Lütkehaus (now Dorothea Krabiell) realized DDD as her Diploma Thesis, 1994

The original DDD had no source window; this was added by Dorothea during the winter of 1994-1995. In the first quarter of 1995, finally, Andreas completed DDD by adding command and execution windows, extensions for DBX and remote debugging as well as configuration support for several architectures. Since then, Andreas has further maintained and extended DDD, based on the comments and suggestions of several DDD users around the world. See the comments in the DDD source for details.

Major DDD events:

April, 1995
DDD 0.9: First DDD beta release.
May, 1995
DDD 1.0: First public DDD release.
December, 1995
DDD 1.4: Machine-level debugging, glyphs, Emacs integration.
October, 1996
DDD 2.0: Color displays, XDB support, generic DBX support, command tool.
May, 1997
DDD 2.1: Alias detection, button tips, status displays.
November, 1997
DDD 2.2: Sessions, display shortcuts.
June, 1998
DDD 3.0: Icon tool bar, Java support, JDB support.
December, 1998
DDD 3.1: Data plotting, Perl support, Python support, Undo/Redo.
January, 2000
DDD 3.2: New manual, Readline support, Ladebug support.


Node:Sample Session, Next:, Previous:Summary, Up:Top

A Sample DDD Session

You can use this manual at your leisure to read all about DDD. However, a handful of features are enough to get started using the debugger. This chapter illustrates those features.

The sample program sample.c (see Sample Program) exhibits the following bug. Normally, sample should sort and print its arguments numerically, as in the following example:

$ ./sample 8 7 5 4 1 3
1 3 4 5 7 8

However, with certain arguments, this goes wrong:

$ ./sample 8000 7000 5000 1000 4000
1000 1913 4000 5000 7000

Although the output is sorted and contains the right number of arguments, some arguments are missing and replaced by bogus numbers; here, 8000 is missing and replaced by 1913.3

Let us use DDD to see what is going on. First, you must compile sample.c for debugging (see Compiling for Debugging), giving the -g flag while compiling:

$ gcc -g -o sample sample.c

Now, you can invoke DDD (see Invocation) on the sample executable:

$ ddd sample

After a few seconds, DDD comes up. The Source Window contains the source of your debugged program; use the Scroll Bar to scroll through the file.

PICS/tut-invoke.jpg


The Debugger Console (at the bottom) contains DDD version information as well as a GDB prompt.4

GNU DDD Version 3.2, by Dorothea Lütkehaus and Andreas Zeller.
Copyright © 1999 Technische Universität Braunschweig, Germany.
Copyright © 1999 Universität Passau, Germany.
Reading symbols from sample...done.
(gdb)

The first thing to do now is to place a Breakpoint (see Breakpoints), making sample stop at a location you are interested in. Click on the blank space left to the initialization of a. The Argument field (): now contains the location (sample.c:31). Now, click on Break to create a breakpoint at the location in (). You see a little red stop sign appear in line 31.

The next thing to do is to actually execute the program, such that you can examine its behavior (see Running). Select Program => Run to execute the program; the Run Program dialog appears.

PICS/tut-run.jpg


In Run with Arguments, you can now enter arguments for the sample program. Enter the arguments resulting in erroneous behavior here--that is, 8000 7000 5000 1000 4000. Click on Run to start execution with the arguments you just entered.

GDB now starts sample. Execution stops after a few moments as the breakpoint is reached. This is reported in the debugger console.

(gdb) break sample.c:31
Breakpoint 1 at 0x8048666: file sample.c, line 31.
(gdb) run 8000 7000 5000 1000 4000
Starting program: sample 8000 7000 5000 1000 4000

Breakpoint 1, main (argc=6, argv=0xbffff918) at sample.c:31
(gdb)

The current execution line is indicated by a green arrow.

=> a = (int *)malloc((argc - 1) * sizeof(int));

You can now examine the variable values. To examine a simple variable, you can simply move the mouse pointer on its name and leave it there. After a second, a small window with the variable value pops up (see Value Tips). Try this with argv to see its value (6). The local variable a is not yet initialized; you'll probably see 0x0 or some other invalid pointer value.

To execute the current line, click on the Next button on the command tool. The arrow advances to the following line. Now, point again on a to see that the value has changed and that a has actually been initialized.

PICS/tut-value.jpg


To examine the individual values of the a array, enter a[0] in the argument field (you can clear it beforehand by clicking on ():) and then click on the Print button. This prints the current value of () in the debugger console (see Printing Values). In our case, you'll get

(gdb) print a[0]
$1 = 0
(gdb)

or some other value (note that a has only been allocated, but the contents have not yet been initialized).

To see all members of a at once, you must use a special GDB operator. Since a has been allocated dynamically, GDB does not know its size; you must specify it explicitly using the @ operator (see Array Slices). Enter a[0]@(argc - 1) in the argument field and click on the Print button. You get the first argc - 1 elements of a, or

(gdb) print a[0]@(argc - 1)
$2 = {0, 0, 0, 0, 0}
(gdb)

Rather than using Print at each stop to see the current value of a, you can also display a, such that its is automatically displayed. With a[0]@(argc - 1) still being shown in the argument field, click on Display. The contents of a are now shown in a new window, the Data Window. Click on Rotate to rotate the array horizontally.

PICS/tut-display.jpg


Now comes the assignment of a's members:

=>  for (i = 0; i < argc - 1; i++)
        a[i] = atoi(argv[i + 1]);

You can now click on Next and Next again to see how the individual members of a are being assigned. Changed members are highlighted.

To resume execution of the loop, use the Until button. This makes GDB execute the program until a line greater than the current is reached. Click on Until until you end at the call of shell_sort in

=>  shell_sort(a, argc);

At this point, a's contents should be 8000 7000 5000 1000 4000. Click again on Next to step over the call to shell_sort. DDD ends in

=>  for (i = 0; i < argc - 1; i++)
        printf("%d ", a[i]);

and you see that after shell_sort has finished, the contents of a are 1000, 1913, 4000, 5000, 7000--that is, shell_sort has somehow garbled the contents of a.

To find out what has happened, execute the program once again. This time, you do not skip through the initialization, but jump directly into the shell_sort call. Delete the old breakpoint by selecting it and clicking on Clear. Then, create a new breakpoint in line 35 before the call to shell_sort. To execute the program once again, select Program => Run Again.

Once more, DDD ends up before the call to shell_sort:

=>  shell_sort(a, argc);

This time, you want to examine closer what shell_sort is doing. Click on Step to step into the call to shell_sort. This leaves your program in the first executable line, or

=> int h = 1;

while the debugger console tells us the function just entered:

(gdb) step
shell_sort (a=0x8049878, size=6) at sample.c:9
(gdb)

This output that shows the function where sample is now suspended (and its arguments) is called a stack frame display. It shows a summary of the stack. You can use Status => Backtrace to see where you are in the stack as a whole; selecting a line (or clicking on Up and Down) will let you move through the stack. Note how the a display disappears when its frame is left.

PICS/tut-backtrace.jpg


Let us now check whether shell_sort's arguments are correct. After returning to the lowest frame, enter a[0]@size in the argument field and click on Print:

(gdb) print a[0] @ size
$4 = {8000, 7000, 5000, 1000, 4000, 1913}
(gdb)

Surprise! Where does this additional value 1913 come from? The answer is simple: The array size as passed in size to shell_sort is too large by one--1913 is a bogus value which happens to reside in memory after a. And this last value is being sorted in as well.

To see whether this is actually the problem cause, you can now assign the correct value to size (see Assignment). Select size in the source code and click on Set. A dialog pops up where you can edit the variable value.

PICS/tut-set.jpg


Change the value of size to 5 and click on OK. Then, click on Finish to resume execution of the shell_sort function:

(gdb) set variable size = 5
(gdb) finish
Run till exit from #0  shell_sort (a=0x8049878, size=5) at sample.c:9
0x80486ed in main (argc=6, argv=0xbffff918) at sample.c:35
(gdb)

Success! The a display now contains the correct values 1000, 4000, 5000, 7000, 8000.

PICS/tut-finish.jpg


You can verify that these values are actually printed to standard output by further executing the program. Click on Cont to continue execution.

(gdb) cont
1000 4000 5000 7000 8000

Program exited normally.
(gdb)

The message Program exited normally. is from GDB; it indicates that the sample program has finished executing.

Having found the problem cause, you can now fix the source code. Click on Edit to edit sample.c, and change the line

shell_sort(a, argc);

to the correct invocation

shell_sort(a, argc - 1);

You can now recompile sample

$ gcc -g -o sample sample.c

and verify (via Program => Run Again) that sample works fine now.

(gdb) run
`sample' has changed; re-reading symbols.
Reading in symbols...done.
Starting program: sample 8000 7000 5000 1000 4000
1000 4000 5000 7000 8000

Program exited normally.
(gdb)

All is done; the program works fine now. You can end this DDD session with Program => Exit or Ctrl+Q.


Node:Sample Program, Up:Sample Session

Sample Program

Here's the source sample.c of the sample program.

/* sample.c -- Sample C program to be debugged with DDD */

#include <stdio.h>
#include <stdlib.h>

static void shell_sort(int a[], int size)
{
    int i, j;
    int h = 1;
    do {
        h = h * 3 + 1;
    } while (h <= size);
    do {
        h /= 3;
        for (i = h; i < size; i++)
        {
            int v = a[i];
            for (j = i; j >= h && a[j - h] > v; j -= h)
                a[j] = a[j - h];
            if (i != j)
                a[j] = v;
        }
    } while (h != 1);
}

int main(int argc, char *argv[])
{
    int *a;
    int i;

    a = (int *)malloc((argc - 1) * sizeof(int));
    for (i = 0; i < argc - 1; i++)
        a[i] = atoi(argv[i + 1]);

    shell_sort(a, argc);

    for (i = 0; i < argc - 1; i++)
        printf("%d ", a[i]);
    printf("\n");

    free(a);
    return 0;
}


Node:Invocation, Next:, Previous:Sample Session, Up:Top

Getting In and Out of DDD

This chapter discusses how to start DDD, and how to get out of it. The essentials are:


Node:Invoking, Next:, Up:Invocation

Invoking DDD

Normally, you can run DDD by invoking the program ddd.

You can also run DDD with a variety of arguments and options, to specify more of your debugging environment at the outset.

The most usual way to start DDD is with one argument, specifying an executable program:

ddd program

If you use GDB, DBX, Ladebug, or XDB as inferior debuggers, you can also start with both an executable program and a core file specified:

ddd program core

You can, instead, specify a process ID as a second argument, if you want to debug a running process:

ddd program 1234

would attach DDD to process 1234 (unless you also have a file named 1234; DDD does check for a core file first).

You can further control DDD by invoking it with specific options. To get a list of DDD options, invoke DDD as

ddd --help

Most important are the options to specify the inferior debugger (see Choosing an Inferior Debugger), but you can also customize several aspects of DDD upon invocation (see Options).

DDD also understands the usual X options such as -display or -geometry. See X Options, for details.

All arguments and options that are not understood by DDD are passed to the inferior debugger; See Inferior Debugger Options, for a survey. To pass an option to the inferior debugger that conflicts with an X option, or with a DDD option listed here, use the --debugger option (see Options).


Node:Choosing an Inferior Debugger, Next:, Up:Invoking

Choosing an Inferior Debugger

The most frequently required options are those to choose a specific inferior debugger.

Normally, the inferior debugger is determined by the program to analyze:

If you invoke DDD without any of these options, but give a program to analyze, then DDD will automatically determine the inferior debugger:

See Customizing Debugger Interaction, for more details on determining the inferior debugger.


Node:Options, Next:, Previous:Choosing an Inferior Debugger, Up:Invoking

DDD Options

You can further control how DDD starts up using the following options. All options may be abbreviated, as long as they are unambiguous; single dashes - instead of double dashes -- may also be used. Almost all options control a specific DDD resource or resource class (see Customizing).

--attach-windows
Attach the source and data windows to the debugger console, creating one single big DDD window. This is the default setting.

Giving this option is equivalent to setting the DDD Separate resource class to off. See Window Layout, for details.

--attach-source-window
Attach only the source window to the debugger console.

Giving this option is equivalent to setting the DDD separateSourceWindow resource to off. See Window Layout, for details.

--attach-data-window
Attach only the source window to the debugger console.

Giving this option is equivalent to setting the DDD separateDataWindow resource to off. See Window Layout, for details.

--automatic-debugger
Determine the inferior debugger automatically from the given arguments.

Giving this option is equivalent to setting the DDD autoDebugger resource to on. See Customizing Debugger Interaction, for details.

--button-tips
Enable button tips.

Giving this option is equivalent to setting the DDD buttonTips resource to on. See Customizing Help, for details.

--configuration
Print the DDD configuration settings on standard output and exit.

Giving this option is equivalent to setting the DDD showConfiguration resource to on. See Diagnostics, for details.

--check-configuration
Check the DDD environment (in particular, the X configuration), report any possible problem causes and exit.

Giving this option is equivalent to setting the DDD checkConfiguration resource to on. See Diagnostics, for details.

--data-window
Open the data window upon start-up.

Giving this option is equivalent to setting the DDD openDataWindow resource to on. See Toggling Windows, for details.

--dbx
Run DBX as inferior debugger.

Giving this option is equivalent to setting the DDD debugger resource to dbx. See Customizing Debugger Interaction, for details.

--debugger name
Invoke the inferior debugger name. This is useful if you have several debugger versions around, or if the inferior debugger cannot be invoked under its usual name (i.e. gdb, dbx, xdb, jdb, pydb, or perl).

This option can also be used to pass options to the inferior debugger that would otherwise conflict with DDD options. For instance, to pass the option -d directory to XDB, use:

ddd --debugger "xdb -d directory"

If you use the --debugger option, be sure that the type of inferior debugger is specified as well. That is, use one of the options --gdb, --dbx, --xdb, --jdb, --pydb, or --perl (unless the default setting works fine).

Giving this option is equivalent to setting the DDD debuggerCommand resource to name. See Customizing Debugger Interaction, for details.

--debugger-console
Open the debugger console upon start-up.

Giving this option is equivalent to setting the DDD openDebuggerConsole resource to on. See Toggling Windows, for details.

--disassemble
Disassemble the source code. See also the --no-disassemble option, below.

Giving this option is equivalent to setting the DDD disassemble resource to on. See Customizing Source, for details.

--exec-window
Run the debugged program in a specially created execution window. This is useful for programs that have special terminal requirements not provided by the debugger window, as raw keyboard processing or terminal control sequences. See Using the Execution Window, for details.

Giving this option is equivalent to setting the DDD separateExecWindow resource to on. See Customizing the Execution Window, for details.

--font fontname
-fn fontname
Use fontname as default font.

Giving this option is equivalent to setting the DDD defaultFont resource to fontname. See Customizing Fonts, for details.

--fonts
Show the font definitions used by DDD on standard output.

Giving this option is equivalent to setting the DDD showFonts resource to on. See Diagnostics, for details.

--fontsize size
Set the default font size to size (in 1/10 points). To make DDD use 12-point fonts, say --fontsize 120.

Giving this option is equivalent to setting the DDD FontSize resource class to size. See Customizing Fonts, for details.

--fullname
-f
Enable the TTY interface, taking additional debugger commands from standard input and forwarding debugger output on standard output. Current positions are issued in GDB -fullname format suitable for debugger front-ends. By default, both the debugger console and source window are disabled. See TTY mode, for a discussion.

Giving this option is equivalent to setting the DDD TTYMode resource class to on. See TTY mode, for details.

--gdb
Run GDB as inferior debugger.

Giving this option is equivalent to setting the DDD debugger resource to gdb. See Customizing Debugger Interaction, for details.

--glyphs
Display the current execution position and breakpoints as glyphs. See also the --no-glyphs option, below.

Giving this option is equivalent to setting the DDD displayGlyphs resource to on. See Customizing Source, for details.

--help
-h
-?
Give a list of frequently used options. Show options of the inferior debugger as well.

Giving this option is equivalent to setting the DDD showInvocation resource to on. See Diagnostics, for details.

--host hostname
--host username@hostname
Invoke the inferior debugger directly on the remote host hostname. If username is given and the --login option is not used, use username as remote user name. See Remote Debugger, for details.

Giving this option is equivalent to setting the DDD debuggerHost resource to hostname. See Remote Debugger, for details.

--jdb
Run JDB as inferior debugger.

Giving this option is equivalent to setting the DDD debugger resource to gdb. See Customizing Debugger Interaction, for details.

--ladebug
Run Ladebug as inferior debugger.

Giving this option is equivalent to setting the DDD debugger resource to ladebug. See Customizing Debugger Interaction, for details.

--lesstif-hacks
Equivalent to --lesstif-version 999. Deprecated.

Giving this option is equivalent to setting the DDD lessTifVersion resource to 999. See LessTif, for details.

--lesstif-version version
Enable some hacks to make DDD run properly with LessTif. See LessTif, for a discussion.

Giving this option is equivalent to setting the DDD lessTifVersion resource to version. See LessTif, for details.

--license
Print the DDD license on standard output and exit.

Giving this option is equivalent to setting the DDD showLicense resource to on. See Diagnostics, for details.

--login username
-l username
Use username as remote user name. See Remote Debugger, for details.

Giving this option is equivalent to setting the DDD debuggerHostLogin resource to username. See Remote Debugger, for details.

--maintenance
Enable the top-level Maintenance menu with options for debugging DDD. See Maintenance Menu, for details.

Giving this option is equivalent to setting the DDD maintenance resource to on. See Maintenance Menu, for details.

--manual
Print the DDD manual on standard output and exit.

Giving this option is equivalent to setting the DDD showManual resource to on. See Diagnostics, for details.

--news
Print the DDD news on standard output and exit.

Giving this option is equivalent to setting the DDD showNews resource to on. See Diagnostics, for details.

--no-button-tips
Disable button tips.

Giving this option is equivalent to setting the DDD buttonTips resource to off. See Customizing Help, for details.

--no-data-window
Do not open the data window upon start-up.

Giving this option is equivalent to setting the DDD openDataWindow resource to off. See Toggling Windows, for details.

--no-debugger-console
Do not open the debugger console upon start-up.

Giving this option is equivalent to setting the DDD openDebuggerConsole resource to off. See Toggling Windows, for details.

--no-disassemble
Do not disassemble the source code.

Giving this option is equivalent to setting the DDD disassemble resource to off. See Customizing Source, for details.

--no-exec-window
Do not run the debugged program in a specially created execution window; use the debugger console instead. Useful for programs that have little terminal input/output, or for remote debugging. See Using the Execution Window, for details.

Giving this option is equivalent to setting the DDD separateExecWindow resource to off. See Customizing the Execution Window, for details.

--no-glyphs
Do not use glyphs; display the current execution position and breakpoints as text characters.

Giving this option is equivalent to setting the DDD displayGlyphs resource to off. See Customizing Source, for details.

--no-lesstif-hacks
Equivalent to --lesstif-version 1000. Deprecated.

Giving this option is equivalent to setting the DDD lessTifVersion resource to 1000. See LessTif, for details.

--no-maintenance
Do not enable the top-level Maintenance menu with options for debugging DDD. This is the default. See Maintenance Menu, for details.

Giving this option is equivalent to setting the DDD maintenance resource to off. See Maintenance Menu, for details.

--no-source-window
Do not open the source window upon start-up.

Giving this option is equivalent to setting the DDD openSourceWindow resource to off. See Toggling Windows, for details.

--no-value-tips
Disable value tips.

Giving this option is equivalent to setting the DDD valueTips resource to off. See Value Tips, for details.

--nw
Do not use the X window interface. Start the inferior debugger on the local host.
--perl
Run Perl as inferior debugger.

Giving this option is equivalent to setting the DDD debugger resource to perl. See Customizing Debugger Interaction, for details.

--pydb
Run PYDB as inferior debugger.

Giving this option is equivalent to setting the DDD debugger resource to pydb. See Customizing Debugger Interaction, for details.

--panned-graph-editor
Use an Athena panner to scroll the data window. Most people prefer panners on scroll bars, since panners allow two-dimensional scrolling. However, the panner is off by default, since some Motif implementations do not work well with Athena widgets. See Customizing Displays, for details; see also --scrolled-graph-editor, below.

Giving this option is equivalent to setting the DDD pannedGraphEditor resource to on. See Customizing Displays, for details.

--play-log log-file
Recapitulate a previous DDD session.
ddd --play-log log-file

invokes DDD as inferior debugger, simulating the inferior debugger given in log-file (see below). This is useful for debugging DDD.

Giving this option is equivalent to setting the DDD playLog resource to on. See Customizing Debugger Interaction, for details.

--PLAY log-file
Simulate an inferior debugger. log-file is a $HOME/.ddd/log file as generated by some previous DDD session (see Logging). When a command is entered, scan log-file for this command and re-issue the logged reply; if the command is not found, do nothing. This is used by the --play option.
--rhost hostname
--rhost username@hostname
Run the inferior debugger interactively on the remote host hostname. If username is given and the --login option is not used, use username as remote user name. See Remote Debugger, for details.

Giving this option is equivalent to setting the DDD debuggerRHost resource to hostname. See Remote Debugger, for details.

--scrolled-graph-editor
Use Motif scroll bars to scroll the data window. This is the default in most DDD configurations. See Customizing Displays, for details; see also --panned-graph-editor, above.

Giving this option is equivalent to setting the DDD pannedGraphEditor resource to off. See Customizing Displays, for details.

--separate-windows
--separate
Separate the console, source and data windows. See also the --attach options, above.

Giving this option is equivalent to setting the DDD Separate resource class to off. See Window Layout, for details.

--session session
Load session upon start-up. See Resuming Sessions, for details.

Giving this option is equivalent to setting the DDD session resource to session. See Resuming Sessions, for details.

--source-window
Open the source window upon start-up.

Giving this option is equivalent to setting the DDD openSourceWindow resource to on. See Toggling Windows, for details.

--status-at-bottom
Place the status line at the bottom of the source window.

Giving this option is equivalent to setting the DDD statusAtBottom resource to on. See Window Layout, for details.

--status-at-top
Place the status line at the top of the source window.

Giving this option is equivalent to setting the DDD statusAtBottom resource to off. See Window Layout, for details.

--sync-debugger
Do not process X events while the debugger is busy. This may result in slightly better performance on single-processor systems.

Giving this option is equivalent to setting the DDD synchronousDebugger resource to on. See Customizing Debugger Interaction, for details.

--toolbars-at-bottom
Place the toolbars at the bottom of the respective window.

Giving this option is equivalent to setting the DDD toolbarsAtBottom resource to on. See Window Layout, for details.

--toolbars-at-top
Place the toolbars at the top of the respective window.

Giving this option is equivalent to setting the DDD toolbarsAtBottom resource to off. See Window Layout, for details.

--trace
Show the interaction between DDD and the inferior debugger on standard error. This is useful for debugging DDD. If --trace is not specified, this information is written into ~/.ddd/log (~ stands for your home directory), such that you can also do a post-mortem debugging. See Logging, for details about logging.

Giving this option is equivalent to setting the DDD trace resource to on. See Diagnostics, for details.

--tty
-t
Enable TTY interface, taking additional debugger commands from standard input and forwarding debugger output on standard output. Current positions are issued in a format readable for humans. By default, the debugger console is disabled.

Giving this option is equivalent to setting the DDD ttyMode resource to on. See TTY mode, for details.

--value-tips
Enable value tips.

Giving this option is equivalent to setting the DDD valueTips resource to on. See Value Tips, for details.

--version
-v
Print the DDD version on standard output and exit.

Giving this option is equivalent to setting the DDD showVersion resource to on. See Diagnostics, for details.

--vsl-library library
Load the VSL library library instead of using the DDD built-in library. This is useful for customizing display shapes and fonts.

Giving this option is equivalent to setting the DDD vslLibrary resource to library. See Customizing Display Appearance, for details.

--vsl-path path
Search VSL libraries in path (a colon-separated directory list).

Giving this option is equivalent to setting the DDD vslPath resource to path. See Customizing Display Appearance, for details.

--vsl-help
Show a list of further options controlling the VSL interpreter. These options are intended for debugging purposes and are subject to change without further notice.
--xdb
Run XDB as inferior debugger.

Giving this option is equivalent to setting the DDD debugger resource to xdb. See Customizing Debugger Interaction, for details.


Node:X Options, Next:, Previous:Options, Up:Invoking

X Options

DDD also understands the following X options. Note that these options only take a single dash -.

-display display
Use the X server display. By default, display is taken from the DISPLAY environment variable.
-geometry geometry
Specify the initial size and location of the debugger console.
-iconic
Start DDD iconified.
-name name
Give DDD the name name.
-selectionTimeout timeout
Specify the timeout in milliseconds within which two communicating applications must respond to one another for a selection request.
-title name
Give the DDD window the title name.
-xrm resourcestring
Specify a resource name and value to override any defaults.


Node:Inferior Debugger Options, Next:, Previous:X Options, Up:Invoking

Inferior Debugger Options

All options that DDD does not recognize are passed to the inferior debugger. This section lists the most useful options of the different inferior debuggers supported by DDD.


Node:GDB Options, Next:, Up:Inferior Debugger Options

GDB Options

These GDB options are useful when using DDD with GDB as inferior debugger. Single dashes - instead of double dashes -- may also be used.

-b baudrate
Set serial port baud rate used for remote debugging.
--cd dir
Change current directory to dir.
--command file
Execute GDB commands from file.
--core corefile
Analyze the core dump corefile.
--directory dir
-d dir
Add directory to the path to search for source files.
--exec execfile
Use execfile as the executable.
--mapped
Use mapped symbol files if supported on this system.
--nx
-n
Do not read .gdbinit file.
--readnow
Fully read symbol files on first access.
--se file
Use file as symbol file and executable file.
--symbols symfile
Read symbols from symfile.

See Invoking GDB, for further options that can be used with GDB.


Node:DBX and Ladebug Options, Next:, Previous:GDB Options, Up:Inferior Debugger Options

DBX and Ladebug Options

DBX variants differ widely in their options, so we cannot give a list here. Check out the dbx(1) and ladebug(1) manual pages.


Node:XDB Options, Next:, Previous:DBX and Ladebug Options, Up:Inferior Debugger Options

XDB Options

These XDB options are useful when using DDD with XDB as inferior debugger.

-d dir
Specify dir as an alternate directory where source files are located.
-P process-id
Specify the process ID of an existing process the user wants to debug.
-l library
Pre-load information about the shared library library. -l ALL means always pre-load shared library information.
-S num
Set the size of the string cache to num bytes (default is 1024, which is also the minimum).
-s
Enable debugging of shared libraries.

Further options can be found in the xdb(1) manual page.


Node:JDB Options, Next:, Previous:XDB Options, Up:Inferior Debugger Options

JDB Options

The following JDB options are useful when using DDD with JDB as inferior debugger.

-host hostname
host machine of interpreter to attach to
-password psswd
password of interpreter to attach to (from -debug)

These JDB options are forwarded to debuggee process:

-verbose
-v
Turn on verbose mode.
-debug
Enable remote Java debugging,
-noasyncgc
Don't allow asynchronous garbage collection.
-verbosegc
Print a message when garbage collection occurs.
-noclassgc
Disable class garbage collection.
-checksource
-cs
Check if source is newer when loading classes.
-ss number
Set the maximum native stack size for any thread.
-oss number
Set the maximum Java stack size for any thread.
-ms number
Set the initial Java heap size.
-mx number
Set the maximum Java heap size.
-Dname=value
Set the system property name to value.
-classpath path
List directories in which to look for classes. path is a list of directories separated by colons.
-prof
-prof:file
Output profiling data to ./java.prof. If file is given, write the data to ./file.
-verify
Verify all classes when read in.
-verifyremote
Verify classes read in over the network (default).
-noverify
Do not verify any class.
-dbgtrace
Print info for debugging JDB.

Further options can be found in the JDB documentation.


Node:PYDB Options, Next:, Previous:JDB Options, Up:Inferior Debugger Options

PYDB Options

For a list of useful PYDB options, check out the PYDB documentation.


Node:Perl Options, Previous:PYDB Options, Up:Inferior Debugger Options

Perl Options

The most important Perl option to use with DDD is -w; it enables several important warnings. For further options, see the perlrun(1) manual page.


Node:Multiple Instances, Next:, Previous:Inferior Debugger Options, Up:Invoking

Multiple DDD Instances

If you have multiple DDD instances running, they share common preferences and history files. This means that changes applied to one instance may get lost when being overwritten by the other instance. DDD has two means to protect you against unwanted losses. The first means is an automatic reloading of changed options, controlled by the following resource (see Customizing):

checkOptions (class CheckOptions) Resource
Every n seconds, where n is the value of this resource, DDD checks whether the options file has changed. Default is 30, which means that every 30 seconds, DDD checks for the options file. Setting this resource to 0 disables checking for changed option files.

Normally, automatic reloading of options should already suffice. If you need stronger protection, DDD also provides a warning against multiple instances. This warning is disabled by default, If you want to be warned about multiple DDD invocations sharing the same preferences and history files, enable Edit => Preferences => Warn if Multiple DDD Instances are Running.

This setting is tied to the following resource (see Customizing):

warnIfLocked (class WarnIfLocked) Resource
Whether to warn if multiple DDD instances are running (on) or not (off, default).


Node:X Warnings, Previous:Multiple Instances, Up:Invoking

X warnings

If you are bothered by X warnings, you can suppress them by setting Edit => Preferences => General => Suppress X warnings.

This setting is tied to the following resource (see Customizing):

suppressWarnings (class SuppressWarnings) Resource
If on, X warnings are suppressed. This is sometimes useful for executables that were built on a machine with a different X or Motif configuration. By default, this is off.


Node:Quitting, Next:, Previous:Invoking, Up:Invocation

Quitting DDD

To exit DDD, select File => Exit. You may also type the quit command at the debugger prompt or press <Ctrl+Q>. GDB and XDB also accept the q command or an end-of-file character (usually <Ctrl+D>). Closing the last DDD window will also exit DDD.

An interrupt (<ESC> or Interrupt) does not exit from DDD, but rather terminates the action of any debugger command that is in progress and returns to the debugger command level. It is safe to type the interrupt character at any time because the debugger does not allow it to take effect until a time when it is safe.

In case an ordinary interrupt does not succeed, you can also use an abort (<Ctrl+\> or Abort), which sends a SIGABRT signal to the inferior debugger. Use this in emergencies only; the inferior debugger may be left inconsistent or even exit after a SIGABRT signal.

As a last resort (if DDD hangs, for example), you may also interrupt DDD itself using an interrupt signal (SIGINT). This can be done by typing the interrupt character (usually <Ctrl+C>) in the shell DDD was started from, or by using the UNIX kill command. An interrupt signal interrupts any DDD action; the inferior debugger is interrupted as well. Since this interrupt signal can result in internal inconsistencies, use this as a last resort in emergencies only; save your work as soon as possible and restart DDD.


Node:Sessions, Next:, Previous:Quitting, Up:Invocation

Persistent Sessions

If you want to interrupt your current DDD session, you can save the entire the entire DDD state as session on disk and resume later.


Node:Saving Sessions, Next:, Up:Sessions

Saving Sessions

To save a session, select File => Save Session As. You will be asked for a symbolic session name session.

If your program is running (see Running), or if you have opened a core file (see Opening Core Dumps), DDD can also include a core file in the session such that the debuggee data will be restored when re-opening it. To get a core file, DDD typically must kill the debuggee. This means that you cannot resume program execution after saving a session. Depending on your architecture, other options for getting a core file may also be available.

Including a core dump is necessary for restoring memory contents and the current execution position. To include a core dump, enable Include Core Dump.

PICS/ddd-save-session.jpg


After clicking on Save, the session is saved in ~/.ddd/sessions/session.

Here's a list of the items whose state is saved in a session:

After saving the current state as a session, the session becomes active. This means that DDD state will be saved as session defaults:

To make the current session inactive, open the default session named [None]. See Resuming Sessions, for details on opening sessions.


Node:Resuming Sessions, Next:, Previous:Saving Sessions, Up:Sessions

Resuming Sessions

To resume a previously saved session, select File => Open Session and choose a session name from the list. After clicking on Open, the entire DDD state will be restored from the given session.

The session named [None] is the default session which is active when starting DDD. To save options for default sessions, open the default session and save options. See Saving Options, for details.

PICS/ddd-open-session.jpg


If a the restored session includes a core dump, the program being debugged will be in the same state at the time the session was saved; in particular, you can examine the program data. However, you will not be able to resume program execution since the process and its environment (open files, resources, etc.) no longer exist. However, you can restart the program, re-using the restored breakpoints and data displays.

Opening sessions also restores command definitions, buttons, display shortcuts and the source tab width. This way, you can maintain a different set of definitions for each session.

You can also specify a session to open when starting DDD. To invoke DDD with a session session, use

ddd --session session

There is also a shortcut that opens the session session and invokes the inferior debugger on an executable named session (in case session cannot be opened):

ddd =session

There is no need to give further command-line options when restarting a session, as they will be overridden by the options saved in the session.

You can also use an X session manager such as xsm to save and restore DDD sessions.7 When being shut down by a session manager, DDD saves its state under the name specified by the session manager; resuming the X session makes DDD reload its saved state.


Node:Deleting Sessions, Next:, Previous:Resuming Sessions, Up:Sessions

Deleting Sessions

To delete sessions that are no longer needed, select File => Open Session or File => Save Session. Select the sessions you want to delete and click on Delete.

The default session [None] cannot be deleted.


Node:Customizing Sessions, Previous:Deleting Sessions, Up:Sessions

Customizing Sessions

You can change the place where DDD saves its sessions by setting the environment variable DDD_SESSIONS to the name of a directory. Default is ~/.ddd/sessions/.

Where applicable, DDD supports a gcore command to obtain core files of the running program. You can enter its path via Edit => Preferences => Helpers => Get Core File. Leave the value empty if you have no gcore or similar command.

This setting is tied to the following resource (see Customizing):

getCoreCommand (class GetCoreCommand) Resource
A command to get a core dump of a running process (typically, gcore) @FILE@ is replaced by the base name of the file to create; @PID@ is replaced by the process id. The output must be written to @FILE@.@PID@.

Leave the value empty if you have no gcore or similar command.


Node:Remote Debugging, Next:, Previous:Sessions, Up:Invocation

Remote Debugging

You can have each of DDD, the inferior debugger, and the debugged program run on different machines.


Node:Remote Host, Next:, Up:Remote Debugging

Running DDD on a Remote Host

You can run DDD on a remote host, using your current host as X display. On the remote host, invoke DDD as

ddd -display display

where display is the name of the X server to connect to (for instance, hostname:0.0, where hostname is your host).

Instead of specifying -display display, you can also set the DISPLAY environment variable to display.


Node:Remote Debugger, Next:, Previous:Remote Host, Up:Remote Debugging

Using DDD with a Remote Inferior Debugger

In order to run the inferior debugger on a remote host, you need remsh (called rsh on BSD systems) access on the remote host.

To run the debugger on a remote host hostname, invoke DDD as

ddd --host hostname remote-program

If your remote username differs from the local username, use

ddd --host hostname --login username remote-program

or

ddd --host username@hostname remote-program

instead.

There are a few caveats in remote mode:

See Customizing Remote Debugging, for customizing remote mode.


Node:Customizing Remote Debugging, Up:Remote Debugger

Customizing Remote Debugging

When having the inferior debugger run on a remote host (see Remote Debugging), all commands to access the inferior debugger as well as its files must be run remotely. This is controlled by the following resources (see Customizing):

rshCommand (class RshCommand) Resource
The remote shell command to invoke TTY-based commands on remote hosts. Usually, remsh, rsh, ssh, or on.

listCoreCommand (class listCoreCommand) Resource
The command to list all core files on the remote host. The string @MASK@ is replaced by a file filter. The default setting is:
Ddd*listCoreCommand: \
file @MASK@ | grep '.*:.*core.*' | cut -d: -f1

listDirCommand (class listDirCommand) Resource
The command to list all directories on the remote host. The string @MASK@ is replaced by a file filter. The default setting is:
Ddd*listDirCommand: \
file @MASK@ | grep '.*:.*directory.*' | cut -d: -f1

listExecCommand (class listExecCommand) Resource
The command to list all executable files on the remote host. The string @MASK@ is replaced by a file filter. The default setting is:
Ddd*listExecCommand: \
file @MASK@ | grep '.*:.*exec.*' \
  | grep -v  '.*:.*script.*' \
  | cut -d: -f1 | grep -v '.*\.o$'

listSourceCommand (class listSourceCommand) Resource
The command to list all source files on the remote host. The string @MASK@ is replaced by a file filter. The default setting is:
Ddd*listSourceCommand: \
file @MASK@ | grep '.*:.*text.*' | cut -d: -f1


Node:Remote Program, Previous:Remote Debugger, Up:Remote Debugging

Debugging a Remote Program

The GDB debugger allows you to run the debugged program on a remote machine (called remote target), while GDB runs on the local machine.

See Remote, for details. Basically, the following steps are required:

The local .gdbinit file is useful for setting up directory search paths, etc.

Of course, you can also combine DDD remote mode and GDB remote mode, running DDD, GDB, and the debugged program each on a different machine.


Node:Customizing Debugger Interaction, Previous:Remote Debugging, Up:Invocation

Customizing Interaction with the Inferior Debugger

These settings control the interaction of DDD with its inferior debugger.


Node:Debugger Invocation, Next:, Up:Customizing Debugger Interaction

Invoking an Inferior Debugger

To choose the default inferior debugger, select Edit => Preferences => Startup => Debugger Type. You can

The following DDD resources control the invocation of the inferior debugger (see Customizing).

autoDebugger (class AutoDebugger) Resource
If this is on (default), DDD will attempt to determine the debugger type from its arguments, possibly overriding the debugger resource (see below). If this is off, DDD will invoke the debugger specified by the debugger resource regardless of DDD arguments.

debugger (class Debugger) Resource
The type of the inferior debugger to invoke (gdb, dbx, ladebug, xdb, jdb, pydb, or perl).

This resource is usually set through the --gdb, --dbx, --ladebug, --xdb, --jdb, --pydb, and --perl, options; See Options, for details.

debuggerCommand (class DebuggerCommand) Resource
The name under which the inferior debugger is to be invoked. If this string is empty (default), the debugger type (debugger resource) is used.

This resource is usually set through the --debugger option; See Options, for details.


Node:Debugger Initialization, Next:, Previous:Debugger Invocation, Up:Customizing Debugger Interaction

Initializing the Inferior Debugger

DDD uses a number of resources to initialize the inferior debugger (see Customizing).


Node:GDB Initialization, Next:, Up:Debugger Initialization

GDB Initialization

gdbInitCommands (class InitCommands) Resource
This string contains a list of newline-separated commands that are initially sent to GDB. As a side-effect, all settings specified in this resource are considered fixed and cannot be changed through the GDB settings panel, unless preceded by white space. By default, the gdbInitCommands resource contains some settings vital to DDD:
  Ddd*gdbInitCommands: \
  set height 0\n\
  set width 0\n\
   set verbose off\n\
  set prompt (gdb) \n

While the set height, set width, and set prompt settings are fixed, the set verbose settings can be changed through the GDB settings panel (although being reset upon each new DDD invocation).

Do not use this resource to customize GDB; instead, use a personal ~/.gdbinit file. See your GDB documentation for details.

gdbSettings (class Settings) Resource
This string contains a list of newline-separated commands that are also initially sent to GDB. Its default value is
  Ddd*gdbSettings: \
  set print asm-demangle on\n

This resource is used to save and restore the debugger settings.

sourceInitCommands (class SourceInitCommands) Resource
If on (default), DDD writes all GDB initialization commands into a temporary file and makes GDB read this file, rather than sending each initialization command separately. This results in faster startup (especially if you have several user-defined commands). If off, DDD makes GDB process each command separately.


Node:DBX Initialization, Next:, Previous:GDB Initialization, Up:Debugger Initialization

DBX Initialization

dbxInitCommands (class InitCommands) Resource
This string contains a list of newline-separated commands that are initially sent to DBX. By default, it is empty.

Do not use this resource to customize DBX; instead, use a personal ~/.dbxinit or ~/.dbxrc file. See your DBX documentation for details.

dbxSettings (class Settings) Resource
This string contains a list of newline-separated commands that are also initially sent to DBX. By default, it is empty.


Node:XDB Initialization, Next:, Previous:DBX Initialization, Up:Debugger Initialization

XDB Initialization

xdbInitCommands (class InitCommands) Resource
This string contains a list of newline-separated commands that are initially sent to XDB. By default, it is empty.

Do not use this resource to customize DBX; instead, use a personal ~/.xdbrc file. See your XDB documentation for details.

xdbSettings (class Settings) Resource
This string contains a list of newline-separated commands that are also initially sent to XDB. By default, it is empty.


Node:JDB Initialization, Next:, Previous:XDB Initialization, Up:Debugger Initialization

JDB Initialization

jdbInitCommands (class InitCommands) Resource
This string contains a list of newline-separated commands that are initially sent to JDB. This resource may be used to customize JDB. By default, it is empty.

jdbSettings (class Settings) Resource
This string contains a list of newline-separated commands that are also initially sent to JDB. By default, it is empty.

This resource is used by DDD to save and restore JDB settings.


Node:PYDB Initialization, Next:, Previous:JDB Initialization, Up:Debugger Initialization

PYDB Initialization

pydbInitCommands (class InitCommands) Resource
This string contains a list of newline-separated commands that are initially sent to PYDB. By default, it is empty.

This resource may be used to customize PYDB.

pydbSettings (class Settings) Resource
This string contains a list of newline-separated commands that are also initially sent to PYDB. By default, it is empty.

This resource is used by DDD to save and restore PYDB settings.


Node:Perl Initialization, Next:, Previous:PYDB Initialization, Up:Debugger Initialization

Perl Initialization

perlInitCommands (class InitCommands) Resource
This string contains a list of newline-separated commands that are initially sent to the Perl debugger. By default, it is empty.

This resource may be used to customize the Perl debugger.

perlSettings (class Settings) Resource
This string contains a list of newline-separated commands that are also initially sent to the Perl debugger. By default, it is empty.

This resource is used by DDD to save and restore Perl debugger settings.


Node:Opening the Selection, Previous:Perl Initialization, Up:Debugger Initialization

Opening the Selection

openSelection (class OpenSelection) Resource
If this is on, DDD invoked without argument checks whether the current selection or clipboard contains the file name or URL of an executable program. If this is so, DDD will automatically open this program for debugging. If this resource is off (default), DDD invoked without arguments will always start without a debugged program.


Node:Debugger Communication, Previous:Debugger Initialization, Up:Customizing Debugger Interaction

Communication with the Inferior Debugger

The following resources control the communication with the inferior debugger.

blockTTYInput (class BlockTTYInput) Resource
Whether DDD should block when reading data from the inferior debugger via the pseudo-tty interface. Most UNIX systems except GNU/Linux require this; set it to on. On GNU/Linux, set it to off. The value auto (default) will always select the "best" choice (that is, the best choice known to the DDD developers).

displayTimeout (class DisplayTimeout) Resource
The time (in ms) to wait for the inferior debugger to finish a partial display information. Default is 2000.

positionTimeout (class PositionTimeout) Resource
The time (in ms) to wait for the inferior debugger to finish a partial position information. Default is 500.

questionTimeout (class QuestionTimeout) Resource
The time (in seconds) to wait for the inferior debugger to reply. Default is 10.

synchronousDebugger (class SynchronousDebugger) Resource
If on, X events are not processed while the debugger is busy. This may result in slightly better performance on single-processor systems. See Options, for the --sync-debugger option.

terminateOnEOF (class TerminateOnEOF) Resource
If on, DDD terminates the inferior debugger when DDD detects an EOF condition (that is, as soon as the inferior debugger closes its output channel). This was the default behavior in DDD 2.x and earlier. If off (default), DDD takes no special action.

useTTYCommand (class UseTTYCommand) Resource
If on, use the GDB tty command for redirecting input/output to the separate execution window. If off, use explicit redirection through shell redirection operators < and >. The default is off (explicit redirection), since on some systems, the tty command does not work properly on some GDB versions.


Node:Windows, Next:, Previous:Invocation, Up:Top

The DDD Windows

DDD is composed of three main windows. From top to bottom, we have:


PICS/ddd-all.jpg


Besides these three main windows, there are some other optional windows:


Node:Menu Bar, Next:, Up:Windows

The Menu Bar

The DDD Menu Bar gives you access to all DDD functions.

File
Perform file-related operations such as selecting programs, processes, and sessions, printing graphs, recompiling, as well as exiting DDD.
Edit
Perform standard editing operations, such as cutting, copying, pasting, and killing selected text. Also allows editing DDD options and preferences.
View
Allows accessing the individual DDD windows.
Program
Perform operations related to the program being debugged, such as starting and stopping the program.
Commands
Perform operations related to DDD commands, such as accessing the command history or defining new commands.
Status
Examine the program status, such as the stack traces, registers, or threads.
Source
Perform source-related operations such as looking up items or editing breakpoints.
Data
Perform data-related operations such as editing displays or layouting the display graph.
Maintenance
Perform operations that are useful for debugging DDD. By default, this menu is disabled.
Help
Give help on DDD usage.

There are two ways of selecting an item from a pull-down menu: