Skip to content

Commit e50094f

Browse files
committed
Release udbserver 0.1.0 version
1 parent c6354bb commit e50094f

File tree

20 files changed

+189
-47
lines changed

20 files changed

+189
-47
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
/target
2+
/build
3+
dist
4+
udbserver.egg-info
25
Cargo.lock
36

47
*.so

Cargo.toml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,24 @@
22
name = "udbserver"
33
version = "0.1.0"
44
authors = ["Bet4 <[email protected]>"]
5-
edition = "2018"
5+
description = "Provide Unicorn emulator with a debug server"
6+
license = "MIT"
7+
edition = "2021"
8+
readme = "README.md"
9+
repository = "http://github.com/bet4it/udbserver"
10+
categories = ["emulators"]
11+
keywords = ["gdb", "debugging", "emulator"]
612

713
[lib]
8-
crate-type = ["lib", "cdylib"]
14+
crate-type = ["lib"]
15+
16+
[features]
17+
capi = []
918

1019
[dependencies]
1120
gdbstub = "0.6"
12-
unicorn-engine = { git = "https://github.com/unicorn-engine/unicorn", branch = "dev", features = ["use_system_unicorn"] }
21+
unicorn-engine = { version = "2.0.0-rc7", features = ["use_system_unicorn"] }
22+
23+
[package.metadata.capi.header]
24+
subdirectory = false
25+
generation = false

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 Bet4
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

Lines changed: 0 additions & 16 deletions
This file was deleted.

README.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# udbserver - Unicorn Emulator Debug Server
2+
3+
When you do emulation with [Unicorn Engine](https://www.unicorn-engine.org/), do you want to inspect the inner state during every step?
4+
5+
`udbserver` is a plugin for Unicorn, provides a debug server which implements [GDB Remote Serial Protocol](https://sourceware.org/gdb/onlinedocs/gdb/Remote-Protocol.html). You can connect it by a `GDB` client and do debugging as what you do on real program.
6+
7+
`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!
8+
9+
## Features
10+
11+
* [x] Registers
12+
* [x] Memory
13+
* [x] Single Step
14+
* [x] Breakpoint
15+
* [x] Watchpoint
16+
* [ ] Ctrl-C interrupt
17+
18+
## Architectures support
19+
20+
* i386
21+
* x86\_64
22+
* ARM
23+
* AArch64
24+
* MIPS
25+
* PowerPC
26+
27+
# Usage
28+
29+
## API
30+
31+
`udbserver` only provides one API:
32+
33+
```c
34+
void udbserver(void* handle, uint16_t port, uint64_t start_addr);
35+
```
36+
37+
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.
38+
39+
You can call this API inside a Unicorn hook, so you can integrate `udbserver` inside other Unicorn based project easily.
40+
41+
## Used in Rust
42+
43+
You can use `udbserver` as a crate in `Rust`.
44+
45+
You can check the [example](examples/server.rs) on how to use it.
46+
47+
And you can try it by:
48+
49+
```sh
50+
$ cargo run --example server
51+
```
52+
53+
Then you can connect it with a `GDB` client.
54+
55+
## Installation
56+
57+
`udbserver` provides a C-compatible set of library, header and pkg-config files, which help you to use it with other languages.
58+
59+
To build and install it you need to use [cargo-c](https://crates.io/crates/cargo-c):
60+
61+
```sh
62+
$ cargo install cargo-c
63+
$ mkdir build
64+
$ cargo cinstall --release --prefix=/usr --destdir build
65+
$ sudo cp -a build/* /
66+
```
67+
68+
## Language bindings
69+
70+
After install the `udbserver` library, you can use `udbserver` in other languages.
71+
72+
You could check the examples on how to use `udbserver` by different languages:
73+
74+
* [C](bindings/c)
75+
* [Go](bindings/go)
76+
* [Java](bindings/java)
77+
* [Python](bindings/python)
File renamed without changes.

bindings/c/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Use udbserver in C
2+
3+
Check the [example](example.c) on how to use it.
4+
5+
```sh
6+
$ gcc example.c -lunicorn -ludbserver -o example
7+
$ ./example
8+
```

bindings/c/example.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include <unicorn/unicorn.h>
2-
#include "udbserver.h"
2+
#include <udbserver.h>
33

44
int ADDRESS = 0x1000;
55
const unsigned char ARM_CODE[64] = {0x0f, 0x00, 0xa0, 0xe1, 0x14, 0x00, 0x80, 0xe2, 0x00, 0x10, 0x90, 0xe5, 0x14, 0x10, 0x81, 0xe2, 0x00, 0x10, 0x80, 0xe5, 0xfb, 0xff, 0xff, 0xea};

bindings/go/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Use udbserver in Go
2+
3+
Check the [example](example/main.go) on how to use it.
4+
5+
```sh
6+
$ go run ./example
7+
```

bindings/go/example/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"fmt"
55

66
uc "github.com/unicorn-engine/unicorn/bindings/go/unicorn"
7-
udbserver "sample.com/udbserver/go/udbserver"
7+
udbserver "github.com/bet4it/udbserver/bindings/go/udbserver"
88
)
99

1010
func run() error {

0 commit comments

Comments
 (0)