allow allocation pass on vmlinux cast

This commit is contained in:
2025-11-21 16:02:54 +05:30
parent 42b8865a56
commit fde8eab775
3 changed files with 14 additions and 3 deletions

View File

@ -118,6 +118,19 @@ def _allocate_for_call(
local_sym_tab[var_name] = LocalSymbol(var, struct_info.ir_type, call_type)
logger.info(f"Pre-allocated {var_name} for struct {call_type}")
elif VmlinuxHandlerRegistry.is_vmlinux_struct(call_type):
# When calling struct_name(pointer), we're doing a cast, not construction
# So we allocate as a pointer (i64) not as the actual struct
ir_type = ir.IntType(64) # Pointer type
var = builder.alloca(ir_type, name=var_name)
var.align = 8
local_sym_tab[var_name] = LocalSymbol(
var, ir_type, VmlinuxHandlerRegistry.get_struct_type(call_type)
)
logger.info(
f"Pre-allocated {var_name} for vmlinux struct pointer cast to {call_type}"
)
else:
logger.warning(f"Unknown call type for allocation: {call_type}")

View File

@ -16,8 +16,6 @@ mapping = {
"c_long": ir.IntType(64),
"c_ulong": ir.IntType(64),
"c_longlong": ir.IntType(64),
"c_uint": ir.IntType(32),
"c_int": ir.IntType(32),
# Not so sure about this one
"str": ir.PointerType(ir.IntType(8)),
}

View File

@ -126,7 +126,7 @@ def _get_field_debug_type(
# If not found, create a forward declaration
# This will be completed when the actual struct is processed
logger.warning(
logger.info(
f"Forward declaration created for {struct_name} in {parent_struct.name}"
)
forward_type = generator.create_struct_type([], 0, is_distinct=True)