mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2025-12-31 21:06:25 +00:00
Comment out non string based decorator to decide later and also make
changes to decorator adding a "section"
This commit is contained in:
@ -1,11 +1,13 @@
|
|||||||
from pythonbpf.decorators import tracepoint, syscalls
|
from pythonbpf.decorators import section
|
||||||
|
# from pythonbpf.decorators import tracepoint, syscalls
|
||||||
from ctypes import c_void_p, c_int32
|
from ctypes import c_void_p, c_int32
|
||||||
|
|
||||||
#This is a test function
|
#This is a test function
|
||||||
def test_function():
|
def test_function():
|
||||||
print("test_function called")
|
print("test_function called")
|
||||||
|
|
||||||
@tracepoint(syscalls.sys_enter_execve)
|
# @tracepoint(syscalls.sys_enter_execve)
|
||||||
|
@section("tracepoint/syscalls/sys_enter_execve")
|
||||||
def trace_execve(ctx: c_void_p) -> c_int32:
|
def trace_execve(ctx: c_void_p) -> c_int32:
|
||||||
print("execve called")
|
print("execve called")
|
||||||
print("execve2 called")
|
print("execve2 called")
|
||||||
|
|||||||
@ -1,14 +1,21 @@
|
|||||||
from types import SimpleNamespace
|
def section(name: str):
|
||||||
|
|
||||||
syscalls = SimpleNamespace(
|
|
||||||
sys_enter_execve="syscalls:sys_enter_execve",
|
|
||||||
sys_exit_execve="syscalls:sys_exit_execve",
|
|
||||||
sys_clone="syscalls:sys_clone",
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def tracepoint(name: str):
|
|
||||||
def wrapper(fn):
|
def wrapper(fn):
|
||||||
fn._section = f"tracepoint/{name}"
|
fn._section = name
|
||||||
return fn
|
return fn
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
|
# from types import SimpleNamespace
|
||||||
|
|
||||||
|
# syscalls = SimpleNamespace(
|
||||||
|
# sys_enter_execve="syscalls:sys_enter_execve",
|
||||||
|
# sys_exit_execve="syscalls:sys_exit_execve",
|
||||||
|
# sys_clone="syscalls:sys_clone",
|
||||||
|
# )
|
||||||
|
|
||||||
|
|
||||||
|
# def tracepoint(name: str):
|
||||||
|
# def wrapper(fn):
|
||||||
|
# fn._section = f"tracepoint/{name}"
|
||||||
|
# fn._section = name
|
||||||
|
# return fn
|
||||||
|
# return wrapper
|
||||||
|
|||||||
@ -33,9 +33,10 @@ def globals_processing(tree, module: ir.Module):
|
|||||||
if (
|
if (
|
||||||
isinstance(dec, ast.Call)
|
isinstance(dec, ast.Call)
|
||||||
and isinstance(dec.func, ast.Name)
|
and isinstance(dec.func, ast.Name)
|
||||||
|
and dec.func.id == "section"
|
||||||
and len(dec.args) == 1
|
and len(dec.args) == 1
|
||||||
and isinstance(dec.args[0], ast.Attribute)
|
and isinstance(dec.args[0], ast.Constant)
|
||||||
and isinstance(dec.args[0].value, ast.Name)
|
and isinstance(dec.args[0].value, str)
|
||||||
):
|
):
|
||||||
collected.append(node.name)
|
collected.append(node.name)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user