mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2025-12-31 21:06:25 +00:00
support vmlinux enum in printk handler
This commit is contained in:
@ -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()
|
||||
|
||||
Reference in New Issue
Block a user