1- import ast
21import logging
32from functools import lru_cache
43import importlib
@@ -20,17 +19,19 @@ def process_vmlinux_class(node, llvm_module, handler: DependencyHandler):
2019 symbols_in_module , imported_module = get_module_symbols ("vmlinux" )
2120
2221 # Handle both node objects and type objects
23- if hasattr (node , ' name' ):
22+ if hasattr (node , " name" ):
2423 current_symbol_name = node .name
25- elif hasattr (node , ' __name__' ):
24+ elif hasattr (node , " __name__" ):
2625 current_symbol_name = node .__name__
2726 else :
2827 current_symbol_name = str (node )
2928
3029 if current_symbol_name not in symbols_in_module :
3130 raise ImportError (f"{ current_symbol_name } not present in module vmlinux" )
3231 logger .info (f"Resolving vmlinux class { current_symbol_name } " )
33- logger .debug (f"Current handler state: { handler .is_ready } readiness and { handler .get_all_nodes ()} all nodes" )
32+ logger .debug (
33+ f"Current handler state: { handler .is_ready } readiness and { handler .get_all_nodes ()} all nodes"
34+ )
3435 field_table = {} # should contain the field and it's type.
3536
3637 # Get the class object from the module
@@ -42,12 +43,12 @@ def process_vmlinux_class(node, llvm_module, handler: DependencyHandler):
4243 # Inspect the class fields
4344 # Assuming class_obj has fields stored in some standard way
4445 # If it's a ctypes-like structure with _fields_
45- if hasattr (class_obj , ' _fields_' ):
46+ if hasattr (class_obj , " _fields_" ):
4647 for field_name , field_type in class_obj ._fields_ :
4748 field_table [field_name ] = field_type
4849
4950 # If it's using __annotations__
50- elif hasattr (class_obj , ' __annotations__' ):
51+ elif hasattr (class_obj , " __annotations__" ):
5152 for field_name , field_type in class_obj .__annotations__ .items ():
5253 field_table [field_name ] = field_type
5354
@@ -69,17 +70,24 @@ def process_vmlinux_class(node, llvm_module, handler: DependencyHandler):
6970 print ("elem_name:" , elem_name , "elem_type:" , elem_type )
7071 # currently fails when a non-normal type appears which is basically everytime
7172 identify_ctypes_type (elem_type )
72- symbol_name = elem_type .__name__ if hasattr (elem_type , '__name__' ) else str (elem_type )
73+ symbol_name = (
74+ elem_type .__name__
75+ if hasattr (elem_type , "__name__" )
76+ else str (elem_type )
77+ )
7378 vmlinux_symbol = getattr (imported_module , symbol_name )
7479 if process_vmlinux_class (vmlinux_symbol , llvm_module , handler ):
7580 new_dep_node .set_field_ready (elem_name , True )
7681 else :
77- raise ValueError (f"{ elem_name } with type { elem_type } not supported in recursive resolver" )
82+ raise ValueError (
83+ f"{ elem_name } with type { elem_type } not supported in recursive resolver"
84+ )
7885 handler .add_node (new_dep_node )
7986 logger .info (f"added node: { current_symbol_name } " )
8087
8188 return True
8289
90+
8391def identify_ctypes_type (t ):
8492 if isinstance (t , type ): # t is a type/class
8593 if issubclass (t , ctypes .Array ):
0 commit comments