Merge pull request #1 from varun-r-mallya/r41k0u-fix-syntax

Fix syntax - make more pythonic
This commit is contained in:
varunrmallya
2025-09-03 11:01:22 +05:30
committed by GitHub
3 changed files with 25 additions and 3 deletions

View File

@ -1,9 +1,11 @@
from pythonbpf.decorators import tracepoint
from pythonbpf.decorators import tracepoint, syscalls
from ctypes import c_void_p, c_int32
@tracepoint("syscalls:sys_enter_execve")
@tracepoint(syscalls.sys_enter_execve)
def trace_execve(ctx: c_void_p) -> c_int32:
print("execve called\n")
print("execve called")
return c_int32(0)
LICENSE = "GPL"

11
examples/hello_world.py Normal file
View File

@ -0,0 +1,11 @@
from pythonbpf.decorators import tracepoint, syscalls
from ctypes import c_void_p, c_int32
@tracepoint(syscalls.sys_clone)
def trace_clone(ctx: c_void_p) -> c_int32:
print("Hello, World!")
return c_int32(0)
LICENSE = "GPL"

View File

@ -1,3 +1,12 @@
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}"