Skip to content

Commit 2483ef2

Browse files
separate vmlinux class handler
1 parent 68e9693 commit 2483ef2

File tree

4 files changed

+34
-3
lines changed

4 files changed

+34
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ __pycache__/
88
*.o
99
.ipynb_checkpoints/
1010
vmlinux.py
11+
~*
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# This will contain a node class that has special properties to be a dependency tree node

pythonbpf/vmlinux_parser/import_detector.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import ast
22
import logging
3-
import llvmlite.ir as ir
43
from typing import List, Tuple
4+
from .vmlinux_class_handler import process_vmlinux_class
55

66
logger = logging.getLogger(__name__)
77

@@ -70,6 +70,27 @@ def detect_import_statement(tree: ast.AST) -> List[Tuple[str, str]]:
7070
logger.info(f"Total vmlinux imports detected: {len(vmlinux_imports)}")
7171
return vmlinux_imports
7272

73-
def vmlinux_proc(tree, module):
73+
def vmlinux_proc(tree: ast.AST, module):
7474
import_statements = detect_import_statement(tree)
75-
logger.info(f"Import statements {import_statements}")
75+
76+
if not import_statements:
77+
logger.info("No vmlinux imports found")
78+
return
79+
80+
vmlinux_types = set()
81+
for module_name, imported_item in import_statements:
82+
vmlinux_types.add(imported_item)
83+
logger.info(f"Registered vmlinux type: {imported_item}")
84+
85+
for node in ast.walk(tree):
86+
if isinstance(node, ast.ClassDef):
87+
# Check if this class uses vmlinux types
88+
logger.info(f"Processing ClassDef with vmlinux types: {node.name}")
89+
process_vmlinux_class(node, module, vmlinux_types)
90+
91+
elif isinstance(node, ast.Assign):
92+
logger.info(f"Processing Assign with vmlinux types")
93+
process_vmlinux_assign(node, module, vmlinux_types)
94+
95+
def process_vmlinux_assign(node, module, vmlinux_types):
96+
raise NotImplementedError("Assignment handling has not been implemented yet")
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import ast
2+
import logging
3+
4+
logger = logging.getLogger(__name__)
5+
6+
def process_vmlinux_class(node, module, vmlinux_types):
7+
# Process ClassDef nodes that use vmlinux imports
8+
pass

0 commit comments

Comments
 (0)