Skip to content

Commit aa51d12

Browse files
r41k0uclaude
andcommitted
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) <noreply@anthropic.com>
1 parent ce222af commit aa51d12

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

pythonbpf/vmlinux_parser/dependency_node.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ class Field:
1717
offset: int
1818
value: Any = None
1919
ready: bool = False
20+
# CO-RE access path from the enclosing struct down to this field, as a tuple
21+
# of member indices. `None` means the field is a plain top-level member and
22+
# its access path is just its own index in the struct. It is only populated
23+
# for fields that live inside an anonymous member and were flattened into
24+
# the parent, e.g. `struct pt_regs.cs` is member 0 of anonymous member 17,
25+
# so its access_path is (17, 0).
26+
access_path: Optional[tuple[int, ...]] = None
2027

2128
def __hash__(self):
2229
"""
@@ -154,6 +161,7 @@ def add_field(
154161
bitfield_size: Optional[int] = None,
155162
ready: bool = False,
156163
offset: int = 0,
164+
access_path: Optional[tuple[int, ...]] = None,
157165
) -> None:
158166
"""Add a field to the node with an optional initial value and readiness state."""
159167
if self.depends_on is None:
@@ -168,6 +176,7 @@ def add_field(
168176
ctype_complex_type=ctype_complex_type,
169177
bitfield_size=bitfield_size,
170178
offset=offset,
179+
access_path=access_path,
171180
)
172181
# Invalidate readiness cache
173182
self._ready_cache = None

0 commit comments

Comments
 (0)