本文最后更新于:2025年11月18日 晚上
BPFtrace动态跟踪工具 source install git clone bpftrace:
1 2 3 git clone https://github.com/iovisor/bpftrace.git git checkout -b v0.16.0 git submodule update --init --recursive
depends 查看宿主机已安装llvm版本:
结果输出如下:
1 ii libllvm11:amd64 1:11.0.1-2 amd64 Modular compiler and toolchain technologies, runtime library
下方安装llvm、clang时版本需要选定为11。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 sudo apt-get install -y \ bison \ cmake \ flex \ g++ \ git \ libelf-dev \ zlib1g-dev \ libfl-dev \ systemtap-sdt-dev \ binutils-dev \ libcereal-dev \ llvm-11-dev \ llvm-11-runtime \ libclang-11-dev \ clang-11 \ libpcap-dev \ libgtest-dev \ libgmock-dev \ asciidoctor
cmake build and install 1 2 3 4 5 6 7 cd bpftracemkdir buildcd build ../build-libs.sh cmake -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release .. make -j8 sudo make install
Environment variable configuration 1 echo "export PATH=$PATH :/usr/local/share/bpftrace/tools" >> /etc/profile
add /usr/local/share/bpftrace/tools to /etc/sudoers:
1 Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/share/bpftrace/tools"
Get started 1 2 sudo bpftrace -l sudo execsnoop.bt
More