From 6831f1117946b6d4051ea2e14e68034d9cb13d33 Mon Sep 17 00:00:00 2001 From: Pragyansh Chaturvedi Date: Thu, 2 Oct 2025 00:22:59 +0530 Subject: [PATCH] Fix fstrings in examples, add alternate map attr access --- examples/struct_and_perf.py | 4 ++-- pythonbpf/helper/bpf_helper_handler.py | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/examples/struct_and_perf.py b/examples/struct_and_perf.py index c545de0..2cfe233 100644 --- a/examples/struct_and_perf.py +++ b/examples/struct_and_perf.py @@ -28,8 +28,8 @@ def hello(ctx: c_void_p) -> c_int32: dataobj.ts = ktime() # dataobj.comm = strobj print( - f"clone called at {dataobj.ts} by pid { - dataobj.pid}, comm {strobj} at time {ts}" + f"clone called at {dataobj.ts} by pid" + f"{dataobj.pid}, comm {strobj}" ) events.output(dataobj) return c_int32(0) diff --git a/pythonbpf/helper/bpf_helper_handler.py b/pythonbpf/helper/bpf_helper_handler.py index a24d9ee..69ca22b 100644 --- a/pythonbpf/helper/bpf_helper_handler.py +++ b/pythonbpf/helper/bpf_helper_handler.py @@ -255,11 +255,14 @@ def handle_helper_call(call, module, builder, func, elif isinstance(call.func, ast.Attribute): method_name = call.func.attr value = call.func.value - + print(f"Handling method call: {ast.dump(call.func)}") # Get map pointer from different styles of map access if isinstance(value, ast.Call) and isinstance(value.func, ast.Name): - # Variable style: my_map.lookup(key) + # Func style: my_map().lookup(key) map_name = value.func.id + elif isinstance(value, ast.Name): + # Direct style: my_map.lookup(key) + map_name = value.id else: raise NotImplementedError( f"Unsupported map access pattern: {ast.dump(value)}")