Skip to content

Commit 3f4f951

Browse files
committed
Core: Pass compilation_context to _prepare_expr_args as it calls eval_expr
1 parent f2b9767 commit 3f4f951

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

pythonbpf/helper/printk_formatter.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,7 @@ def handle_fstring_print(
5555

5656
for expr in exprs[:3]:
5757
arg_value = _prepare_expr_args(
58-
expr,
59-
func,
60-
compilation_context.module,
61-
builder,
62-
local_sym_tab,
63-
compilation_context.structs_sym_tab,
58+
expr, func, compilation_context, builder, local_sym_tab
6459
)
6560
args.append(arg_value)
6661

@@ -216,19 +211,19 @@ def _create_format_string_global(fmt_str, func, module, builder):
216211
return builder.bitcast(fmt_gvar, ir.PointerType())
217212

218213

219-
def _prepare_expr_args(expr, func, module, builder, local_sym_tab, struct_sym_tab):
214+
def _prepare_expr_args(expr, func, compilation_context, builder, local_sym_tab):
220215
"""Evaluate and prepare an expression to use as an arg for bpf_printk."""
221216

222217
# Special case: struct field char array needs pointer to first element
223218
if isinstance(expr, ast.Attribute):
224219
char_array_ptr, _ = get_char_array_ptr_and_size(
225-
expr, builder, local_sym_tab, struct_sym_tab, func
220+
expr, builder, local_sym_tab, compilation_context, func
226221
)
227222
if char_array_ptr:
228223
return char_array_ptr
229224

230225
# Regular expression evaluation
231-
val, _ = eval_expr(func, module, builder, expr, local_sym_tab, None, struct_sym_tab)
226+
val, _ = eval_expr(func, compilation_context, builder, expr, local_sym_tab)
232227

233228
if not val:
234229
logger.warning("Failed to evaluate expression for bpf_printk, defaulting to 0")

0 commit comments

Comments
 (0)