python-bpfcc on Ubuntu 19.10 misses PerfEventArray due to an outdated bpfcc-tools
If you, like me, follow bcc Python Developer Tutorial, to sharpen bpf skills you might hit the same snag as I did when I was trying to implement a solution for lesson 8:
Traceback (most recent call last): File "_ctypes/callbacks.c", line 315, in 'calling callback function' File "/usr/lib/python2.7/dist-packages/bcc/table.py", line 572, in raw_cb_ callback(cpu, data, size) File "./sync_perf_output.py.py", line 69, in print_event event = b["events"].event(data) AttributeError: 'PerfEventArray' object has no attribute 'event'
Lesson 7 doesn’t work and fails with the same error.
Originally, one had to use ctypes to define the event data structure in Python but this PR changed that. So now perf event data structure in Python is auto-generated. The code for leasson 8 has been updated accordingly as well
However bpf which is shipped with Ubuntu 19.10 is outdated, version 0.8.0-4 versus 0.12.0 as of this writing, and the only way around is to keep using ctypes, or build the tool chain from source due to a known bug