Store kprobes with string keys, fix num_open_kprobes
Prior to this diff we used inconsistent types for keys in `open_kprobes`. The results from the regex match (`attach_kprobe(event_re=..)`) and the automatic `kprobe__` features were passed through `str.decode()`, yielding unicode keys, but specific matches (i.e. from `attach_kprobe(event=..)`) were stored with string keys passed down from the caller. Only probes under string keys were released in `cleanup_kprobes`, leaving attached probes on program exit. This diff makes all the keys regular strings. I erred on the side of using regular strings over `str.decode()`ing them because a) this data isn't passed outside of Python, b) it's more Python 3 compatible (there is no `.decode()` on a regular string object in Python 3 so such a change would ultimately need removing again). I also cleaned up a few other things: * removed the call to `awk` for getting probable functions * removed the `isinstance` checks when cleaning uprobes/tracepoints -- we should only have string keys in these dicts * made `num_open_kprobes` skip the perf_events buffers. People likely use this to check that the right number of probes have been placed so counting perf_events buffers doesn't make sense here
Showing
Please register or sign in to comment