Skip to content

Commit

Permalink
funccount: Bail early if there are no matching functions (iovisor#792)
Browse files Browse the repository at this point in the history
funccount now bails early with an error if there are no
functions matching the specified pattern (the same applies
to tracepoints and USDT probes). For example:

```
No functions matched by pattern ^sched:sched_fork$
```

Fixes iovisor#789.
  • Loading branch information
goldshtn authored and 4ast committed Oct 28, 2016
1 parent b0468d9 commit 8e6109b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tools/funccount.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,6 @@ def attach(self):
elif self.type == "u":
pass # Nothing to do -- attach already happened in `load`

if self.matched == 0:
raise Exception("No functions matched by pattern %s" %
self.pattern)

def _add_function(self, template, probe_name):
new_func = "trace_count_%d" % self.matched
text = template.replace("PROBE_FUNCTION", new_func)
Expand Down Expand Up @@ -199,6 +195,10 @@ def load(self):
if debug:
print(bpf_text)

if self.matched == 0:
raise Exception("No functions matched by pattern %s" %
self.pattern)

self.bpf = BPF(text=bpf_text,
usdt_contexts=[self.usdt] if self.usdt else [])
self.clear() # Initialize all array items to zero
Expand Down

0 comments on commit 8e6109b

Please sign in to comment.