@@ -23,17 +23,18 @@ with Table; use Table;
23
23
with Uintp.LLVM ; use Uintp.LLVM;
24
24
with Urealp ; use Urealp;
25
25
26
- with GNATLLVM.Arrays ; use GNATLLVM.Arrays;
27
- with GNATLLVM.Codegen ; use GNATLLVM.Codegen;
28
- with GNATLLVM.Environment ; use GNATLLVM.Environment;
29
- with GNATLLVM.GLType ; use GNATLLVM.GLType;
30
- with GNATLLVM.Helper ; use GNATLLVM.Helper;
31
- with GNATLLVM.MDType ; use GNATLLVM.MDType;
32
- with GNATLLVM.Records ; use GNATLLVM.Records;
33
- with GNATLLVM.Subprograms ; use GNATLLVM.Subprograms;
34
- with GNATLLVM.Types ; use GNATLLVM.Types;
35
- with GNATLLVM.Utils ; use GNATLLVM.Utils;
36
- with GNATLLVM.Wrapper ; use GNATLLVM.Wrapper;
26
+ with GNATLLVM.Arrays ; use GNATLLVM.Arrays;
27
+ with GNATLLVM.Codegen ; use GNATLLVM.Codegen;
28
+ with GNATLLVM.Environment ; use GNATLLVM.Environment;
29
+ with GNATLLVM.GLType ; use GNATLLVM.GLType;
30
+ with GNATLLVM.Helper ; use GNATLLVM.Helper;
31
+ with GNATLLVM.MDType ; use GNATLLVM.MDType;
32
+ with GNATLLVM.Records ; use GNATLLVM.Records;
33
+ with GNATLLVM.Records.Debug ; use GNATLLVM.Records.Debug;
34
+ with GNATLLVM.Subprograms ; use GNATLLVM.Subprograms;
35
+ with GNATLLVM.Types ; use GNATLLVM.Types;
36
+ with GNATLLVM.Utils ; use GNATLLVM.Utils;
37
+ with GNATLLVM.Wrapper ; use GNATLLVM.Wrapper;
37
38
38
39
package body GNATLLVM.DebugInfo is
39
40
@@ -115,11 +116,6 @@ package body GNATLLVM.DebugInfo is
115
116
Post => Present (Create_Array_Type'Result);
116
117
-- Create metadata corresponding to the array type GT.
117
118
118
- function Create_Type_Data (GT : GL_Type) return Metadata_T
119
- with Pre => Present (GT);
120
- -- Create metadata corresponding to the type of GT. Return
121
- -- No_Metadata_T if the type is too complex.
122
-
123
119
function Create_Type_Data (V : GL_Value) return Metadata_T
124
120
with Pre => Present (V);
125
121
-- Create metadata for the type and relationship of R. Don't return
@@ -953,9 +949,7 @@ package body GNATLLVM.DebugInfo is
953
949
if Is_Unchecked_Union (TE) then
954
950
-- Allow.
955
951
null ;
956
- elsif Ekind (TE) in Record_Kind or
957
- else not Types_Can_Have_Dynamic_Offsets
958
- then
952
+ elsif not Types_Can_Have_Dynamic_Offsets then
959
953
return DI_Create_Unspecified_Type (Name);
960
954
end if ;
961
955
end if ;
@@ -1113,111 +1107,19 @@ package body GNATLLVM.DebugInfo is
1113
1107
-- for the type and the position and size are known and static,
1114
1108
-- add that field as a member.
1115
1109
1116
- when Record_Kind => Record_Type : declare
1117
-
1118
- package Member_Table is new Table.Table
1119
- (Table_Component_Type => Metadata_T,
1120
- Table_Index_Type => Int,
1121
- Table_Low_Bound => 1 ,
1122
- Table_Initial => 20 ,
1123
- Table_Increment => 5 ,
1124
- Table_Name => " Member_Table" );
1125
-
1126
- F : Opt_Record_Field_Kind_Id;
1127
-
1110
+ when Record_Kind => declare
1128
1111
Original_Type : constant Entity_Id :=
1129
- (if Is_Packed (TE)
1130
- then Etype (TE)
1131
- elsif Ekind (TE) = E_Record_Subtype
1132
- then Implementation_Base_Type (TE)
1133
- else Get_Fullest_View (TE));
1134
-
1135
- Empty_Fields : Metadata_Array (1 .. 0 );
1136
-
1112
+ (if Ekind (TE) = E_Record_Subtype
1113
+ then Implementation_Base_Type (TE)
1114
+ else Get_Fullest_View (TE));
1137
1115
begin
1138
- -- A type might be self-referential. For example, a
1139
- -- record may have a member whose type refers back to the
1140
- -- same record type. To handle this case, we construct a
1141
- -- empty composite type and record it; then later we
1142
- -- update the members of the type.
1143
- if Is_Unchecked_Union (TE) then
1144
- Result := DI_Create_Union_Type
1145
- (Get_Scope_For (TE), Get_Possibly_Local_Name (TE),
1146
- Get_Debug_File_Node (Get_Source_File_Index (S)),
1147
- Get_Physical_Line_Number (S), Size, Align, DI_Flag_Zero,
1148
- Empty_Fields, 0 , " " );
1149
- else
1150
- Result := DI_Create_Struct_Type
1151
- (Get_Scope_For (TE), Get_Possibly_Local_Name (TE),
1152
- Get_Debug_File_Node (Get_Source_File_Index (S)),
1153
- Get_Physical_Line_Number (S), Size, Align, DI_Flag_Zero,
1154
- No_Metadata_T, Empty_Fields, 0 , No_Metadata_T, " " );
1155
- end if ;
1156
-
1157
- Set_Debug_Metadata (TE, Result);
1158
-
1159
- F := First_Component_Or_Discriminant (TE);
1160
- while Present (F) loop
1161
- if Get_Fullest_View (Scope (Ancestor_Field (F)))
1162
- /= Original_Type
1163
- then
1164
- -- Inherited component, so we can skip it here.
1165
- null ;
1166
- elsif Known_Static_Component_Bit_Offset (F)
1167
- and then Known_Static_Esize (F)
1168
- then
1169
- declare
1170
- F_GT : constant GL_Type := Field_Type (F);
1171
- Mem_MD : constant Metadata_T :=
1172
- Create_Type_Data (F_GT);
1173
- Name : constant String := Get_Name (F);
1174
- F_S : constant Source_Ptr := Sloc (F);
1175
- File : constant Metadata_T :=
1176
- Get_Debug_File_Node (Get_Source_File_Index (F_S));
1177
- Offset : constant ULL :=
1178
- UI_To_ULL (Component_Bit_Offset (F));
1179
- Storage_Offset : constant ULL :=
1180
- (Offset / UBPU) * UBPU;
1181
- MD : constant Metadata_T :=
1182
- (if Is_Bitfield (F)
1183
- then DI_Create_Bit_Field_Member_Type
1184
- (No_Metadata_T, Name, File,
1185
- Get_Physical_Line_Number (F_S),
1186
- UI_To_ULL (Esize (F)), Offset,
1187
- Storage_Offset, Mem_MD)
1188
- else DI_Create_Member_Type
1189
- (No_Metadata_T, Name, File,
1190
- Get_Physical_Line_Number (F_S),
1191
- UI_To_ULL (Esize (F)),
1192
- Get_Type_Alignment (F_GT), Offset, Mem_MD));
1193
-
1194
- begin
1195
- -- Add the member type to the table
1196
-
1197
- Member_Table.Append (MD);
1198
- end ;
1199
- end if ;
1200
-
1201
- Next_Component_Or_Discriminant (F);
1202
- end loop ;
1203
-
1204
- declare
1205
- Members : Metadata_Array (1 .. Member_Table.Last);
1206
-
1207
- begin
1208
- for J in Members'Range loop
1209
- Members (J) := Member_Table.Table (J);
1210
- end loop ;
1211
-
1212
- -- At least in theory it seems that LLVM may replace
1213
- -- the object entirely, so don't assume Result will be
1214
- -- the same, and be sure to clear it from the cache.
1215
- Result := Replace_Composite_Elements (DI_Builder, Result,
1216
- Members);
1217
- Clear_Debug_Metadata (TE);
1218
- end ;
1219
-
1220
- end Record_Type ;
1116
+ Result :=
1117
+ Create_Record_Debug_Info
1118
+ (TE, Original_Type,
1119
+ Get_Scope_For (Original_Type),
1120
+ Get_Possibly_Local_Name (Original_Type),
1121
+ Size, Align, S);
1122
+ end ;
1221
1123
1222
1124
-- For an enumeration type, make an enumerator metadata for each
1223
1125
-- entry. The code below is a bit convoluted to avoid needing a
0 commit comments