diff --git a/examples/struct_and_perf.py b/examples/struct_and_perf.py index ed74258..abdb7f0 100644 --- a/examples/struct_and_perf.py +++ b/examples/struct_and_perf.py @@ -23,8 +23,6 @@ def events() -> PerfEventArray: @section("tracepoint/syscalls/sys_enter_clone") def hello(ctx: c_void_p) -> c_int32: dataobj = data_t() - ts = ktime() - process_id = pid() strobj = "hellohellohello" dataobj.pid = pid() dataobj.ts = ktime() diff --git a/examples/sys_sync.py b/examples/sys_sync.py index 953cb11..f8cf45b 100644 --- a/examples/sys_sync.py +++ b/examples/sys_sync.py @@ -1,5 +1,5 @@ from pythonbpf import bpf, map, section, bpfglobal, compile -from pythonbpf.helpers import ktime +from pythonbpf.helper.helpers import ktime from pythonbpf.maps import HashMap from ctypes import c_void_p, c_int64, c_uint64 @@ -10,6 +10,7 @@ from ctypes import c_void_p, c_int64, c_uint64 # 3. Run the program with sudo: sudo tools/check.sh run examples/sys_sync.o # 4. Start a Python repl and `import os` and then keep entering `os.sync()` to see reponses. + @bpf @map def last() -> HashMap: diff --git a/pythonbpf/expr_pass.py b/pythonbpf/expr_pass.py index db3ffbb..1c497be 100644 --- a/pythonbpf/expr_pass.py +++ b/pythonbpf/expr_pass.py @@ -23,7 +23,7 @@ def eval_expr(func, module, builder, expr, local_sym_tab, map_sym_tab, structs_s return None elif isinstance(expr, ast.Call): # delayed import to avoid circular dependency - from .bpf_helper_handler import helper_func_list, handle_helper_call + from .helper.bpf_helper_handler import helper_func_list, handle_helper_call if isinstance(expr.func, ast.Name): # check deref diff --git a/pythonbpf/functions_pass.py b/pythonbpf/functions_pass.py index 0b99546..04e9c52 100644 --- a/pythonbpf/functions_pass.py +++ b/pythonbpf/functions_pass.py @@ -2,7 +2,7 @@ from llvmlite import ir import ast -from .bpf_helper_handler import helper_func_list, handle_helper_call +from .helper.bpf_helper_handler import helper_func_list, handle_helper_call from .type_deducer import ctypes_to_ir from .binary_ops import handle_binary_op from .expr_pass import eval_expr, handle_expr diff --git a/pythonbpf/bpf_helper_handler.py b/pythonbpf/helper/bpf_helper_handler.py similarity index 99% rename from pythonbpf/bpf_helper_handler.py rename to pythonbpf/helper/bpf_helper_handler.py index cfce892..fe8fbe0 100644 --- a/pythonbpf/bpf_helper_handler.py +++ b/pythonbpf/helper/bpf_helper_handler.py @@ -1,6 +1,6 @@ import ast from llvmlite import ir -from .expr_pass import eval_expr +from pythonbpf.expr_pass import eval_expr from enum import Enum diff --git a/pythonbpf/helpers.py b/pythonbpf/helper/helpers.py similarity index 100% rename from pythonbpf/helpers.py rename to pythonbpf/helper/helpers.py