内容简介
安装命令
# go get golang.org/x/sys/unix # go get github.com/tobert/pcstat/pcstat
常见错误汇总
Exception: Failed to compile BPF text
could not open bpf map: Operation not permitted · Issue #281 · iovisor/bcc · GitHub
问题描述:
# memleak-bpfcc -a -p $(pidof remmina) /virtual/main.c:16:1: error: could not open bpf map: Cannot allocate memory is maps/hash map type enabled in your kernel? BPF_TABLE("hash", u64, struct alloc_info_t, allocs, 1000000); ^ /virtual/include/bcc/helpers.h:75:76: note: expanded from macro 'BPF_TABLE' #define BPF_TABLE(_table_type, _key_type, _leaf_type, _name, _max_entries) \ ^ /virtual/include/bcc/helpers.h:71:4: note: expanded from macro '\ BPF_F_TABLE' }; \ ^ /virtual/main.c:84:9: error: bpf_table allocs failed to open allocs.update(&address, &info); ^ /virtual/main.c:100:37: error: bpf_table allocs failed to open struct alloc_info_t *info = allocs.lookup(&addr); ^ 3 errors generated. Traceback (most recent call last): File "/usr/sbin/memleak-bpfcc", line 394, in <module> bpf = BPF(text=bpf_source) File "/usr/lib/python2.7/dist-packages/bcc/__init__.py", line 320, in __init__ raise Exception("Failed to compile BPF text") Exception: Failed to compile BPF text
解决办法:
ulimit -n 65535
Exception: Failed to attach BPF to uprobe
问题描述:
# /usr/share/bcc/tools/memleak -a -p 21642 Attaching to pid 21642, Ctrl+C to quit. perf_event_open(/sys/kernel/debug/tracing/events/uprobes/p__lib_x86_64_linux_gnu_libc_2_27_so_0x97070_21642_bcc_21882/id): Input/output error Traceback (most recent call last): File "/usr/share/bcc/tools/memleak", line 416, in <module> attach_probes("malloc") File "/usr/share/bcc/tools/memleak", line 406, in attach_probes pid=pid) File "/usr/lib/python2.7/dist-packages/bcc/__init__.py", line 989, in attach_uprobe raise Exception("Failed to attach BPF to uprobe") Exception: Failed to attach BPF to uprobe
解决办法:
在内核中,需要开启 CONFIG_UPROBE_EVENTS=y 选项