Change API of attach_kprobe to take a name argument
Per feedback on the attach_kprobe api, change up the arguments to remove
the load_func that typically preceeds the call. Instead, move this
inside the attach_kprobe implementation. Also, this makes attach_kprobe
need to be non-static. The same applies to attach_kretprobe.
Old:
fn = b.load_func("hello", BPF.KPROBE)
BPF.attach_kprobe(fn, "sys_clone")
New:
b.attach_kprobe(event="sys_clone", fn_name="hello")
Note that the kwarg style is not required, but I fixed up the current
usages to provide readability.
Signed-off-by: Brenden Blanco <bblanco@plumgrid.com>
diff --git a/tools/pidpersec b/tools/pidpersec
index bb022a5..32afaa1 100755
--- a/tools/pidpersec
+++ b/tools/pidpersec
@@ -18,7 +18,7 @@
# load BPF program
b = BPF(src_file = "pidpersec.c")
-BPF.attach_kprobe(b.load_func("do_count", BPF.KPROBE), "sched_fork")
+b.attach_kprobe(event="sched_fork", fn_name="do_count")
stats = b.get_table("stats")
# stat indexes