22from ..dependency_node import DependencyNode
33import ctypes
44import logging
5- from typing import List , Any , Tuple , Optional
5+ from typing import List , Any , Tuple
66
77logger = logging .getLogger (__name__ )
88
9+
910def debug_info_generation (
10- struct : DependencyNode , llvm_module , generated_debug_info : List [Tuple [DependencyNode , Any ]]
11+ struct : DependencyNode ,
12+ llvm_module ,
13+ generated_debug_info : List [Tuple [DependencyNode , Any ]],
1114) -> Any :
1215 """
1316 Generate DWARF debug information for a struct defined in a DependencyNode.
@@ -54,11 +57,11 @@ def debug_info_generation(
5457
5558
5659def _get_field_debug_type (
57- field_name : str ,
58- field ,
59- generator : DebugInfoGenerator ,
60- parent_struct : DependencyNode ,
61- generated_debug_info : List [Tuple [DependencyNode , Any ]]
60+ field_name : str ,
61+ field ,
62+ generator : DebugInfoGenerator ,
63+ parent_struct : DependencyNode ,
64+ generated_debug_info : List [Tuple [DependencyNode , Any ]],
6265) -> tuple [Any , int ]:
6366 """
6467 Determine the appropriate debug type for a field based on its Python/ctypes type.
@@ -77,8 +80,12 @@ def _get_field_debug_type(
7780 if field .ctype_complex_type is not None :
7881 if issubclass (field .ctype_complex_type , ctypes .Array ):
7982 # Handle array types
80- element_type , base_type_size = _get_basic_debug_type (field .containing_type , generator )
81- return generator .create_array_type (element_type , field .type_size ), field .type_size * base_type_size
83+ element_type , base_type_size = _get_basic_debug_type (
84+ field .containing_type , generator
85+ )
86+ return generator .create_array_type_vmlinux (
87+ (element_type , base_type_size * field .type_size ), field .type_size
88+ ), field .type_size * base_type_size
8289 elif issubclass (field .ctype_complex_type , ctypes ._Pointer ):
8390 # Handle pointer types
8491 pointee_type , _ = _get_basic_debug_type (field .containing_type , generator )
@@ -136,7 +143,9 @@ def _get_basic_debug_type(ctype, generator: DebugInfoGenerator) -> Any:
136143 elif ctype == ctypes .c_longlong or ctype == ctypes .c_int64 :
137144 return generator .get_basic_type ("long long" , 64 , dc .DW_ATE_signed ), 64
138145 elif ctype == ctypes .c_ulonglong or ctype == ctypes .c_uint64 :
139- return generator .get_basic_type ("unsigned long long" , 64 , dc .DW_ATE_unsigned ), 64
146+ return generator .get_basic_type (
147+ "unsigned long long" , 64 , dc .DW_ATE_unsigned
148+ ), 64
140149 elif ctype == ctypes .c_float :
141150 return generator .get_basic_type ("float" , 32 , dc .DW_ATE_float ), 32
142151 elif ctype == ctypes .c_double :
@@ -147,9 +156,7 @@ def _get_basic_debug_type(ctype, generator: DebugInfoGenerator) -> Any:
147156 char_type = generator .get_basic_type ("char" , 8 , dc .DW_ATE_signed_char ), 8
148157 return generator .create_pointer_type (char_type )
149158 elif ctype == ctypes .c_void_p :
150- void_type = generator .module .add_debug_info (
151- "DIBasicType" , {"name" : "void" }
152- )
159+ void_type = generator .module .add_debug_info ("DIBasicType" , {"name" : "void" })
153160 return generator .create_pointer_type (void_type ), 64
154161 else :
155162 return generator .get_uint64_type (), 64
0 commit comments