mirror of
https://github.com/eunomia-bpf/bpf-developer-tutorial.git
synced 2026-02-04 10:44:14 +08:00
add bootstrap files
This commit is contained in:
@@ -151,6 +151,22 @@ int handle_exit(struct trace_event_raw_sched_process_template* ctx)
|
||||
|
||||
最后,主函数调用bpf_ringbuf_poll来轮询BPF ringbuf,并在接收到新的事件时处理该事件。这个函数会持续运行,直到全局标志exiting被设置为true,此时它会清理资源并退出。
|
||||
|
||||
## Install Dependencies
|
||||
|
||||
You will need `clang`, `libelf` and `zlib` to build the examples, package names may vary across distros.
|
||||
|
||||
On Ubuntu/Debian, you need:
|
||||
```shell
|
||||
$ apt install clang libelf1 libelf-dev zlib1g-dev
|
||||
```
|
||||
|
||||
On CentOS/Fedora, you need:
|
||||
|
||||
```shell
|
||||
$ dnf install clang elfutils-libelf elfutils-libelf-devel zlib-devel
|
||||
```
|
||||
|
||||
## 编译运行
|
||||
|
||||
编译运行上述代码:
|
||||
|
||||
@@ -162,7 +178,6 @@ $ sudo ecli run package.json
|
||||
Runing eBPF program...
|
||||
```
|
||||
|
||||
|
||||
## 总结
|
||||
|
||||
这是一个使用BPF的C程序,用于跟踪进程的启动和退出事件,并显示有关这些事件的信息。它通过使用argp API来解析命令行参数,并使用BPF地图存储进程的信息,包括进程的PID和执行文件的文件名。程序还使用了SEC函数来附加BPF程序,以监视进程的执行和退出事件。最后,程序在终端中打印出启动和退出的进程信息。
|
||||
|
||||
Reference in New Issue
Block a user