diff --git a/pythonbpf/allocation_pass.py b/pythonbpf/allocation_pass.py index b5fa37c..a096739 100644 --- a/pythonbpf/allocation_pass.py +++ b/pythonbpf/allocation_pass.py @@ -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}") diff --git a/pythonbpf/type_deducer.py b/pythonbpf/type_deducer.py index fd589ae..a6834a9 100644 --- a/pythonbpf/type_deducer.py +++ b/pythonbpf/type_deducer.py @@ -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)), } diff --git a/pythonbpf/vmlinux_parser/ir_gen/debug_info_gen.py b/pythonbpf/vmlinux_parser/ir_gen/debug_info_gen.py index eb7636f..7ee187b 100644 --- a/pythonbpf/vmlinux_parser/ir_gen/debug_info_gen.py +++ b/pythonbpf/vmlinux_parser/ir_gen/debug_info_gen.py @@ -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)