From 5413cc793b1ce7dc8a84580416a717cc27e35680 Mon Sep 17 00:00:00 2001 From: varun-r-mallya Date: Thu, 16 Oct 2025 18:06:36 +0530 Subject: [PATCH] something fixed itself. --- pythonbpf/vmlinux_parser/class_handler.py | 36 +++++++++++++++-------- tests/failing_tests/xdp_pass.py | 2 +- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/pythonbpf/vmlinux_parser/class_handler.py b/pythonbpf/vmlinux_parser/class_handler.py index 48668a2..34cdf73 100644 --- a/pythonbpf/vmlinux_parser/class_handler.py +++ b/pythonbpf/vmlinux_parser/class_handler.py @@ -145,15 +145,30 @@ def process_vmlinux_post_ast( ) new_dep_node.set_field_type(elem_name, elem_type) if containing_type.__module__ == "vmlinux": - process_vmlinux_post_ast( - containing_type, llvm_handler, handler, processing_stack - ) - size_of_containing_type = ( - handler[containing_type.__name__] - ).__sizeof__() - new_dep_node.set_field_ready( - elem_name, True, size_of_containing_type + containing_type_name = ( + containing_type.__name__ + if hasattr(containing_type, "__name__") + else str(containing_type) ) + + # Check for self-reference or already processed + if containing_type_name == current_symbol_name: + # Self-referential pointer + logger.debug( + f"Self-referential pointer in {current_symbol_name}.{elem_name}" + ) + new_dep_node.set_field_ready(elem_name, True) + elif handler.has_node(containing_type_name): + # Already processed + logger.debug(f"Reusing already processed {containing_type_name}") + new_dep_node.set_field_ready(elem_name, True) + else: + # Process recursively - THIS WAS MISSING + new_dep_node.add_dependent(containing_type_name) + process_vmlinux_post_ast( + containing_type, llvm_handler, handler, processing_stack + ) + new_dep_node.set_field_ready(elem_name, True) elif containing_type.__module__ == ctypes.__name__: logger.debug(f"Processing ctype internal{containing_type}") new_dep_node.set_field_ready(elem_name, True) @@ -170,11 +185,8 @@ def process_vmlinux_post_ast( process_vmlinux_post_ast( elem_type, llvm_handler, handler, processing_stack ) - size_of_containing_type = ( - handler[elem_type.__name__] - ).__sizeof__() new_dep_node.set_field_ready( - elem_name, True, size_of_containing_type + elem_name, True ) else: raise ValueError( diff --git a/tests/failing_tests/xdp_pass.py b/tests/failing_tests/xdp_pass.py index bf31ee8..83433be 100644 --- a/tests/failing_tests/xdp_pass.py +++ b/tests/failing_tests/xdp_pass.py @@ -6,7 +6,7 @@ from vmlinux import struct_trace_event_raw_sys_enter # noqa: F401 from vmlinux import struct_posix_cputimers # noqa: F401 from vmlinux import struct_xdp_md # from vmlinux import struct_trace_event_raw_sys_enter # noqa: F401 -# from vmlinux import struct_ring_buffer_per_cpu # noqa: F401 +from vmlinux import struct_ring_buffer_per_cpu # noqa: F401 from ctypes import c_int64