Check if raw tracepoint in module is supported
authorFei Li <lifei.shirley@bytedance.com>
Sun, 20 Jun 2021 14:18:32 +0000 (22:18 +0800)
committeryonghong-song <ys114321@gmail.com>
Sun, 11 Jul 2021 23:25:04 +0000 (16:25 -0700)
Actually there are two stages to fully support raw tracepoint: the
first stage is only for in-kernel functions, and the second stage is
for kernel modules. For the latter stage, the corresponding kernel
commit is a38d1107, and it is merged since v5.0.

Signed-off-by: Fei Li <lifei.shirley@bytedance.com>
src/python/bcc/__init__.py

index 96c3dd6b351f8fbe6dfaebbc4296f988342cf938..ab80f81e2f98d7bebf42c85f24cfe008a7ca945e 100644 (file)
@@ -1123,6 +1123,18 @@ class BPF(object):
             return True
         return False
 
+    @staticmethod
+    def support_raw_tracepoint_in_module():
+        # kernel symbol "bpf_trace_modules" indicates raw tp support in modules, ref: kernel commit a38d1107
+        kallsyms = "/proc/kallsyms"
+        with open(kallsyms) as syms:
+            for line in syms:
+                (_, _, name) = line.rstrip().split(" ", 2)
+                name = name.split("\t")[0]
+                if name == "bpf_trace_modules":
+                    return True
+            return False
+
     def detach_tracepoint(self, tp=b""):
         """detach_tracepoint(tp="")