ugdb

ugdb is an unsegen based alternative TUI for gdb.

Screenshots

What's that? Oh, yes. Yes, you can totally use ugdb to debug ugdb debugging ugdb.

Building

ugdb is written in Rust and needs a working installation of cargo to build.

$ git clone https://github.com/ftilde/ugdb $ cd ugdb $ cargo build --release $ target/release/ugdb

Installation

If you're an Arch Linux user, then you can install ugdb from the arch user repository: yay -S ugdb

ugdb can also be installed from crates.io using cargo: cargo install ugdb

Usage

The command line interface is aimed to be mostly compatible with gdb: ``` $ ugdb --help ugdb 0.1.7 ftilde ftilde@protonmail.com An unsegen-based GDB frontend.

USAGE: ugdb [FLAGS] [OPTIONS] [program]...

FLAGS: -h, --help Prints help information --nh Do not execute commands from ~/.gdbinit. -n, --nx Do not execute commands from any .gdbinit initialization files. -q, --quiet "Quiet". Do not print the introductory and copyright messages. These messages are also suppressed in batch mode. -V, --version Prints version information

OPTIONS: -b Set the line speed (baud rate or bits per second) of any serial interface used by GDB for remote debugging. --cd Run GDB using directory as its working directory, instead of the current directory. -x, --command Execute GDB commands from file. -c, --core Use file file as a core dump to examine. --gdb Path to alternative gdb binary. [default: gdb] --log_dir Directory in which the log file will be stored [default: /tmp] -p, --pid Attach to process with given id. -d, --directory Add directory to the path to search for source files. -s, --symbols Read symbols from the given file.

ARGS: ... Path to program to debug (with arguments). ```

Some notable differences:

User interface

The interface consists of 4 containers between which the user can switch with vim-like controls: To enter selection mode, press ESC (indicated by orange separators). You can then navigate between containers using arrow keys or hjkl. Press Enter to enter insert-mode and interact with the selected container. Alternatively press the shortcut key for the specific container to directly enter it (see below) from selection mode.

GDB console

Interact using the standard gdb interface. Enter by pressing i.

Pager

View and browse source code or assembly around the current program location. Enter by pressing s.

Expression table

View and watch the (structured) results of gdb expressions (everything you can put after p in the console). Changes between steps are highlighted. Enter by pressing e.

Note: The viewer is somewhat broken for displaying structures with custom pretty-printers. A workaround would be to use variable objects, but that would not allow for evaluation of arbitrary expressions.

Terminal

The tty of the program to be debugged is automatically redirected to this virtual terminal. Enter by pressing t, or press T for locked mode. Locked mode can only be exited by pressing Esc twice in rapid succession. All other input is directly sent to the virtual terminal. However, for most application the regular insert mode is sufficient and can be left by a single press of Esc.

The virtual terminal does not yet properly implement all ansi functions, but it quite usable for a number of terminal applications.

IPC Interface

ugdb can be controlled remotely via a unix domain socket-based (undocumented, quite limited) IPC interface. In practice this means that you can install vim-ugdb and set breakpoints in ugdb from vim using the UGDBBreakpoint command.

FAQ

I get the error message "Cannot because gdb is busy"

Because we communicate with gdb in synchronous mode, some tasks that require cooperation of gdb (such as setting breakpoints and disassembling source files) cannot be done when gdb is busy, i.e., when the currently debugged program is running. In this case you have to interrupt execution by pressing Ctrl-C in the console first. It may be possible to lift this limitation in the future using the non-stop-mode, but there are no immediate plans for implementation.

Some notes on the status

This project mostly scratches my own itch -- successfully. I use it as my primary debugger. In that sense I consider this project as "done", but additional sub-itches may be sub-scratched in the future.

Licensing

ugdb is released under the MIT license.