mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2025-12-31 21:06:25 +00:00
allow allocation pass on vmlinux cast
This commit is contained in:
@ -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}")
|
||||
|
||||
|
||||
@ -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)),
|
||||
}
|
||||
|
||||
@ -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)
|
||||
|
||||
Reference in New Issue
Block a user