bcc: funccount: "cannot attach kprobe" warning instead of failing?
I just got this error:
$ ./funccount.py 'serio*'
cannot attach kprobe, Invalid argument
Failed to attach BPF program trace_count_38 to kprobe serio_raw_drv_exit
It looks like serio_raw_drv_exit is a function defined in the __exit section (module cleanup function), therefore attaching a kprobe fails (EINVAL).
Ideally, it’d be nice to blacklist all functions defined in the __exit section (somehow…), but more in general I was wondering if it’d be better to simply report a warning when a single kprobe can’t be attached with funccount and keep going, instead of failing.
In practice, something like this:
diff --git a/tools/funccount.py b/tools/funccount.py
index 69dd01c8cada..22ae31c3397b 100755
--- a/tools/funccount.py
+++ b/tools/funccount.py
@@ -88,9 +88,12 @@ class Probe(object):
def attach(self):
if self.type == b"p" and not self.library:
for index, function in self.trace_functions.items():
- self.bpf.attach_kprobe(
- event=function,
- fn_name="trace_count_%d" % index)
+ try:
+ self.bpf.attach_kprobe(
+ event=function,
+ fn_name="trace_count_%d" % index)
+ except Exception as e:
+ print("warning: " + str(e))
elif self.type == b"p" and self.library:
for index, function in self.trace_functions.items():
self.bpf.attach_uprobe(
What do you think?
About this issue
- Original URL
- State: open
- Created 6 years ago
- Reactions: 1
- Comments: 18 (9 by maintainers)
Great. Thanks. Just merged.
@yonghong-song here’s the PR #3772
I also just stumbled over this on Debian buster:
As a workaround, you use can use a regex and specifically exclude the failing kprobe with a negative look-ahead assertion:
I’m hitting this error on Linux 4.20 and bcc git master.