Skip to content

Commit

Permalink
fix ci
Browse files Browse the repository at this point in the history
  • Loading branch information
yunwei37 committed Nov 20, 2023
1 parent c52a8e7 commit 508dde3
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ jobs:
syscall_trace: false
expected_str: "malloc calls: "
- path: minimal
executable: ./malloc
executable: ./uprobe
victim: ./victim
syscall_trace: false
expected_str: "malloc calls: "
expected_str: "target_func called."
- path: opensnoop
executable: ./opensnoop
victim: ./victim
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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,
Expand All @@ -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.
13 changes: 13 additions & 0 deletions example/minimal/syscall.bpf.c
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";
73 changes: 73 additions & 0 deletions example/minimal/syscall.c
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;
}

0 comments on commit 508dde3

Please sign in to comment.