use new num_open_kprobes() function
diff --git a/tools/funclatency b/tools/funclatency
index 7cfe6b0..7ed3e1b 100755
--- a/tools/funclatency
+++ b/tools/funclatency
@@ -121,9 +121,14 @@
b = BPF(text=bpf_text)
b.attach_kprobe(event_re=pattern, fn_name="trace_func_entry")
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
-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
exiting = 0 if args.interval else 1