add support with ctypes getattr offset. Also supports bitfields.

* breaks when struct_ring_buffer_per_cpu
This commit is contained in:
2025-10-16 04:08:06 +05:30
parent c22d85ceb8
commit de02731ea1
2 changed files with 76 additions and 36 deletions

View File

@ -25,7 +25,7 @@ def process_vmlinux_class(node, llvm_module, handler: DependencyHandler):
def process_vmlinux_post_ast(
elem_type_class, llvm_handler, handler: DependencyHandler, processing_stack=None
elem_type_class, llvm_handler, handler: DependencyHandler, processing_stack=None
):
# Initialize processing stack on first call
if processing_stack is None:
@ -60,6 +60,10 @@ def process_vmlinux_post_ast(
pass
else:
new_dep_node = DependencyNode(name=current_symbol_name)
# elem_type_class is the actual vmlinux struct/class
new_dep_node.set_ctype_struct(elem_type_class)
handler.add_node(new_dep_node)
class_obj = getattr(imported_module, current_symbol_name)
# Inspect the class fields
@ -71,9 +75,6 @@ def process_vmlinux_post_ast(
if len(field_elem) == 2:
field_name, field_type = field_elem
elif len(field_elem) == 3:
raise NotImplementedError(
"Bitfields are not supported in the current version"
)
field_name, field_type, bitfield_size = field_elem
field_table[field_name] = [field_type, bitfield_size]
elif hasattr(class_obj, "__annotations__"):