参考
- 用clang编译Linux内核
- type_id=3 vlen != 0 on 5.4 LTS kernel
- libbpf-tools compile with core_fixes.bpf.h include got error
- bpf_btf_info has no member named 'name'
- https://github.com/tiann/eadb
- https://github.com/joelagnel/adeb/tree/master/
- 编译bpftrace的官方参考:
- 编译bcc的官方参考:
操作
- 参考eadb的readme,安装基本的环境
eadb prepare
这里安装一个基本的环境,后面自己编译bcc和bpftrace
- 如果希望把/data/目录也传给chroot环境:
卸载文件系统:
/data/eadb # ./device-umount-all
修改/data/eadb/run.common,增加:
然后再次eadb shell
登录即可。
- 安装clang-12
在编译bcc的libbpf-tools目录下的文件遇到built-in函数无效的报错,参考:
libbpf-tools compile with core_fixes.bpf.h include got error
./core_fixes.bpf.h:79:6: error: use of unknown builtin '__builtin_preserve_type_info' [-Wimplicit-function-declaration] if (bpf_core_type_exists(struct trace_event_raw_block_rq_completion___x)) ^ /root/ebpfcompiletest/libbpfgo-tools/bcc/libbpf-tools/.output/bpf/bpf_core_read.h:185:2: note: expanded from macro 'bpf_core_type_exists' __builtin_preserve_type_info(*(typeof(type) )0, BPF_TYPE_EXISTS)
需要升级clang的版本,升级到12即可,参考用clang编译Linux内核
./llvm.sh 12 all
- 在编译BCC时,如果编译tests遇到错误,可以在cmake的时候不编译tests
可以直接修改CMakeLists.txt:
- 下载和编译libbpf
make install_uapi_headers
- 编译bpftrace是提示:bpf_btf_info中的name成员找不到
参考:bpf_btf_info has no member named 'name'
在libbpf源码下执行:
make install_uapi_headers
- 运行bpftrace必现vlen错误
参考:type_id=3 vlen != 0 on 5.4 LTS kernel - 编译javac.bpf.c报错:
In file included from javagc.bpf.c:6: In file included from /data/bpf/bcc/libbpf-tools/.output/bpf/usdt.bpf.h:6: /usr/include/linux/errno.h:1:10: fatal error: 'asm/errno.h' file not found #include <asm/errno.h>
解决:
ln -sf /usr/include/aarch64-linux-gnu/asm/ /usr/include/asm