Commit 6b8add07 authored by Brendan Gregg's avatar Brendan Gregg

use new num_open_kprobes() function

parent 0823f564
...@@ -81,9 +81,14 @@ if debug: ...@@ -81,9 +81,14 @@ if debug:
print(bpf_text) print(bpf_text)
b = BPF(text=bpf_text) b = BPF(text=bpf_text)
b.attach_kprobe(event_re=pattern, fn_name="trace_count") b.attach_kprobe(event_re=pattern, fn_name="trace_count")
matched = b.num_open_kprobes()
if matched == 0:
print("0 functions matched by \"%s\". Exiting." % args.pattern)
exit()
# header # header
print("Tracing... Ctrl-C to end.") print("Tracing %d functions for \"%s\"... Hit Ctrl-C to end." %
(matched, args.pattern))
# output # output
exiting = 0 if args.interval else 1 exiting = 0 if args.interval else 1
......
...@@ -121,9 +121,14 @@ def signal_ignore(signal, frame): ...@@ -121,9 +121,14 @@ def signal_ignore(signal, frame):
b = BPF(text=bpf_text) b = BPF(text=bpf_text)
b.attach_kprobe(event_re=pattern, fn_name="trace_func_entry") b.attach_kprobe(event_re=pattern, fn_name="trace_func_entry")
b.attach_kretprobe(event_re=pattern, fn_name="trace_func_return") b.attach_kretprobe(event_re=pattern, fn_name="trace_func_return")
matched = b.num_open_kprobes()
if matched == 0:
print("0 functions matched by \"%s\". Exiting." % args.pattern)
exit()
# header # header
print("Tracing %s... Hit Ctrl-C to end." % args.pattern) print("Tracing %d functions for \"%s\"... Hit Ctrl-C to end." %
(matched / 2, args.pattern))
# output # output
exiting = 0 if args.interval else 1 exiting = 0 if args.interval else 1
......
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