@@ -99,13 +99,32 @@ def process_vmlinux_post_ast(
9999 local_module_name = getattr (elem_type , "__module__" , None )
100100 new_dep_node .add_field (elem_name , elem_type , ready = False )
101101 if local_module_name == ctypes .__name__ :
102- #TODO: need to process pointer to ctype and also CFUNCTYPES here
102+ #TODO: need to process pointer to ctype and also CFUNCTYPES here recursively.
103+ # for now, function pointers should give an error
103104 new_dep_node .set_field_bitfield_size (elem_name , elem_bitfield_size )
104- print (elem_type )
105- new_dep_node .set_field_ready (elem_name , is_ready = True )
106- logger .debug (
107- f"Field { elem_name } is direct ctypes type: { elem_type } "
108- )
105+
106+ # Process pointer to ctype
107+ if isinstance (elem_type , type ) and issubclass (elem_type , ctypes ._Pointer ):
108+ # Get the pointed-to type
109+ pointed_type = elem_type ._type_
110+ logger .debug (f"Found pointer to type: { pointed_type } " )
111+ new_dep_node .set_field_containing_type (elem_name , pointed_type )
112+ new_dep_node .set_field_ctype_complex_type (elem_name , ctypes ._Pointer )
113+ new_dep_node .set_field_ready (elem_name , is_ready = True )
114+
115+ # Process function pointers (CFUNCTYPE)
116+ elif hasattr (elem_type , '_restype_' ) and hasattr (elem_type , '_argtypes_' ):
117+ # This is a CFUNCTYPE or similar
118+ logger .info (f"Function pointer detected for { elem_name } with return type { elem_type ._restype_ } and arguments { elem_type ._argtypes_ } " )
119+ # Set the field as ready but mark it with special handling
120+ new_dep_node .set_field_ctype_complex_type (elem_name , ctypes .CFUNCTYPE )
121+ new_dep_node .set_field_ready (elem_name , is_ready = True )
122+ logger .warning ("Blindly processing CFUNCTYPE ctypes to ensure compilation. Unsupported" )
123+
124+ else :
125+ # Regular ctype
126+ new_dep_node .set_field_ready (elem_name , is_ready = True )
127+ logger .debug (f"Field { elem_name } is direct ctypes type: { elem_type } " )
109128 elif local_module_name == "vmlinux" :
110129 new_dep_node .set_field_bitfield_size (elem_name , elem_bitfield_size )
111130 logger .debug (
0 commit comments