-
-
Notifications
You must be signed in to change notification settings - Fork 84
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
4 changed files
with
92 additions
and
6 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
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 |
---|---|---|
|
@@ -119,7 +119,7 @@ More bcc/libbpf-tools examples can be found in [example/libbpf-tools](https://gi | |
|
||
You can also run bpftime with `bpftrace`, we've test it on [this commit](https://github.com/iovisor/bpftrace/commit/75aca47dd8e1d642ff31c9d3ce330e0c616e5b96). More details about how to run bpftrace in usespace, can be found in [example/bpftrace](https://github.com/eunomia-bpf/bpftime/tree/master/example/bpftrace). | ||
|
||
> ⚠️ **Note**: `bpftime` is actively under development, and it's not yet recommended for production use. See our [roadmap](#roadmap) for details. We'd love to hear your feedback and suggestions! Please feel free to open an issue or [Contact us](#contact). | ||
> ⚠️ **Note**: `bpftime` is actively under development, and it's not yet recommended for production use. See our [roadmap](#roadmap) for details. We'd love to hear your feedback and suggestions! Please feel free to open an issue or [Contact us](#contact-and-citations). | ||
## In-Depth | ||
|
||
|
@@ -213,10 +213,10 @@ This project is licensed under the MIT License. | |
|
||
## Contact and citations | ||
|
||
Have any questions or suggestions on future development? Free free to open an issue or contact | ||
Have any questions or suggestions on future development? Free free to open an issue or contact | ||
<[email protected]> ! | ||
|
||
Our arxiv preprint: https://arxiv.org/abs/2311.07923 | ||
Our arxiv preprint: <https://arxiv.org/abs/2311.07923> | ||
|
||
```txt | ||
@misc{zheng2023bpftime, | ||
|
@@ -233,5 +233,5 @@ Our arxiv preprint: https://arxiv.org/abs/2311.07923 | |
|
||
eunomia-bpf community is sponsored by [PLCT Lab](https://plctlab.github.io/) from [ISCAS](http://english.is.cas.cn/au/). | ||
|
||
Thanks for other sponsors and discussions help building this project: [Prof. Xiaozheng lai](https://www2.scut.edu.cn/cs/2017/0129/c22285a327654/page.htm) from SCUT, [Prof lijun chen](http://www.xiyou.edu.cn/info/2394/67845.htm) from XUPT, | ||
Thanks for other sponsors and discussions help building this project: [Prof. Xiaozheng lai](https://www2.scut.edu.cn/cs/2017/0129/c22285a327654/page.htm) from SCUT, [Prof lijun chen](http://www.xiyou.edu.cn/info/2394/67845.htm) from XUPT, | ||
[Prof. Qi Li](https://sites.google.com/site/qili2012/) from THU [NISL Lab](https://netsec.ccert.edu.cn/en/), and Linux eBPF maintainers. |
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,13 @@ | ||
#define BPF_NO_GLOBAL_DATA | ||
#include <vmlinux.h> | ||
#include <bpf/bpf_helpers.h> | ||
#include <bpf/bpf_tracing.h> | ||
|
||
SEC("uprobe/example/minimal/victim:target_func") | ||
int do_uprobe_trace(struct pt_regs *ctx) | ||
{ | ||
bpf_printk("target_func called.\n"); | ||
return 0; | ||
} | ||
|
||
char LICENSE[] SEC("license") = "GPL"; |
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,73 @@ | ||
// SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) | ||
/* Copyright (c) 2020 Facebook */ | ||
#include <signal.h> | ||
#include <stdio.h> | ||
#include <time.h> | ||
#include <stdint.h> | ||
#include <sys/resource.h> | ||
#include <bpf/libbpf.h> | ||
#include <bpf/bpf.h> | ||
#include <unistd.h> | ||
#include <stdlib.h> | ||
#include "uprobe.skel.h" | ||
#include <inttypes.h> | ||
|
||
#define warn(...) fprintf(stderr, __VA_ARGS__) | ||
|
||
static int libbpf_print_fn(enum libbpf_print_level level, const char *format, | ||
va_list args) | ||
{ | ||
return vfprintf(stderr, format, args); | ||
} | ||
|
||
static volatile bool exiting = false; | ||
|
||
static void sig_handler(int sig) | ||
{ | ||
exiting = true; | ||
} | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
struct uprobe_bpf *skel; | ||
int err; | ||
|
||
/* Set up libbpf errors and debug info callback */ | ||
libbpf_set_print(libbpf_print_fn); | ||
|
||
/* Cleaner handling of Ctrl-C */ | ||
signal(SIGINT, sig_handler); | ||
signal(SIGTERM, sig_handler); | ||
|
||
/* Load and verify BPF application */ | ||
skel = uprobe_bpf__open(); | ||
if (!skel) { | ||
fprintf(stderr, "Failed to open and load BPF skeleton\n"); | ||
return 1; | ||
} | ||
|
||
/* Load & verify BPF programs */ | ||
err = uprobe_bpf__load(skel); | ||
if (err) { | ||
fprintf(stderr, "Failed to load and verify BPF skeleton\n"); | ||
goto cleanup; | ||
} | ||
LIBBPF_OPTS(bpf_uprobe_opts, attach_opts, .func_name = "target_func", | ||
.retprobe = false, .attach_mode = PROBE_ATTACH_MODE_PERF); | ||
struct bpf_link *attach = bpf_program__attach_uprobe_opts( | ||
skel->progs.do_uprobe_trace, -1, "example/minimal/victim", 0, | ||
&attach_opts); | ||
if (!attach) { | ||
fprintf(stderr, "Failed to attach BPF skeleton\n"); | ||
err = -1; | ||
goto cleanup; | ||
} | ||
while (!exiting) { | ||
sleep(1); | ||
} | ||
cleanup: | ||
/* Clean up */ | ||
uprobe_bpf__destroy(skel); | ||
|
||
return err < 0 ? -err : 0; | ||
} |