Skip to content

Commit 3c976b8

Browse files
committed
pass down structs_sym_tab
1 parent 69a86c2 commit 3c976b8

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

pythonbpf/bpf_helper_handler.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def bpf_ktime_get_ns_emitter(call, map_ptr, module, builder, func, local_sym_tab
1616
return result
1717

1818

19-
def bpf_map_lookup_elem_emitter(call, map_ptr, module, builder, local_sym_tab=None):
19+
def bpf_map_lookup_elem_emitter(call, map_ptr, module, builder, local_sym_tab=None, struct_sym_tab=None):
2020
"""
2121
Emit LLVM IR for bpf_map_lookup_elem helper function call.
2222
"""
@@ -172,7 +172,7 @@ def bpf_printk_emitter(call, map_ptr, module, builder, func, local_sym_tab=None)
172172
ir.IntType(32), len(fmt_str))], tail=True)
173173

174174

175-
def bpf_map_update_elem_emitter(call, map_ptr, module, builder, local_sym_tab=None):
175+
def bpf_map_update_elem_emitter(call, map_ptr, module, builder, local_sym_tab=None, struct_sym_tab=None):
176176
"""
177177
Emit LLVM IR for bpf_map_update_elem helper function call.
178178
Expected call signature: map.update(key, value, flags=0)
@@ -268,7 +268,7 @@ def bpf_map_update_elem_emitter(call, map_ptr, module, builder, local_sym_tab=No
268268
return result
269269

270270

271-
def bpf_map_delete_elem_emitter(call, map_ptr, module, builder, local_sym_tab=None):
271+
def bpf_map_delete_elem_emitter(call, map_ptr, module, builder, local_sym_tab=None, struct_sym_tab=None):
272272
"""
273273
Emit LLVM IR for bpf_map_delete_elem helper function call.
274274
Expected call signature: map.delete(key)
@@ -340,7 +340,7 @@ def bpf_get_current_pid_tgid_emitter(call, map_ptr, module, builder, func, local
340340
return pid
341341

342342

343-
def bpf_perf_event_output_handler(call, map_ptr, module, builder, local_sym_tab=None):
343+
def bpf_perf_event_output_handler(call, map_ptr, module, builder, local_sym_tab=None, struct_sym_tab=None):
344344
pass
345345

346346

@@ -355,7 +355,7 @@ def bpf_perf_event_output_handler(call, map_ptr, module, builder, local_sym_tab=
355355
}
356356

357357

358-
def handle_helper_call(call, module, builder, func, local_sym_tab=None, map_sym_tab=None):
358+
def handle_helper_call(call, module, builder, func, local_sym_tab=None, map_sym_tab=None, struct_sym_tab=None):
359359
if isinstance(call.func, ast.Name):
360360
func_name = call.func.id
361361
if func_name in helper_func_list:
@@ -373,7 +373,7 @@ def handle_helper_call(call, module, builder, func, local_sym_tab=None, map_sym_
373373
map_ptr = map_sym_tab[map_name]
374374
if method_name in helper_func_list:
375375
return helper_func_list[method_name](
376-
call, map_ptr, module, builder, local_sym_tab)
376+
call, map_ptr, module, builder, local_sym_tab, struct_sym_tab)
377377
else:
378378
raise NotImplementedError(
379379
f"Map method {method_name} is not implemented as a helper function.")

pythonbpf/functions_pass.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def handle_assign(func, module, builder, stmt, map_sym_tab, local_sym_tab, struc
100100
# var = builder.alloca(ir.IntType(64), name=var_name)
101101
# var.align = 8
102102
val = handle_helper_call(
103-
rval, module, builder, None, local_sym_tab, map_sym_tab)
103+
rval, module, builder, None, local_sym_tab, map_sym_tab, structs_sym_tab)
104104
builder.store(val, local_sym_tab[var_name])
105105
# local_sym_tab[var_name] = var
106106
print(f"Assigned constant {rval.func.id} to {var_name}")
@@ -139,7 +139,7 @@ def handle_assign(func, module, builder, stmt, map_sym_tab, local_sym_tab, struc
139139
map_ptr = map_sym_tab[map_name]
140140
if method_name in helper_func_list:
141141
val = handle_helper_call(
142-
rval, module, builder, func, local_sym_tab, map_sym_tab)
142+
rval, module, builder, func, local_sym_tab, map_sym_tab, structs_sym_tab)
143143
# var = builder.alloca(ir.IntType(64), name=var_name)
144144
# var.align = 8
145145
builder.store(val, local_sym_tab[var_name])

0 commit comments

Comments
 (0)