mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2026-03-29 16:41:29 +00:00
Core: Pass compilation_context to _prepare_expr_args as it calls eval_expr
This commit is contained in:
@ -55,12 +55,7 @@ def handle_fstring_print(
|
|||||||
|
|
||||||
for expr in exprs[:3]:
|
for expr in exprs[:3]:
|
||||||
arg_value = _prepare_expr_args(
|
arg_value = _prepare_expr_args(
|
||||||
expr,
|
expr, func, compilation_context, builder, local_sym_tab
|
||||||
func,
|
|
||||||
compilation_context.module,
|
|
||||||
builder,
|
|
||||||
local_sym_tab,
|
|
||||||
compilation_context.structs_sym_tab,
|
|
||||||
)
|
)
|
||||||
args.append(arg_value)
|
args.append(arg_value)
|
||||||
|
|
||||||
@ -216,19 +211,19 @@ def _create_format_string_global(fmt_str, func, module, builder):
|
|||||||
return builder.bitcast(fmt_gvar, ir.PointerType())
|
return builder.bitcast(fmt_gvar, ir.PointerType())
|
||||||
|
|
||||||
|
|
||||||
def _prepare_expr_args(expr, func, module, builder, local_sym_tab, struct_sym_tab):
|
def _prepare_expr_args(expr, func, compilation_context, builder, local_sym_tab):
|
||||||
"""Evaluate and prepare an expression to use as an arg for bpf_printk."""
|
"""Evaluate and prepare an expression to use as an arg for bpf_printk."""
|
||||||
|
|
||||||
# Special case: struct field char array needs pointer to first element
|
# Special case: struct field char array needs pointer to first element
|
||||||
if isinstance(expr, ast.Attribute):
|
if isinstance(expr, ast.Attribute):
|
||||||
char_array_ptr, _ = get_char_array_ptr_and_size(
|
char_array_ptr, _ = get_char_array_ptr_and_size(
|
||||||
expr, builder, local_sym_tab, struct_sym_tab, func
|
expr, builder, local_sym_tab, compilation_context, func
|
||||||
)
|
)
|
||||||
if char_array_ptr:
|
if char_array_ptr:
|
||||||
return char_array_ptr
|
return char_array_ptr
|
||||||
|
|
||||||
# Regular expression evaluation
|
# Regular expression evaluation
|
||||||
val, _ = eval_expr(func, module, builder, expr, local_sym_tab, None, struct_sym_tab)
|
val, _ = eval_expr(func, compilation_context, builder, expr, local_sym_tab)
|
||||||
|
|
||||||
if not val:
|
if not val:
|
||||||
logger.warning("Failed to evaluate expression for bpf_printk, defaulting to 0")
|
logger.warning("Failed to evaluate expression for bpf_printk, defaulting to 0")
|
||||||
|
|||||||
Reference in New Issue
Block a user