GDB Front Ends: TUI and DDD Explained
Add a code window to plain GDB with TUI, or go fully graphical with DDD — free linux device drivers course
Command-line GDB is powerful but easy to get lost in once you’re stepping through more than a handful of lines. This lecture from our free linux device drivers course looks at two front ends that sit on top of the same GDB engine: the built-in Terminal User Interface (TUI), which works over any SSH session, and Data Display Debugger (DDD), a graphical front end for visually tracking pointers and data structures. Neither changes what GDB does — they change how much of it you can see at once.
Topics Covered
What You Will Learn
Prerequisites
You should already be comfortable with plain command-line GDB — breakpoints, step, next, continue — since TUI and DDD are layers on top of that same command set, not replacements for it.
GDB/MI: The Layer Underneath
GDB exposes a structured, machine-readable protocol called the GDB Machine Interface (GDB/MI). Every front end — TUI, DDD, IDE plugins — ultimately talks to GDB either directly through its command-line interpreter or through GDB/MI. Knowing this matters practically: if a graphical tool misbehaves, you can usually fall back to plain GDB and issue the identical commands by hand, because nothing the front end does is magic — it is just automating commands you could type yourself.
Front End Layering
Terminal User Interface (TUI)
TUI ships inside standard GDB — there is nothing extra to install on most distributions, and because it runs in plain text mode it works perfectly over an SSH session to a target board, which makes it the practical default for embedded work where a GUI display isn’t available.
Launch GDB with TUI enabled
$ gdb -tui ./ep_crashdemo
This splits the terminal into a source-code pane on top and the familiar command prompt below. You can also flip TUI on and off inside an already-running session:
(gdb) tui enable
(gdb) tui disable
A few TUI navigation keys are worth memorizing:
| Key | Effect |
|---|---|
| Ctrl-x, a | Toggle TUI on/off |
| Ctrl-x, 2 | Switch to a second window layout (e.g. source + registers) |
| Ctrl-l | Refresh the display if it becomes garbled |
| PgUp / PgDn | Scroll the source window |
Every command you already know — break, next, print, bt — still works exactly the same in TUI mode; the only difference is that the current line and any breakpoints stay visible as you step, instead of having to re-run list after every step.
Ctrl-l fixes most garbled screens without restarting GDB.
Data Display Debugger (DDD)
DDD is a separate, standalone graphical application that drives GDB underneath — it doesn’t replace GDB, it wraps it. Its standout feature is the data window: when you display a pointer, DDD draws it as a box, and double-clicking that pointer expands the structure it references into a new linked box with an arrow connecting them — genuinely useful when you’re chasing a corrupted linked list or tree and want to see the shape of the data rather than reading addresses off a text dump.
Point DDD at a cross toolchain’s GDB
$ ddd --debugger arm-none-linux-gnueabihf-gdb ./ep_crashdemo
Inside a session, the data window is driven by the same graph display command you could type into plain GDB — DDD is simply rendering the result visually:
(gdb) break ep_bump
(gdb) run
(gdb) graph display *n
(gdb) graph display n->next dependent on -1
The second line links the displayed node to the one before it, so as you step through a list-walking function DDD keeps redrawing the chain of nodes and their pointer connections automatically.
Choosing Between Them
| Situation | Best fit |
|---|---|
| Debugging over SSH to a headless board | TUI |
| Quick single-step session, no extra setup wanted | TUI |
| Chasing pointer/data-structure corruption visually | DDD |
| Local desktop with a display available | DDD |
| Scripting or building your own IDE integration | GDB/MI directly |
Common Mistakes
Best Practices
Default to TUI for remote embedded sessions since it needs zero extra setup. Reach for DDD only when you’re actively untangling a data structure and have a local display or X forwarding available — it adds real value there but is unnecessary overhead for a simple step-through session.
Summary
TUI and DDD are both front ends over the same GDB engine and the same GDB/MI protocol — TUI adds a live source window inside your terminal with zero setup, while DDD adds a graphical, clickable view of your data structures. Picking the right one for the situation, rather than always reaching for a GUI, is a habit worth building early in any free linux kernel development course track.
FAQ
Do I need to install anything extra to use TUI?
Usually not — TUI is built into standard GDB packages on most distributions; just add -tui to the command line.
Can I use DDD over SSH?
Only with X forwarding (ssh -X) or a local display; DDD is a graphical X11 application, unlike TUI.
Does TUI support register viewing?
Yes — Ctrl-x followed by 2 cycles through layouts that include a registers window alongside the source pane.
Is GDB/MI something I use directly?
Rarely by hand — it’s the protocol IDEs and DDD use internally, though you can script against it if you’re building custom tooling.
Which is better for kernel debugging with kgdb?
TUI is the common choice, since kgdb sessions typically run over a serial console rather than a graphical display.
Keep Building Your Debugging Skills
Continue this free linux device drivers course with the next lecture on debugging kernel code directly.
Browse the Course Join Free
2 Comments