support vmlinux enum in printk handler

This commit is contained in:
2025-10-21 04:10:25 +05:30
parent c3f3d1e564
commit 190baf2674
2 changed files with 17 additions and 3 deletions

View File

@ -1,4 +1,7 @@
from pythonbpf import bpf, section, bpfglobal, compile_to_ir, compile
import logging
from pythonbpf import bpf, section, bpfglobal, compile_to_ir
from pythonbpf import compile # noqa: F401
from vmlinux import TASK_COMM_LEN # noqa: F401
from vmlinux import struct_trace_event_raw_sys_enter # noqa: F401
@ -17,7 +20,7 @@ from ctypes import c_int64
@section("tracepoint/syscalls/sys_enter_execve")
def hello_world(ctx: struct_trace_event_raw_sys_enter) -> c_int64:
a = 2 + TASK_COMM_LEN + TASK_COMM_LEN
print(f"Hello, World{a}")
print(f"Hello, World{TASK_COMM_LEN} and {a}")
return c_int64(TASK_COMM_LEN)
@ -27,5 +30,5 @@ def LICENSE() -> str:
return "GPL"
compile_to_ir("simple_struct_test.py", "simple_struct_test.ll")
compile_to_ir("simple_struct_test.py", "simple_struct_test.ll", loglevel=logging.DEBUG)
compile()