Skip to content

Commit 6831f11

Browse files
committed
Fix fstrings in examples, add alternate map attr access
1 parent d4e8e1b commit 6831f11

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

examples/struct_and_perf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ def hello(ctx: c_void_p) -> c_int32:
2828
dataobj.ts = ktime()
2929
# dataobj.comm = strobj
3030
print(
31-
f"clone called at {dataobj.ts} by pid {
32-
dataobj.pid}, comm {strobj} at time {ts}"
31+
f"clone called at {dataobj.ts} by pid"
32+
f"{dataobj.pid}, comm {strobj}"
3333
)
3434
events.output(dataobj)
3535
return c_int32(0)

pythonbpf/helper/bpf_helper_handler.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,11 +255,14 @@ def invoke_helper(method_name, map_ptr=None):
255255
elif isinstance(call.func, ast.Attribute):
256256
method_name = call.func.attr
257257
value = call.func.value
258-
258+
print(f"Handling method call: {ast.dump(call.func)}")
259259
# Get map pointer from different styles of map access
260260
if isinstance(value, ast.Call) and isinstance(value.func, ast.Name):
261-
# Variable style: my_map.lookup(key)
261+
# Func style: my_map().lookup(key)
262262
map_name = value.func.id
263+
elif isinstance(value, ast.Name):
264+
# Direct style: my_map.lookup(key)
265+
map_name = value.id
263266
else:
264267
raise NotImplementedError(
265268
f"Unsupported map access pattern: {ast.dump(value)}")

0 commit comments

Comments
 (0)