bcc
BPF Compiler Collection (BCC)
本教程适用于Deepin 20.6、Deepin 20.7。
安装依赖
查看宿主机已安装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 sudo apt -y install bison \ build-essential \ cmake \ flex \ git \ libedit-dev \ llvm-11-dev \ libclang-11-dev \ python \ zlib1g-dev \ libelf-dev \ libfl-dev \ python3-distutils
源码下载
代码下载方式一(推荐使用)
1 2 wget https://github.com/iovisor/bcc/releases/download/v0.25.0/bcc-src-with-submodule.tar.gz tar -zxvf bcc-src-with-submodule.tar.gz
代码下载方式二
1 2 3 git clone https://github.com/iovisor/bcc.git git checkout -b v0.25.0 git submodule update --init --recursive
编译安装bcc
1 2 3 4 5 6 7 8 9 10 11 set -exmkdir bcc/buildcd bcc/build cmake .. make sudo make install cmake -DPYTHON_CMD=python3 .. pushd src/python/ make sudo make installpopd
Environment variable configuration
1 echo "export PATH=$PATH :/usr/share/bcc/tools" >> /etc/profile
1 2 sudo visudo后追加/usr/share/bcc/tools到secure_path后面 Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/usr/share/bcc/tools"
将python3设置为默认的python
直接执行这两个命令即可:
1 2 sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 100 sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 150
上述命令执行后,python3已被设置为默认的python。
切换到Python2,执行:
1 sudo update-alternatives --config python
Get started
1 trace-bpfcc -tKU -I 'sound/pci/hda/hda_codec.h' 'r::snd_hda_codec_configure(struct hda_codec *codec) "ret:%d", retval'
1 trace-bpfcc 'r::parse_user_pin_configs "ret:%d", retval'
More