From aa51d123de116012795b1c959db0fd38f67427a5 Mon Sep 17 00:00:00 2001 From: Pragyansh Chaturvedi Date: Fri, 7 Aug 2026 04:48:06 +0530 Subject: [PATCH] Core: Add an optional CO-RE access path to Field Carries the chain of member indices from the enclosing struct down to a field, so a field that does not sit at the top level of the struct can still describe where it lives. Defaults to None, which keeps meaning "this field is a plain top-level member". Pure data, nothing reads it yet, generated IR is unchanged. Co-Authored-By: Claude Opus 5 (1M context) --- pythonbpf/vmlinux_parser/dependency_node.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pythonbpf/vmlinux_parser/dependency_node.py b/pythonbpf/vmlinux_parser/dependency_node.py index dd413ad..d870e4b 100644 --- a/pythonbpf/vmlinux_parser/dependency_node.py +++ b/pythonbpf/vmlinux_parser/dependency_node.py @@ -17,6 +17,13 @@ class Field: offset: int value: Any = None ready: bool = False + # CO-RE access path from the enclosing struct down to this field, as a tuple + # of member indices. `None` means the field is a plain top-level member and + # its access path is just its own index in the struct. It is only populated + # for fields that live inside an anonymous member and were flattened into + # the parent, e.g. `struct pt_regs.cs` is member 0 of anonymous member 17, + # so its access_path is (17, 0). + access_path: Optional[tuple[int, ...]] = None def __hash__(self): """ @@ -154,6 +161,7 @@ class DependencyNode: bitfield_size: Optional[int] = None, ready: bool = False, offset: int = 0, + access_path: Optional[tuple[int, ...]] = None, ) -> None: """Add a field to the node with an optional initial value and readiness state.""" if self.depends_on is None: @@ -168,6 +176,7 @@ class DependencyNode: ctype_complex_type=ctype_complex_type, bitfield_size=bitfield_size, offset=offset, + access_path=access_path, ) # Invalidate readiness cache self._ready_cache = None