mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2025-12-31 21:06:25 +00:00
Fix fstrings in examples, add alternate map attr access
This commit is contained in:
@ -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)
|
||||
|
||||
@ -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)}")
|
||||
|
||||
Reference in New Issue
Block a user