-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
189 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
/target | ||
/build | ||
dist | ||
udbserver.egg-info | ||
Cargo.lock | ||
|
||
*.so | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,11 +2,24 @@ | |
name = "udbserver" | ||
version = "0.1.0" | ||
authors = ["Bet4 <[email protected]>"] | ||
edition = "2018" | ||
description = "Provide Unicorn emulator with a debug server" | ||
license = "MIT" | ||
edition = "2021" | ||
readme = "README.md" | ||
repository = "http://github.com/bet4it/udbserver" | ||
categories = ["emulators"] | ||
keywords = ["gdb", "debugging", "emulator"] | ||
|
||
[lib] | ||
crate-type = ["lib", "cdylib"] | ||
crate-type = ["lib"] | ||
|
||
[features] | ||
capi = [] | ||
|
||
[dependencies] | ||
gdbstub = "0.6" | ||
unicorn-engine = { git = "https://github.com/unicorn-engine/unicorn", branch = "dev", features = ["use_system_unicorn"] } | ||
unicorn-engine = { version = "2.0.0-rc7", features = ["use_system_unicorn"] } | ||
|
||
[package.metadata.capi.header] | ||
subdirectory = false | ||
generation = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 Bet4 | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# udbserver - Unicorn Emulator Debug Server | ||
|
||
When you do emulation with [Unicorn Engine](https://www.unicorn-engine.org/), 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](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. | ||
|
||
`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 | ||
|
||
* [x] Registers | ||
* [x] Memory | ||
* [x] Single Step | ||
* [x] Breakpoint | ||
* [x] Watchpoint | ||
* [ ] Ctrl-C interrupt | ||
|
||
## Architectures support | ||
|
||
* i386 | ||
* x86\_64 | ||
* ARM | ||
* AArch64 | ||
* MIPS | ||
* PowerPC | ||
|
||
# Usage | ||
|
||
## API | ||
|
||
`udbserver` only provides one API: | ||
|
||
```c | ||
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](examples/server.rs) on how to use it. | ||
And you can try it by: | ||
```sh | ||
$ 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](https://crates.io/crates/cargo-c): | ||
|
||
```sh | ||
$ 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: | ||
|
||
* [C](bindings/c) | ||
* [Go](bindings/go) | ||
* [Java](bindings/java) | ||
* [Python](bindings/python) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Use udbserver in C | ||
|
||
Check the [example](example.c) on how to use it. | ||
|
||
```sh | ||
$ gcc example.c -lunicorn -ludbserver -o example | ||
$ ./example | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Use udbserver in Go | ||
|
||
Check the [example](example/main.go) on how to use it. | ||
|
||
```sh | ||
$ go run ./example | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
module sample.com/udbserver/go | ||
module github.com/bet4it/udbserver/bindings/go | ||
|
||
go 1.16 | ||
go 1.18 | ||
|
||
require github.com/unicorn-engine/unicorn v0.0.0-20210516133931-668c43c94d5b // indirect | ||
require github.com/unicorn-engine/unicorn v0.0.0-20220417144812-185a6fec9eaa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
github.com/unicorn-engine/unicorn v0.0.0-20210516133931-668c43c94d5b h1:2EG7u1+P+rTXwIO37ciA9Te7WcpdJRzmb7jLo/c1vt8= | ||
github.com/unicorn-engine/unicorn v0.0.0-20210516133931-668c43c94d5b/go.mod h1:vm0xtY46O4X0t1J6Ob+syPhvL38XAAidXGXmTSlcMZM= | ||
github.com/unicorn-engine/unicorn v0.0.0-20220417144812-185a6fec9eaa h1:xm6nL6HwVdIwdXyOZBSAmBBhwJuiqd2ca2dwSyTMLoU= | ||
github.com/unicorn-engine/unicorn v0.0.0-20220417144812-185a6fec9eaa/go.mod h1:mcHBrigWSHlMZYol9QOFnK7sbltIt/OaKP5CQBZsC+4= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Use udbserver in Java | ||
|
||
Remember to [install Unicorn java bindings](https://github.com/unicorn-engine/unicorn/tree/master/bindings/java) before use it. | ||
|
||
Check the [example](Example.java) on how to use it. | ||
|
||
```sh | ||
$ sudo make install | ||
$ make example | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Use udbserver in Python | ||
|
||
Check the [example](example.py) on how to use it. | ||
|
||
```sh | ||
$ sudo python3 setup.py install | ||
$ python3 example.py | ||
``` | ||
|
||
If you encounter any errors when use it, try to compile and install the latest Unicorn library and Unicorn python bindings by yourself. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,27 @@ | ||
#!/usr/bin/env python3 | ||
# encoding: utf-8 | ||
|
||
from distutils.core import setup, Extension | ||
from setuptools import setup, Extension | ||
|
||
|
||
rust_module = Extension('udbserver', | ||
sources=['udbserver.c'], | ||
libraries=['udbserver'], | ||
include_dirs=['../../include'], | ||
library_dirs=['../../target/release'], | ||
) | ||
|
||
setup (name = 'udbserver', | ||
version = '0.1', | ||
author = "Bet4", | ||
description = """Udbserver""", | ||
author = 'Bet4', | ||
author_email = '[email protected]', | ||
description = 'Python bindings of udbserver', | ||
url = 'https://github.com/bet4it/udbserver', | ||
license='MIT License', | ||
classifiers=[ | ||
'Intended Audience :: Developers', | ||
'License :: OSI Approved :: MIT License', | ||
'Programming Language :: Python :: 3', | ||
'Topic :: Software Development :: Debuggers', | ||
], | ||
ext_modules = [rust_module], | ||
py_modules = [], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
mod arch; | ||
#[cfg(feature = "capi")] | ||
mod capi; | ||
|
||
mod arch; | ||
mod emu; | ||
mod reg; | ||
|
||
|