Commit bf96d374 authored by Dr.Z's avatar Dr.Z

Python: fix detach_kprobe()

As open_kprobes contains not fd but pointer to struct perf_reader,
it should call lib.perf_reader_free() instead of os.close()
parent f701b520
......@@ -575,7 +575,7 @@ class BPF(object):
ev_name = "p_" + event.replace("+", "_").replace(".", "_")
if ev_name not in open_kprobes:
raise Exception("Kprobe %s is not attached" % event)
os.close(open_kprobes[ev_name])
lib.perf_reader_free(open_kprobes[ev_name])
desc = "-:kprobes/%s" % ev_name
res = lib.bpf_detach_kprobe(desc.encode("ascii"))
if res < 0:
......@@ -612,7 +612,7 @@ class BPF(object):
ev_name = "r_" + event.replace("+", "_").replace(".", "_")
if ev_name not in open_kprobes:
raise Exception("Kretprobe %s is not attached" % event)
os.close(open_kprobes[ev_name])
lib.perf_reader_free(open_kprobes[ev_name])
desc = "-:kprobes/%s" % ev_name
res = lib.bpf_detach_kprobe(desc.encode("ascii"))
if res < 0:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment