Skip to content

Commit 8774277

Browse files
try to separate out ast node from vmlinux type
1 parent 8743ea1 commit 8774277

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

pythonbpf/vmlinux_parser/class_handler.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,16 @@ def get_module_symbols(module_name: str):
1313
imported_module = importlib.import_module(module_name)
1414
return [name for name in dir(imported_module)], imported_module
1515

16+
def process_vmlinux_class(node, llvm_module, handler: DependencyHandler):
17+
symbols_in_module, imported_module = get_module_symbols("vmlinux")
18+
if node.name in symbols_in_module:
19+
vmlinux_type = getattr(imported_module, node.name)
20+
process_vmlinux_post_ast(vmlinux_type, llvm_module, handler)
21+
else:
22+
raise ImportError(f"{node.name} not in vmlinux")
1623

1724
# Recursive function that gets all the dependent classes and adds them to handler
18-
def process_vmlinux_class(node, llvm_module, handler: DependencyHandler, processing_stack=None):
25+
def process_vmlinux_post_ast(node, llvm_module, handler: DependencyHandler, processing_stack=None):
1926
"""
2027
Recursively process vmlinux classes and their dependencies.
2128
@@ -142,7 +149,7 @@ def process_vmlinux_class(node, llvm_module, handler: DependencyHandler, process
142149

143150
# Recursively process the dependency
144151
if vmlinux_symbol is not None:
145-
if process_vmlinux_class(vmlinux_symbol, llvm_module, handler, processing_stack):
152+
if process_vmlinux_post_ast(vmlinux_symbol, llvm_module, handler, processing_stack):
146153
new_dep_node.set_field_ready(elem_name, True)
147154
else:
148155
raise ValueError(

0 commit comments

Comments
 (0)