GDB: An Open Source Debugger for Embedded Development
Back to Cygnus White Papers index

Interfaces to GDB
Unlike the compiler, assembler, and linker, GDB is an interactive tool. Therefore the question of user interface is important. Over the years, GDB has accumulated a number of different interfaces, each designed for a different audience.

Command-Line Interface
The most basic, and, for many users, the only interface is the command line. Although it almost seems dated to have one, many power users of GDB rely on the command line, and refuse to use anything else. As command interfaces go, GDB's is rather sophisticated, featuring extensive online help, tab-completion for both commands and arguments, in-place editing, and other useful features.

Perhaps the most attractive feature of the command-line interface is its ubiquity. A new college graduate, fresh from using GDB on Linux and Solaris at school, can go to Cisco and start using Cisco's version of GDB right away. Similarly, a senior engineer familiar with command-line GDB can switch from VxWorks to eCos debugging and still be productive.

Another valuable feature of the command line interface is that it can be used over networks. We know of many users who've had to debug using GDB located on a machine on the other side of the net, and usually the connection is too slow to use a fancy GUIif indeed the GUI is network-capable at all! The command-line interface is a savior in these situations.

Emacs Editor Interface
Emacs is the powerful text editor used by most workstation developers. For Emacs editor users, there is an Emacs mode that displays the source code and shows the movement of the program counter, but relies on normal GDB commands for everything else.

This works by running a command-line GDB as a subprocess, intercepting and directing GDB's output into program source and interaction buffers, and turning keystrokes into GDB commands.

Windowed (Graphical) Interfaces
Still, what most users want these days is a dedicated multi-window interface to the debugger. Multiple windows are good for debuggers for the same reason that they are good for desktops; the programmer needs to be able to get and synthesize several different kinds of data, and wants to be able to shift focus quickly, which is easy with overlapping windows.

Unfortunately, there is no universally accepted windowed interface to GDB. Instead, there are a number of options from which to choose.

Most GDB GUIs work as does the Emacs interface; they run a command-line GDB as a subprocess, issuing commands and parsing GDB's output. This is a weak point of the architecture; the reliability of this approach depends on the predictability of GDB's command set and output. In practice, though, this works better than one might expect. GDB GUIs that work in this way include xxgdb, mxgdb, DDD, kdbg, Code Crusader, and Wind River's Crosswind.

The following screenshot illustrates DDD, the most popular free GUI for GDB. DDD is short for Data Display Debugger, and its forte is indeed data display. The screenshot shows its ability to display box-and-arrow diagrams of linked data structures, and it can also display arrays of numerical data using 2D and 3D graphs. Note that the bottom of the screen reveals the prompt (gdb) which is the standard command-line GDB prompt.

Although the subprocess approach has its value, it is hard to make it maximally efficient and interactive. Cygnus has focussed on a different approach, and has built three successive GUIs that are actually compiled into GDB. The first, GDBtk, was written in 1994 and based on the scripting language and GUI toolkit tcl/tk. This version was released as part of Cygnus releases of GDB 4.14 through 4.16, although it didn't appear in FSF versions of GDB, since the FSF objected to the use of tcl/tk.

Later on, to provide an Windows™ version of GDB, Cygnus created WinGDB, a now-discontinued version of GDB that used an MFC-based interface, and was built using Microsoft tools. Although it worked, it had serious reliability and maintenance problems, and has since been retired.

In 1997, Cygnus undertook the task of overhauling GDBtk and making it available on both Windows and Unix, since by that time the tcl/tk port to Windows was working well. This version was designed to have a Windows-style look and feel, and to completely avoid the use of the command line for normal debugging tasks (a console window is available, just in case!). Internally, it is implemented using "[incr tcl]", which is an object-oriented extension to tcl. This version, dubbed Insight, has been much more successful than the first two Cygnus GUIs, and is shipped with all of Cygnus' releases, including boxed products. It has not yet been released to the net.

The following screenshot shows a current version of Insight. The source window is displaying mixed source and assembly code, which makes it possible to insert breakpoints at specific instructions within a C statement. The target selection dialog shows that it is possible to set up a working target connection without typing any commands, which most other interfaces to GDB don't support yet.

Prev Table of Contents Next
GDB Features   Internal Structure of GDB