Skip to content

Commit de733e9

Browse files
committed
Docs: improve descriptions
1 parent ce9f4de commit de733e9

File tree

4 files changed

+73
-27
lines changed

4 files changed

+73
-27
lines changed

README.md

+19-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# bpftime: Userspace eBPF runtime for fast Uprobe & Syscall hook
1+
# bpftime: Userspace eBPF runtime for fast Uprobe & Syscall Hook
22

3-
`bpftime`, a full-featured, high-performance eBPF runtime designed to operate in userspace. It's engineered to offer fast Uprobe and Syscall hook capabilities. Userspace uprobe can be **10x faster than kernel uprobe!**
3+
`bpftime`, a full-featured, high-performance eBPF runtime designed to operate in userspace. It offers fast Uprobe and Syscall hook capabilities: Userspace uprobe can be **10x faster than kernel uprobe!** and can programmatically **hook all syscalls of a process** safely and efficiently.
44

55
> ⚠️ **Note**: `bpftime` is actively under development. The API or design might change in upcoming releases, and it's not yet recommended for production use. See our [roadmap](#roadmap) for details.
66
@@ -41,10 +41,22 @@ continue malloc...
4141
malloc called from pid 250215
4242
```
4343

44-
You can also inject the userspace runtime library into a running process:
44+
You can also dynamically attach the eBPF program with a running process:
4545

4646
```console
47+
$ ./example/malloc/test & echo $! # The pid is 101771
48+
[1] 101771
49+
101771
50+
continue malloc...
51+
continue malloc...
52+
```
4753

54+
And attach to it:
55+
56+
```console
57+
$ sudo bpftime attach 101771 # You may need to run make install in root
58+
Inject: "/root/.bpftime/libbpftime-agent.so"
59+
Successfully injected. ID: 1
4860
```
4961

5062
You can see the output from original program:
@@ -57,11 +69,6 @@ $ bpftime load ./example/malloc/malloc
5769
pid=247322 malloc calls: 10
5870
```
5971

60-
Run the target program and dynamically attach the eBPF program into it:
61-
62-
```console
63-
```
64-
6572
Alternatively, you can also run our sample eBPF program directly in the kernel eBPF, to see the similar output:
6673

6774
```console
@@ -102,7 +109,10 @@ Left: kernel eBPF | Right: userspace bpftime
102109

103110
![How it works](documents/bpftime.png)
104111

105-
The inline hook implementation is based on frida.
112+
The hook implementation is based on binary rewriting and the underly technique is inspired by:
113+
114+
- Userspace function hook: [frida-gum](https://github.com/frida/frida-gum)
115+
- Syscall hooks: [zpoline: a system call hook mechanism based on binary rewriting](https://www.usenix.org/conference/atc23/presentation/yasukata)
106116

107117
see [documents/how-it-works.md](documents/how-it-works.md) for details.
108118

documents/build-and-test.md

+18-15
Original file line numberDiff line numberDiff line change
@@ -12,34 +12,37 @@ sudo apt install -y --no-install-recommends \
1212
git submodule update --init --recursive
1313
```
1414

15-
## Compilation
16-
17-
Build the complete runtime:
15+
### Build and install cli tool
1816

1917
```bash
20-
make build
18+
sudo apt-get install libelf-dev zlib1g-dev # Install dependencies
19+
make build && make install # Build and install the runtime
20+
cd tools/cli-rs && cargo build --release
21+
mkdir -p ~/.bpftime && cp ./target/release/bpftime ~/.bpftime
22+
export PATH=$PATH:~/.bpftime
2123
```
2224

23-
For a lightweight build without the runtime (only vm library and LLVM JIT):
25+
Then you can run cli:
2426

25-
```bash
26-
make build-vm # build the simple vm with a simple jit
27-
make build-llvm # build the vm with llvm jit
27+
```console
28+
$ bpftime
29+
Usage: bpftime [OPTIONS] <COMMAND>
30+
...
2831
```
2932

30-
### Build and install cli tool
33+
## Compilation
34+
35+
Build the complete runtime:
3136

3237
```bash
33-
sudo apt-get install libelf-dev zlib1g-dev # Install dependencies
34-
cd tools/cli-rs && cargo build --release
35-
mkdir ~/.bpftime && cp ./target/release/bpftime ~/.bpftime
36-
export PATH=$PATH:~/.bpftime
38+
make build
3739
```
3840

39-
### Build and install runtime
41+
For a lightweight build without the runtime (only vm library and LLVM JIT):
4042

4143
```bash
42-
make install # Install the runtime
44+
make build-vm # build the simple vm with a simple jit
45+
make build-llvm # build the vm with llvm jit
4346
```
4447

4548
## Testing

tools/cli/main.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ static libbpf_object_ptr open_and_attach_libbpf_object(const char *filename)
7474
return obj_ptr;
7575
}
7676

77-
void inject_agent(int target_pid, const char *agent_dynlib_path)
77+
int inject_agent(int target_pid, const char *agent_dynlib_path)
7878
{
7979
// check the args
8080
frida_init();
@@ -98,6 +98,7 @@ void inject_agent(int target_pid, const char *agent_dynlib_path)
9898
frida_injector_close_sync(injector, NULL, NULL);
9999
frida_unref(injector);
100100
frida_deinit();
101+
return 0;
101102
}
102103

103104
std::string get_lib_path(const char *library_name)

vm/README.md

+34-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
# bpftime vm
1+
# bpftime vm: userspace eBPF vm with JIT support
22

3-
the bpf vm and jit for eBPF, you can choose from llvm-jit and a simple-jit/interpreter based on ubpf.
3+
The bpf vm and jit for eBPF usersapce runtime.
4+
5+
you can choose from llvm-jit and a simple-jit/interpreter based on ubpf.
46

57
## LLVM jit for eBPF
68

@@ -10,3 +12,33 @@ see [llvm-jit/README.md](llvm-jit/README.md)
1012

1113
see [simple-jit/README.md](simple-jit/README.md)
1214

15+
## build
16+
17+
The JIT can be built as a standalone library and integrated into other projects.
18+
19+
In `vm` directory, run:
20+
21+
```sh
22+
make build
23+
```
24+
25+
## Example Usage
26+
27+
See [example/main.c](example/main.c) for how to use it.
28+
29+
## cli
30+
31+
A tool for loading and running eBPF programs.
32+
33+
```console
34+
$ bpftime-cli
35+
Usage: build/vm/cli/bpftime-cli <path to ebpf instructions> [path to memory for the ebpf program]
36+
```
37+
38+
## benchmark
39+
40+
see [github.com/eunomia-bpf/bpf-benchmark](https://github.com/eunomia-bpf/bpf-benchmark) for how we evaluate and details.
41+
42+
## Roadmap
43+
44+
- [ ] AOT support for LLVM JIT

0 commit comments

Comments
 (0)