Fix struct_access in eval_expr, move struct_access conditional test to passing

This commit is contained in:
Pragyansh Chaturvedi
2025-10-07 13:35:31 +05:30
parent f41693bc6d
commit caa5d92c32
3 changed files with 10 additions and 5 deletions

View File

@ -43,7 +43,6 @@ def _handle_attribute_expr(
var_ptr, var_type, var_metadata = local_sym_tab[var_name]
logger.info(f"Loading attribute {attr_name} from variable {var_name}")
logger.info(f"Variable type: {var_type}, Variable ptr: {var_ptr}")
metadata = structs_sym_tab[var_metadata]
if attr_name in metadata.fields:
gep = metadata.gep(builder, var_ptr, attr_name)

View File

@ -240,9 +240,13 @@ def handle_assign(
logger.info("Unsupported assignment value type")
def handle_cond(func, module, builder, cond, local_sym_tab, map_sym_tab):
def handle_cond(
func, module, builder, cond, local_sym_tab, map_sym_tab, structs_sym_tab=None
):
if True:
val = eval_expr(func, module, builder, cond, local_sym_tab, map_sym_tab)[0]
val = eval_expr(
func, module, builder, cond, local_sym_tab, map_sym_tab, structs_sym_tab
)[0]
return convert_to_bool(builder, val)
if isinstance(cond, ast.Constant):
if isinstance(cond.value, bool) or isinstance(cond.value, int):
@ -321,7 +325,9 @@ def handle_if(
else:
else_block = None
cond = handle_cond(func, module, builder, stmt.test, local_sym_tab, map_sym_tab)
cond = handle_cond(
func, module, builder, stmt.test, local_sym_tab, map_sym_tab, structs_sym_tab
)
if else_block:
builder.cbranch(cond, then_block, else_block)
else:

View File

@ -13,7 +13,7 @@ class data_t:
@section("tracepoint/syscalls/sys_enter_execve")
def hello_world(ctx: c_void_p) -> c_int64:
dat = data_t()
if dat.pid:
if dat.ts:
print("Hello, World!")
else:
print("Goodbye, World!")