Fix fstrings in examples, add alternate map attr access

This commit is contained in:
Pragyansh Chaturvedi
2025-10-02 00:22:59 +05:30
parent d4e8e1bf73
commit 6831f11179
2 changed files with 7 additions and 4 deletions

View File

@ -28,8 +28,8 @@ def hello(ctx: c_void_p) -> c_int32:
dataobj.ts = ktime() dataobj.ts = ktime()
# dataobj.comm = strobj # dataobj.comm = strobj
print( print(
f"clone called at {dataobj.ts} by pid { f"clone called at {dataobj.ts} by pid"
dataobj.pid}, comm {strobj} at time {ts}" f"{dataobj.pid}, comm {strobj}"
) )
events.output(dataobj) events.output(dataobj)
return c_int32(0) return c_int32(0)

View File

@ -255,11 +255,14 @@ def handle_helper_call(call, module, builder, func,
elif isinstance(call.func, ast.Attribute): elif isinstance(call.func, ast.Attribute):
method_name = call.func.attr method_name = call.func.attr
value = call.func.value value = call.func.value
print(f"Handling method call: {ast.dump(call.func)}")
# Get map pointer from different styles of map access # Get map pointer from different styles of map access
if isinstance(value, ast.Call) and isinstance(value.func, ast.Name): 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 map_name = value.func.id
elif isinstance(value, ast.Name):
# Direct style: my_map.lookup(key)
map_name = value.id
else: else:
raise NotImplementedError( raise NotImplementedError(
f"Unsupported map access pattern: {ast.dump(value)}") f"Unsupported map access pattern: {ast.dump(value)}")