support binary ops with vmlinux enums

This commit is contained in:
2025-10-21 03:41:21 +05:30
parent 5955db88cf
commit e7734629a5
3 changed files with 11 additions and 4 deletions

View File

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