Skip to content

Commit fde8eab

Browse files
allow allocation pass on vmlinux cast
1 parent 42b8865 commit fde8eab

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

pythonbpf/allocation_pass.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,19 @@ def _allocate_for_call(
118118
local_sym_tab[var_name] = LocalSymbol(var, struct_info.ir_type, call_type)
119119
logger.info(f"Pre-allocated {var_name} for struct {call_type}")
120120

121+
elif VmlinuxHandlerRegistry.is_vmlinux_struct(call_type):
122+
# When calling struct_name(pointer), we're doing a cast, not construction
123+
# So we allocate as a pointer (i64) not as the actual struct
124+
ir_type = ir.IntType(64) # Pointer type
125+
var = builder.alloca(ir_type, name=var_name)
126+
var.align = 8
127+
local_sym_tab[var_name] = LocalSymbol(
128+
var, ir_type, VmlinuxHandlerRegistry.get_struct_type(call_type)
129+
)
130+
logger.info(
131+
f"Pre-allocated {var_name} for vmlinux struct pointer cast to {call_type}"
132+
)
133+
121134
else:
122135
logger.warning(f"Unknown call type for allocation: {call_type}")
123136

pythonbpf/type_deducer.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
"c_long": ir.IntType(64),
1717
"c_ulong": ir.IntType(64),
1818
"c_longlong": ir.IntType(64),
19-
"c_uint": ir.IntType(32),
20-
"c_int": ir.IntType(32),
2119
# Not so sure about this one
2220
"str": ir.PointerType(ir.IntType(8)),
2321
}

pythonbpf/vmlinux_parser/ir_gen/debug_info_gen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def _get_field_debug_type(
126126

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

0 commit comments

Comments
 (0)