Skip to content

Commit

Permalink
libbcc-py: Fix libbpf types
Browse files Browse the repository at this point in the history
1ad2656 ("Add support_kfunc function to BPF object") added new functions
to libbcc-py but didn't set the restype and argstypes for those. It's causing
the `bpf_has_kernel_btf` function to return True in systems without support
for BTF, making tools like opensnoop, klockstat and any other using kfuncs
unusable in those systems.

The following Python script reproduces the problem:

```
from bcc import BPF
print(BPF.support_kfunc())
```

Signed-off-by: Mauricio Vásquez <[email protected]>
  • Loading branch information
mauriciovasquezbernal authored and yonghong-song committed May 21, 2020
1 parent 44e0f43 commit 7722fc5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/python/bcc/libbcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@
lib.bpf_detach_tracepoint.argtypes = [ct.c_char_p, ct.c_char_p]
lib.bpf_attach_raw_tracepoint.restype = ct.c_int
lib.bpf_attach_raw_tracepoint.argtypes = [ct.c_int, ct.c_char_p]
lib.bpf_attach_kfunc.restype = ct.c_int
lib.bpf_attach_kfunc.argtypes = [ct.c_int]
lib.bpf_has_kernel_btf.restype = ct.c_bool
lib.bpf_has_kernel_btf.argtypes = None
lib.bpf_open_perf_buffer.restype = ct.c_void_p
lib.bpf_open_perf_buffer.argtypes = [_RAW_CB_TYPE, _LOST_CB_TYPE, ct.py_object, ct.c_int, ct.c_int, ct.c_int]
lib.bpf_open_perf_event.restype = ct.c_int
Expand Down

0 comments on commit 7722fc5

Please sign in to comment.