#debugging #emulator #gdb

udbserver

Provide Unicorn emulator with a debug server

1 unstable release

0.1.0 Apr 22, 2022

#157 in Emulators

MIT and GPL-2.0 licenses

48KB
1K SLoC

Rust 1K SLoC C 55 SLoC Go 42 SLoC // 0.1% comments Python 34 SLoC // 0.1% comments Java 26 SLoC

udbserver - Unicorn Emulator Debug Server

When you do emulation with Unicorn Engine, do you want to inspect the inner state during every step?

udbserver is a plugin for Unicorn, provides a debug server which implements GDB Remote Serial Protocol. You can connect it by a GDB client and do debugging as what you do on real program.

udbserver can be used as a crate by Rust program, but it also provides a C library and bindings for other languages. You can use it inside most Unicorn based projects!

Features

  • Registers
  • Memory
  • Single Step
  • Breakpoint
  • Watchpoint
  • Ctrl-C interrupt

Architectures support

  • i386
  • x86_64
  • ARM
  • AArch64
  • MIPS
  • PowerPC

Usage

API

udbserver only provides one API:

void udbserver(void* handle, uint16_t port, uint64_t start_addr);

The handle should be the raw handle of a Unicorn instance, port is the port to be listened, start_addr is the address which when Unicorn runs at the debug server will start and wait to be connected. if start_addr is provided with 0, the debug server will start instantly.

You can call this API inside a Unicorn hook, so you can integrate udbserver inside other Unicorn based project easily.

Used in Rust

You can use udbserver as a crate in Rust.

You can check the example on how to use it.

And you can try it by:

$ cargo run --example server

Then you can connect it with a GDB client.

Installation

udbserver provides a C-compatible set of library, header and pkg-config files, which help you to use it with other languages.

To build and install it you need to use cargo-c:

$ cargo install cargo-c
$ mkdir build
$ cargo cinstall --release --prefix=/usr --destdir build
$ sudo cp -a build/* /

Language bindings

After install the udbserver library, you can use udbserver in other languages.

You could check the examples on how to use udbserver by different languages:

Dependencies

~14MB
~315K SLoC