From 45352512b45c04bbf7ede90a9c626a3f3aa7ac5f Mon Sep 17 00:00:00 2001 From: Fei Li Date: Sun, 20 Jun 2021 22:18:32 +0800 Subject: [PATCH] Check if raw tracepoint in module is supported 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 --- src/python/bcc/__init__.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/python/bcc/__init__.py b/src/python/bcc/__init__.py index 96c3dd6b351f..ab80f81e2f98 100644 --- a/src/python/bcc/__init__.py +++ b/src/python/bcc/__init__.py @@ -1123,6 +1123,18 @@ def support_raw_tracepoint(): 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="")