从 bcc python 脚本生成可执行文件

Generate a executable from bcc python script

bcc 使用 python 编译 ebpf 程序,有什么方便的方法可以从这些 python 脚本生成可执行文件,以便我可以 运行 这些跟踪服务器上没有安装clang和llvm环境的程序?

TL;DR. 不,不使用密件抄送。不过,您可能想查看 BPF CO-RE


密件抄送有两个部分可以解决这个问题。首先,您需要使用 BPF 程序和映射编译目标文件,以便在您的目标系统上运行(与 Linux BPF 加载程序相同的内核 version/headers 和相同的约定)。其次,您需要 BCC 的用户空间组件来识别和使用该程序和地图。

密件抄送当前均未启用这些。我的fork has a (somewhat stale) branch where I implemented support for dumping an object file to disk with conventions that enable you to load it in the Linux kernel. This is probably incomplete for your purpose, as I was only trying to load the program in the kernel; I didn't care what happened afterward. There has also been some work to run BCC's tools on remote systems,但我不知道它现在是什么状态。

BPF CO-RE 正在努力解决您的问题。 BPF CO-RE 允许您开发可跨 Linux 版本移植的 BPF 跟踪程序。 因此您不需要使用 Linux 头文件进行编译目标系统,不再需要 LLVM/Clang。这项工作背后的团队最近在 the principles and inner workings of BPF CO-RE and how it would apply to BCC's tools.

上发布了两篇文章