@@ -86,6 +86,7 @@ def struct_processor(self, struct, processing_stack=None):
8686 members_dict = {}
8787 for field_name , field in struct .fields .items ():
8888 # Get the generated field name from our dictionary, or use field_name if not found
89+ print (f"DEBUG: { struct .name } , { field_name } " )
8990 if (
9091 struct .name in self .generated_field_names
9192 and field_name in self .generated_field_names [struct .name ]
@@ -181,20 +182,45 @@ def gen_ir(self, struct, generated_debug_info):
181182 containing_type = field .containing_type
182183 if containing_type .__module__ == "vmlinux" :
183184 print (struct )
184- containing_type_size = self .handler [
185- containing_type .__name__
186- ].current_offset
187- for i in range (0 , array_size ):
185+ # Unwrap all pointer layers to get the base struct type
186+ base_containing_type = containing_type
187+ while hasattr (base_containing_type , "_type_" ):
188+ next_type = base_containing_type ._type_
189+ # Stop if _type_ is a string (like 'c' for c_char)
190+ #TODO: stacked pointers not handl;ing ctypes check here as well
191+ if isinstance (next_type , str ):
192+ break
193+ base_containing_type = next_type
194+
195+ # Get the base struct name
196+ base_struct_name = base_containing_type .__name__ if hasattr (base_containing_type , "__name__" ) else str (base_containing_type )
197+
198+ # Look up the size using the base struct name
199+ containing_type_size = self .handler [base_struct_name ].current_offset
200+ print (f"GAY: { array_size } , { struct .name } , { field_name } " )
201+ if array_size == 0 :
188202 field_co_re_name , returned = self ._struct_name_generator (
189- struct , field , field_index , True , i , containing_type_size
203+ struct , field , field_index , True , 0 , containing_type_size
190204 )
191205 globvar = ir .GlobalVariable (
192206 self .llvm_module , ir .IntType (64 ), name = field_co_re_name
193207 )
194208 globvar .linkage = "external"
195209 globvar .set_metadata ("llvm.preserve.access.index" , debug_info )
196210 self .generated_field_names [struct .name ][field_name ] = globvar
197- field_index += 1
211+ field_index += 1
212+ else :
213+ for i in range (0 , array_size ):
214+ field_co_re_name , returned = self ._struct_name_generator (
215+ struct , field , field_index , True , i , containing_type_size
216+ )
217+ globvar = ir .GlobalVariable (
218+ self .llvm_module , ir .IntType (64 ), name = field_co_re_name
219+ )
220+ globvar .linkage = "external"
221+ globvar .set_metadata ("llvm.preserve.access.index" , debug_info )
222+ self .generated_field_names [struct .name ][field_name ] = globvar
223+ field_index += 1
198224 else :
199225 field_co_re_name , returned = self ._struct_name_generator (
200226 struct , field , field_index
0 commit comments