Skip to content

Commit c6b5ecb

Browse files
find global variable ir and field data from metadata
1 parent 30bcfcb commit c6b5ecb

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

pythonbpf/functions/functions_pass.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -348,9 +348,7 @@ def process_func_body(
348348
resolved_type = VmlinuxHandlerRegistry.get_struct_type(
349349
context_type_name
350350
)
351-
context_type = LocalSymbol(
352-
None, ir.PointerType(resolved_type), resolved_type
353-
)
351+
context_type = LocalSymbol(None, None, resolved_type)
354352
local_sym_tab[context_name] = context_type
355353
logger.info(f"Added argument '{context_name}' to local symbol table")
356354

pythonbpf/vmlinux_parser/vmlinux_exports_handler.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,11 @@ def handle_vmlinux_struct_field(
9393
logger.info(
9494
f"Attempting to access field {field_name} of possible vmlinux struct {struct_var_name}"
9595
)
96-
print(var_info.ir_type)
97-
print(self.get_field_type(struct_var_name, field_name))
96+
python_type: type = var_info.metadata
97+
globvar_ir, field_data = self.get_field_type(
98+
python_type.__name__, field_name
99+
)
100+
98101
# Return pointer to field and field type
99102
return None
100103
else:

tests/failing_tests/vmlinux/struct_field_access.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def hello_world(ctx: struct_trace_event_raw_sys_enter) -> c_int64:
1717
a = 2 + TASK_COMM_LEN + TASK_COMM_LEN
1818
b = ctx.id
1919
print(f"Hello, World{TASK_COMM_LEN} and {a}")
20-
# print(f"This is context field {b}")
20+
print(f"This is context field {b}")
2121
return c_int64(TASK_COMM_LEN + 2)
2222

2323

0 commit comments

Comments
 (0)