From 9dbca410c2558fe0d9bf420096fd3fe90832b01a Mon Sep 17 00:00:00 2001 From: Pragyansh Chaturvedi Date: Thu, 2 Oct 2025 21:24:15 +0530 Subject: [PATCH 1/3] Remove calls from map in sys_sync --- examples/sys_sync.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/sys_sync.py b/examples/sys_sync.py index 3b65f46..0f56153 100644 --- a/examples/sys_sync.py +++ b/examples/sys_sync.py @@ -21,17 +21,17 @@ def last() -> HashMap: @section("tracepoint/syscalls/sys_enter_sync") def do_trace(ctx: c_void_p) -> c_int64: key = 0 - tsp = last().lookup(key) + tsp = last.lookup(key) if tsp: kt = ktime() delta = kt - tsp if delta < 1000000000: time_ms = delta // 1000000 print(f"sync called within last second, last {time_ms} ms ago") - last().delete(key) + last.delete(key) else: kt = ktime() - last().update(key, kt) + last.update(key, kt) return c_int64(0) From 6e4c3407802dd0f54aa5842ace8b4110a1917451 Mon Sep 17 00:00:00 2001 From: Pragyansh Chaturvedi Date: Thu, 2 Oct 2025 22:07:28 +0530 Subject: [PATCH 2/3] Allow non-call convention for maps --- pythonbpf/functions_pass.py | 19 +++++++++++++++++-- pythonbpf/maps/maps_pass.py | 1 + 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/pythonbpf/functions_pass.py b/pythonbpf/functions_pass.py index fc3ddc3..05d0e90 100644 --- a/pythonbpf/functions_pass.py +++ b/pythonbpf/functions_pass.py @@ -192,8 +192,23 @@ def handle_assign( elif isinstance(rval.func, ast.Attribute): print(f"Assignment call attribute: {ast.dump(rval.func)}") if isinstance(rval.func.value, ast.Name): - # TODO: probably a struct access - print(f"TODO STRUCT ACCESS {ast.dump(rval)}") + if rval.func.value.id in map_sym_tab: + map_name = rval.func.value.id + method_name = rval.func.attr + if HelperHandlerRegistry.has_handler(method_name): + val = handle_helper_call( + rval, + module, + builder, + func, + local_sym_tab, + map_sym_tab, + structs_sym_tab, + ) + builder.store(val[0], local_sym_tab[var_name].var) + else: + # TODO: probably a struct access + print(f"TODO STRUCT ACCESS {ast.dump(rval)}") elif isinstance(rval.func.value, ast.Call) and isinstance( rval.func.value.func, ast.Name ): diff --git a/pythonbpf/maps/maps_pass.py b/pythonbpf/maps/maps_pass.py index 693655f..e7dd174 100644 --- a/pythonbpf/maps/maps_pass.py +++ b/pythonbpf/maps/maps_pass.py @@ -274,6 +274,7 @@ def process_bpf_map(func_node, module): rval = return_stmt.value if isinstance(rval, ast.Call) and isinstance(rval.func, ast.Name): + print(f"we're lit, {ast.dump(rval)}") handler = MapProcessorRegistry.get_processor(rval.func.id) if handler: return handler(map_name, rval, module) From 05083bd51352201cc1fb873075b2d7599dc99b98 Mon Sep 17 00:00:00 2001 From: Pragyansh Chaturvedi Date: Thu, 2 Oct 2025 22:10:28 +0530 Subject: [PATCH 3/3] janitorial nitpicks --- pythonbpf/maps/maps_pass.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pythonbpf/maps/maps_pass.py b/pythonbpf/maps/maps_pass.py index e7dd174..693655f 100644 --- a/pythonbpf/maps/maps_pass.py +++ b/pythonbpf/maps/maps_pass.py @@ -274,7 +274,6 @@ def process_bpf_map(func_node, module): rval = return_stmt.value if isinstance(rval, ast.Call) and isinstance(rval.func, ast.Name): - print(f"we're lit, {ast.dump(rval)}") handler = MapProcessorRegistry.get_processor(rval.func.id) if handler: return handler(map_name, rval, module)