Mercurial > hg > CbC > CbC_gcc
comparison gcc/dwarf2out.c @ 131:84e7813d76e9
gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 07:37:49 +0900 |
parents | 04ced10e8804 |
children | 1830386684a0 |
comparison
equal
deleted
inserted
replaced
111:04ced10e8804 | 131:84e7813d76e9 |
---|---|
1 /* Output Dwarf2 format symbol table information from GCC. | 1 /* Output Dwarf2 format symbol table information from GCC. |
2 Copyright (C) 1992-2017 Free Software Foundation, Inc. | 2 Copyright (C) 1992-2018 Free Software Foundation, Inc. |
3 Contributed by Gary Funck (gary@intrepid.com). | 3 Contributed by Gary Funck (gary@intrepid.com). |
4 Derived from DWARF 1 implementation of Ron Guilmette (rfg@monkeys.com). | 4 Derived from DWARF 1 implementation of Ron Guilmette (rfg@monkeys.com). |
5 Extensively modified by Jason Merrill (jason@cygnus.com). | 5 Extensively modified by Jason Merrill (jason@cygnus.com). |
6 | 6 |
7 This file is part of GCC. | 7 This file is part of GCC. |
81 #include "dwarf2out.h" | 81 #include "dwarf2out.h" |
82 #include "dwarf2asm.h" | 82 #include "dwarf2asm.h" |
83 #include "toplev.h" | 83 #include "toplev.h" |
84 #include "md5.h" | 84 #include "md5.h" |
85 #include "tree-pretty-print.h" | 85 #include "tree-pretty-print.h" |
86 #include "print-rtl.h" | |
86 #include "debug.h" | 87 #include "debug.h" |
87 #include "common/common-target.h" | 88 #include "common/common-target.h" |
88 #include "langhooks.h" | 89 #include "langhooks.h" |
89 #include "lra.h" | 90 #include "lra.h" |
90 #include "dumpfile.h" | 91 #include "dumpfile.h" |
92 #include "tree-dfa.h" | 93 #include "tree-dfa.h" |
93 #include "gdb/gdb-index.h" | 94 #include "gdb/gdb-index.h" |
94 #include "rtl-iter.h" | 95 #include "rtl-iter.h" |
95 #include "stringpool.h" | 96 #include "stringpool.h" |
96 #include "attribs.h" | 97 #include "attribs.h" |
98 #include "file-prefix-map.h" /* remap_debug_filename() */ | |
97 | 99 |
98 static void dwarf2out_source_line (unsigned int, unsigned int, const char *, | 100 static void dwarf2out_source_line (unsigned int, unsigned int, const char *, |
99 int, bool); | 101 int, bool); |
100 static rtx_insn *last_var_location_insn; | 102 static rtx_insn *last_var_location_insn; |
101 static rtx_insn *cached_next_real_insn; | 103 static rtx_insn *cached_next_real_insn; |
102 static void dwarf2out_decl (tree); | 104 static void dwarf2out_decl (tree); |
105 static bool is_redundant_typedef (const_tree); | |
103 | 106 |
104 #ifndef XCOFF_DEBUGGING_INFO | 107 #ifndef XCOFF_DEBUGGING_INFO |
105 #define XCOFF_DEBUGGING_INFO 0 | 108 #define XCOFF_DEBUGGING_INFO 0 |
106 #endif | 109 #endif |
107 | 110 |
145 /* A pointer to the base of a list of incomplete types which might be | 148 /* A pointer to the base of a list of incomplete types which might be |
146 completed at some later time. incomplete_types_list needs to be a | 149 completed at some later time. incomplete_types_list needs to be a |
147 vec<tree, va_gc> *because we want to tell the garbage collector about | 150 vec<tree, va_gc> *because we want to tell the garbage collector about |
148 it. */ | 151 it. */ |
149 static GTY(()) vec<tree, va_gc> *incomplete_types; | 152 static GTY(()) vec<tree, va_gc> *incomplete_types; |
150 | |
151 /* A pointer to the base of a table of references to declaration | |
152 scopes. This table is a display which tracks the nesting | |
153 of declaration scopes at the current scope and containing | |
154 scopes. This table is used to find the proper place to | |
155 define type declaration DIE's. */ | |
156 static GTY(()) vec<tree, va_gc> *decl_scope_table; | |
157 | 153 |
158 /* Pointers to various DWARF2 sections. */ | 154 /* Pointers to various DWARF2 sections. */ |
159 static GTY(()) section *debug_info_section; | 155 static GTY(()) section *debug_info_section; |
160 static GTY(()) section *debug_skeleton_info_section; | 156 static GTY(()) section *debug_skeleton_info_section; |
161 static GTY(()) section *debug_abbrev_section; | 157 static GTY(()) section *debug_abbrev_section; |
242 | 238 |
243 1) The string is needed in both the main object file and the dwo. | 239 1) The string is needed in both the main object file and the dwo. |
244 That is, the comp_dir and dwo_name will appear in both places. | 240 That is, the comp_dir and dwo_name will appear in both places. |
245 | 241 |
246 2) Strings can use four forms: DW_FORM_string, DW_FORM_strp, | 242 2) Strings can use four forms: DW_FORM_string, DW_FORM_strp, |
247 DW_FORM_line_strp or DW_FORM_GNU_str_index. | 243 DW_FORM_line_strp or DW_FORM_strx/GNU_str_index. |
248 | 244 |
249 3) GCC chooses the form to use late, depending on the size and | 245 3) GCC chooses the form to use late, depending on the size and |
250 reference count. | 246 reference count. |
251 | 247 |
252 Rather than forcing the all debug string handling functions and | 248 Rather than forcing the all debug string handling functions and |
261 | 257 |
262 /* True if the compilation unit places functions in more than one section. */ | 258 /* True if the compilation unit places functions in more than one section. */ |
263 static GTY(()) bool have_multiple_function_sections = false; | 259 static GTY(()) bool have_multiple_function_sections = false; |
264 | 260 |
265 /* Whether the default text and cold text sections have been used at all. */ | 261 /* Whether the default text and cold text sections have been used at all. */ |
266 | |
267 static GTY(()) bool text_section_used = false; | 262 static GTY(()) bool text_section_used = false; |
268 static GTY(()) bool cold_text_section_used = false; | 263 static GTY(()) bool cold_text_section_used = false; |
269 | 264 |
270 /* The default cold text section. */ | 265 /* The default cold text section. */ |
271 static GTY(()) section *cold_text_section; | 266 static GTY(()) section *cold_text_section; |
283 | 278 |
284 /* Personality decl of current unit. Used only when assembler does not support | 279 /* Personality decl of current unit. Used only when assembler does not support |
285 personality CFI. */ | 280 personality CFI. */ |
286 static GTY(()) rtx current_unit_personality; | 281 static GTY(()) rtx current_unit_personality; |
287 | 282 |
283 /* Whether an eh_frame section is required. */ | |
284 static GTY(()) bool do_eh_frame = false; | |
285 | |
288 /* .debug_rnglists next index. */ | 286 /* .debug_rnglists next index. */ |
289 static unsigned int rnglist_idx; | 287 static unsigned int rnglist_idx; |
290 | 288 |
291 /* Data and reference forms for relocatable data. */ | 289 /* Data and reference forms for relocatable data. */ |
292 #define DW_FORM_data (DWARF_OFFSET_SIZE == 8 ? DW_FORM_data8 : DW_FORM_data4) | 290 #define DW_FORM_data (DWARF_OFFSET_SIZE == 8 ? DW_FORM_data8 : DW_FORM_data4) |
296 #define DEBUG_FRAME_SECTION ".debug_frame" | 294 #define DEBUG_FRAME_SECTION ".debug_frame" |
297 #endif | 295 #endif |
298 | 296 |
299 #ifndef FUNC_BEGIN_LABEL | 297 #ifndef FUNC_BEGIN_LABEL |
300 #define FUNC_BEGIN_LABEL "LFB" | 298 #define FUNC_BEGIN_LABEL "LFB" |
299 #endif | |
300 | |
301 #ifndef FUNC_SECOND_SECT_LABEL | |
302 #define FUNC_SECOND_SECT_LABEL "LFSB" | |
301 #endif | 303 #endif |
302 | 304 |
303 #ifndef FUNC_END_LABEL | 305 #ifndef FUNC_END_LABEL |
304 #define FUNC_END_LABEL "LFE" | 306 #define FUNC_END_LABEL "LFE" |
305 #endif | 307 #endif |
567 return dw_cfi_oprnd_reg_num; | 569 return dw_cfi_oprnd_reg_num; |
568 | 570 |
569 case DW_CFA_expression: | 571 case DW_CFA_expression: |
570 case DW_CFA_val_expression: | 572 case DW_CFA_val_expression: |
571 return dw_cfi_oprnd_loc; | 573 return dw_cfi_oprnd_loc; |
574 | |
575 case DW_CFA_def_cfa_expression: | |
576 return dw_cfi_oprnd_cfa_loc; | |
572 | 577 |
573 default: | 578 default: |
574 return dw_cfi_oprnd_unused; | 579 return dw_cfi_oprnd_unused; |
575 } | 580 } |
576 } | 581 } |
959 static void | 964 static void |
960 dwarf2out_do_cfi_startproc (bool second) | 965 dwarf2out_do_cfi_startproc (bool second) |
961 { | 966 { |
962 int enc; | 967 int enc; |
963 rtx ref; | 968 rtx ref; |
969 | |
970 fprintf (asm_out_file, "\t.cfi_startproc\n"); | |
971 | |
972 /* .cfi_personality and .cfi_lsda are only relevant to DWARF2 | |
973 eh unwinders. */ | |
974 if (targetm_common.except_unwind_info (&global_options) != UI_DWARF2) | |
975 return; | |
976 | |
964 rtx personality = get_personality_function (current_function_decl); | 977 rtx personality = get_personality_function (current_function_decl); |
965 | |
966 fprintf (asm_out_file, "\t.cfi_startproc\n"); | |
967 | 978 |
968 if (personality) | 979 if (personality) |
969 { | 980 { |
970 enc = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/2, /*global=*/1); | 981 enc = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/2, /*global=*/1); |
971 ref = personality; | 982 ref = personality; |
1058 ASM_OUTPUT_DEBUG_LABEL (asm_out_file, FUNC_BEGIN_LABEL, | 1069 ASM_OUTPUT_DEBUG_LABEL (asm_out_file, FUNC_BEGIN_LABEL, |
1059 current_function_funcdef_no); | 1070 current_function_funcdef_no); |
1060 dup_label = xstrdup (label); | 1071 dup_label = xstrdup (label); |
1061 current_function_func_begin_label = dup_label; | 1072 current_function_func_begin_label = dup_label; |
1062 | 1073 |
1063 /* We can elide the fde allocation if we're not emitting debug info. */ | 1074 /* We can elide FDE allocation if we're not emitting frame unwind info. */ |
1064 if (!do_frame) | 1075 if (!do_frame) |
1065 return; | 1076 return; |
1077 | |
1078 /* Unlike the debug version, the EH version of frame unwind info is a per- | |
1079 function setting so we need to record whether we need it for the unit. */ | |
1080 do_eh_frame |= dwarf2out_do_eh_frame (); | |
1066 | 1081 |
1067 /* Cater to the various TARGET_ASM_OUTPUT_MI_THUNK implementations that | 1082 /* Cater to the various TARGET_ASM_OUTPUT_MI_THUNK implementations that |
1068 emit insns as rtx but bypass the bulk of rest_of_compilation, which | 1083 emit insns as rtx but bypass the bulk of rest_of_compilation, which |
1069 would include pass_dwarf2_frame. If we've not created the FDE yet, | 1084 would include pass_dwarf2_frame. If we've not created the FDE yet, |
1070 do so now. */ | 1085 do so now. */ |
1178 /* Output call frame information. */ | 1193 /* Output call frame information. */ |
1179 if (targetm.debug_unwind_info () == UI_DWARF2) | 1194 if (targetm.debug_unwind_info () == UI_DWARF2) |
1180 output_call_frame_info (0); | 1195 output_call_frame_info (0); |
1181 | 1196 |
1182 /* Output another copy for the unwinder. */ | 1197 /* Output another copy for the unwinder. */ |
1183 if ((flag_unwind_tables || flag_exceptions) | 1198 if (do_eh_frame) |
1184 && targetm_common.except_unwind_info (&global_options) == UI_DWARF2) | |
1185 output_call_frame_info (1); | 1199 output_call_frame_info (1); |
1186 } | 1200 } |
1187 | 1201 |
1188 /* Note that the current function section is being used for code. */ | 1202 /* Note that the current function section is being used for code. */ |
1189 | 1203 |
1201 static void set_cur_line_info_table (section *); | 1215 static void set_cur_line_info_table (section *); |
1202 | 1216 |
1203 void | 1217 void |
1204 dwarf2out_switch_text_section (void) | 1218 dwarf2out_switch_text_section (void) |
1205 { | 1219 { |
1220 char label[MAX_ARTIFICIAL_LABEL_BYTES]; | |
1206 section *sect; | 1221 section *sect; |
1207 dw_fde_ref fde = cfun->fde; | 1222 dw_fde_ref fde = cfun->fde; |
1208 | 1223 |
1209 gcc_assert (cfun && fde && fde->dw_fde_second_begin == NULL); | 1224 gcc_assert (cfun && fde && fde->dw_fde_second_begin == NULL); |
1210 | 1225 |
1226 ASM_GENERATE_INTERNAL_LABEL (label, FUNC_SECOND_SECT_LABEL, | |
1227 current_function_funcdef_no); | |
1228 | |
1229 fde->dw_fde_second_begin = ggc_strdup (label); | |
1211 if (!in_cold_section_p) | 1230 if (!in_cold_section_p) |
1212 { | 1231 { |
1213 fde->dw_fde_end = crtl->subsections.cold_section_end_label; | 1232 fde->dw_fde_end = crtl->subsections.cold_section_end_label; |
1214 fde->dw_fde_second_begin = crtl->subsections.hot_section_label; | |
1215 fde->dw_fde_second_end = crtl->subsections.hot_section_end_label; | 1233 fde->dw_fde_second_end = crtl->subsections.hot_section_end_label; |
1216 } | 1234 } |
1217 else | 1235 else |
1218 { | 1236 { |
1219 fde->dw_fde_end = crtl->subsections.hot_section_end_label; | 1237 fde->dw_fde_end = crtl->subsections.hot_section_end_label; |
1220 fde->dw_fde_second_begin = crtl->subsections.cold_section_label; | |
1221 fde->dw_fde_second_end = crtl->subsections.cold_section_end_label; | 1238 fde->dw_fde_second_end = crtl->subsections.cold_section_end_label; |
1222 } | 1239 } |
1223 have_multiple_function_sections = true; | 1240 have_multiple_function_sections = true; |
1224 | 1241 |
1225 /* There is no need to mark used sections when not debugging. */ | 1242 /* There is no need to mark used sections when not debugging. */ |
1272 rtx GTY ((tag ("0"))) rtl; | 1289 rtx GTY ((tag ("0"))) rtl; |
1273 char * GTY ((tag ("1"))) label; | 1290 char * GTY ((tag ("1"))) label; |
1274 } | 1291 } |
1275 GTY ((desc ("%1.kind"))) addr; | 1292 GTY ((desc ("%1.kind"))) addr; |
1276 }; | 1293 }; |
1294 | |
1295 typedef unsigned int var_loc_view; | |
1277 | 1296 |
1278 /* Location lists are ranges + location descriptions for that range, | 1297 /* Location lists are ranges + location descriptions for that range, |
1279 so you can track variables that are in different places over | 1298 so you can track variables that are in different places over |
1280 their entire life. */ | 1299 their entire life. */ |
1281 typedef struct GTY(()) dw_loc_list_struct { | 1300 typedef struct GTY(()) dw_loc_list_struct { |
1282 dw_loc_list_ref dw_loc_next; | 1301 dw_loc_list_ref dw_loc_next; |
1283 const char *begin; /* Label and addr_entry for start of range */ | 1302 const char *begin; /* Label and addr_entry for start of range */ |
1284 addr_table_entry *begin_entry; | 1303 addr_table_entry *begin_entry; |
1285 const char *end; /* Label for end of range */ | 1304 const char *end; /* Label for end of range */ |
1286 char *ll_symbol; /* Label for beginning of location list. | 1305 char *ll_symbol; /* Label for beginning of location list. |
1287 Only on head of list */ | 1306 Only on head of list. */ |
1307 char *vl_symbol; /* Label for beginning of view list. Ditto. */ | |
1288 const char *section; /* Section this loclist is relative to */ | 1308 const char *section; /* Section this loclist is relative to */ |
1289 dw_loc_descr_ref expr; | 1309 dw_loc_descr_ref expr; |
1310 var_loc_view vbegin, vend; | |
1290 hashval_t hash; | 1311 hashval_t hash; |
1291 /* True if all addresses in this and subsequent lists are known to be | 1312 /* True if all addresses in this and subsequent lists are known to be |
1292 resolved. */ | 1313 resolved. */ |
1293 bool resolved_addr; | 1314 bool resolved_addr; |
1294 /* True if this list has been replaced by dw_loc_next. */ | 1315 /* True if this list has been replaced by dw_loc_next. */ |
1305 /* True if the range should be emitted even if begin and end | 1326 /* True if the range should be emitted even if begin and end |
1306 are the same. */ | 1327 are the same. */ |
1307 bool force; | 1328 bool force; |
1308 } dw_loc_list_node; | 1329 } dw_loc_list_node; |
1309 | 1330 |
1310 static dw_loc_descr_ref int_loc_descriptor (HOST_WIDE_INT); | 1331 static dw_loc_descr_ref int_loc_descriptor (poly_int64); |
1311 static dw_loc_descr_ref uint_loc_descriptor (unsigned HOST_WIDE_INT); | 1332 static dw_loc_descr_ref uint_loc_descriptor (unsigned HOST_WIDE_INT); |
1312 | 1333 |
1313 /* Convert a DWARF stack opcode into its string name. */ | 1334 /* Convert a DWARF stack opcode into its string name. */ |
1314 | 1335 |
1315 static const char * | 1336 static const char * |
1319 | 1340 |
1320 if (name != NULL) | 1341 if (name != NULL) |
1321 return name; | 1342 return name; |
1322 | 1343 |
1323 return "OP_<unknown>"; | 1344 return "OP_<unknown>"; |
1345 } | |
1346 | |
1347 /* Return TRUE iff we're to output location view lists as a separate | |
1348 attribute next to the location lists, as an extension compatible | |
1349 with DWARF 2 and above. */ | |
1350 | |
1351 static inline bool | |
1352 dwarf2out_locviews_in_attribute () | |
1353 { | |
1354 return debug_variable_location_views == 1; | |
1355 } | |
1356 | |
1357 /* Return TRUE iff we're to output location view lists as part of the | |
1358 location lists, as proposed for standardization after DWARF 5. */ | |
1359 | |
1360 static inline bool | |
1361 dwarf2out_locviews_in_loclist () | |
1362 { | |
1363 #ifndef DW_LLE_view_pair | |
1364 return false; | |
1365 #else | |
1366 return debug_variable_location_views == -1; | |
1367 #endif | |
1324 } | 1368 } |
1325 | 1369 |
1326 /* Return a pointer to a newly allocated location description. Location | 1370 /* Return a pointer to a newly allocated location description. Location |
1327 descriptions are simple expression terms that can be strung | 1371 descriptions are simple expression terms that can be strung |
1328 together to form more complicated location (address) descriptions. */ | 1372 together to form more complicated location (address) descriptions. */ |
1340 descr->dw_loc_oprnd2.val_class = dw_val_class_unsigned_const; | 1384 descr->dw_loc_oprnd2.val_class = dw_val_class_unsigned_const; |
1341 descr->dw_loc_oprnd2.val_entry = NULL; | 1385 descr->dw_loc_oprnd2.val_entry = NULL; |
1342 descr->dw_loc_oprnd2.v.val_unsigned = oprnd2; | 1386 descr->dw_loc_oprnd2.v.val_unsigned = oprnd2; |
1343 | 1387 |
1344 return descr; | 1388 return descr; |
1345 } | |
1346 | |
1347 /* Return a pointer to a newly allocated location description for | |
1348 REG and OFFSET. */ | |
1349 | |
1350 static inline dw_loc_descr_ref | |
1351 new_reg_loc_descr (unsigned int reg, unsigned HOST_WIDE_INT offset) | |
1352 { | |
1353 if (reg <= 31) | |
1354 return new_loc_descr ((enum dwarf_location_atom) (DW_OP_breg0 + reg), | |
1355 offset, 0); | |
1356 else | |
1357 return new_loc_descr (DW_OP_bregx, reg, offset); | |
1358 } | 1389 } |
1359 | 1390 |
1360 /* Add a location description term to a location description expression. */ | 1391 /* Add a location description term to a location description expression. */ |
1361 | 1392 |
1362 static inline void | 1393 static inline void |
1396 | 1427 |
1397 case dw_val_class_loc: | 1428 case dw_val_class_loc: |
1398 return a->v.val_loc == b->v.val_loc; | 1429 return a->v.val_loc == b->v.val_loc; |
1399 case dw_val_class_loc_list: | 1430 case dw_val_class_loc_list: |
1400 return a->v.val_loc_list == b->v.val_loc_list; | 1431 return a->v.val_loc_list == b->v.val_loc_list; |
1432 case dw_val_class_view_list: | |
1433 return a->v.val_view_list == b->v.val_view_list; | |
1401 case dw_val_class_die_ref: | 1434 case dw_val_class_die_ref: |
1402 return a->v.val_die_ref.die == b->v.val_die_ref.die; | 1435 return a->v.val_die_ref.die == b->v.val_die_ref.die; |
1403 case dw_val_class_fde_ref: | 1436 case dw_val_class_fde_ref: |
1404 return a->v.val_fde_index == b->v.val_fde_index; | 1437 return a->v.val_fde_index == b->v.val_fde_index; |
1438 case dw_val_class_symview: | |
1439 return strcmp (a->v.val_symbolic_view, b->v.val_symbolic_view) == 0; | |
1405 case dw_val_class_lbl_id: | 1440 case dw_val_class_lbl_id: |
1406 case dw_val_class_lineptr: | 1441 case dw_val_class_lineptr: |
1407 case dw_val_class_macptr: | 1442 case dw_val_class_macptr: |
1408 case dw_val_class_loclistsptr: | 1443 case dw_val_class_loclistsptr: |
1409 case dw_val_class_high_pc: | 1444 case dw_val_class_high_pc: |
1487 b = b->dw_loc_next; | 1522 b = b->dw_loc_next; |
1488 } | 1523 } |
1489 } | 1524 } |
1490 | 1525 |
1491 | 1526 |
1492 /* Add a constant OFFSET to a location expression. */ | 1527 /* Add a constant POLY_OFFSET to a location expression. */ |
1493 | 1528 |
1494 static void | 1529 static void |
1495 loc_descr_plus_const (dw_loc_descr_ref *list_head, HOST_WIDE_INT offset) | 1530 loc_descr_plus_const (dw_loc_descr_ref *list_head, poly_int64 poly_offset) |
1496 { | 1531 { |
1497 dw_loc_descr_ref loc; | 1532 dw_loc_descr_ref loc; |
1498 HOST_WIDE_INT *p; | 1533 HOST_WIDE_INT *p; |
1499 | 1534 |
1500 gcc_assert (*list_head != NULL); | 1535 gcc_assert (*list_head != NULL); |
1501 | 1536 |
1502 if (!offset) | 1537 if (known_eq (poly_offset, 0)) |
1503 return; | 1538 return; |
1504 | 1539 |
1505 /* Find the end of the chain. */ | 1540 /* Find the end of the chain. */ |
1506 for (loc = *list_head; loc->dw_loc_next != NULL; loc = loc->dw_loc_next) | 1541 for (loc = *list_head; loc->dw_loc_next != NULL; loc = loc->dw_loc_next) |
1507 ; | 1542 ; |
1543 | |
1544 HOST_WIDE_INT offset; | |
1545 if (!poly_offset.is_constant (&offset)) | |
1546 { | |
1547 loc->dw_loc_next = int_loc_descriptor (poly_offset); | |
1548 add_loc_descr (&loc->dw_loc_next, new_loc_descr (DW_OP_plus, 0, 0)); | |
1549 return; | |
1550 } | |
1508 | 1551 |
1509 p = NULL; | 1552 p = NULL; |
1510 if (loc->dw_loc_opc == DW_OP_fbreg | 1553 if (loc->dw_loc_opc == DW_OP_fbreg |
1511 || (loc->dw_loc_opc >= DW_OP_breg0 && loc->dw_loc_opc <= DW_OP_breg31)) | 1554 || (loc->dw_loc_opc >= DW_OP_breg0 && loc->dw_loc_opc <= DW_OP_breg31)) |
1512 p = &loc->dw_loc_oprnd1.v.val_int; | 1555 p = &loc->dw_loc_oprnd1.v.val_int; |
1529 = uint_loc_descriptor (-(unsigned HOST_WIDE_INT) offset); | 1572 = uint_loc_descriptor (-(unsigned HOST_WIDE_INT) offset); |
1530 add_loc_descr (&loc->dw_loc_next, new_loc_descr (DW_OP_minus, 0, 0)); | 1573 add_loc_descr (&loc->dw_loc_next, new_loc_descr (DW_OP_minus, 0, 0)); |
1531 } | 1574 } |
1532 } | 1575 } |
1533 | 1576 |
1577 /* Return a pointer to a newly allocated location description for | |
1578 REG and OFFSET. */ | |
1579 | |
1580 static inline dw_loc_descr_ref | |
1581 new_reg_loc_descr (unsigned int reg, poly_int64 offset) | |
1582 { | |
1583 HOST_WIDE_INT const_offset; | |
1584 if (offset.is_constant (&const_offset)) | |
1585 { | |
1586 if (reg <= 31) | |
1587 return new_loc_descr ((enum dwarf_location_atom) (DW_OP_breg0 + reg), | |
1588 const_offset, 0); | |
1589 else | |
1590 return new_loc_descr (DW_OP_bregx, reg, const_offset); | |
1591 } | |
1592 else | |
1593 { | |
1594 dw_loc_descr_ref ret = new_reg_loc_descr (reg, 0); | |
1595 loc_descr_plus_const (&ret, offset); | |
1596 return ret; | |
1597 } | |
1598 } | |
1599 | |
1534 /* Add a constant OFFSET to a location list. */ | 1600 /* Add a constant OFFSET to a location list. */ |
1535 | 1601 |
1536 static void | 1602 static void |
1537 loc_list_plus_const (dw_loc_list_ref list_head, HOST_WIDE_INT offset) | 1603 loc_list_plus_const (dw_loc_list_ref list_head, poly_int64 offset) |
1538 { | 1604 { |
1539 dw_loc_list_ref d; | 1605 dw_loc_list_ref d; |
1540 for (d = list_head; d != NULL; d = d->dw_loc_next) | 1606 for (d = list_head; d != NULL; d = d->dw_loc_next) |
1541 loc_descr_plus_const (&d->expr, offset); | 1607 loc_descr_plus_const (&d->expr, offset); |
1542 } | 1608 } |
1590 case DW_OP_reinterpret: | 1656 case DW_OP_reinterpret: |
1591 if (dwarf_version < 5) | 1657 if (dwarf_version < 5) |
1592 return DW_OP_GNU_reinterpret; | 1658 return DW_OP_GNU_reinterpret; |
1593 break; | 1659 break; |
1594 | 1660 |
1661 case DW_OP_addrx: | |
1662 if (dwarf_version < 5) | |
1663 return DW_OP_GNU_addr_index; | |
1664 break; | |
1665 | |
1666 case DW_OP_constx: | |
1667 if (dwarf_version < 5) | |
1668 return DW_OP_GNU_const_index; | |
1669 break; | |
1670 | |
1595 default: | 1671 default: |
1596 break; | 1672 break; |
1597 } | 1673 } |
1598 return op; | 1674 return op; |
1599 } | 1675 } |
1657 case DW_AT_dwo_name: | 1733 case DW_AT_dwo_name: |
1658 if (dwarf_version < 5) | 1734 if (dwarf_version < 5) |
1659 return DW_AT_GNU_dwo_name; | 1735 return DW_AT_GNU_dwo_name; |
1660 break; | 1736 break; |
1661 | 1737 |
1738 case DW_AT_addr_base: | |
1739 if (dwarf_version < 5) | |
1740 return DW_AT_GNU_addr_base; | |
1741 break; | |
1742 | |
1662 default: | 1743 default: |
1663 break; | 1744 break; |
1664 } | 1745 } |
1665 return at; | 1746 return at; |
1666 } | 1747 } |
1685 break; | 1766 break; |
1686 } | 1767 } |
1687 return tag; | 1768 return tag; |
1688 } | 1769 } |
1689 | 1770 |
1771 /* And similarly for forms. */ | |
1772 static inline enum dwarf_form | |
1773 dwarf_FORM (enum dwarf_form form) | |
1774 { | |
1775 switch (form) | |
1776 { | |
1777 case DW_FORM_addrx: | |
1778 if (dwarf_version < 5) | |
1779 return DW_FORM_GNU_addr_index; | |
1780 break; | |
1781 | |
1782 case DW_FORM_strx: | |
1783 if (dwarf_version < 5) | |
1784 return DW_FORM_GNU_str_index; | |
1785 break; | |
1786 | |
1787 default: | |
1788 break; | |
1789 } | |
1790 return form; | |
1791 } | |
1792 | |
1690 static unsigned long int get_base_type_offset (dw_die_ref); | 1793 static unsigned long int get_base_type_offset (dw_die_ref); |
1691 | 1794 |
1692 /* Return the size of a location descriptor. */ | 1795 /* Return the size of a location descriptor. */ |
1693 | 1796 |
1694 static unsigned long | 1797 static unsigned long |
1700 { | 1803 { |
1701 case DW_OP_addr: | 1804 case DW_OP_addr: |
1702 size += DWARF2_ADDR_SIZE; | 1805 size += DWARF2_ADDR_SIZE; |
1703 break; | 1806 break; |
1704 case DW_OP_GNU_addr_index: | 1807 case DW_OP_GNU_addr_index: |
1808 case DW_OP_addrx: | |
1705 case DW_OP_GNU_const_index: | 1809 case DW_OP_GNU_const_index: |
1810 case DW_OP_constx: | |
1706 gcc_assert (loc->dw_loc_oprnd1.val_entry->index != NO_INDEX_ASSIGNED); | 1811 gcc_assert (loc->dw_loc_oprnd1.val_entry->index != NO_INDEX_ASSIGNED); |
1707 size += size_of_uleb128 (loc->dw_loc_oprnd1.val_entry->index); | 1812 size += size_of_uleb128 (loc->dw_loc_oprnd1.val_entry->index); |
1708 break; | 1813 break; |
1709 case DW_OP_const1u: | 1814 case DW_OP_const1u: |
1710 case DW_OP_const1s: | 1815 case DW_OP_const1s: |
2200 #endif | 2305 #endif |
2201 } | 2306 } |
2202 break; | 2307 break; |
2203 | 2308 |
2204 case DW_OP_GNU_addr_index: | 2309 case DW_OP_GNU_addr_index: |
2310 case DW_OP_addrx: | |
2205 case DW_OP_GNU_const_index: | 2311 case DW_OP_GNU_const_index: |
2312 case DW_OP_constx: | |
2206 gcc_assert (loc->dw_loc_oprnd1.val_entry->index != NO_INDEX_ASSIGNED); | 2313 gcc_assert (loc->dw_loc_oprnd1.val_entry->index != NO_INDEX_ASSIGNED); |
2207 dw2_asm_output_data_uleb128 (loc->dw_loc_oprnd1.val_entry->index, | 2314 dw2_asm_output_data_uleb128 (loc->dw_loc_oprnd1.val_entry->index, |
2208 "(index into .debug_addr)"); | 2315 "(index into .debug_addr)"); |
2209 break; | 2316 break; |
2210 | 2317 |
2431 | 2538 |
2432 switch (loc->dw_loc_opc) | 2539 switch (loc->dw_loc_opc) |
2433 { | 2540 { |
2434 case DW_OP_addr: | 2541 case DW_OP_addr: |
2435 case DW_OP_GNU_addr_index: | 2542 case DW_OP_GNU_addr_index: |
2543 case DW_OP_addrx: | |
2436 case DW_OP_GNU_const_index: | 2544 case DW_OP_GNU_const_index: |
2545 case DW_OP_constx: | |
2437 case DW_OP_implicit_value: | 2546 case DW_OP_implicit_value: |
2438 /* We cannot output addresses in .cfi_escape, only bytes. */ | 2547 /* We cannot output addresses in .cfi_escape, only bytes. */ |
2439 gcc_unreachable (); | 2548 gcc_unreachable (); |
2440 | 2549 |
2441 case DW_OP_const1u: | 2550 case DW_OP_const1u: |
2612 /* This function builds a dwarf location descriptor sequence from a | 2721 /* This function builds a dwarf location descriptor sequence from a |
2613 dw_cfa_location, adding the given OFFSET to the result of the | 2722 dw_cfa_location, adding the given OFFSET to the result of the |
2614 expression. */ | 2723 expression. */ |
2615 | 2724 |
2616 struct dw_loc_descr_node * | 2725 struct dw_loc_descr_node * |
2617 build_cfa_loc (dw_cfa_location *cfa, HOST_WIDE_INT offset) | 2726 build_cfa_loc (dw_cfa_location *cfa, poly_int64 offset) |
2618 { | 2727 { |
2619 struct dw_loc_descr_node *head, *tmp; | 2728 struct dw_loc_descr_node *head, *tmp; |
2620 | 2729 |
2621 offset += cfa->offset; | 2730 offset += cfa->offset; |
2622 | 2731 |
2625 head = new_reg_loc_descr (cfa->reg, cfa->base_offset); | 2734 head = new_reg_loc_descr (cfa->reg, cfa->base_offset); |
2626 head->dw_loc_oprnd1.val_class = dw_val_class_const; | 2735 head->dw_loc_oprnd1.val_class = dw_val_class_const; |
2627 head->dw_loc_oprnd1.val_entry = NULL; | 2736 head->dw_loc_oprnd1.val_entry = NULL; |
2628 tmp = new_loc_descr (DW_OP_deref, 0, 0); | 2737 tmp = new_loc_descr (DW_OP_deref, 0, 0); |
2629 add_loc_descr (&head, tmp); | 2738 add_loc_descr (&head, tmp); |
2630 if (offset != 0) | 2739 loc_descr_plus_const (&head, offset); |
2631 { | |
2632 tmp = new_loc_descr (DW_OP_plus_uconst, offset, 0); | |
2633 add_loc_descr (&head, tmp); | |
2634 } | |
2635 } | 2740 } |
2636 else | 2741 else |
2637 head = new_reg_loc_descr (cfa->reg, offset); | 2742 head = new_reg_loc_descr (cfa->reg, offset); |
2638 | 2743 |
2639 return head; | 2744 return head; |
2643 the address at OFFSET from the CFA when stack is aligned to | 2748 the address at OFFSET from the CFA when stack is aligned to |
2644 ALIGNMENT byte. */ | 2749 ALIGNMENT byte. */ |
2645 | 2750 |
2646 struct dw_loc_descr_node * | 2751 struct dw_loc_descr_node * |
2647 build_cfa_aligned_loc (dw_cfa_location *cfa, | 2752 build_cfa_aligned_loc (dw_cfa_location *cfa, |
2648 HOST_WIDE_INT offset, HOST_WIDE_INT alignment) | 2753 poly_int64 offset, HOST_WIDE_INT alignment) |
2649 { | 2754 { |
2650 struct dw_loc_descr_node *head; | 2755 struct dw_loc_descr_node *head; |
2651 unsigned int dwarf_fp | 2756 unsigned int dwarf_fp |
2652 = DWARF_FRAME_REGNUM (HARD_FRAME_POINTER_REGNUM); | 2757 = DWARF_FRAME_REGNUM (HARD_FRAME_POINTER_REGNUM); |
2653 | 2758 |
2686 static void dwarf2out_imported_module_or_decl (tree, tree, tree, bool, bool); | 2791 static void dwarf2out_imported_module_or_decl (tree, tree, tree, bool, bool); |
2687 static void dwarf2out_imported_module_or_decl_1 (tree, tree, tree, | 2792 static void dwarf2out_imported_module_or_decl_1 (tree, tree, tree, |
2688 dw_die_ref); | 2793 dw_die_ref); |
2689 static void dwarf2out_abstract_function (tree); | 2794 static void dwarf2out_abstract_function (tree); |
2690 static void dwarf2out_var_location (rtx_insn *); | 2795 static void dwarf2out_var_location (rtx_insn *); |
2796 static void dwarf2out_inline_entry (tree); | |
2691 static void dwarf2out_size_function (tree); | 2797 static void dwarf2out_size_function (tree); |
2692 static void dwarf2out_begin_function (tree); | 2798 static void dwarf2out_begin_function (tree); |
2693 static void dwarf2out_end_function (unsigned int); | 2799 static void dwarf2out_end_function (unsigned int); |
2694 static void dwarf2out_register_main_translation_unit (tree unit); | 2800 static void dwarf2out_register_main_translation_unit (tree unit); |
2695 static void dwarf2out_set_name (tree, tree); | 2801 static void dwarf2out_set_name (tree, tree); |
2739 something tries to reference them. */ | 2845 something tries to reference them. */ |
2740 dwarf2out_abstract_function, /* outlining_inline_function */ | 2846 dwarf2out_abstract_function, /* outlining_inline_function */ |
2741 debug_nothing_rtx_code_label, /* label */ | 2847 debug_nothing_rtx_code_label, /* label */ |
2742 debug_nothing_int, /* handle_pch */ | 2848 debug_nothing_int, /* handle_pch */ |
2743 dwarf2out_var_location, | 2849 dwarf2out_var_location, |
2850 dwarf2out_inline_entry, /* inline_entry */ | |
2744 dwarf2out_size_function, /* size_function */ | 2851 dwarf2out_size_function, /* size_function */ |
2745 dwarf2out_switch_text_section, | 2852 dwarf2out_switch_text_section, |
2746 dwarf2out_set_name, | 2853 dwarf2out_set_name, |
2747 1, /* start_end_main_source_file */ | 2854 1, /* start_end_main_source_file */ |
2748 TYPE_SYMTAB_IS_DIE /* tree_type_symtab_field */ | 2855 TYPE_SYMTAB_IS_DIE /* tree_type_symtab_field */ |
2779 debug_nothing_tree, /* deferred_inline_function */ | 2886 debug_nothing_tree, /* deferred_inline_function */ |
2780 debug_nothing_tree, /* outlining_inline_function */ | 2887 debug_nothing_tree, /* outlining_inline_function */ |
2781 debug_nothing_rtx_code_label, /* label */ | 2888 debug_nothing_rtx_code_label, /* label */ |
2782 debug_nothing_int, /* handle_pch */ | 2889 debug_nothing_int, /* handle_pch */ |
2783 debug_nothing_rtx_insn, /* var_location */ | 2890 debug_nothing_rtx_insn, /* var_location */ |
2891 debug_nothing_tree, /* inline_entry */ | |
2784 debug_nothing_tree, /* size_function */ | 2892 debug_nothing_tree, /* size_function */ |
2785 debug_nothing_void, /* switch_text_section */ | 2893 debug_nothing_void, /* switch_text_section */ |
2786 debug_nothing_tree_tree, /* set_name */ | 2894 debug_nothing_tree_tree, /* set_name */ |
2787 0, /* start_end_main_source_file */ | 2895 0, /* start_end_main_source_file */ |
2788 TYPE_SYMTAB_IS_ADDRESS /* tree_type_symtab_field */ | 2896 TYPE_SYMTAB_IS_ADDRESS /* tree_type_symtab_field */ |
2841 /* Emit a DW_LNS_set_prologue_end/epilogue_begin; the operand is ignored. */ | 2949 /* Emit a DW_LNS_set_prologue_end/epilogue_begin; the operand is ignored. */ |
2842 LI_set_prologue_end, | 2950 LI_set_prologue_end, |
2843 LI_set_epilogue_begin, | 2951 LI_set_epilogue_begin, |
2844 | 2952 |
2845 /* Emit a DW_LNE_set_discriminator. */ | 2953 /* Emit a DW_LNE_set_discriminator. */ |
2846 LI_set_discriminator | 2954 LI_set_discriminator, |
2955 | |
2956 /* Output a Fixed Advance PC; the target PC is the label index; the | |
2957 base PC is the previous LI_adv_address or LI_set_address entry. | |
2958 We only use this when emitting debug views without assembler | |
2959 support, at explicit user request. Ideally, we should only use | |
2960 it when the offset might be zero but we can't tell: it's the only | |
2961 way to maybe change the PC without resetting the view number. */ | |
2962 LI_adv_address | |
2847 }; | 2963 }; |
2848 | 2964 |
2849 typedef struct GTY(()) dw_line_info_struct { | 2965 typedef struct GTY(()) dw_line_info_struct { |
2850 enum dw_line_info_opcode opcode; | 2966 enum dw_line_info_opcode opcode; |
2851 unsigned int val; | 2967 unsigned int val; |
2863 unsigned int column_num; | 2979 unsigned int column_num; |
2864 int discrim_num; | 2980 int discrim_num; |
2865 bool is_stmt; | 2981 bool is_stmt; |
2866 bool in_use; | 2982 bool in_use; |
2867 | 2983 |
2984 /* This denotes the NEXT view number. | |
2985 | |
2986 If it is 0, it is known that the NEXT view will be the first view | |
2987 at the given PC. | |
2988 | |
2989 If it is -1, we're forcing the view number to be reset, e.g. at a | |
2990 function entry. | |
2991 | |
2992 The meaning of other nonzero values depends on whether we're | |
2993 computing views internally or leaving it for the assembler to do | |
2994 so. If we're emitting them internally, view denotes the view | |
2995 number since the last known advance of PC. If we're leaving it | |
2996 for the assembler, it denotes the LVU label number that we're | |
2997 going to ask the assembler to assign. */ | |
2998 var_loc_view view; | |
2999 | |
3000 /* This counts the number of symbolic views emitted in this table | |
3001 since the latest view reset. Its max value, over all tables, | |
3002 sets symview_upper_bound. */ | |
3003 var_loc_view symviews_since_reset; | |
3004 | |
3005 #define FORCE_RESET_NEXT_VIEW(x) ((x) = (var_loc_view)-1) | |
3006 #define RESET_NEXT_VIEW(x) ((x) = (var_loc_view)0) | |
3007 #define FORCE_RESETTING_VIEW_P(x) ((x) == (var_loc_view)-1) | |
3008 #define RESETTING_VIEW_P(x) ((x) == (var_loc_view)0 || FORCE_RESETTING_VIEW_P (x)) | |
3009 | |
2868 vec<dw_line_info_entry, va_gc> *entries; | 3010 vec<dw_line_info_entry, va_gc> *entries; |
2869 }; | 3011 }; |
2870 | 3012 |
3013 /* This is an upper bound for view numbers that the assembler may | |
3014 assign to symbolic views output in this translation. It is used to | |
3015 decide how big a field to use to represent view numbers in | |
3016 symview-classed attributes. */ | |
3017 | |
3018 static var_loc_view symview_upper_bound; | |
3019 | |
3020 /* If we're keep track of location views and their reset points, and | |
3021 INSN is a reset point (i.e., it necessarily advances the PC), mark | |
3022 the next view in TABLE as reset. */ | |
3023 | |
3024 static void | |
3025 maybe_reset_location_view (rtx_insn *insn, dw_line_info_table *table) | |
3026 { | |
3027 if (!debug_internal_reset_location_views) | |
3028 return; | |
3029 | |
3030 /* Maybe turn (part of?) this test into a default target hook. */ | |
3031 int reset = 0; | |
3032 | |
3033 if (targetm.reset_location_view) | |
3034 reset = targetm.reset_location_view (insn); | |
3035 | |
3036 if (reset) | |
3037 ; | |
3038 else if (JUMP_TABLE_DATA_P (insn)) | |
3039 reset = 1; | |
3040 else if (GET_CODE (insn) == USE | |
3041 || GET_CODE (insn) == CLOBBER | |
3042 || GET_CODE (insn) == ASM_INPUT | |
3043 || asm_noperands (insn) >= 0) | |
3044 ; | |
3045 else if (get_attr_min_length (insn) > 0) | |
3046 reset = 1; | |
3047 | |
3048 if (reset > 0 && !RESETTING_VIEW_P (table->view)) | |
3049 RESET_NEXT_VIEW (table->view); | |
3050 } | |
2871 | 3051 |
2872 /* Each DIE attribute has a field specifying the attribute kind, | 3052 /* Each DIE attribute has a field specifying the attribute kind, |
2873 a link to the next attribute in the chain, and an attribute value. | 3053 a link to the next attribute in the chain, and an attribute value. |
2874 Attributes are typically linked below the DIE they modify. */ | 3054 Attributes are typically linked below the DIE they modify. */ |
2875 | 3055 |
3064 #else | 3244 #else |
3065 #define DWARF2_ASM_LINE_DEBUG_INFO 0 | 3245 #define DWARF2_ASM_LINE_DEBUG_INFO 0 |
3066 #endif | 3246 #endif |
3067 #endif | 3247 #endif |
3068 | 3248 |
3249 /* Use assembler views in line directives if available. */ | |
3250 #ifndef DWARF2_ASM_VIEW_DEBUG_INFO | |
3251 #ifdef HAVE_AS_DWARF2_DEBUG_VIEW | |
3252 #define DWARF2_ASM_VIEW_DEBUG_INFO 1 | |
3253 #else | |
3254 #define DWARF2_ASM_VIEW_DEBUG_INFO 0 | |
3255 #endif | |
3256 #endif | |
3257 | |
3258 /* Return true if GCC configure detected assembler support for .loc. */ | |
3259 | |
3260 bool | |
3261 dwarf2out_default_as_loc_support (void) | |
3262 { | |
3263 return DWARF2_ASM_LINE_DEBUG_INFO; | |
3264 #if (GCC_VERSION >= 3000) | |
3265 # undef DWARF2_ASM_LINE_DEBUG_INFO | |
3266 # pragma GCC poison DWARF2_ASM_LINE_DEBUG_INFO | |
3267 #endif | |
3268 } | |
3269 | |
3270 /* Return true if GCC configure detected assembler support for views | |
3271 in .loc directives. */ | |
3272 | |
3273 bool | |
3274 dwarf2out_default_as_locview_support (void) | |
3275 { | |
3276 return DWARF2_ASM_VIEW_DEBUG_INFO; | |
3277 #if (GCC_VERSION >= 3000) | |
3278 # undef DWARF2_ASM_VIEW_DEBUG_INFO | |
3279 # pragma GCC poison DWARF2_ASM_VIEW_DEBUG_INFO | |
3280 #endif | |
3281 } | |
3282 | |
3283 /* A bit is set in ZERO_VIEW_P if we are using the assembler-supported | |
3284 view computation, and it refers to a view identifier for which we | |
3285 will not emit a label because it is known to map to a view number | |
3286 zero. We won't allocate the bitmap if we're not using assembler | |
3287 support for location views, but we have to make the variable | |
3288 visible for GGC and for code that will be optimized out for lack of | |
3289 support but that's still parsed and compiled. We could abstract it | |
3290 out with macros, but it's not worth it. */ | |
3291 static GTY(()) bitmap zero_view_p; | |
3292 | |
3293 /* Evaluate to TRUE iff N is known to identify the first location view | |
3294 at its PC. When not using assembler location view computation, | |
3295 that must be view number zero. Otherwise, ZERO_VIEW_P is allocated | |
3296 and views label numbers recorded in it are the ones known to be | |
3297 zero. */ | |
3298 #define ZERO_VIEW_P(N) ((N) == (var_loc_view)0 \ | |
3299 || (N) == (var_loc_view)-1 \ | |
3300 || (zero_view_p \ | |
3301 && bitmap_bit_p (zero_view_p, (N)))) | |
3302 | |
3303 /* Return true iff we're to emit .loc directives for the assembler to | |
3304 generate line number sections. | |
3305 | |
3306 When we're not emitting views, all we need from the assembler is | |
3307 support for .loc directives. | |
3308 | |
3309 If we are emitting views, we can only use the assembler's .loc | |
3310 support if it also supports views. | |
3311 | |
3312 When the compiler is emitting the line number programs and | |
3313 computing view numbers itself, it resets view numbers at known PC | |
3314 changes and counts from that, and then it emits view numbers as | |
3315 literal constants in locviewlists. There are cases in which the | |
3316 compiler is not sure about PC changes, e.g. when extra alignment is | |
3317 requested for a label. In these cases, the compiler may not reset | |
3318 the view counter, and the potential PC advance in the line number | |
3319 program will use an opcode that does not reset the view counter | |
3320 even if the PC actually changes, so that compiler and debug info | |
3321 consumer can keep view numbers in sync. | |
3322 | |
3323 When the compiler defers view computation to the assembler, it | |
3324 emits symbolic view numbers in locviewlists, with the exception of | |
3325 views known to be zero (forced resets, or reset after | |
3326 compiler-visible PC changes): instead of emitting symbols for | |
3327 these, we emit literal zero and assert the assembler agrees with | |
3328 the compiler's assessment. We could use symbolic views everywhere, | |
3329 instead of special-casing zero views, but then we'd be unable to | |
3330 optimize out locviewlists that contain only zeros. */ | |
3331 | |
3332 static bool | |
3333 output_asm_line_debug_info (void) | |
3334 { | |
3335 return (dwarf2out_as_loc_support | |
3336 && (dwarf2out_as_locview_support | |
3337 || !debug_variable_location_views)); | |
3338 } | |
3339 | |
3069 /* Minimum line offset in a special line info. opcode. | 3340 /* Minimum line offset in a special line info. opcode. |
3070 This value was chosen to give a reasonable range of values. */ | 3341 This value was chosen to give a reasonable range of values. */ |
3071 #define DWARF_LINE_BASE -10 | 3342 #define DWARF_LINE_BASE -10 |
3072 | 3343 |
3073 /* First special line opcode - leave room for the standard opcodes. */ | 3344 /* First special line opcode - leave room for the standard opcodes. */ |
3173 as first CONCAT operand and NOTE_INSN_VAR_LOCATION resp. | 3444 as first CONCAT operand and NOTE_INSN_VAR_LOCATION resp. |
3174 NULL as second operand. */ | 3445 NULL as second operand. */ |
3175 rtx GTY (()) loc; | 3446 rtx GTY (()) loc; |
3176 const char * GTY (()) label; | 3447 const char * GTY (()) label; |
3177 struct var_loc_node * GTY (()) next; | 3448 struct var_loc_node * GTY (()) next; |
3449 var_loc_view view; | |
3178 }; | 3450 }; |
3179 | 3451 |
3180 /* Variable location list. */ | 3452 /* Variable location list. */ |
3181 struct GTY ((for_user)) var_loc_list_def { | 3453 struct GTY ((for_user)) var_loc_list_def { |
3182 struct var_loc_node * GTY (()) first; | 3454 struct var_loc_node * GTY (()) first; |
3329 we do it at the end of compilation. */ | 3601 we do it at the end of compilation. */ |
3330 static GTY(()) vec<tree, va_gc> *generic_type_instances; | 3602 static GTY(()) vec<tree, va_gc> *generic_type_instances; |
3331 | 3603 |
3332 /* Offset from the "steady-state frame pointer" to the frame base, | 3604 /* Offset from the "steady-state frame pointer" to the frame base, |
3333 within the current function. */ | 3605 within the current function. */ |
3334 static HOST_WIDE_INT frame_pointer_fb_offset; | 3606 static poly_int64 frame_pointer_fb_offset; |
3335 static bool frame_pointer_fb_offset_valid; | 3607 static bool frame_pointer_fb_offset_valid; |
3336 | 3608 |
3337 static vec<dw_die_ref> base_types; | 3609 static vec<dw_die_ref> base_types; |
3338 | 3610 |
3339 /* Flags to represent a set of attribute classes for attributes that represent | 3611 /* Flags to represent a set of attribute classes for attributes that represent |
3375 static void add_AT_die_ref (dw_die_ref, enum dwarf_attribute, dw_die_ref); | 3647 static void add_AT_die_ref (dw_die_ref, enum dwarf_attribute, dw_die_ref); |
3376 static void add_AT_specification (dw_die_ref, dw_die_ref); | 3648 static void add_AT_specification (dw_die_ref, dw_die_ref); |
3377 static inline dw_die_ref AT_ref (dw_attr_node *); | 3649 static inline dw_die_ref AT_ref (dw_attr_node *); |
3378 static inline int AT_ref_external (dw_attr_node *); | 3650 static inline int AT_ref_external (dw_attr_node *); |
3379 static inline void set_AT_ref_external (dw_attr_node *, int); | 3651 static inline void set_AT_ref_external (dw_attr_node *, int); |
3380 static void add_AT_fde_ref (dw_die_ref, enum dwarf_attribute, unsigned); | |
3381 static void add_AT_loc (dw_die_ref, enum dwarf_attribute, dw_loc_descr_ref); | 3652 static void add_AT_loc (dw_die_ref, enum dwarf_attribute, dw_loc_descr_ref); |
3382 static inline dw_loc_descr_ref AT_loc (dw_attr_node *); | 3653 static inline dw_loc_descr_ref AT_loc (dw_attr_node *); |
3383 static void add_AT_loc_list (dw_die_ref, enum dwarf_attribute, | 3654 static void add_AT_loc_list (dw_die_ref, enum dwarf_attribute, |
3384 dw_loc_list_ref); | 3655 dw_loc_list_ref); |
3385 static inline dw_loc_list_ref AT_loc_list (dw_attr_node *); | 3656 static inline dw_loc_list_ref AT_loc_list (dw_attr_node *); |
3657 static void add_AT_view_list (dw_die_ref, enum dwarf_attribute); | |
3658 static inline dw_loc_list_ref AT_loc_list (dw_attr_node *); | |
3386 static addr_table_entry *add_addr_table_entry (void *, enum ate_kind); | 3659 static addr_table_entry *add_addr_table_entry (void *, enum ate_kind); |
3387 static void remove_addr_table_entry (addr_table_entry *); | 3660 static void remove_addr_table_entry (addr_table_entry *); |
3388 static void add_AT_addr (dw_die_ref, enum dwarf_attribute, rtx, bool); | 3661 static void add_AT_addr (dw_die_ref, enum dwarf_attribute, rtx, bool); |
3389 static inline rtx AT_addr (dw_attr_node *); | 3662 static inline rtx AT_addr (dw_attr_node *); |
3663 static void add_AT_symview (dw_die_ref, enum dwarf_attribute, const char *); | |
3390 static void add_AT_lbl_id (dw_die_ref, enum dwarf_attribute, const char *); | 3664 static void add_AT_lbl_id (dw_die_ref, enum dwarf_attribute, const char *); |
3391 static void add_AT_lineptr (dw_die_ref, enum dwarf_attribute, const char *); | 3665 static void add_AT_lineptr (dw_die_ref, enum dwarf_attribute, const char *); |
3392 static void add_AT_macptr (dw_die_ref, enum dwarf_attribute, const char *); | 3666 static void add_AT_macptr (dw_die_ref, enum dwarf_attribute, const char *); |
3393 static void add_AT_loclistsptr (dw_die_ref, enum dwarf_attribute, | |
3394 const char *); | |
3395 static void add_AT_offset (dw_die_ref, enum dwarf_attribute, | |
3396 unsigned HOST_WIDE_INT); | |
3397 static void add_AT_range_list (dw_die_ref, enum dwarf_attribute, | 3667 static void add_AT_range_list (dw_die_ref, enum dwarf_attribute, |
3398 unsigned long, bool); | 3668 unsigned long, bool); |
3399 static inline const char *AT_lbl (dw_attr_node *); | 3669 static inline const char *AT_lbl (dw_attr_node *); |
3400 static dw_attr_node *get_AT (dw_die_ref, enum dwarf_attribute); | 3670 static dw_attr_node *get_AT (dw_die_ref, enum dwarf_attribute); |
3401 static const char *get_AT_low_pc (dw_die_ref); | 3671 static const char *get_AT_low_pc (dw_die_ref); |
3402 static const char *get_AT_hi_pc (dw_die_ref); | |
3403 static const char *get_AT_string (dw_die_ref, enum dwarf_attribute); | 3672 static const char *get_AT_string (dw_die_ref, enum dwarf_attribute); |
3404 static int get_AT_flag (dw_die_ref, enum dwarf_attribute); | 3673 static int get_AT_flag (dw_die_ref, enum dwarf_attribute); |
3405 static unsigned get_AT_unsigned (dw_die_ref, enum dwarf_attribute); | 3674 static unsigned get_AT_unsigned (dw_die_ref, enum dwarf_attribute); |
3406 static inline dw_die_ref get_AT_ref (dw_die_ref, enum dwarf_attribute); | 3675 static inline dw_die_ref get_AT_ref (dw_die_ref, enum dwarf_attribute); |
3676 static bool is_c (void); | |
3407 static bool is_cxx (void); | 3677 static bool is_cxx (void); |
3408 static bool is_cxx (const_tree); | 3678 static bool is_cxx (const_tree); |
3409 static bool is_fortran (void); | 3679 static bool is_fortran (void); |
3410 static bool is_ada (void); | 3680 static bool is_ada (void); |
3411 static bool remove_AT (dw_die_ref, enum dwarf_attribute); | 3681 static bool remove_AT (dw_die_ref, enum dwarf_attribute); |
3417 static dw_die_ref lookup_type_die_strip_naming_typedef (tree); | 3687 static dw_die_ref lookup_type_die_strip_naming_typedef (tree); |
3418 static void equate_type_number_to_die (tree, dw_die_ref); | 3688 static void equate_type_number_to_die (tree, dw_die_ref); |
3419 static dw_die_ref lookup_decl_die (tree); | 3689 static dw_die_ref lookup_decl_die (tree); |
3420 static var_loc_list *lookup_decl_loc (const_tree); | 3690 static var_loc_list *lookup_decl_loc (const_tree); |
3421 static void equate_decl_number_to_die (tree, dw_die_ref); | 3691 static void equate_decl_number_to_die (tree, dw_die_ref); |
3422 static struct var_loc_node *add_var_loc_to_decl (tree, rtx, const char *); | 3692 static struct var_loc_node *add_var_loc_to_decl (tree, rtx, const char *, var_loc_view); |
3423 static void print_spaces (FILE *); | 3693 static void print_spaces (FILE *); |
3424 static void print_die (dw_die_ref, FILE *); | 3694 static void print_die (dw_die_ref, FILE *); |
3425 static void loc_checksum (dw_loc_descr_ref, struct md5_ctx *); | 3695 static void loc_checksum (dw_loc_descr_ref, struct md5_ctx *); |
3426 static void attr_checksum (dw_attr_node *, struct md5_ctx *, int *); | 3696 static void attr_checksum (dw_attr_node *, struct md5_ctx *, int *); |
3427 static void die_checksum (dw_die_ref, struct md5_ctx *, int *); | 3697 static void die_checksum (dw_die_ref, struct md5_ctx *, int *); |
3438 static int same_loc_p (dw_loc_descr_ref, dw_loc_descr_ref, int *); | 3708 static int same_loc_p (dw_loc_descr_ref, dw_loc_descr_ref, int *); |
3439 static int same_dw_val_p (const dw_val_node *, const dw_val_node *, int *); | 3709 static int same_dw_val_p (const dw_val_node *, const dw_val_node *, int *); |
3440 static int same_attr_p (dw_attr_node *, dw_attr_node *, int *); | 3710 static int same_attr_p (dw_attr_node *, dw_attr_node *, int *); |
3441 static int same_die_p (dw_die_ref, dw_die_ref, int *); | 3711 static int same_die_p (dw_die_ref, dw_die_ref, int *); |
3442 static int is_type_die (dw_die_ref); | 3712 static int is_type_die (dw_die_ref); |
3443 static int is_comdat_die (dw_die_ref); | |
3444 static inline bool is_template_instantiation (dw_die_ref); | 3713 static inline bool is_template_instantiation (dw_die_ref); |
3445 static int is_declaration_die (dw_die_ref); | 3714 static int is_declaration_die (dw_die_ref); |
3446 static int should_move_die_to_comdat (dw_die_ref); | 3715 static int should_move_die_to_comdat (dw_die_ref); |
3447 static dw_die_ref clone_as_declaration (dw_die_ref); | 3716 static dw_die_ref clone_as_declaration (dw_die_ref); |
3448 static dw_die_ref clone_die (dw_die_ref); | 3717 static dw_die_ref clone_die (dw_die_ref); |
3495 static dw_die_ref subrange_type_die (tree, tree, tree, tree, dw_die_ref); | 3764 static dw_die_ref subrange_type_die (tree, tree, tree, tree, dw_die_ref); |
3496 static int decl_quals (const_tree); | 3765 static int decl_quals (const_tree); |
3497 static dw_die_ref modified_type_die (tree, int, bool, dw_die_ref); | 3766 static dw_die_ref modified_type_die (tree, int, bool, dw_die_ref); |
3498 static dw_die_ref generic_parameter_die (tree, tree, bool, dw_die_ref); | 3767 static dw_die_ref generic_parameter_die (tree, tree, bool, dw_die_ref); |
3499 static dw_die_ref template_parameter_pack_die (tree, tree, dw_die_ref); | 3768 static dw_die_ref template_parameter_pack_die (tree, tree, dw_die_ref); |
3500 static int type_is_enum (const_tree); | |
3501 static unsigned int dbx_reg_number (const_rtx); | 3769 static unsigned int dbx_reg_number (const_rtx); |
3502 static void add_loc_descr_op_piece (dw_loc_descr_ref *, int); | 3770 static void add_loc_descr_op_piece (dw_loc_descr_ref *, int); |
3503 static dw_loc_descr_ref reg_loc_descriptor (rtx, enum var_init_status); | 3771 static dw_loc_descr_ref reg_loc_descriptor (rtx, enum var_init_status); |
3504 static dw_loc_descr_ref one_reg_loc_descriptor (unsigned int, | 3772 static dw_loc_descr_ref one_reg_loc_descriptor (unsigned int, |
3505 enum var_init_status); | 3773 enum var_init_status); |
3506 static dw_loc_descr_ref multiple_reg_loc_descriptor (rtx, rtx, | 3774 static dw_loc_descr_ref multiple_reg_loc_descriptor (rtx, rtx, |
3507 enum var_init_status); | 3775 enum var_init_status); |
3508 static dw_loc_descr_ref based_loc_descr (rtx, HOST_WIDE_INT, | 3776 static dw_loc_descr_ref based_loc_descr (rtx, poly_int64, |
3509 enum var_init_status); | 3777 enum var_init_status); |
3510 static int is_based_loc (const_rtx); | 3778 static int is_based_loc (const_rtx); |
3511 static bool resolve_one_addr (rtx *); | 3779 static bool resolve_one_addr (rtx *); |
3512 static dw_loc_descr_ref concat_loc_descriptor (rtx, rtx, | 3780 static dw_loc_descr_ref concat_loc_descriptor (rtx, rtx, |
3513 enum var_init_status); | 3781 enum var_init_status); |
3518 static void add_loc_list (dw_loc_list_ref *ret, dw_loc_list_ref list); | 3786 static void add_loc_list (dw_loc_list_ref *ret, dw_loc_list_ref list); |
3519 static dw_loc_list_ref loc_list_from_tree (tree, int, | 3787 static dw_loc_list_ref loc_list_from_tree (tree, int, |
3520 struct loc_descr_context *); | 3788 struct loc_descr_context *); |
3521 static dw_loc_descr_ref loc_descriptor_from_tree (tree, int, | 3789 static dw_loc_descr_ref loc_descriptor_from_tree (tree, int, |
3522 struct loc_descr_context *); | 3790 struct loc_descr_context *); |
3523 static HOST_WIDE_INT ceiling (HOST_WIDE_INT, unsigned int); | |
3524 static tree field_type (const_tree); | 3791 static tree field_type (const_tree); |
3525 static unsigned int simple_type_align_in_bits (const_tree); | 3792 static unsigned int simple_type_align_in_bits (const_tree); |
3526 static unsigned int simple_decl_align_in_bits (const_tree); | 3793 static unsigned int simple_decl_align_in_bits (const_tree); |
3527 static unsigned HOST_WIDE_INT simple_type_size_in_bits (const_tree); | 3794 static unsigned HOST_WIDE_INT simple_type_size_in_bits (const_tree); |
3528 struct vlr_context; | 3795 struct vlr_context; |
3539 static rtx rtl_for_decl_location (tree); | 3806 static rtx rtl_for_decl_location (tree); |
3540 static bool add_location_or_const_value_attribute (dw_die_ref, tree, bool); | 3807 static bool add_location_or_const_value_attribute (dw_die_ref, tree, bool); |
3541 static bool tree_add_const_value_attribute (dw_die_ref, tree); | 3808 static bool tree_add_const_value_attribute (dw_die_ref, tree); |
3542 static bool tree_add_const_value_attribute_for_decl (dw_die_ref, tree); | 3809 static bool tree_add_const_value_attribute_for_decl (dw_die_ref, tree); |
3543 static void add_name_attribute (dw_die_ref, const char *); | 3810 static void add_name_attribute (dw_die_ref, const char *); |
3811 static void add_desc_attribute (dw_die_ref, tree); | |
3544 static void add_gnat_descriptive_type_attribute (dw_die_ref, tree, dw_die_ref); | 3812 static void add_gnat_descriptive_type_attribute (dw_die_ref, tree, dw_die_ref); |
3545 static void add_comp_dir_attribute (dw_die_ref); | 3813 static void add_comp_dir_attribute (dw_die_ref); |
3546 static void add_scalar_info (dw_die_ref, enum dwarf_attribute, tree, int, | 3814 static void add_scalar_info (dw_die_ref, enum dwarf_attribute, tree, int, |
3547 struct loc_descr_context *); | 3815 struct loc_descr_context *); |
3548 static void add_bound_info (dw_die_ref, enum dwarf_attribute, tree, | 3816 static void add_bound_info (dw_die_ref, enum dwarf_attribute, tree, |
3552 static void add_alignment_attribute (dw_die_ref, tree); | 3820 static void add_alignment_attribute (dw_die_ref, tree); |
3553 static inline void add_bit_offset_attribute (dw_die_ref, tree, | 3821 static inline void add_bit_offset_attribute (dw_die_ref, tree, |
3554 struct vlr_context *); | 3822 struct vlr_context *); |
3555 static void add_bit_size_attribute (dw_die_ref, tree); | 3823 static void add_bit_size_attribute (dw_die_ref, tree); |
3556 static void add_prototyped_attribute (dw_die_ref, tree); | 3824 static void add_prototyped_attribute (dw_die_ref, tree); |
3557 static dw_die_ref add_abstract_origin_attribute (dw_die_ref, tree); | 3825 static void add_abstract_origin_attribute (dw_die_ref, tree); |
3558 static void add_pure_or_virtual_attribute (dw_die_ref, tree); | 3826 static void add_pure_or_virtual_attribute (dw_die_ref, tree); |
3559 static void add_src_coords_attributes (dw_die_ref, tree); | 3827 static void add_src_coords_attributes (dw_die_ref, tree); |
3560 static void add_name_and_src_coords_attributes (dw_die_ref, tree, bool = false); | 3828 static void add_name_and_src_coords_attributes (dw_die_ref, tree, bool = false); |
3561 static void add_discr_value (dw_die_ref, dw_discr_value *); | 3829 static void add_discr_value (dw_die_ref, dw_discr_value *); |
3562 static void add_discr_list (dw_die_ref, dw_discr_list_ref); | 3830 static void add_discr_list (dw_die_ref, dw_discr_list_ref); |
3563 static inline dw_discr_list_ref AT_discr_list (dw_attr_node *); | 3831 static inline dw_discr_list_ref AT_discr_list (dw_attr_node *); |
3564 static void push_decl_scope (tree); | |
3565 static void pop_decl_scope (void); | |
3566 static dw_die_ref scope_die_for (tree, dw_die_ref); | 3832 static dw_die_ref scope_die_for (tree, dw_die_ref); |
3567 static inline int local_scope_p (dw_die_ref); | 3833 static inline int local_scope_p (dw_die_ref); |
3568 static inline int class_scope_p (dw_die_ref); | 3834 static inline int class_scope_p (dw_die_ref); |
3569 static inline int class_or_namespace_scope_p (dw_die_ref); | 3835 static inline int class_or_namespace_scope_p (dw_die_ref); |
3570 static void add_type_attribute (dw_die_ref, tree, int, bool, dw_die_ref); | 3836 static void add_type_attribute (dw_die_ref, tree, int, bool, dw_die_ref); |
3599 enum debug_info_usage); | 3865 enum debug_info_usage); |
3600 static void gen_subroutine_type_die (tree, dw_die_ref); | 3866 static void gen_subroutine_type_die (tree, dw_die_ref); |
3601 static void gen_typedef_die (tree, dw_die_ref); | 3867 static void gen_typedef_die (tree, dw_die_ref); |
3602 static void gen_type_die (tree, dw_die_ref); | 3868 static void gen_type_die (tree, dw_die_ref); |
3603 static void gen_block_die (tree, dw_die_ref); | 3869 static void gen_block_die (tree, dw_die_ref); |
3604 static void decls_for_scope (tree, dw_die_ref); | 3870 static void decls_for_scope (tree, dw_die_ref, bool = true); |
3605 static bool is_naming_typedef_decl (const_tree); | 3871 static bool is_naming_typedef_decl (const_tree); |
3606 static inline dw_die_ref get_context_die (tree); | 3872 static inline dw_die_ref get_context_die (tree); |
3607 static void gen_namespace_die (tree, dw_die_ref); | 3873 static void gen_namespace_die (tree, dw_die_ref); |
3608 static dw_die_ref gen_namelist_decl (tree, dw_die_ref, tree); | 3874 static dw_die_ref gen_namelist_decl (tree, dw_die_ref, tree); |
3609 static dw_die_ref gen_decl_die (tree, tree, struct vlr_context *, dw_die_ref); | 3875 static dw_die_ref gen_decl_die (tree, tree, struct vlr_context *, dw_die_ref); |
3617 static void gen_generic_params_dies (tree); | 3883 static void gen_generic_params_dies (tree); |
3618 static void gen_tagged_type_die (tree, dw_die_ref, enum debug_info_usage); | 3884 static void gen_tagged_type_die (tree, dw_die_ref, enum debug_info_usage); |
3619 static void gen_type_die_with_usage (tree, dw_die_ref, enum debug_info_usage); | 3885 static void gen_type_die_with_usage (tree, dw_die_ref, enum debug_info_usage); |
3620 static void splice_child_die (dw_die_ref, dw_die_ref); | 3886 static void splice_child_die (dw_die_ref, dw_die_ref); |
3621 static int file_info_cmp (const void *, const void *); | 3887 static int file_info_cmp (const void *, const void *); |
3622 static dw_loc_list_ref new_loc_list (dw_loc_descr_ref, const char *, | 3888 static dw_loc_list_ref new_loc_list (dw_loc_descr_ref, const char *, var_loc_view, |
3623 const char *, const char *); | 3889 const char *, var_loc_view, const char *); |
3624 static void output_loc_list (dw_loc_list_ref); | 3890 static void output_loc_list (dw_loc_list_ref); |
3625 static char *gen_internal_sym (const char *); | 3891 static char *gen_internal_sym (const char *); |
3626 static bool want_pubnames (void); | 3892 static bool want_pubnames (void); |
3627 | 3893 |
3628 static void prune_unmark_dies (dw_die_ref); | 3894 static void prune_unmark_dies (dw_die_ref); |
3633 static void prune_unused_types_prune (dw_die_ref); | 3899 static void prune_unused_types_prune (dw_die_ref); |
3634 static void prune_unused_types (void); | 3900 static void prune_unused_types (void); |
3635 static int maybe_emit_file (struct dwarf_file_data *fd); | 3901 static int maybe_emit_file (struct dwarf_file_data *fd); |
3636 static inline const char *AT_vms_delta1 (dw_attr_node *); | 3902 static inline const char *AT_vms_delta1 (dw_attr_node *); |
3637 static inline const char *AT_vms_delta2 (dw_attr_node *); | 3903 static inline const char *AT_vms_delta2 (dw_attr_node *); |
3638 static inline void add_AT_vms_delta (dw_die_ref, enum dwarf_attribute, | |
3639 const char *, const char *); | |
3640 static void append_entry_to_tmpl_value_parm_die_table (dw_die_ref, tree); | 3904 static void append_entry_to_tmpl_value_parm_die_table (dw_die_ref, tree); |
3641 static void gen_remaining_tmpl_value_param_die_attribute (void); | 3905 static void gen_remaining_tmpl_value_param_die_attribute (void); |
3642 static bool generic_type_p (tree); | 3906 static bool generic_type_p (tree); |
3643 static void schedule_generic_params_dies_gen (tree t); | 3907 static void schedule_generic_params_dies_gen (tree t); |
3644 static void gen_scheduled_generic_parms_dies (void); | 3908 static void gen_scheduled_generic_parms_dies (void); |
3665 | 3929 |
3666 static inline enum dwarf_location_atom | 3930 static inline enum dwarf_location_atom |
3667 dw_addr_op (enum dtprel_bool dtprel) | 3931 dw_addr_op (enum dtprel_bool dtprel) |
3668 { | 3932 { |
3669 if (dtprel == dtprel_true) | 3933 if (dtprel == dtprel_true) |
3670 return (dwarf_split_debug_info ? DW_OP_GNU_const_index | 3934 return (dwarf_split_debug_info ? dwarf_OP (DW_OP_constx) |
3671 : (DWARF2_ADDR_SIZE == 4 ? DW_OP_const4u : DW_OP_const8u)); | 3935 : (DWARF2_ADDR_SIZE == 4 ? DW_OP_const4u : DW_OP_const8u)); |
3672 else | 3936 else |
3673 return dwarf_split_debug_info ? DW_OP_GNU_addr_index : DW_OP_addr; | 3937 return dwarf_split_debug_info ? dwarf_OP (DW_OP_addrx) : DW_OP_addr; |
3674 } | 3938 } |
3675 | 3939 |
3676 /* Return a pointer to a newly allocated address location description. If | 3940 /* Return a pointer to a newly allocated address location description. If |
3677 dwarf_split_debug_info is true, then record the address with the appropriate | 3941 dwarf_split_debug_info is true, then record the address with the appropriate |
3678 relocation. */ | 3942 relocation. */ |
3910 #define COLD_END_LABEL "Letext_cold" | 4174 #define COLD_END_LABEL "Letext_cold" |
3911 #endif | 4175 #endif |
3912 #ifndef BLOCK_BEGIN_LABEL | 4176 #ifndef BLOCK_BEGIN_LABEL |
3913 #define BLOCK_BEGIN_LABEL "LBB" | 4177 #define BLOCK_BEGIN_LABEL "LBB" |
3914 #endif | 4178 #endif |
4179 #ifndef BLOCK_INLINE_ENTRY_LABEL | |
4180 #define BLOCK_INLINE_ENTRY_LABEL "LBI" | |
4181 #endif | |
3915 #ifndef BLOCK_END_LABEL | 4182 #ifndef BLOCK_END_LABEL |
3916 #define BLOCK_END_LABEL "LBE" | 4183 #define BLOCK_END_LABEL "LBE" |
3917 #endif | 4184 #endif |
3918 #ifndef LINE_CODE_LABEL | 4185 #ifndef LINE_CODE_LABEL |
3919 #define LINE_CODE_LABEL "LM" | 4186 #define LINE_CODE_LABEL "LM" |
4146 { | 4413 { |
4147 return a->dw_attr_val.val_class; | 4414 return a->dw_attr_val.val_class; |
4148 } | 4415 } |
4149 | 4416 |
4150 /* Return the index for any attribute that will be referenced with a | 4417 /* Return the index for any attribute that will be referenced with a |
4151 DW_FORM_GNU_addr_index or DW_FORM_GNU_str_index. String indices | 4418 DW_FORM_addrx/GNU_addr_index or DW_FORM_strx/GNU_str_index. String |
4152 are stored in dw_attr_val.v.val_str for reference counting | 4419 indices are stored in dw_attr_val.v.val_str for reference counting |
4153 pruning. */ | 4420 pruning. */ |
4154 | 4421 |
4155 static inline unsigned int | 4422 static inline unsigned int |
4156 AT_index (dw_attr_node *a) | 4423 AT_index (dw_attr_node *a) |
4157 { | 4424 { |
4411 { | 4678 { |
4412 char label[MAX_ARTIFICIAL_LABEL_BYTES]; | 4679 char label[MAX_ARTIFICIAL_LABEL_BYTES]; |
4413 /* Already indirect is a no op. */ | 4680 /* Already indirect is a no op. */ |
4414 if (node->form == DW_FORM_strp | 4681 if (node->form == DW_FORM_strp |
4415 || node->form == DW_FORM_line_strp | 4682 || node->form == DW_FORM_line_strp |
4416 || node->form == DW_FORM_GNU_str_index) | 4683 || node->form == dwarf_FORM (DW_FORM_strx)) |
4417 { | 4684 { |
4418 gcc_assert (node->label); | 4685 gcc_assert (node->label); |
4419 return; | 4686 return; |
4420 } | 4687 } |
4421 ASM_GENERATE_INTERNAL_LABEL (label, "LASF", dw2_string_counter); | 4688 ASM_GENERATE_INTERNAL_LABEL (label, "LASF", dw2_string_counter); |
4427 node->form = DW_FORM_strp; | 4694 node->form = DW_FORM_strp; |
4428 node->index = NOT_INDEXED; | 4695 node->index = NOT_INDEXED; |
4429 } | 4696 } |
4430 else | 4697 else |
4431 { | 4698 { |
4432 node->form = DW_FORM_GNU_str_index; | 4699 node->form = dwarf_FORM (DW_FORM_strx); |
4433 node->index = NO_INDEX_ASSIGNED; | 4700 node->index = NO_INDEX_ASSIGNED; |
4434 } | 4701 } |
4435 } | 4702 } |
4436 | 4703 |
4437 /* A helper function for dwarf2out_finish, called to reset indirect | 4704 /* A helper function for dwarf2out_finish, called to reset indirect |
4440 | 4707 |
4441 int | 4708 int |
4442 reset_indirect_string (indirect_string_node **h, void *) | 4709 reset_indirect_string (indirect_string_node **h, void *) |
4443 { | 4710 { |
4444 struct indirect_string_node *node = *h; | 4711 struct indirect_string_node *node = *h; |
4445 if (node->form == DW_FORM_strp || node->form == DW_FORM_GNU_str_index) | 4712 if (node->form == DW_FORM_strp || node->form == dwarf_FORM (DW_FORM_strx)) |
4446 { | 4713 { |
4447 free (node->label); | 4714 free (node->label); |
4448 node->label = NULL; | 4715 node->label = NULL; |
4449 node->form = (dwarf_form) 0; | 4716 node->form = (dwarf_form) 0; |
4450 node->index = 0; | 4717 node->index = 0; |
4556 { | 4823 { |
4557 gcc_assert (a && AT_class (a) == dw_val_class_die_ref); | 4824 gcc_assert (a && AT_class (a) == dw_val_class_die_ref); |
4558 a->dw_attr_val.v.val_die_ref.external = i; | 4825 a->dw_attr_val.v.val_die_ref.external = i; |
4559 } | 4826 } |
4560 | 4827 |
4561 /* Add an FDE reference attribute value to a DIE. */ | |
4562 | |
4563 static inline void | |
4564 add_AT_fde_ref (dw_die_ref die, enum dwarf_attribute attr_kind, unsigned int targ_fde) | |
4565 { | |
4566 dw_attr_node attr; | |
4567 | |
4568 attr.dw_attr = attr_kind; | |
4569 attr.dw_attr_val.val_class = dw_val_class_fde_ref; | |
4570 attr.dw_attr_val.val_entry = NULL; | |
4571 attr.dw_attr_val.v.val_fde_index = targ_fde; | |
4572 add_dwarf_attr (die, &attr); | |
4573 } | |
4574 | |
4575 /* Add a location description attribute value to a DIE. */ | 4828 /* Add a location description attribute value to a DIE. */ |
4576 | 4829 |
4577 static inline void | 4830 static inline void |
4578 add_AT_loc (dw_die_ref die, enum dwarf_attribute attr_kind, dw_loc_descr_ref loc) | 4831 add_AT_loc (dw_die_ref die, enum dwarf_attribute attr_kind, dw_loc_descr_ref loc) |
4579 { | 4832 { |
4614 { | 4867 { |
4615 gcc_assert (a && AT_class (a) == dw_val_class_loc_list); | 4868 gcc_assert (a && AT_class (a) == dw_val_class_loc_list); |
4616 return a->dw_attr_val.v.val_loc_list; | 4869 return a->dw_attr_val.v.val_loc_list; |
4617 } | 4870 } |
4618 | 4871 |
4872 /* Add a view list attribute to DIE. It must have a DW_AT_location | |
4873 attribute, because the view list complements the location list. */ | |
4874 | |
4875 static inline void | |
4876 add_AT_view_list (dw_die_ref die, enum dwarf_attribute attr_kind) | |
4877 { | |
4878 dw_attr_node attr; | |
4879 | |
4880 if (XCOFF_DEBUGGING_INFO && !HAVE_XCOFF_DWARF_EXTRAS) | |
4881 return; | |
4882 | |
4883 attr.dw_attr = attr_kind; | |
4884 attr.dw_attr_val.val_class = dw_val_class_view_list; | |
4885 attr.dw_attr_val.val_entry = NULL; | |
4886 attr.dw_attr_val.v.val_view_list = die; | |
4887 add_dwarf_attr (die, &attr); | |
4888 gcc_checking_assert (get_AT (die, DW_AT_location)); | |
4889 gcc_assert (have_location_lists); | |
4890 } | |
4891 | |
4892 /* Return a pointer to the location list referenced by the attribute. | |
4893 If the named attribute is a view list, look up the corresponding | |
4894 DW_AT_location attribute and return its location list. */ | |
4895 | |
4619 static inline dw_loc_list_ref * | 4896 static inline dw_loc_list_ref * |
4620 AT_loc_list_ptr (dw_attr_node *a) | 4897 AT_loc_list_ptr (dw_attr_node *a) |
4621 { | 4898 { |
4622 gcc_assert (a && AT_class (a) == dw_val_class_loc_list); | 4899 gcc_assert (a); |
4623 return &a->dw_attr_val.v.val_loc_list; | 4900 switch (AT_class (a)) |
4901 { | |
4902 case dw_val_class_loc_list: | |
4903 return &a->dw_attr_val.v.val_loc_list; | |
4904 case dw_val_class_view_list: | |
4905 { | |
4906 dw_attr_node *l; | |
4907 l = get_AT (a->dw_attr_val.v.val_view_list, DW_AT_location); | |
4908 if (!l) | |
4909 return NULL; | |
4910 gcc_checking_assert (l + 1 == a); | |
4911 return AT_loc_list_ptr (l); | |
4912 } | |
4913 default: | |
4914 gcc_unreachable (); | |
4915 } | |
4916 } | |
4917 | |
4918 /* Return the location attribute value associated with a view list | |
4919 attribute value. */ | |
4920 | |
4921 static inline dw_val_node * | |
4922 view_list_to_loc_list_val_node (dw_val_node *val) | |
4923 { | |
4924 gcc_assert (val->val_class == dw_val_class_view_list); | |
4925 dw_attr_node *loc = get_AT (val->v.val_view_list, DW_AT_location); | |
4926 if (!loc) | |
4927 return NULL; | |
4928 gcc_checking_assert (&(loc + 1)->dw_attr_val == val); | |
4929 gcc_assert (AT_class (loc) == dw_val_class_loc_list); | |
4930 return &loc->dw_attr_val; | |
4624 } | 4931 } |
4625 | 4932 |
4626 struct addr_hasher : ggc_ptr_hash<addr_table_entry> | 4933 struct addr_hasher : ggc_ptr_hash<addr_table_entry> |
4627 { | 4934 { |
4628 static hashval_t hash (addr_table_entry *); | 4935 static hashval_t hash (addr_table_entry *); |
4826 gcc_assert (a && (AT_class (a) == dw_val_class_file | 5133 gcc_assert (a && (AT_class (a) == dw_val_class_file |
4827 || AT_class (a) == dw_val_class_file_implicit)); | 5134 || AT_class (a) == dw_val_class_file_implicit)); |
4828 return a->dw_attr_val.v.val_file; | 5135 return a->dw_attr_val.v.val_file; |
4829 } | 5136 } |
4830 | 5137 |
4831 /* Add a vms delta attribute value to a DIE. */ | 5138 /* Add a symbolic view identifier attribute value to a DIE. */ |
4832 | 5139 |
4833 static inline void | 5140 static inline void |
4834 add_AT_vms_delta (dw_die_ref die, enum dwarf_attribute attr_kind, | 5141 add_AT_symview (dw_die_ref die, enum dwarf_attribute attr_kind, |
4835 const char *lbl1, const char *lbl2) | 5142 const char *view_label) |
4836 { | 5143 { |
4837 dw_attr_node attr; | 5144 dw_attr_node attr; |
4838 | 5145 |
4839 attr.dw_attr = attr_kind; | 5146 attr.dw_attr = attr_kind; |
4840 attr.dw_attr_val.val_class = dw_val_class_vms_delta; | 5147 attr.dw_attr_val.val_class = dw_val_class_symview; |
4841 attr.dw_attr_val.val_entry = NULL; | 5148 attr.dw_attr_val.val_entry = NULL; |
4842 attr.dw_attr_val.v.val_vms_delta.lbl1 = xstrdup (lbl1); | 5149 attr.dw_attr_val.v.val_symbolic_view = xstrdup (view_label); |
4843 attr.dw_attr_val.v.val_vms_delta.lbl2 = xstrdup (lbl2); | |
4844 add_dwarf_attr (die, &attr); | 5150 add_dwarf_attr (die, &attr); |
4845 } | 5151 } |
4846 | 5152 |
4847 /* Add a label identifier attribute value to a DIE. */ | 5153 /* Add a label identifier attribute value to a DIE. */ |
4848 | 5154 |
4878 attr.dw_attr_val.v.val_lbl_id = xstrdup (label); | 5184 attr.dw_attr_val.v.val_lbl_id = xstrdup (label); |
4879 add_dwarf_attr (die, &attr); | 5185 add_dwarf_attr (die, &attr); |
4880 } | 5186 } |
4881 | 5187 |
4882 /* Add a section offset attribute value to a DIE, an offset into the | 5188 /* Add a section offset attribute value to a DIE, an offset into the |
4883 debug_loclists section. */ | |
4884 | |
4885 static inline void | |
4886 add_AT_loclistsptr (dw_die_ref die, enum dwarf_attribute attr_kind, | |
4887 const char *label) | |
4888 { | |
4889 dw_attr_node attr; | |
4890 | |
4891 attr.dw_attr = attr_kind; | |
4892 attr.dw_attr_val.val_class = dw_val_class_loclistsptr; | |
4893 attr.dw_attr_val.val_entry = NULL; | |
4894 attr.dw_attr_val.v.val_lbl_id = xstrdup (label); | |
4895 add_dwarf_attr (die, &attr); | |
4896 } | |
4897 | |
4898 /* Add a section offset attribute value to a DIE, an offset into the | |
4899 debug_macinfo section. */ | 5189 debug_macinfo section. */ |
4900 | 5190 |
4901 static inline void | 5191 static inline void |
4902 add_AT_macptr (dw_die_ref die, enum dwarf_attribute attr_kind, | 5192 add_AT_macptr (dw_die_ref die, enum dwarf_attribute attr_kind, |
4903 const char *label) | 5193 const char *label) |
4906 | 5196 |
4907 attr.dw_attr = attr_kind; | 5197 attr.dw_attr = attr_kind; |
4908 attr.dw_attr_val.val_class = dw_val_class_macptr; | 5198 attr.dw_attr_val.val_class = dw_val_class_macptr; |
4909 attr.dw_attr_val.val_entry = NULL; | 5199 attr.dw_attr_val.val_entry = NULL; |
4910 attr.dw_attr_val.v.val_lbl_id = xstrdup (label); | 5200 attr.dw_attr_val.v.val_lbl_id = xstrdup (label); |
4911 add_dwarf_attr (die, &attr); | |
4912 } | |
4913 | |
4914 /* Add an offset attribute value to a DIE. */ | |
4915 | |
4916 static inline void | |
4917 add_AT_offset (dw_die_ref die, enum dwarf_attribute attr_kind, | |
4918 unsigned HOST_WIDE_INT offset) | |
4919 { | |
4920 dw_attr_node attr; | |
4921 | |
4922 attr.dw_attr = attr_kind; | |
4923 attr.dw_attr_val.val_class = dw_val_class_offset; | |
4924 attr.dw_attr_val.val_entry = NULL; | |
4925 attr.dw_attr_val.v.val_offset = offset; | |
4926 add_dwarf_attr (die, &attr); | 5201 add_dwarf_attr (die, &attr); |
4927 } | 5202 } |
4928 | 5203 |
4929 /* Add a range_list attribute value to a DIE. When using | 5204 /* Add a range_list attribute value to a DIE. When using |
4930 dwarf_split_debug_info, address attributes in dies destined for the | 5205 dwarf_split_debug_info, address attributes in dies destined for the |
5034 dw_attr_node *a = get_AT (die, DW_AT_low_pc); | 5309 dw_attr_node *a = get_AT (die, DW_AT_low_pc); |
5035 | 5310 |
5036 return a ? AT_lbl (a) : NULL; | 5311 return a ? AT_lbl (a) : NULL; |
5037 } | 5312 } |
5038 | 5313 |
5039 /* Return the "high pc" attribute value, typically associated with a subprogram | |
5040 DIE. Return null if the "high pc" attribute is either not present, or if it | |
5041 cannot be represented as an assembler label identifier. */ | |
5042 | |
5043 static inline const char * | |
5044 get_AT_hi_pc (dw_die_ref die) | |
5045 { | |
5046 dw_attr_node *a = get_AT (die, DW_AT_high_pc); | |
5047 | |
5048 return a ? AT_lbl (a) : NULL; | |
5049 } | |
5050 | |
5051 /* Return the value of the string attribute designated by ATTR_KIND, or | 5314 /* Return the value of the string attribute designated by ATTR_KIND, or |
5052 NULL if it is not present. */ | 5315 NULL if it is not present. */ |
5053 | 5316 |
5054 static inline const char * | 5317 static inline const char * |
5055 get_AT_string (dw_die_ref die, enum dwarf_attribute attr_kind) | 5318 get_AT_string (dw_die_ref die, enum dwarf_attribute attr_kind) |
5095 dw_attr_node *a = get_AT (die, attr_kind); | 5358 dw_attr_node *a = get_AT (die, attr_kind); |
5096 | 5359 |
5097 return a ? AT_file (a) : NULL; | 5360 return a ? AT_file (a) : NULL; |
5098 } | 5361 } |
5099 | 5362 |
5100 /* Returns the ultimate TRANSLATION_UNIT_DECL context of DECL or NULL. */ | 5363 /* Return TRUE if the language is C. */ |
5101 | 5364 |
5102 static const_tree | 5365 static inline bool |
5103 get_ultimate_context (const_tree decl) | 5366 is_c (void) |
5104 { | 5367 { |
5105 while (decl && TREE_CODE (decl) != TRANSLATION_UNIT_DECL) | 5368 unsigned int lang = get_AT_unsigned (comp_unit_die (), DW_AT_language); |
5106 { | 5369 |
5107 if (TREE_CODE (decl) == BLOCK) | 5370 return (lang == DW_LANG_C || lang == DW_LANG_C89 || lang == DW_LANG_C99 |
5108 decl = BLOCK_SUPERCONTEXT (decl); | 5371 || lang == DW_LANG_C11 || lang == DW_LANG_ObjC); |
5109 else | 5372 |
5110 decl = get_containing_scope (decl); | 5373 |
5111 } | |
5112 return decl; | |
5113 } | 5374 } |
5114 | 5375 |
5115 /* Return TRUE if the language is C++. */ | 5376 /* Return TRUE if the language is C++. */ |
5116 | 5377 |
5117 static inline bool | 5378 static inline bool |
5483 equate_type_number_to_die (tree type, dw_die_ref type_die) | 5744 equate_type_number_to_die (tree type, dw_die_ref type_die) |
5484 { | 5745 { |
5485 TYPE_SYMTAB_DIE (type) = type_die; | 5746 TYPE_SYMTAB_DIE (type) = type_die; |
5486 } | 5747 } |
5487 | 5748 |
5749 static dw_die_ref maybe_create_die_with_external_ref (tree); | |
5750 struct GTY(()) sym_off_pair | |
5751 { | |
5752 const char * GTY((skip)) sym; | |
5753 unsigned HOST_WIDE_INT off; | |
5754 }; | |
5755 static GTY(()) hash_map<tree, sym_off_pair> *external_die_map; | |
5756 | |
5488 /* Returns a hash value for X (which really is a die_struct). */ | 5757 /* Returns a hash value for X (which really is a die_struct). */ |
5489 | 5758 |
5490 inline hashval_t | 5759 inline hashval_t |
5491 decl_die_hasher::hash (die_node *x) | 5760 decl_die_hasher::hash (die_node *x) |
5492 { | 5761 { |
5507 lookup_decl_die (tree decl) | 5776 lookup_decl_die (tree decl) |
5508 { | 5777 { |
5509 dw_die_ref *die = decl_die_table->find_slot_with_hash (decl, DECL_UID (decl), | 5778 dw_die_ref *die = decl_die_table->find_slot_with_hash (decl, DECL_UID (decl), |
5510 NO_INSERT); | 5779 NO_INSERT); |
5511 if (!die) | 5780 if (!die) |
5512 return NULL; | 5781 { |
5782 if (in_lto_p) | |
5783 return maybe_create_die_with_external_ref (decl); | |
5784 return NULL; | |
5785 } | |
5513 if ((*die)->removed) | 5786 if ((*die)->removed) |
5514 { | 5787 { |
5515 decl_die_table->clear_slot (die); | 5788 decl_die_table->clear_slot (die); |
5516 return NULL; | 5789 return NULL; |
5517 } | 5790 } |
5518 return *die; | 5791 return *die; |
5519 } | 5792 } |
5793 | |
5794 | |
5795 /* Return the DIE associated with BLOCK. */ | |
5796 | |
5797 static inline dw_die_ref | |
5798 lookup_block_die (tree block) | |
5799 { | |
5800 dw_die_ref die = BLOCK_DIE (block); | |
5801 if (!die && in_lto_p) | |
5802 return maybe_create_die_with_external_ref (block); | |
5803 return die; | |
5804 } | |
5805 | |
5806 /* Associate DIE with BLOCK. */ | |
5807 | |
5808 static inline void | |
5809 equate_block_to_die (tree block, dw_die_ref die) | |
5810 { | |
5811 BLOCK_DIE (block) = die; | |
5812 } | |
5813 #undef BLOCK_DIE | |
5520 | 5814 |
5521 | 5815 |
5522 /* For DECL which might have early dwarf output query a SYMBOL + OFFSET | 5816 /* For DECL which might have early dwarf output query a SYMBOL + OFFSET |
5523 style reference. Return true if we found one refering to a DIE for | 5817 style reference. Return true if we found one refering to a DIE for |
5524 DECL, otherwise return false. */ | 5818 DECL, otherwise return false. */ |
5527 dwarf2out_die_ref_for_decl (tree decl, const char **sym, | 5821 dwarf2out_die_ref_for_decl (tree decl, const char **sym, |
5528 unsigned HOST_WIDE_INT *off) | 5822 unsigned HOST_WIDE_INT *off) |
5529 { | 5823 { |
5530 dw_die_ref die; | 5824 dw_die_ref die; |
5531 | 5825 |
5532 if (flag_wpa && !decl_die_table) | 5826 if (in_lto_p) |
5533 return false; | 5827 { |
5828 /* During WPA stage and incremental linking we use a hash-map | |
5829 to store the decl <-> label + offset map. */ | |
5830 if (!external_die_map) | |
5831 return false; | |
5832 sym_off_pair *desc = external_die_map->get (decl); | |
5833 if (!desc) | |
5834 return false; | |
5835 *sym = desc->sym; | |
5836 *off = desc->off; | |
5837 return true; | |
5838 } | |
5534 | 5839 |
5535 if (TREE_CODE (decl) == BLOCK) | 5840 if (TREE_CODE (decl) == BLOCK) |
5536 die = BLOCK_DIE (decl); | 5841 die = lookup_block_die (decl); |
5537 else | 5842 else |
5538 die = lookup_decl_die (decl); | 5843 die = lookup_decl_die (decl); |
5539 if (!die) | 5844 if (!die) |
5540 return false; | 5845 return false; |
5541 | |
5542 /* During WPA stage we currently use DIEs to store the | |
5543 decl <-> label + offset map. That's quite inefficient but it | |
5544 works for now. */ | |
5545 if (flag_wpa) | |
5546 { | |
5547 dw_die_ref ref = get_AT_ref (die, DW_AT_abstract_origin); | |
5548 if (!ref) | |
5549 { | |
5550 gcc_assert (die == comp_unit_die ()); | |
5551 return false; | |
5552 } | |
5553 *off = ref->die_offset; | |
5554 *sym = ref->die_id.die_symbol; | |
5555 return true; | |
5556 } | |
5557 | 5846 |
5558 /* Similar to get_ref_die_offset_label, but using the "correct" | 5847 /* Similar to get_ref_die_offset_label, but using the "correct" |
5559 label. */ | 5848 label. */ |
5560 *off = die->die_offset; | 5849 *off = die->die_offset; |
5561 while (die->die_parent) | 5850 while (die->die_parent) |
5574 add_AT_external_die_ref (dw_die_ref die, enum dwarf_attribute attr_kind, | 5863 add_AT_external_die_ref (dw_die_ref die, enum dwarf_attribute attr_kind, |
5575 const char *symbol, HOST_WIDE_INT offset) | 5864 const char *symbol, HOST_WIDE_INT offset) |
5576 { | 5865 { |
5577 /* Create a fake DIE that contains the reference. Don't use | 5866 /* Create a fake DIE that contains the reference. Don't use |
5578 new_die because we don't want to end up in the limbo list. */ | 5867 new_die because we don't want to end up in the limbo list. */ |
5868 /* ??? We probably want to share these, thus put a ref to the DIE | |
5869 we create here to the external_die_map entry. */ | |
5579 dw_die_ref ref = new_die_raw (die->die_tag); | 5870 dw_die_ref ref = new_die_raw (die->die_tag); |
5580 ref->die_id.die_symbol = IDENTIFIER_POINTER (get_identifier (symbol)); | 5871 ref->die_id.die_symbol = symbol; |
5581 ref->die_offset = offset; | 5872 ref->die_offset = offset; |
5582 ref->with_offset = 1; | 5873 ref->with_offset = 1; |
5583 add_AT_die_ref (die, attr_kind, ref); | 5874 add_AT_die_ref (die, attr_kind, ref); |
5584 } | 5875 } |
5585 | 5876 |
5591 unsigned HOST_WIDE_INT off) | 5882 unsigned HOST_WIDE_INT off) |
5592 { | 5883 { |
5593 if (debug_info_level == DINFO_LEVEL_NONE) | 5884 if (debug_info_level == DINFO_LEVEL_NONE) |
5594 return; | 5885 return; |
5595 | 5886 |
5596 if (flag_wpa && !decl_die_table) | 5887 if (!external_die_map) |
5597 decl_die_table = hash_table<decl_die_hasher>::create_ggc (1000); | 5888 external_die_map = hash_map<tree, sym_off_pair>::create_ggc (1000); |
5598 | 5889 gcc_checking_assert (!external_die_map->get (decl)); |
5599 dw_die_ref die | 5890 sym_off_pair p = { IDENTIFIER_POINTER (get_identifier (sym)), off }; |
5600 = TREE_CODE (decl) == BLOCK ? BLOCK_DIE (decl) : lookup_decl_die (decl); | 5891 external_die_map->put (decl, p); |
5892 } | |
5893 | |
5894 /* If we have a registered external DIE for DECL return a new DIE for | |
5895 the concrete instance with an appropriate abstract origin. */ | |
5896 | |
5897 static dw_die_ref | |
5898 maybe_create_die_with_external_ref (tree decl) | |
5899 { | |
5900 if (!external_die_map) | |
5901 return NULL; | |
5902 sym_off_pair *desc = external_die_map->get (decl); | |
5903 if (!desc) | |
5904 return NULL; | |
5905 | |
5906 const char *sym = desc->sym; | |
5907 unsigned HOST_WIDE_INT off = desc->off; | |
5908 | |
5909 in_lto_p = false; | |
5910 dw_die_ref die = (TREE_CODE (decl) == BLOCK | |
5911 ? lookup_block_die (decl) : lookup_decl_die (decl)); | |
5601 gcc_assert (!die); | 5912 gcc_assert (!die); |
5913 in_lto_p = true; | |
5602 | 5914 |
5603 tree ctx; | 5915 tree ctx; |
5604 dw_die_ref parent = NULL; | 5916 dw_die_ref parent = NULL; |
5605 /* Need to lookup a DIE for the decls context - the containing | 5917 /* Need to lookup a DIE for the decls context - the containing |
5606 function or translation unit. */ | 5918 function or translation unit. */ |
5608 { | 5920 { |
5609 ctx = BLOCK_SUPERCONTEXT (decl); | 5921 ctx = BLOCK_SUPERCONTEXT (decl); |
5610 /* ??? We do not output DIEs for all scopes thus skip as | 5922 /* ??? We do not output DIEs for all scopes thus skip as |
5611 many DIEs as needed. */ | 5923 many DIEs as needed. */ |
5612 while (TREE_CODE (ctx) == BLOCK | 5924 while (TREE_CODE (ctx) == BLOCK |
5613 && !BLOCK_DIE (ctx)) | 5925 && !lookup_block_die (ctx)) |
5614 ctx = BLOCK_SUPERCONTEXT (ctx); | 5926 ctx = BLOCK_SUPERCONTEXT (ctx); |
5615 } | 5927 } |
5616 else | 5928 else |
5617 ctx = DECL_CONTEXT (decl); | 5929 ctx = DECL_CONTEXT (decl); |
5930 /* Peel types in the context stack. */ | |
5618 while (ctx && TYPE_P (ctx)) | 5931 while (ctx && TYPE_P (ctx)) |
5619 ctx = TYPE_CONTEXT (ctx); | 5932 ctx = TYPE_CONTEXT (ctx); |
5933 /* Likewise namespaces in case we do not want to emit DIEs for them. */ | |
5934 if (debug_info_level <= DINFO_LEVEL_TERSE) | |
5935 while (ctx && TREE_CODE (ctx) == NAMESPACE_DECL) | |
5936 ctx = DECL_CONTEXT (ctx); | |
5620 if (ctx) | 5937 if (ctx) |
5621 { | 5938 { |
5622 if (TREE_CODE (ctx) == BLOCK) | 5939 if (TREE_CODE (ctx) == BLOCK) |
5623 parent = BLOCK_DIE (ctx); | 5940 parent = lookup_block_die (ctx); |
5624 else if (TREE_CODE (ctx) == TRANSLATION_UNIT_DECL | 5941 else if (TREE_CODE (ctx) == TRANSLATION_UNIT_DECL |
5625 /* Keep the 1:1 association during WPA. */ | 5942 /* Keep the 1:1 association during WPA. */ |
5626 && !flag_wpa) | 5943 && !flag_wpa |
5944 && flag_incremental_link != INCREMENTAL_LINK_LTO) | |
5627 /* Otherwise all late annotations go to the main CU which | 5945 /* Otherwise all late annotations go to the main CU which |
5628 imports the original CUs. */ | 5946 imports the original CUs. */ |
5629 parent = comp_unit_die (); | 5947 parent = comp_unit_die (); |
5630 else if (TREE_CODE (ctx) == FUNCTION_DECL | 5948 else if (TREE_CODE (ctx) == FUNCTION_DECL |
5949 && TREE_CODE (decl) != FUNCTION_DECL | |
5631 && TREE_CODE (decl) != PARM_DECL | 5950 && TREE_CODE (decl) != PARM_DECL |
5951 && TREE_CODE (decl) != RESULT_DECL | |
5632 && TREE_CODE (decl) != BLOCK) | 5952 && TREE_CODE (decl) != BLOCK) |
5633 /* Leave function local entities parent determination to when | 5953 /* Leave function local entities parent determination to when |
5634 we process scope vars. */ | 5954 we process scope vars. */ |
5635 ; | 5955 ; |
5636 else | 5956 else |
5642 parent = comp_unit_die (); | 5962 parent = comp_unit_die (); |
5643 /* Create a DIE "stub". */ | 5963 /* Create a DIE "stub". */ |
5644 switch (TREE_CODE (decl)) | 5964 switch (TREE_CODE (decl)) |
5645 { | 5965 { |
5646 case TRANSLATION_UNIT_DECL: | 5966 case TRANSLATION_UNIT_DECL: |
5647 if (! flag_wpa) | 5967 { |
5648 { | 5968 die = comp_unit_die (); |
5649 die = comp_unit_die (); | 5969 /* We re-target all CU decls to the LTRANS CU DIE, so no need |
5650 dw_die_ref import = new_die (DW_TAG_imported_unit, die, NULL_TREE); | 5970 to create a DIE for the original CUs. */ |
5651 add_AT_external_die_ref (import, DW_AT_import, sym, off); | 5971 return die; |
5652 /* We re-target all CU decls to the LTRANS CU DIE, so no need | 5972 } |
5653 to create a DIE for the original CUs. */ | |
5654 return; | |
5655 } | |
5656 /* Keep the 1:1 association during WPA. */ | |
5657 die = new_die (DW_TAG_compile_unit, NULL, decl); | |
5658 break; | |
5659 case NAMESPACE_DECL: | 5973 case NAMESPACE_DECL: |
5660 if (is_fortran (decl)) | 5974 if (is_fortran (decl)) |
5661 die = new_die (DW_TAG_module, parent, decl); | 5975 die = new_die (DW_TAG_module, parent, decl); |
5662 else | 5976 else |
5663 die = new_die (DW_TAG_namespace, parent, decl); | 5977 die = new_die (DW_TAG_namespace, parent, decl); |
5685 break; | 5999 break; |
5686 default: | 6000 default: |
5687 gcc_unreachable (); | 6001 gcc_unreachable (); |
5688 } | 6002 } |
5689 if (TREE_CODE (decl) == BLOCK) | 6003 if (TREE_CODE (decl) == BLOCK) |
5690 BLOCK_DIE (decl) = die; | 6004 equate_block_to_die (decl, die); |
5691 else | 6005 else |
5692 equate_decl_number_to_die (decl, die); | 6006 equate_decl_number_to_die (decl, die); |
5693 | 6007 |
6008 add_desc_attribute (die, decl); | |
6009 | |
5694 /* Add a reference to the DIE providing early debug at $sym + off. */ | 6010 /* Add a reference to the DIE providing early debug at $sym + off. */ |
5695 add_AT_external_die_ref (die, DW_AT_abstract_origin, sym, off); | 6011 add_AT_external_die_ref (die, DW_AT_abstract_origin, sym, off); |
6012 | |
6013 return die; | |
5696 } | 6014 } |
5697 | 6015 |
5698 /* Returns a hash value for X (which really is a var_loc_list). */ | 6016 /* Returns a hash value for X (which really is a var_loc_list). */ |
5699 | 6017 |
5700 inline hashval_t | 6018 inline hashval_t |
5888 } | 6206 } |
5889 | 6207 |
5890 /* Add a variable location node to the linked list for DECL. */ | 6208 /* Add a variable location node to the linked list for DECL. */ |
5891 | 6209 |
5892 static struct var_loc_node * | 6210 static struct var_loc_node * |
5893 add_var_loc_to_decl (tree decl, rtx loc_note, const char *label) | 6211 add_var_loc_to_decl (tree decl, rtx loc_note, const char *label, var_loc_view view) |
5894 { | 6212 { |
5895 unsigned int decl_id; | 6213 unsigned int decl_id; |
5896 var_loc_list *temp; | 6214 var_loc_list *temp; |
5897 struct var_loc_node *loc = NULL; | 6215 struct var_loc_node *loc = NULL; |
5898 HOST_WIDE_INT bitsize = -1, bitpos = -1; | 6216 HOST_WIDE_INT bitsize = -1, bitpos = -1; |
5902 tree realdecl = DECL_DEBUG_EXPR (decl); | 6220 tree realdecl = DECL_DEBUG_EXPR (decl); |
5903 if (handled_component_p (realdecl) | 6221 if (handled_component_p (realdecl) |
5904 || (TREE_CODE (realdecl) == MEM_REF | 6222 || (TREE_CODE (realdecl) == MEM_REF |
5905 && TREE_CODE (TREE_OPERAND (realdecl, 0)) == ADDR_EXPR)) | 6223 && TREE_CODE (TREE_OPERAND (realdecl, 0)) == ADDR_EXPR)) |
5906 { | 6224 { |
5907 HOST_WIDE_INT maxsize; | |
5908 bool reverse; | 6225 bool reverse; |
5909 tree innerdecl | 6226 tree innerdecl = get_ref_base_and_extent_hwi (realdecl, &bitpos, |
5910 = get_ref_base_and_extent (realdecl, &bitpos, &bitsize, &maxsize, | 6227 &bitsize, &reverse); |
5911 &reverse); | 6228 if (!innerdecl |
5912 if (!DECL_P (innerdecl) | 6229 || !DECL_P (innerdecl) |
5913 || DECL_IGNORED_P (innerdecl) | 6230 || DECL_IGNORED_P (innerdecl) |
5914 || TREE_STATIC (innerdecl) | 6231 || TREE_STATIC (innerdecl) |
5915 || bitsize <= 0 | 6232 || bitsize == 0 |
5916 || bitpos + bitsize > 256 | 6233 || bitpos + bitsize > 256) |
5917 || bitsize != maxsize) | |
5918 return NULL; | 6234 return NULL; |
5919 decl = innerdecl; | 6235 decl = innerdecl; |
5920 } | 6236 } |
5921 } | 6237 } |
5922 | 6238 |
5979 while (*piece_loc); | 6295 while (*piece_loc); |
5980 } | 6296 } |
5981 /* TEMP->LAST here is either pointer to the last but one or | 6297 /* TEMP->LAST here is either pointer to the last but one or |
5982 last element in the chained list, LAST is pointer to the | 6298 last element in the chained list, LAST is pointer to the |
5983 last element. */ | 6299 last element. */ |
5984 if (label && strcmp (last->label, label) == 0) | 6300 if (label && strcmp (last->label, label) == 0 && last->view == view) |
5985 { | 6301 { |
5986 /* For SRA optimized variables if there weren't any real | 6302 /* For SRA optimized variables if there weren't any real |
5987 insns since last note, just modify the last node. */ | 6303 insns since last note, just modify the last node. */ |
5988 if (piece_loc != NULL) | 6304 if (piece_loc != NULL) |
5989 { | 6305 { |
5995 if (temp->last != last) | 6311 if (temp->last != last) |
5996 { | 6312 { |
5997 temp->last->next = NULL; | 6313 temp->last->next = NULL; |
5998 unused = last; | 6314 unused = last; |
5999 last = temp->last; | 6315 last = temp->last; |
6000 gcc_assert (strcmp (last->label, label) != 0); | 6316 gcc_assert (strcmp (last->label, label) != 0 || last->view != view); |
6001 } | 6317 } |
6002 else | 6318 else |
6003 { | 6319 { |
6004 gcc_assert (temp->first == temp->last | 6320 gcc_assert (temp->first == temp->last |
6005 || (temp->first->next == temp->last | 6321 || (temp->first->next == temp->last |
6124 print_indent += 4; | 6440 print_indent += 4; |
6125 print_loc_descr (val->v.val_loc, outfile); | 6441 print_loc_descr (val->v.val_loc, outfile); |
6126 print_indent -= 4; | 6442 print_indent -= 4; |
6127 } | 6443 } |
6128 else | 6444 else |
6129 fprintf (outfile, " (%p)\n", (void *) val->v.val_loc); | 6445 { |
6446 if (flag_dump_noaddr || flag_dump_unnumbered) | |
6447 fprintf (outfile, " #\n"); | |
6448 else | |
6449 fprintf (outfile, " (%p)\n", (void *) val->v.val_loc); | |
6450 } | |
6130 break; | 6451 break; |
6131 case dw_val_class_loc_list: | 6452 case dw_val_class_loc_list: |
6132 fprintf (outfile, "location list -> label:%s", | 6453 fprintf (outfile, "location list -> label:%s", |
6133 val->v.val_loc_list->ll_symbol); | 6454 val->v.val_loc_list->ll_symbol); |
6455 break; | |
6456 case dw_val_class_view_list: | |
6457 val = view_list_to_loc_list_val_node (val); | |
6458 fprintf (outfile, "location list with views -> labels:%s and %s", | |
6459 val->v.val_loc_list->ll_symbol, | |
6460 val->v.val_loc_list->vl_symbol); | |
6134 break; | 6461 break; |
6135 case dw_val_class_range_list: | 6462 case dw_val_class_range_list: |
6136 fprintf (outfile, "range list"); | 6463 fprintf (outfile, "range list"); |
6137 break; | 6464 break; |
6138 case dw_val_class_const: | 6465 case dw_val_class_const: |
6187 if (die->with_offset) | 6514 if (die->with_offset) |
6188 fprintf (outfile, " + %ld", die->die_offset); | 6515 fprintf (outfile, " + %ld", die->die_offset); |
6189 } | 6516 } |
6190 else | 6517 else |
6191 fprintf (outfile, "die -> %ld", die->die_offset); | 6518 fprintf (outfile, "die -> %ld", die->die_offset); |
6192 fprintf (outfile, " (%p)", (void *) die); | 6519 if (flag_dump_noaddr || flag_dump_unnumbered) |
6520 fprintf (outfile, " #"); | |
6521 else | |
6522 fprintf (outfile, " (%p)", (void *) die); | |
6193 } | 6523 } |
6194 else | 6524 else |
6195 fprintf (outfile, "die -> <null>"); | 6525 fprintf (outfile, "die -> <null>"); |
6196 break; | 6526 break; |
6197 case dw_val_class_vms_delta: | 6527 case dw_val_class_vms_delta: |
6198 fprintf (outfile, "delta: @slotcount(%s-%s)", | 6528 fprintf (outfile, "delta: @slotcount(%s-%s)", |
6199 val->v.val_vms_delta.lbl2, val->v.val_vms_delta.lbl1); | 6529 val->v.val_vms_delta.lbl2, val->v.val_vms_delta.lbl1); |
6530 break; | |
6531 case dw_val_class_symview: | |
6532 fprintf (outfile, "view: %s", val->v.val_symbolic_view); | |
6200 break; | 6533 break; |
6201 case dw_val_class_lbl_id: | 6534 case dw_val_class_lbl_id: |
6202 case dw_val_class_lineptr: | 6535 case dw_val_class_lineptr: |
6203 case dw_val_class_macptr: | 6536 case dw_val_class_macptr: |
6204 case dw_val_class_loclistsptr: | 6537 case dw_val_class_loclistsptr: |
6274 } | 6607 } |
6275 | 6608 |
6276 for (l = loc; l != NULL; l = l->dw_loc_next) | 6609 for (l = loc; l != NULL; l = l->dw_loc_next) |
6277 { | 6610 { |
6278 print_spaces (outfile); | 6611 print_spaces (outfile); |
6279 fprintf (outfile, "(%p) %s", | 6612 if (flag_dump_noaddr || flag_dump_unnumbered) |
6280 (void *) l, | 6613 fprintf (outfile, "#"); |
6614 else | |
6615 fprintf (outfile, "(%p)", (void *) l); | |
6616 fprintf (outfile, " %s", | |
6281 dwarf_stack_op_name (l->dw_loc_opc)); | 6617 dwarf_stack_op_name (l->dw_loc_opc)); |
6282 if (l->dw_loc_oprnd1.val_class != dw_val_class_none) | 6618 if (l->dw_loc_oprnd1.val_class != dw_val_class_none) |
6283 { | 6619 { |
6284 fprintf (outfile, " "); | 6620 fprintf (outfile, " "); |
6285 print_dw_val (&l->dw_loc_oprnd1, false, outfile); | 6621 print_dw_val (&l->dw_loc_oprnd1, false, outfile); |
6302 dw_attr_node *a; | 6638 dw_attr_node *a; |
6303 dw_die_ref c; | 6639 dw_die_ref c; |
6304 unsigned ix; | 6640 unsigned ix; |
6305 | 6641 |
6306 print_spaces (outfile); | 6642 print_spaces (outfile); |
6307 fprintf (outfile, "DIE %4ld: %s (%p)\n", | 6643 fprintf (outfile, "DIE %4ld: %s ", |
6308 die->die_offset, dwarf_tag_name (die->die_tag), | 6644 die->die_offset, dwarf_tag_name (die->die_tag)); |
6309 (void*) die); | 6645 if (flag_dump_noaddr || flag_dump_unnumbered) |
6646 fprintf (outfile, "#\n"); | |
6647 else | |
6648 fprintf (outfile, "(%p)\n", (void*) die); | |
6310 print_spaces (outfile); | 6649 print_spaces (outfile); |
6311 fprintf (outfile, " abbrev id: %lu", die->die_abbrev); | 6650 fprintf (outfile, " abbrev id: %lu", die->die_abbrev); |
6312 fprintf (outfile, " offset: %ld", die->die_offset); | 6651 fprintf (outfile, " offset: %ld", die->die_offset); |
6313 fprintf (outfile, " mark: %d\n", die->die_mark); | 6652 fprintf (outfile, " mark: %d\n", die->die_mark); |
6314 | 6653 |
6567 die_checksum (AT_ref (at), ctx, mark); | 6906 die_checksum (AT_ref (at), ctx, mark); |
6568 break; | 6907 break; |
6569 | 6908 |
6570 case dw_val_class_fde_ref: | 6909 case dw_val_class_fde_ref: |
6571 case dw_val_class_vms_delta: | 6910 case dw_val_class_vms_delta: |
6911 case dw_val_class_symview: | |
6572 case dw_val_class_lbl_id: | 6912 case dw_val_class_lbl_id: |
6573 case dw_val_class_lineptr: | 6913 case dw_val_class_lineptr: |
6574 case dw_val_class_macptr: | 6914 case dw_val_class_macptr: |
6575 case dw_val_class_loclistsptr: | 6915 case dw_val_class_loclistsptr: |
6576 case dw_val_class_high_pc: | 6916 case dw_val_class_high_pc: |
6863 for (loc = AT_loc (at); loc; loc = loc->dw_loc_next) | 7203 for (loc = AT_loc (at); loc; loc = loc->dw_loc_next) |
6864 loc_checksum_ordered (loc, ctx); | 7204 loc_checksum_ordered (loc, ctx); |
6865 break; | 7205 break; |
6866 | 7206 |
6867 case dw_val_class_fde_ref: | 7207 case dw_val_class_fde_ref: |
7208 case dw_val_class_symview: | |
6868 case dw_val_class_lbl_id: | 7209 case dw_val_class_lbl_id: |
6869 case dw_val_class_lineptr: | 7210 case dw_val_class_lineptr: |
6870 case dw_val_class_macptr: | 7211 case dw_val_class_macptr: |
6871 case dw_val_class_loclistsptr: | 7212 case dw_val_class_loclistsptr: |
6872 case dw_val_class_high_pc: | 7213 case dw_val_class_high_pc: |
7363 return !loc1 && !loc2; | 7704 return !loc1 && !loc2; |
7364 | 7705 |
7365 case dw_val_class_die_ref: | 7706 case dw_val_class_die_ref: |
7366 return same_die_p (v1->v.val_die_ref.die, v2->v.val_die_ref.die, mark); | 7707 return same_die_p (v1->v.val_die_ref.die, v2->v.val_die_ref.die, mark); |
7367 | 7708 |
7709 case dw_val_class_symview: | |
7710 return strcmp (v1->v.val_symbolic_view, v2->v.val_symbolic_view) == 0; | |
7711 | |
7368 case dw_val_class_fde_ref: | 7712 case dw_val_class_fde_ref: |
7369 case dw_val_class_vms_delta: | 7713 case dw_val_class_vms_delta: |
7370 case dw_val_class_lbl_id: | 7714 case dw_val_class_lbl_id: |
7371 case dw_val_class_lineptr: | 7715 case dw_val_class_lineptr: |
7372 case dw_val_class_macptr: | 7716 case dw_val_class_macptr: |
7523 default: | 7867 default: |
7524 return 0; | 7868 return 0; |
7525 } | 7869 } |
7526 } | 7870 } |
7527 | 7871 |
7528 /* Returns 1 iff C is the sort of DIE that should go into a COMDAT CU. | |
7529 Basically, we want to choose the bits that are likely to be shared between | |
7530 compilations (types) and leave out the bits that are specific to individual | |
7531 compilations (functions). */ | |
7532 | |
7533 static int | |
7534 is_comdat_die (dw_die_ref c) | |
7535 { | |
7536 /* I think we want to leave base types and __vtbl_ptr_type in the main CU, as | |
7537 we do for stabs. The advantage is a greater likelihood of sharing between | |
7538 objects that don't include headers in the same order (and therefore would | |
7539 put the base types in a different comdat). jason 8/28/00 */ | |
7540 | |
7541 if (c->die_tag == DW_TAG_base_type) | |
7542 return 0; | |
7543 | |
7544 if (c->die_tag == DW_TAG_pointer_type | |
7545 || c->die_tag == DW_TAG_reference_type | |
7546 || c->die_tag == DW_TAG_rvalue_reference_type | |
7547 || c->die_tag == DW_TAG_const_type | |
7548 || c->die_tag == DW_TAG_volatile_type) | |
7549 { | |
7550 dw_die_ref t = get_AT_ref (c, DW_AT_type); | |
7551 | |
7552 return t ? is_comdat_die (t) : 0; | |
7553 } | |
7554 | |
7555 return is_type_die (c); | |
7556 } | |
7557 | |
7558 /* Returns true iff C is a compile-unit DIE. */ | 7872 /* Returns true iff C is a compile-unit DIE. */ |
7559 | 7873 |
7560 static inline bool | 7874 static inline bool |
7561 is_cu_die (dw_die_ref c) | 7875 is_cu_die (dw_die_ref c) |
7562 { | 7876 { |
7579 | 7893 |
7580 static inline bool | 7894 static inline bool |
7581 is_namespace_die (dw_die_ref c) | 7895 is_namespace_die (dw_die_ref c) |
7582 { | 7896 { |
7583 return c && c->die_tag == DW_TAG_namespace; | 7897 return c && c->die_tag == DW_TAG_namespace; |
7584 } | |
7585 | |
7586 /* Returns true iff C is a class or structure DIE. */ | |
7587 | |
7588 static inline bool | |
7589 is_class_die (dw_die_ref c) | |
7590 { | |
7591 return c && (c->die_tag == DW_TAG_class_type | |
7592 || c->die_tag == DW_TAG_structure_type); | |
7593 } | 7898 } |
7594 | 7899 |
7595 /* Return non-zero if this DIE is a template parameter. */ | 7900 /* Return non-zero if this DIE is a template parameter. */ |
7596 | 7901 |
7597 static inline bool | 7902 static inline bool |
8990 size += constant_size (lsize); | 9295 size += constant_size (lsize); |
8991 size += lsize; | 9296 size += lsize; |
8992 } | 9297 } |
8993 break; | 9298 break; |
8994 case dw_val_class_loc_list: | 9299 case dw_val_class_loc_list: |
9300 case dw_val_class_view_list: | |
8995 if (dwarf_split_debug_info && dwarf_version >= 5) | 9301 if (dwarf_split_debug_info && dwarf_version >= 5) |
8996 { | 9302 { |
8997 gcc_assert (AT_loc_list (a)->num_assigned); | 9303 gcc_assert (AT_loc_list (a)->num_assigned); |
8998 size += size_of_uleb128 (AT_loc_list (a)->hash); | 9304 size += size_of_uleb128 (AT_loc_list (a)->hash); |
8999 } | 9305 } |
9021 && csize >= 4) | 9327 && csize >= 4) |
9022 size += size_of_uleb128 (AT_unsigned (a)); | 9328 size += size_of_uleb128 (AT_unsigned (a)); |
9023 else | 9329 else |
9024 size += csize; | 9330 size += csize; |
9025 } | 9331 } |
9332 break; | |
9333 case dw_val_class_symview: | |
9334 if (symview_upper_bound <= 0xff) | |
9335 size += 1; | |
9336 else if (symview_upper_bound <= 0xffff) | |
9337 size += 2; | |
9338 else if (symview_upper_bound <= 0xffffffff) | |
9339 size += 4; | |
9340 else | |
9341 size += 8; | |
9026 break; | 9342 break; |
9027 case dw_val_class_const_implicit: | 9343 case dw_val_class_const_implicit: |
9028 case dw_val_class_unsigned_const_implicit: | 9344 case dw_val_class_unsigned_const_implicit: |
9029 case dw_val_class_file_implicit: | 9345 case dw_val_class_file_implicit: |
9030 /* These occupy no size in the DIE, just an extra sleb128 in | 9346 /* These occupy no size in the DIE, just an extra sleb128 in |
9096 break; | 9412 break; |
9097 case dw_val_class_str: | 9413 case dw_val_class_str: |
9098 form = AT_string_form (a); | 9414 form = AT_string_form (a); |
9099 if (form == DW_FORM_strp || form == DW_FORM_line_strp) | 9415 if (form == DW_FORM_strp || form == DW_FORM_line_strp) |
9100 size += DWARF_OFFSET_SIZE; | 9416 size += DWARF_OFFSET_SIZE; |
9101 else if (form == DW_FORM_GNU_str_index) | 9417 else if (form == dwarf_FORM (DW_FORM_strx)) |
9102 size += size_of_uleb128 (AT_index (a)); | 9418 size += size_of_uleb128 (AT_index (a)); |
9103 else | 9419 else |
9104 size += strlen (a->dw_attr_val.v.val_str->str) + 1; | 9420 size += strlen (a->dw_attr_val.v.val_str->str) + 1; |
9105 break; | 9421 break; |
9106 case dw_val_class_file: | 9422 case dw_val_class_file: |
9343 case DW_AT_low_pc: | 9659 case DW_AT_low_pc: |
9344 case DW_AT_high_pc: | 9660 case DW_AT_high_pc: |
9345 case DW_AT_entry_pc: | 9661 case DW_AT_entry_pc: |
9346 case DW_AT_trampoline: | 9662 case DW_AT_trampoline: |
9347 return (AT_index (a) == NOT_INDEXED | 9663 return (AT_index (a) == NOT_INDEXED |
9348 ? DW_FORM_addr : DW_FORM_GNU_addr_index); | 9664 ? DW_FORM_addr : dwarf_FORM (DW_FORM_addrx)); |
9349 default: | 9665 default: |
9350 break; | 9666 break; |
9351 } | 9667 } |
9352 switch (DWARF2_ADDR_SIZE) | 9668 switch (DWARF2_ADDR_SIZE) |
9353 { | 9669 { |
9361 return DW_FORM_data8; | 9677 return DW_FORM_data8; |
9362 default: | 9678 default: |
9363 gcc_unreachable (); | 9679 gcc_unreachable (); |
9364 } | 9680 } |
9365 case dw_val_class_loc_list: | 9681 case dw_val_class_loc_list: |
9682 case dw_val_class_view_list: | |
9366 if (dwarf_split_debug_info | 9683 if (dwarf_split_debug_info |
9367 && dwarf_version >= 5 | 9684 && dwarf_version >= 5 |
9368 && AT_loc_list (a)->num_assigned) | 9685 && AT_loc_list (a)->num_assigned) |
9369 return DW_FORM_loclistx; | 9686 return DW_FORM_loclistx; |
9370 /* FALLTHRU */ | 9687 /* FALLTHRU */ |
9469 return DW_FORM_data16; | 9786 return DW_FORM_data16; |
9470 /* FALLTHRU */ | 9787 /* FALLTHRU */ |
9471 default: | 9788 default: |
9472 return DW_FORM_block1; | 9789 return DW_FORM_block1; |
9473 } | 9790 } |
9791 case dw_val_class_symview: | |
9792 /* ??? We might use uleb128, but then we'd have to compute | |
9793 .debug_info offsets in the assembler. */ | |
9794 if (symview_upper_bound <= 0xff) | |
9795 return DW_FORM_data1; | |
9796 else if (symview_upper_bound <= 0xffff) | |
9797 return DW_FORM_data2; | |
9798 else if (symview_upper_bound <= 0xffffffff) | |
9799 return DW_FORM_data4; | |
9800 else | |
9801 return DW_FORM_data8; | |
9474 case dw_val_class_vec: | 9802 case dw_val_class_vec: |
9475 switch (constant_size (a->dw_attr_val.v.val_vec.length | 9803 switch (constant_size (a->dw_attr_val.v.val_vec.length |
9476 * a->dw_attr_val.v.val_vec.elt_size)) | 9804 * a->dw_attr_val.v.val_vec.elt_size)) |
9477 { | 9805 { |
9478 case 1: | 9806 case 1: |
9504 return DW_FORM_ref; | 9832 return DW_FORM_ref; |
9505 case dw_val_class_fde_ref: | 9833 case dw_val_class_fde_ref: |
9506 return DW_FORM_data; | 9834 return DW_FORM_data; |
9507 case dw_val_class_lbl_id: | 9835 case dw_val_class_lbl_id: |
9508 return (AT_index (a) == NOT_INDEXED | 9836 return (AT_index (a) == NOT_INDEXED |
9509 ? DW_FORM_addr : DW_FORM_GNU_addr_index); | 9837 ? DW_FORM_addr : dwarf_FORM (DW_FORM_addrx)); |
9510 case dw_val_class_lineptr: | 9838 case dw_val_class_lineptr: |
9511 case dw_val_class_macptr: | 9839 case dw_val_class_macptr: |
9512 case dw_val_class_loclistsptr: | 9840 case dw_val_class_loclistsptr: |
9513 return dwarf_version >= 4 ? DW_FORM_sec_offset : DW_FORM_data; | 9841 return dwarf_version >= 4 ? DW_FORM_sec_offset : DW_FORM_data; |
9514 case dw_val_class_str: | 9842 case dw_val_class_str: |
9635 | 9963 |
9636 /* Return a new location list, given the begin and end range, and the | 9964 /* Return a new location list, given the begin and end range, and the |
9637 expression. */ | 9965 expression. */ |
9638 | 9966 |
9639 static inline dw_loc_list_ref | 9967 static inline dw_loc_list_ref |
9640 new_loc_list (dw_loc_descr_ref expr, const char *begin, const char *end, | 9968 new_loc_list (dw_loc_descr_ref expr, const char *begin, var_loc_view vbegin, |
9969 const char *end, var_loc_view vend, | |
9641 const char *section) | 9970 const char *section) |
9642 { | 9971 { |
9643 dw_loc_list_ref retlist = ggc_cleared_alloc<dw_loc_list_node> (); | 9972 dw_loc_list_ref retlist = ggc_cleared_alloc<dw_loc_list_node> (); |
9644 | 9973 |
9645 retlist->begin = begin; | 9974 retlist->begin = begin; |
9646 retlist->begin_entry = NULL; | 9975 retlist->begin_entry = NULL; |
9647 retlist->end = end; | 9976 retlist->end = end; |
9648 retlist->expr = expr; | 9977 retlist->expr = expr; |
9649 retlist->section = section; | 9978 retlist->section = section; |
9979 retlist->vbegin = vbegin; | |
9980 retlist->vend = vend; | |
9650 | 9981 |
9651 return retlist; | 9982 return retlist; |
9983 } | |
9984 | |
9985 /* Return true iff there's any nonzero view number in the loc list. | |
9986 | |
9987 ??? When views are not enabled, we'll often extend a single range | |
9988 to the entire function, so that we emit a single location | |
9989 expression rather than a location list. With views, even with a | |
9990 single range, we'll output a list if start or end have a nonzero | |
9991 view. If we change this, we may want to stop splitting a single | |
9992 range in dw_loc_list just because of a nonzero view, even if it | |
9993 straddles across hot/cold partitions. */ | |
9994 | |
9995 static bool | |
9996 loc_list_has_views (dw_loc_list_ref list) | |
9997 { | |
9998 if (!debug_variable_location_views) | |
9999 return false; | |
10000 | |
10001 for (dw_loc_list_ref loc = list; | |
10002 loc != NULL; loc = loc->dw_loc_next) | |
10003 if (!ZERO_VIEW_P (loc->vbegin) || !ZERO_VIEW_P (loc->vend)) | |
10004 return true; | |
10005 | |
10006 return false; | |
9652 } | 10007 } |
9653 | 10008 |
9654 /* Generate a new internal symbol for this location list node, if it | 10009 /* Generate a new internal symbol for this location list node, if it |
9655 hasn't got one yet. */ | 10010 hasn't got one yet. */ |
9656 | 10011 |
9657 static inline void | 10012 static inline void |
9658 gen_llsym (dw_loc_list_ref list) | 10013 gen_llsym (dw_loc_list_ref list) |
9659 { | 10014 { |
9660 gcc_assert (!list->ll_symbol); | 10015 gcc_assert (!list->ll_symbol); |
9661 list->ll_symbol = gen_internal_sym ("LLST"); | 10016 list->ll_symbol = gen_internal_sym ("LLST"); |
10017 | |
10018 if (!loc_list_has_views (list)) | |
10019 return; | |
10020 | |
10021 if (dwarf2out_locviews_in_attribute ()) | |
10022 { | |
10023 /* Use the same label_num for the view list. */ | |
10024 label_num--; | |
10025 list->vl_symbol = gen_internal_sym ("LVUS"); | |
10026 } | |
10027 else | |
10028 list->vl_symbol = list->ll_symbol; | |
10029 } | |
10030 | |
10031 /* Generate a symbol for the list, but only if we really want to emit | |
10032 it as a list. */ | |
10033 | |
10034 static inline void | |
10035 maybe_gen_llsym (dw_loc_list_ref list) | |
10036 { | |
10037 if (!list || (!list->dw_loc_next && !loc_list_has_views (list))) | |
10038 return; | |
10039 | |
10040 gen_llsym (list); | |
10041 } | |
10042 | |
10043 /* Determine whether or not to skip loc_list entry CURR. If SIZEP is | |
10044 NULL, don't consider size of the location expression. If we're not | |
10045 to skip it, and SIZEP is non-null, store the size of CURR->expr's | |
10046 representation in *SIZEP. */ | |
10047 | |
10048 static bool | |
10049 skip_loc_list_entry (dw_loc_list_ref curr, unsigned long *sizep = NULL) | |
10050 { | |
10051 /* Don't output an entry that starts and ends at the same address. */ | |
10052 if (strcmp (curr->begin, curr->end) == 0 | |
10053 && curr->vbegin == curr->vend && !curr->force) | |
10054 return true; | |
10055 | |
10056 if (!sizep) | |
10057 return false; | |
10058 | |
10059 unsigned long size = size_of_locs (curr->expr); | |
10060 | |
10061 /* If the expression is too large, drop it on the floor. We could | |
10062 perhaps put it into DW_TAG_dwarf_procedure and refer to that | |
10063 in the expression, but >= 64KB expressions for a single value | |
10064 in a single range are unlikely very useful. */ | |
10065 if (dwarf_version < 5 && size > 0xffff) | |
10066 return true; | |
10067 | |
10068 *sizep = size; | |
10069 | |
10070 return false; | |
10071 } | |
10072 | |
10073 /* Output a view pair loclist entry for CURR, if it requires one. */ | |
10074 | |
10075 static void | |
10076 dwarf2out_maybe_output_loclist_view_pair (dw_loc_list_ref curr) | |
10077 { | |
10078 if (!dwarf2out_locviews_in_loclist ()) | |
10079 return; | |
10080 | |
10081 if (ZERO_VIEW_P (curr->vbegin) && ZERO_VIEW_P (curr->vend)) | |
10082 return; | |
10083 | |
10084 #ifdef DW_LLE_view_pair | |
10085 dw2_asm_output_data (1, DW_LLE_view_pair, "DW_LLE_view_pair"); | |
10086 | |
10087 if (dwarf2out_as_locview_support) | |
10088 { | |
10089 if (ZERO_VIEW_P (curr->vbegin)) | |
10090 dw2_asm_output_data_uleb128 (0, "Location view begin"); | |
10091 else | |
10092 { | |
10093 char label[MAX_ARTIFICIAL_LABEL_BYTES]; | |
10094 ASM_GENERATE_INTERNAL_LABEL (label, "LVU", curr->vbegin); | |
10095 dw2_asm_output_symname_uleb128 (label, "Location view begin"); | |
10096 } | |
10097 | |
10098 if (ZERO_VIEW_P (curr->vend)) | |
10099 dw2_asm_output_data_uleb128 (0, "Location view end"); | |
10100 else | |
10101 { | |
10102 char label[MAX_ARTIFICIAL_LABEL_BYTES]; | |
10103 ASM_GENERATE_INTERNAL_LABEL (label, "LVU", curr->vend); | |
10104 dw2_asm_output_symname_uleb128 (label, "Location view end"); | |
10105 } | |
10106 } | |
10107 else | |
10108 { | |
10109 dw2_asm_output_data_uleb128 (curr->vbegin, "Location view begin"); | |
10110 dw2_asm_output_data_uleb128 (curr->vend, "Location view end"); | |
10111 } | |
10112 #endif /* DW_LLE_view_pair */ | |
10113 | |
10114 return; | |
9662 } | 10115 } |
9663 | 10116 |
9664 /* Output the location list given to us. */ | 10117 /* Output the location list given to us. */ |
9665 | 10118 |
9666 static void | 10119 static void |
9667 output_loc_list (dw_loc_list_ref list_head) | 10120 output_loc_list (dw_loc_list_ref list_head) |
9668 { | 10121 { |
10122 int vcount = 0, lcount = 0; | |
10123 | |
9669 if (list_head->emitted) | 10124 if (list_head->emitted) |
9670 return; | 10125 return; |
9671 list_head->emitted = true; | 10126 list_head->emitted = true; |
9672 | 10127 |
10128 if (list_head->vl_symbol && dwarf2out_locviews_in_attribute ()) | |
10129 { | |
10130 ASM_OUTPUT_LABEL (asm_out_file, list_head->vl_symbol); | |
10131 | |
10132 for (dw_loc_list_ref curr = list_head; curr != NULL; | |
10133 curr = curr->dw_loc_next) | |
10134 { | |
10135 unsigned long size; | |
10136 | |
10137 if (skip_loc_list_entry (curr, &size)) | |
10138 continue; | |
10139 | |
10140 vcount++; | |
10141 | |
10142 /* ?? dwarf_split_debug_info? */ | |
10143 if (dwarf2out_as_locview_support) | |
10144 { | |
10145 char label[MAX_ARTIFICIAL_LABEL_BYTES]; | |
10146 | |
10147 if (!ZERO_VIEW_P (curr->vbegin)) | |
10148 { | |
10149 ASM_GENERATE_INTERNAL_LABEL (label, "LVU", curr->vbegin); | |
10150 dw2_asm_output_symname_uleb128 (label, | |
10151 "View list begin (%s)", | |
10152 list_head->vl_symbol); | |
10153 } | |
10154 else | |
10155 dw2_asm_output_data_uleb128 (0, | |
10156 "View list begin (%s)", | |
10157 list_head->vl_symbol); | |
10158 | |
10159 if (!ZERO_VIEW_P (curr->vend)) | |
10160 { | |
10161 ASM_GENERATE_INTERNAL_LABEL (label, "LVU", curr->vend); | |
10162 dw2_asm_output_symname_uleb128 (label, | |
10163 "View list end (%s)", | |
10164 list_head->vl_symbol); | |
10165 } | |
10166 else | |
10167 dw2_asm_output_data_uleb128 (0, | |
10168 "View list end (%s)", | |
10169 list_head->vl_symbol); | |
10170 } | |
10171 else | |
10172 { | |
10173 dw2_asm_output_data_uleb128 (curr->vbegin, | |
10174 "View list begin (%s)", | |
10175 list_head->vl_symbol); | |
10176 dw2_asm_output_data_uleb128 (curr->vend, | |
10177 "View list end (%s)", | |
10178 list_head->vl_symbol); | |
10179 } | |
10180 } | |
10181 } | |
10182 | |
9673 ASM_OUTPUT_LABEL (asm_out_file, list_head->ll_symbol); | 10183 ASM_OUTPUT_LABEL (asm_out_file, list_head->ll_symbol); |
9674 | 10184 |
9675 dw_loc_list_ref curr = list_head; | |
9676 const char *last_section = NULL; | 10185 const char *last_section = NULL; |
9677 const char *base_label = NULL; | 10186 const char *base_label = NULL; |
9678 | 10187 |
9679 /* Walk the location list, and output each range + expression. */ | 10188 /* Walk the location list, and output each range + expression. */ |
9680 for (curr = list_head; curr != NULL; curr = curr->dw_loc_next) | 10189 for (dw_loc_list_ref curr = list_head; curr != NULL; |
10190 curr = curr->dw_loc_next) | |
9681 { | 10191 { |
9682 unsigned long size; | 10192 unsigned long size; |
9683 /* Don't output an entry that starts and ends at the same address. */ | 10193 |
9684 if (strcmp (curr->begin, curr->end) == 0 && !curr->force) | 10194 /* Skip this entry? If we skip it here, we must skip it in the |
10195 view list above as well. */ | |
10196 if (skip_loc_list_entry (curr, &size)) | |
9685 continue; | 10197 continue; |
9686 size = size_of_locs (curr->expr); | 10198 |
9687 /* If the expression is too large, drop it on the floor. We could | 10199 lcount++; |
9688 perhaps put it into DW_TAG_dwarf_procedure and refer to that | 10200 |
9689 in the expression, but >= 64KB expressions for a single value | |
9690 in a single range are unlikely very useful. */ | |
9691 if (dwarf_version < 5 && size > 0xffff) | |
9692 continue; | |
9693 if (dwarf_version >= 5) | 10201 if (dwarf_version >= 5) |
9694 { | 10202 { |
9695 if (dwarf_split_debug_info) | 10203 if (dwarf_split_debug_info) |
9696 { | 10204 { |
10205 dwarf2out_maybe_output_loclist_view_pair (curr); | |
9697 /* For -gsplit-dwarf, emit DW_LLE_starx_length, which has | 10206 /* For -gsplit-dwarf, emit DW_LLE_starx_length, which has |
9698 uleb128 index into .debug_addr and uleb128 length. */ | 10207 uleb128 index into .debug_addr and uleb128 length. */ |
9699 dw2_asm_output_data (1, DW_LLE_startx_length, | 10208 dw2_asm_output_data (1, DW_LLE_startx_length, |
9700 "DW_LLE_startx_length (%s)", | 10209 "DW_LLE_startx_length (%s)", |
9701 list_head->ll_symbol); | 10210 list_head->ll_symbol); |
9709 "Location list length (%s)", | 10218 "Location list length (%s)", |
9710 list_head->ll_symbol); | 10219 list_head->ll_symbol); |
9711 } | 10220 } |
9712 else if (!have_multiple_function_sections && HAVE_AS_LEB128) | 10221 else if (!have_multiple_function_sections && HAVE_AS_LEB128) |
9713 { | 10222 { |
10223 dwarf2out_maybe_output_loclist_view_pair (curr); | |
9714 /* If all code is in .text section, the base address is | 10224 /* If all code is in .text section, the base address is |
9715 already provided by the CU attributes. Use | 10225 already provided by the CU attributes. Use |
9716 DW_LLE_offset_pair where both addresses are uleb128 encoded | 10226 DW_LLE_offset_pair where both addresses are uleb128 encoded |
9717 offsets against that base. */ | 10227 offsets against that base. */ |
9718 dw2_asm_output_data (1, DW_LLE_offset_pair, | 10228 dw2_asm_output_data (1, DW_LLE_offset_pair, |
9759 /* Only one entry with the same base address. Use | 10269 /* Only one entry with the same base address. Use |
9760 DW_LLE_start_length with absolute address and uleb128 | 10270 DW_LLE_start_length with absolute address and uleb128 |
9761 length. */ | 10271 length. */ |
9762 if (last_section == NULL) | 10272 if (last_section == NULL) |
9763 { | 10273 { |
10274 dwarf2out_maybe_output_loclist_view_pair (curr); | |
9764 dw2_asm_output_data (1, DW_LLE_start_length, | 10275 dw2_asm_output_data (1, DW_LLE_start_length, |
9765 "DW_LLE_start_length (%s)", | 10276 "DW_LLE_start_length (%s)", |
9766 list_head->ll_symbol); | 10277 list_head->ll_symbol); |
9767 dw2_asm_output_addr (DWARF2_ADDR_SIZE, curr->begin, | 10278 dw2_asm_output_addr (DWARF2_ADDR_SIZE, curr->begin, |
9768 "Location list begin address (%s)", | 10279 "Location list begin address (%s)", |
9773 } | 10284 } |
9774 /* Otherwise emit DW_LLE_offset_pair, relative to above emitted | 10285 /* Otherwise emit DW_LLE_offset_pair, relative to above emitted |
9775 DW_LLE_base_address. */ | 10286 DW_LLE_base_address. */ |
9776 else | 10287 else |
9777 { | 10288 { |
10289 dwarf2out_maybe_output_loclist_view_pair (curr); | |
9778 dw2_asm_output_data (1, DW_LLE_offset_pair, | 10290 dw2_asm_output_data (1, DW_LLE_offset_pair, |
9779 "DW_LLE_offset_pair (%s)", | 10291 "DW_LLE_offset_pair (%s)", |
9780 list_head->ll_symbol); | 10292 list_head->ll_symbol); |
9781 dw2_asm_output_delta_uleb128 (curr->begin, base_label, | 10293 dw2_asm_output_delta_uleb128 (curr->begin, base_label, |
9782 "Location list begin address " | 10294 "Location list begin address " |
9788 } | 10300 } |
9789 /* The assembler does not support .uleb128 directive. Emit | 10301 /* The assembler does not support .uleb128 directive. Emit |
9790 DW_LLE_start_end with a pair of absolute addresses. */ | 10302 DW_LLE_start_end with a pair of absolute addresses. */ |
9791 else | 10303 else |
9792 { | 10304 { |
10305 dwarf2out_maybe_output_loclist_view_pair (curr); | |
9793 dw2_asm_output_data (1, DW_LLE_start_end, | 10306 dw2_asm_output_data (1, DW_LLE_start_end, |
9794 "DW_LLE_start_end (%s)", | 10307 "DW_LLE_start_end (%s)", |
9795 list_head->ll_symbol); | 10308 list_head->ll_symbol); |
9796 dw2_asm_output_addr (DWARF2_ADDR_SIZE, curr->begin, | 10309 dw2_asm_output_addr (DWARF2_ADDR_SIZE, curr->begin, |
9797 "Location list begin address (%s)", | 10310 "Location list begin address (%s)", |
9866 list_head->ll_symbol); | 10379 list_head->ll_symbol); |
9867 dw2_asm_output_data (DWARF2_ADDR_SIZE, 0, | 10380 dw2_asm_output_data (DWARF2_ADDR_SIZE, 0, |
9868 "Location list terminator end (%s)", | 10381 "Location list terminator end (%s)", |
9869 list_head->ll_symbol); | 10382 list_head->ll_symbol); |
9870 } | 10383 } |
10384 | |
10385 gcc_assert (!list_head->vl_symbol | |
10386 || vcount == lcount * (dwarf2out_locviews_in_attribute () ? 1 : 0)); | |
9871 } | 10387 } |
9872 | 10388 |
9873 /* Output a range_list offset into the .debug_ranges or .debug_rnglists | 10389 /* Output a range_list offset into the .debug_ranges or .debug_rnglists |
9874 section. Emit a relocated reference if val_entry is NULL, otherwise, | 10390 section. Emit a relocated reference if val_entry is NULL, otherwise, |
9875 emit an indirect reference. */ | 10391 emit an indirect reference. */ |
9928 sym); | 10444 sym); |
9929 } | 10445 } |
9930 else | 10446 else |
9931 dw2_asm_output_delta (DWARF_OFFSET_SIZE, sym, loc_section_label, | 10447 dw2_asm_output_delta (DWARF_OFFSET_SIZE, sym, loc_section_label, |
9932 "%s", dwarf_attr_name (a->dw_attr)); | 10448 "%s", dwarf_attr_name (a->dw_attr)); |
10449 } | |
10450 | |
10451 /* Output the offset into the debug_loc section. */ | |
10452 | |
10453 static void | |
10454 output_view_list_offset (dw_attr_node *a) | |
10455 { | |
10456 char *sym = (*AT_loc_list_ptr (a))->vl_symbol; | |
10457 | |
10458 gcc_assert (sym); | |
10459 if (dwarf_split_debug_info) | |
10460 dw2_asm_output_delta (DWARF_OFFSET_SIZE, sym, loc_section_label, | |
10461 "%s", dwarf_attr_name (a->dw_attr)); | |
10462 else | |
10463 dw2_asm_output_offset (DWARF_OFFSET_SIZE, sym, debug_loc_section, | |
10464 "%s", dwarf_attr_name (a->dw_attr)); | |
9933 } | 10465 } |
9934 | 10466 |
9935 /* Output an attribute's index or value appropriately. */ | 10467 /* Output an attribute's index or value appropriately. */ |
9936 | 10468 |
9937 static void | 10469 static void |
10040 && a->dw_attr == DW_AT_data_member_location | 10572 && a->dw_attr == DW_AT_data_member_location |
10041 && csize >= 4) | 10573 && csize >= 4) |
10042 dw2_asm_output_data_uleb128 (AT_unsigned (a), "%s", name); | 10574 dw2_asm_output_data_uleb128 (AT_unsigned (a), "%s", name); |
10043 else | 10575 else |
10044 dw2_asm_output_data (csize, AT_unsigned (a), "%s", name); | 10576 dw2_asm_output_data (csize, AT_unsigned (a), "%s", name); |
10577 } | |
10578 break; | |
10579 | |
10580 case dw_val_class_symview: | |
10581 { | |
10582 int vsize; | |
10583 if (symview_upper_bound <= 0xff) | |
10584 vsize = 1; | |
10585 else if (symview_upper_bound <= 0xffff) | |
10586 vsize = 2; | |
10587 else if (symview_upper_bound <= 0xffffffff) | |
10588 vsize = 4; | |
10589 else | |
10590 vsize = 8; | |
10591 dw2_asm_output_addr (vsize, a->dw_attr_val.v.val_symbolic_view, | |
10592 "%s", name); | |
10045 } | 10593 } |
10046 break; | 10594 break; |
10047 | 10595 |
10048 case dw_val_class_const_implicit: | 10596 case dw_val_class_const_implicit: |
10049 if (flag_debug_asm) | 10597 if (flag_debug_asm) |
10153 dw2_asm_output_data (1, AT_flag (a), "%s", name); | 10701 dw2_asm_output_data (1, AT_flag (a), "%s", name); |
10154 break; | 10702 break; |
10155 | 10703 |
10156 case dw_val_class_loc_list: | 10704 case dw_val_class_loc_list: |
10157 output_loc_list_offset (a); | 10705 output_loc_list_offset (a); |
10706 break; | |
10707 | |
10708 case dw_val_class_view_list: | |
10709 output_view_list_offset (a); | |
10158 break; | 10710 break; |
10159 | 10711 |
10160 case dw_val_class_die_ref: | 10712 case dw_val_class_die_ref: |
10161 if (AT_ref_external (a)) | 10713 if (AT_ref_external (a)) |
10162 { | 10714 { |
10256 else if (a->dw_attr_val.v.val_str->form == DW_FORM_line_strp) | 10808 else if (a->dw_attr_val.v.val_str->form == DW_FORM_line_strp) |
10257 dw2_asm_output_offset (DWARF_OFFSET_SIZE, | 10809 dw2_asm_output_offset (DWARF_OFFSET_SIZE, |
10258 a->dw_attr_val.v.val_str->label, | 10810 a->dw_attr_val.v.val_str->label, |
10259 debug_line_str_section, | 10811 debug_line_str_section, |
10260 "%s: \"%s\"", name, AT_string (a)); | 10812 "%s: \"%s\"", name, AT_string (a)); |
10261 else if (a->dw_attr_val.v.val_str->form == DW_FORM_GNU_str_index) | 10813 else if (a->dw_attr_val.v.val_str->form == dwarf_FORM (DW_FORM_strx)) |
10262 dw2_asm_output_data_uleb128 (AT_index (a), | 10814 dw2_asm_output_data_uleb128 (AT_index (a), |
10263 "%s: \"%s\"", name, AT_string (a)); | 10815 "%s: \"%s\"", name, AT_string (a)); |
10264 else | 10816 else |
10265 dw2_asm_output_nstring (AT_string (a), -1, "%s", name); | 10817 dw2_asm_output_nstring (AT_string (a), -1, "%s", name); |
10266 break; | 10818 break; |
10339 if (die->die_child != NULL) | 10891 if (die->die_child != NULL) |
10340 dw2_asm_output_data (1, 0, "end of children of DIE %#lx", | 10892 dw2_asm_output_data (1, 0, "end of children of DIE %#lx", |
10341 (unsigned long) die->die_offset); | 10893 (unsigned long) die->die_offset); |
10342 } | 10894 } |
10343 | 10895 |
10896 /* Output the dwarf version number. */ | |
10897 | |
10898 static void | |
10899 output_dwarf_version () | |
10900 { | |
10901 /* ??? For now, if -gdwarf-6 is specified, we output version 5 with | |
10902 views in loclist. That will change eventually. */ | |
10903 if (dwarf_version == 6) | |
10904 { | |
10905 static bool once; | |
10906 if (!once) | |
10907 { | |
10908 warning (0, | |
10909 "-gdwarf-6 is output as version 5 with incompatibilities"); | |
10910 once = true; | |
10911 } | |
10912 dw2_asm_output_data (2, 5, "DWARF version number"); | |
10913 } | |
10914 else | |
10915 dw2_asm_output_data (2, dwarf_version, "DWARF version number"); | |
10916 } | |
10917 | |
10344 /* Output the compilation unit that appears at the beginning of the | 10918 /* Output the compilation unit that appears at the beginning of the |
10345 .debug_info section, and precedes the DIE descriptions. */ | 10919 .debug_info section, and precedes the DIE descriptions. */ |
10346 | 10920 |
10347 static void | 10921 static void |
10348 output_compilation_unit_header (enum dwarf_unit_type ut) | 10922 output_compilation_unit_header (enum dwarf_unit_type ut) |
10355 dw2_asm_output_data (DWARF_OFFSET_SIZE, | 10929 dw2_asm_output_data (DWARF_OFFSET_SIZE, |
10356 next_die_offset - DWARF_INITIAL_LENGTH_SIZE, | 10930 next_die_offset - DWARF_INITIAL_LENGTH_SIZE, |
10357 "Length of Compilation Unit Info"); | 10931 "Length of Compilation Unit Info"); |
10358 } | 10932 } |
10359 | 10933 |
10360 dw2_asm_output_data (2, dwarf_version, "DWARF version number"); | 10934 output_dwarf_version (); |
10361 if (dwarf_version >= 5) | 10935 if (dwarf_version >= 5) |
10362 { | 10936 { |
10363 const char *name; | 10937 const char *name; |
10364 switch (ut) | 10938 switch (ut) |
10365 { | 10939 { |
10515 skeleton_debug_str_hash | 11089 skeleton_debug_str_hash |
10516 = hash_table<indirect_string_hasher>::create_ggc (10); | 11090 = hash_table<indirect_string_hasher>::create_ggc (10); |
10517 | 11091 |
10518 node = find_AT_string_in_table (str, skeleton_debug_str_hash); | 11092 node = find_AT_string_in_table (str, skeleton_debug_str_hash); |
10519 find_string_form (node); | 11093 find_string_form (node); |
10520 if (node->form == DW_FORM_GNU_str_index) | 11094 if (node->form == dwarf_FORM (DW_FORM_strx)) |
10521 node->form = DW_FORM_strp; | 11095 node->form = DW_FORM_strp; |
10522 | 11096 |
10523 attr.dw_attr = attr_kind; | 11097 attr.dw_attr = attr_kind; |
10524 attr.dw_attr_val.val_class = dw_val_class_str; | 11098 attr.dw_attr_val.val_class = dw_val_class_str; |
10525 attr.dw_attr_val.val_entry = NULL; | 11099 attr.dw_attr_val.val_entry = NULL; |
10538 | 11112 |
10539 add_skeleton_AT_string (die, dwarf_AT (DW_AT_dwo_name), dwo_file_name); | 11113 add_skeleton_AT_string (die, dwarf_AT (DW_AT_dwo_name), dwo_file_name); |
10540 if (comp_dir != NULL) | 11114 if (comp_dir != NULL) |
10541 add_skeleton_AT_string (die, DW_AT_comp_dir, comp_dir); | 11115 add_skeleton_AT_string (die, DW_AT_comp_dir, comp_dir); |
10542 add_AT_pubnames (die); | 11116 add_AT_pubnames (die); |
10543 add_AT_lineptr (die, DW_AT_GNU_addr_base, debug_addr_section_label); | 11117 add_AT_lineptr (die, dwarf_AT (DW_AT_addr_base), debug_addr_section_label); |
10544 } | 11118 } |
10545 | 11119 |
10546 /* Output skeleton debug sections that point to the dwo file. */ | 11120 /* Output skeleton debug sections that point to the dwo file. */ |
10547 | 11121 |
10548 static void | 11122 static void |
10567 dw2_asm_output_data (DWARF_OFFSET_SIZE, | 11141 dw2_asm_output_data (DWARF_OFFSET_SIZE, |
10568 DWARF_COMPILE_UNIT_SKELETON_HEADER_SIZE | 11142 DWARF_COMPILE_UNIT_SKELETON_HEADER_SIZE |
10569 - DWARF_INITIAL_LENGTH_SIZE | 11143 - DWARF_INITIAL_LENGTH_SIZE |
10570 + size_of_die (comp_unit), | 11144 + size_of_die (comp_unit), |
10571 "Length of Compilation Unit Info"); | 11145 "Length of Compilation Unit Info"); |
10572 dw2_asm_output_data (2, dwarf_version, "DWARF version number"); | 11146 output_dwarf_version (); |
10573 if (dwarf_version >= 5) | 11147 if (dwarf_version >= 5) |
10574 { | 11148 { |
10575 dw2_asm_output_data (1, DW_UT_skeleton, "DW_UT_skeleton"); | 11149 dw2_asm_output_data (1, DW_UT_skeleton, "DW_UT_skeleton"); |
10576 dw2_asm_output_data (1, DWARF2_ADDR_SIZE, "Pointer Size (in bytes)"); | 11150 dw2_asm_output_data (1, DWARF2_ADDR_SIZE, "Pointer Size (in bytes)"); |
10577 } | 11151 } |
10866 dw2_asm_output_data (DWARF_OFFSET_SIZE, pubnames_length, | 11440 dw2_asm_output_data (DWARF_OFFSET_SIZE, pubnames_length, |
10867 "Pub Info Length"); | 11441 "Pub Info Length"); |
10868 } | 11442 } |
10869 | 11443 |
10870 /* Version number for pubnames/pubtypes is independent of dwarf version. */ | 11444 /* Version number for pubnames/pubtypes is independent of dwarf version. */ |
10871 dw2_asm_output_data (2, 2, "DWARF Version"); | 11445 dw2_asm_output_data (2, 2, "DWARF pubnames/pubtypes version"); |
10872 | 11446 |
10873 if (dwarf_split_debug_info) | 11447 if (dwarf_split_debug_info) |
10874 dw2_asm_output_offset (DWARF_OFFSET_SIZE, debug_skeleton_info_section_label, | 11448 dw2_asm_output_offset (DWARF_OFFSET_SIZE, debug_skeleton_info_section_label, |
10875 debug_skeleton_info_section, | 11449 debug_skeleton_info_section, |
10876 "Offset of Compilation Unit Info"); | 11450 "Offset of Compilation Unit Info"); |
10948 dw2_asm_output_data (DWARF_OFFSET_SIZE, aranges_length, | 11522 dw2_asm_output_data (DWARF_OFFSET_SIZE, aranges_length, |
10949 "Length of Address Ranges Info"); | 11523 "Length of Address Ranges Info"); |
10950 } | 11524 } |
10951 | 11525 |
10952 /* Version number for aranges is still 2, even up to DWARF5. */ | 11526 /* Version number for aranges is still 2, even up to DWARF5. */ |
10953 dw2_asm_output_data (2, 2, "DWARF Version"); | 11527 dw2_asm_output_data (2, 2, "DWARF aranges version"); |
10954 if (dwarf_split_debug_info) | 11528 if (dwarf_split_debug_info) |
10955 dw2_asm_output_offset (DWARF_OFFSET_SIZE, debug_skeleton_info_section_label, | 11529 dw2_asm_output_offset (DWARF_OFFSET_SIZE, debug_skeleton_info_section_label, |
10956 debug_skeleton_info_section, | 11530 debug_skeleton_info_section, |
10957 "Offset of Compilation Unit Info"); | 11531 "Offset of Compilation Unit Info"); |
10958 else | 11532 else |
11190 } | 11764 } |
11191 | 11765 |
11192 /* Emit .debug_rnglists section. */ | 11766 /* Emit .debug_rnglists section. */ |
11193 | 11767 |
11194 static void | 11768 static void |
11195 output_rnglists (void) | 11769 output_rnglists (unsigned generation) |
11196 { | 11770 { |
11197 unsigned i; | 11771 unsigned i; |
11198 dw_ranges *r; | 11772 dw_ranges *r; |
11199 char l1[MAX_ARTIFICIAL_LABEL_BYTES]; | 11773 char l1[MAX_ARTIFICIAL_LABEL_BYTES]; |
11200 char l2[MAX_ARTIFICIAL_LABEL_BYTES]; | 11774 char l2[MAX_ARTIFICIAL_LABEL_BYTES]; |
11201 char basebuf[MAX_ARTIFICIAL_LABEL_BYTES]; | 11775 char basebuf[MAX_ARTIFICIAL_LABEL_BYTES]; |
11202 | 11776 |
11203 switch_to_section (debug_ranges_section); | 11777 switch_to_section (debug_ranges_section); |
11204 ASM_OUTPUT_LABEL (asm_out_file, ranges_section_label); | 11778 ASM_OUTPUT_LABEL (asm_out_file, ranges_section_label); |
11205 ASM_GENERATE_INTERNAL_LABEL (l1, DEBUG_RANGES_SECTION_LABEL, 2); | 11779 /* There are up to 4 unique ranges labels per generation. |
11206 ASM_GENERATE_INTERNAL_LABEL (l2, DEBUG_RANGES_SECTION_LABEL, 3); | 11780 See also init_sections_and_labels. */ |
11781 ASM_GENERATE_INTERNAL_LABEL (l1, DEBUG_RANGES_SECTION_LABEL, | |
11782 2 + generation * 4); | |
11783 ASM_GENERATE_INTERNAL_LABEL (l2, DEBUG_RANGES_SECTION_LABEL, | |
11784 3 + generation * 4); | |
11207 if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4) | 11785 if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4) |
11208 dw2_asm_output_data (4, 0xffffffff, | 11786 dw2_asm_output_data (4, 0xffffffff, |
11209 "Initial length escape value indicating " | 11787 "Initial length escape value indicating " |
11210 "64-bit DWARF extension"); | 11788 "64-bit DWARF extension"); |
11211 dw2_asm_output_delta (DWARF_OFFSET_SIZE, l2, l1, | 11789 dw2_asm_output_delta (DWARF_OFFSET_SIZE, l2, l1, |
11212 "Length of Range Lists"); | 11790 "Length of Range Lists"); |
11213 ASM_OUTPUT_LABEL (asm_out_file, l1); | 11791 ASM_OUTPUT_LABEL (asm_out_file, l1); |
11214 dw2_asm_output_data (2, dwarf_version, "DWARF Version"); | 11792 output_dwarf_version (); |
11215 dw2_asm_output_data (1, DWARF2_ADDR_SIZE, "Address Size"); | 11793 dw2_asm_output_data (1, DWARF2_ADDR_SIZE, "Address Size"); |
11216 dw2_asm_output_data (1, 0, "Segment Size"); | 11794 dw2_asm_output_data (1, 0, "Segment Size"); |
11217 /* Emit the offset table only for -gsplit-dwarf. If we don't care | 11795 /* Emit the offset table only for -gsplit-dwarf. If we don't care |
11218 about relocation sizes and primarily care about the size of .debug* | 11796 about relocation sizes and primarily care about the size of .debug* |
11219 sections in linked shared libraries and executables, then | 11797 sections in linked shared libraries and executables, then |
11383 | 11961 |
11384 /* Take care of file names without directories. We need to make sure that | 11962 /* Take care of file names without directories. We need to make sure that |
11385 we return consistent values to qsort since some will get confused if | 11963 we return consistent values to qsort since some will get confused if |
11386 we return the same value when identical operands are passed in opposite | 11964 we return the same value when identical operands are passed in opposite |
11387 orders. So if neither has a directory, return 0 and otherwise return | 11965 orders. So if neither has a directory, return 0 and otherwise return |
11388 1 or -1 depending on which one has the directory. */ | 11966 1 or -1 depending on which one has the directory. We want the one with |
11967 the directory to sort after the one without, so all no directory files | |
11968 are at the start (normally only the compilation unit file). */ | |
11389 if ((s1->path == s1->fname || s2->path == s2->fname)) | 11969 if ((s1->path == s1->fname || s2->path == s2->fname)) |
11390 return (s2->path == s2->fname) - (s1->path == s1->fname); | 11970 return (s2->path == s2->fname) - (s1->path == s1->fname); |
11391 | 11971 |
11392 cp1 = (const unsigned char *) s1->path; | 11972 cp1 = (const unsigned char *) s1->path; |
11393 cp2 = (const unsigned char *) s2->path; | 11973 cp2 = (const unsigned char *) s2->path; |
11394 | 11974 |
11395 while (1) | 11975 while (1) |
11396 { | 11976 { |
11397 ++cp1; | 11977 ++cp1; |
11398 ++cp2; | 11978 ++cp2; |
11399 /* Reached the end of the first path? If so, handle like above. */ | 11979 /* Reached the end of the first path? If so, handle like above, |
11980 but now we want longer directory prefixes before shorter ones. */ | |
11400 if ((cp1 == (const unsigned char *) s1->fname) | 11981 if ((cp1 == (const unsigned char *) s1->fname) |
11401 || (cp2 == (const unsigned char *) s2->fname)) | 11982 || (cp2 == (const unsigned char *) s2->fname)) |
11402 return ((cp2 == (const unsigned char *) s2->fname) | 11983 return ((cp1 == (const unsigned char *) s1->fname) |
11403 - (cp1 == (const unsigned char *) s1->fname)); | 11984 - (cp2 == (const unsigned char *) s2->fname)); |
11404 | 11985 |
11405 /* Character of current path component the same? */ | 11986 /* Character of current path component the same? */ |
11406 else if (*cp1 != *cp2) | 11987 else if (*cp1 != *cp2) |
11407 return *cp1 - *cp2; | 11988 return *cp1 - *cp2; |
11408 } | 11989 } |
11843 output_one_line_info_table (dw_line_info_table *table) | 12424 output_one_line_info_table (dw_line_info_table *table) |
11844 { | 12425 { |
11845 char line_label[MAX_ARTIFICIAL_LABEL_BYTES]; | 12426 char line_label[MAX_ARTIFICIAL_LABEL_BYTES]; |
11846 unsigned int current_line = 1; | 12427 unsigned int current_line = 1; |
11847 bool current_is_stmt = DWARF_LINE_DEFAULT_IS_STMT_START; | 12428 bool current_is_stmt = DWARF_LINE_DEFAULT_IS_STMT_START; |
11848 dw_line_info_entry *ent; | 12429 dw_line_info_entry *ent, *prev_addr; |
11849 size_t i; | 12430 size_t i; |
12431 unsigned int view; | |
12432 | |
12433 view = 0; | |
11850 | 12434 |
11851 FOR_EACH_VEC_SAFE_ELT (table->entries, i, ent) | 12435 FOR_EACH_VEC_SAFE_ELT (table->entries, i, ent) |
11852 { | 12436 { |
11853 switch (ent->opcode) | 12437 switch (ent->opcode) |
11854 { | 12438 { |
11859 ports do have length attributes which will give an upper bound | 12443 ports do have length attributes which will give an upper bound |
11860 on the address range. We could perhaps use length attributes | 12444 on the address range. We could perhaps use length attributes |
11861 to determine when it is safe to use DW_LNS_fixed_advance_pc. */ | 12445 to determine when it is safe to use DW_LNS_fixed_advance_pc. */ |
11862 ASM_GENERATE_INTERNAL_LABEL (line_label, LINE_CODE_LABEL, ent->val); | 12446 ASM_GENERATE_INTERNAL_LABEL (line_label, LINE_CODE_LABEL, ent->val); |
11863 | 12447 |
12448 view = 0; | |
12449 | |
11864 /* This can handle any delta. This takes | 12450 /* This can handle any delta. This takes |
11865 4+DWARF2_ADDR_SIZE bytes. */ | 12451 4+DWARF2_ADDR_SIZE bytes. */ |
11866 dw2_asm_output_data (1, 0, "set address %s", line_label); | 12452 dw2_asm_output_data (1, 0, "set address %s%s", line_label, |
12453 debug_variable_location_views | |
12454 ? ", reset view to 0" : ""); | |
11867 dw2_asm_output_data_uleb128 (1 + DWARF2_ADDR_SIZE, NULL); | 12455 dw2_asm_output_data_uleb128 (1 + DWARF2_ADDR_SIZE, NULL); |
11868 dw2_asm_output_data (1, DW_LNE_set_address, NULL); | 12456 dw2_asm_output_data (1, DW_LNE_set_address, NULL); |
11869 dw2_asm_output_addr (DWARF2_ADDR_SIZE, line_label, NULL); | 12457 dw2_asm_output_addr (DWARF2_ADDR_SIZE, line_label, NULL); |
12458 | |
12459 prev_addr = ent; | |
11870 break; | 12460 break; |
12461 | |
12462 case LI_adv_address: | |
12463 { | |
12464 ASM_GENERATE_INTERNAL_LABEL (line_label, LINE_CODE_LABEL, ent->val); | |
12465 char prev_label[MAX_ARTIFICIAL_LABEL_BYTES]; | |
12466 ASM_GENERATE_INTERNAL_LABEL (prev_label, LINE_CODE_LABEL, prev_addr->val); | |
12467 | |
12468 view++; | |
12469 | |
12470 dw2_asm_output_data (1, DW_LNS_fixed_advance_pc, "fixed advance PC, increment view to %i", view); | |
12471 dw2_asm_output_delta (2, line_label, prev_label, | |
12472 "from %s to %s", prev_label, line_label); | |
12473 | |
12474 prev_addr = ent; | |
12475 break; | |
12476 } | |
11871 | 12477 |
11872 case LI_set_line: | 12478 case LI_set_line: |
11873 if (ent->val == current_line) | 12479 if (ent->val == current_line) |
11874 { | 12480 { |
11875 /* We still need to start a new row, so output a copy insn. */ | 12481 /* We still need to start a new row, so output a copy insn. */ |
11974 "Length of Source Line Info"); | 12580 "Length of Source Line Info"); |
11975 } | 12581 } |
11976 | 12582 |
11977 ASM_OUTPUT_LABEL (asm_out_file, l1); | 12583 ASM_OUTPUT_LABEL (asm_out_file, l1); |
11978 | 12584 |
11979 dw2_asm_output_data (2, dwarf_version, "DWARF Version"); | 12585 output_dwarf_version (); |
11980 if (dwarf_version >= 5) | 12586 if (dwarf_version >= 5) |
11981 { | 12587 { |
11982 dw2_asm_output_data (1, DWARF2_ADDR_SIZE, "Address Size"); | 12588 dw2_asm_output_data (1, DWARF2_ADDR_SIZE, "Address Size"); |
11983 dw2_asm_output_data (1, 0, "Segment Size"); | 12589 dw2_asm_output_data (1, 0, "Segment Size"); |
11984 } | 12590 } |
12271 case INTEGER_TYPE: | 12877 case INTEGER_TYPE: |
12272 case REAL_TYPE: | 12878 case REAL_TYPE: |
12273 case FIXED_POINT_TYPE: | 12879 case FIXED_POINT_TYPE: |
12274 case COMPLEX_TYPE: | 12880 case COMPLEX_TYPE: |
12275 case BOOLEAN_TYPE: | 12881 case BOOLEAN_TYPE: |
12276 case POINTER_BOUNDS_TYPE: | |
12277 return 1; | 12882 return 1; |
12278 | 12883 |
12279 case VOID_TYPE: | 12884 case VOID_TYPE: |
12280 case ARRAY_TYPE: | 12885 case ARRAY_TYPE: |
12281 case RECORD_TYPE: | 12886 case RECORD_TYPE: |
12479 tree qualified_type; | 13084 tree qualified_type; |
12480 tree name, low, high; | 13085 tree name, low, high; |
12481 dw_die_ref mod_scope; | 13086 dw_die_ref mod_scope; |
12482 /* Only these cv-qualifiers are currently handled. */ | 13087 /* Only these cv-qualifiers are currently handled. */ |
12483 const int cv_qual_mask = (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE | 13088 const int cv_qual_mask = (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE |
12484 | TYPE_QUAL_RESTRICT | TYPE_QUAL_ATOMIC); | 13089 | TYPE_QUAL_RESTRICT | TYPE_QUAL_ATOMIC | |
13090 ENCODE_QUAL_ADDR_SPACE(~0U)); | |
12485 const bool reverse_base_type | 13091 const bool reverse_base_type |
12486 = need_endianity_attribute_p (reverse) && is_base_type (type); | 13092 = need_endianity_attribute_p (reverse) && is_base_type (type); |
12487 | 13093 |
12488 if (code == ERROR_MARK) | 13094 if (code == ERROR_MARK) |
12489 return NULL; | 13095 return NULL; |
13018 false /* Don't emit DW_AT_name */, | 13624 false /* Don't emit DW_AT_name */, |
13019 die); | 13625 die); |
13020 return die; | 13626 return die; |
13021 } | 13627 } |
13022 | 13628 |
13023 /* Given a pointer to an arbitrary ..._TYPE tree node, return true if it is | |
13024 an enumerated type. */ | |
13025 | |
13026 static inline int | |
13027 type_is_enum (const_tree type) | |
13028 { | |
13029 return TREE_CODE (type) == ENUMERAL_TYPE; | |
13030 } | |
13031 | |
13032 /* Return the DBX register number described by a given RTL node. */ | 13629 /* Return the DBX register number described by a given RTL node. */ |
13033 | 13630 |
13034 static unsigned int | 13631 static unsigned int |
13035 dbx_reg_number (const_rtx rtl) | 13632 dbx_reg_number (const_rtx rtl) |
13036 { | 13633 { |
13163 #endif | 13760 #endif |
13164 | 13761 |
13165 gcc_assert ((unsigned) DBX_REGISTER_NUMBER (reg) == dbx_reg_number (rtl)); | 13762 gcc_assert ((unsigned) DBX_REGISTER_NUMBER (reg) == dbx_reg_number (rtl)); |
13166 nregs = REG_NREGS (rtl); | 13763 nregs = REG_NREGS (rtl); |
13167 | 13764 |
13168 size = GET_MODE_SIZE (GET_MODE (rtl)) / nregs; | 13765 /* At present we only track constant-sized pieces. */ |
13766 if (!GET_MODE_SIZE (GET_MODE (rtl)).is_constant (&size)) | |
13767 return NULL; | |
13768 size /= nregs; | |
13169 | 13769 |
13170 loc_result = NULL; | 13770 loc_result = NULL; |
13171 while (nregs--) | 13771 while (nregs--) |
13172 { | 13772 { |
13173 dw_loc_descr_ref t; | 13773 dw_loc_descr_ref t; |
13183 | 13783 |
13184 /* Now onto stupid register sets in non contiguous locations. */ | 13784 /* Now onto stupid register sets in non contiguous locations. */ |
13185 | 13785 |
13186 gcc_assert (GET_CODE (regs) == PARALLEL); | 13786 gcc_assert (GET_CODE (regs) == PARALLEL); |
13187 | 13787 |
13188 size = GET_MODE_SIZE (GET_MODE (XVECEXP (regs, 0, 0))); | 13788 /* At present we only track constant-sized pieces. */ |
13789 if (!GET_MODE_SIZE (GET_MODE (XVECEXP (regs, 0, 0))).is_constant (&size)) | |
13790 return NULL; | |
13189 loc_result = NULL; | 13791 loc_result = NULL; |
13190 | 13792 |
13191 for (i = 0; i < XVECLEN (regs, 0); ++i) | 13793 for (i = 0; i < XVECLEN (regs, 0); ++i) |
13192 { | 13794 { |
13193 dw_loc_descr_ref t; | 13795 dw_loc_descr_ref t; |
13216 add_loc_descr (&ret, int_loc_descriptor (shift)); | 13818 add_loc_descr (&ret, int_loc_descriptor (shift)); |
13217 add_loc_descr (&ret, new_loc_descr (DW_OP_shl, 0, 0)); | 13819 add_loc_descr (&ret, new_loc_descr (DW_OP_shl, 0, 0)); |
13218 return ret; | 13820 return ret; |
13219 } | 13821 } |
13220 | 13822 |
13221 /* Return a location descriptor that designates a constant. */ | 13823 /* Return a location descriptor that designates constant POLY_I. */ |
13222 | 13824 |
13223 static dw_loc_descr_ref | 13825 static dw_loc_descr_ref |
13224 int_loc_descriptor (HOST_WIDE_INT i) | 13826 int_loc_descriptor (poly_int64 poly_i) |
13225 { | 13827 { |
13226 enum dwarf_location_atom op; | 13828 enum dwarf_location_atom op; |
13829 | |
13830 HOST_WIDE_INT i; | |
13831 if (!poly_i.is_constant (&i)) | |
13832 { | |
13833 /* Create location descriptions for the non-constant part and | |
13834 add any constant offset at the end. */ | |
13835 dw_loc_descr_ref ret = NULL; | |
13836 HOST_WIDE_INT constant = poly_i.coeffs[0]; | |
13837 for (unsigned int j = 1; j < NUM_POLY_INT_COEFFS; ++j) | |
13838 { | |
13839 HOST_WIDE_INT coeff = poly_i.coeffs[j]; | |
13840 if (coeff != 0) | |
13841 { | |
13842 dw_loc_descr_ref start = ret; | |
13843 unsigned int factor; | |
13844 int bias; | |
13845 unsigned int regno = targetm.dwarf_poly_indeterminate_value | |
13846 (j, &factor, &bias); | |
13847 | |
13848 /* Add COEFF * ((REGNO / FACTOR) - BIAS) to the value: | |
13849 add COEFF * (REGNO / FACTOR) now and subtract | |
13850 COEFF * BIAS from the final constant part. */ | |
13851 constant -= coeff * bias; | |
13852 add_loc_descr (&ret, new_reg_loc_descr (regno, 0)); | |
13853 if (coeff % factor == 0) | |
13854 coeff /= factor; | |
13855 else | |
13856 { | |
13857 int amount = exact_log2 (factor); | |
13858 gcc_assert (amount >= 0); | |
13859 add_loc_descr (&ret, int_loc_descriptor (amount)); | |
13860 add_loc_descr (&ret, new_loc_descr (DW_OP_shr, 0, 0)); | |
13861 } | |
13862 if (coeff != 1) | |
13863 { | |
13864 add_loc_descr (&ret, int_loc_descriptor (coeff)); | |
13865 add_loc_descr (&ret, new_loc_descr (DW_OP_mul, 0, 0)); | |
13866 } | |
13867 if (start) | |
13868 add_loc_descr (&ret, new_loc_descr (DW_OP_plus, 0, 0)); | |
13869 } | |
13870 } | |
13871 loc_descr_plus_const (&ret, constant); | |
13872 return ret; | |
13873 } | |
13227 | 13874 |
13228 /* Pick the smallest representation of a constant, rather than just | 13875 /* Pick the smallest representation of a constant, rather than just |
13229 defaulting to the LEB encoding. */ | 13876 defaulting to the LEB encoding. */ |
13230 if (i >= 0) | 13877 if (i >= 0) |
13231 { | 13878 { |
13588 } | 14235 } |
13589 | 14236 |
13590 /* Return a location descriptor that designates a base+offset location. */ | 14237 /* Return a location descriptor that designates a base+offset location. */ |
13591 | 14238 |
13592 static dw_loc_descr_ref | 14239 static dw_loc_descr_ref |
13593 based_loc_descr (rtx reg, HOST_WIDE_INT offset, | 14240 based_loc_descr (rtx reg, poly_int64 offset, |
13594 enum var_init_status initialized) | 14241 enum var_init_status initialized) |
13595 { | 14242 { |
13596 unsigned int regno; | 14243 unsigned int regno; |
13597 dw_loc_descr_ref result; | 14244 dw_loc_descr_ref result; |
13598 dw_fde_ref fde = cfun->fde; | 14245 dw_fde_ref fde = cfun->fde; |
13607 ? lra_eliminate_regs (reg, VOIDmode, NULL_RTX) | 14254 ? lra_eliminate_regs (reg, VOIDmode, NULL_RTX) |
13608 : eliminate_regs (reg, VOIDmode, NULL_RTX)); | 14255 : eliminate_regs (reg, VOIDmode, NULL_RTX)); |
13609 | 14256 |
13610 if (elim != reg) | 14257 if (elim != reg) |
13611 { | 14258 { |
13612 if (GET_CODE (elim) == PLUS) | 14259 /* Allow hard frame pointer here even if frame pointer |
13613 { | 14260 isn't used since hard frame pointer is encoded with |
13614 offset += INTVAL (XEXP (elim, 1)); | 14261 DW_OP_fbreg which uses the DW_AT_frame_base attribute, |
13615 elim = XEXP (elim, 0); | 14262 not hard frame pointer directly. */ |
13616 } | 14263 elim = strip_offset_and_add (elim, &offset); |
13617 gcc_assert ((SUPPORTS_STACK_ALIGNMENT | 14264 gcc_assert (elim == hard_frame_pointer_rtx |
13618 && (elim == hard_frame_pointer_rtx | 14265 || elim == stack_pointer_rtx); |
13619 || elim == stack_pointer_rtx)) | |
13620 || elim == (frame_pointer_needed | |
13621 ? hard_frame_pointer_rtx | |
13622 : stack_pointer_rtx)); | |
13623 | 14266 |
13624 /* If drap register is used to align stack, use frame | 14267 /* If drap register is used to align stack, use frame |
13625 pointer + offset to access stack variables. If stack | 14268 pointer + offset to access stack variables. If stack |
13626 is aligned without drap, use stack pointer + offset to | 14269 is aligned without drap, use stack pointer + offset to |
13627 access stack variables. */ | 14270 access stack variables. */ |
13635 return new_reg_loc_descr (base_reg, offset); | 14278 return new_reg_loc_descr (base_reg, offset); |
13636 } | 14279 } |
13637 | 14280 |
13638 gcc_assert (frame_pointer_fb_offset_valid); | 14281 gcc_assert (frame_pointer_fb_offset_valid); |
13639 offset += frame_pointer_fb_offset; | 14282 offset += frame_pointer_fb_offset; |
13640 return new_loc_descr (DW_OP_fbreg, offset, 0); | 14283 HOST_WIDE_INT const_offset; |
14284 if (offset.is_constant (&const_offset)) | |
14285 return new_loc_descr (DW_OP_fbreg, const_offset, 0); | |
14286 else | |
14287 { | |
14288 dw_loc_descr_ref ret = new_loc_descr (DW_OP_fbreg, 0, 0); | |
14289 loc_descr_plus_const (&ret, offset); | |
14290 return ret; | |
14291 } | |
13641 } | 14292 } |
13642 } | 14293 } |
13643 | 14294 |
13644 regno = REGNO (reg); | 14295 regno = REGNO (reg); |
13645 #ifdef LEAF_REG_REMAP | 14296 #ifdef LEAF_REG_REMAP |
13650 regno = (unsigned) leaf_reg; | 14301 regno = (unsigned) leaf_reg; |
13651 } | 14302 } |
13652 #endif | 14303 #endif |
13653 regno = DWARF_FRAME_REGNUM (regno); | 14304 regno = DWARF_FRAME_REGNUM (regno); |
13654 | 14305 |
14306 HOST_WIDE_INT const_offset; | |
13655 if (!optimize && fde | 14307 if (!optimize && fde |
13656 && (fde->drap_reg == regno || fde->vdrap_reg == regno)) | 14308 && (fde->drap_reg == regno || fde->vdrap_reg == regno) |
14309 && offset.is_constant (&const_offset)) | |
13657 { | 14310 { |
13658 /* Use cfa+offset to represent the location of arguments passed | 14311 /* Use cfa+offset to represent the location of arguments passed |
13659 on the stack when drap is used to align stack. | 14312 on the stack when drap is used to align stack. |
13660 Only do this when not optimizing, for optimized code var-tracking | 14313 Only do this when not optimizing, for optimized code var-tracking |
13661 is supposed to track where the arguments live and the register | 14314 is supposed to track where the arguments live and the register |
13662 used as vdrap or drap in some spot might be used for something | 14315 used as vdrap or drap in some spot might be used for something |
13663 else in other part of the routine. */ | 14316 else in other part of the routine. */ |
13664 return new_loc_descr (DW_OP_fbreg, offset, 0); | 14317 return new_loc_descr (DW_OP_fbreg, const_offset, 0); |
13665 } | 14318 } |
13666 | 14319 |
13667 if (regno <= 31) | 14320 result = new_reg_loc_descr (regno, offset); |
13668 result = new_loc_descr ((enum dwarf_location_atom) (DW_OP_breg0 + regno), | |
13669 offset, 0); | |
13670 else | |
13671 result = new_loc_descr (DW_OP_bregx, regno, offset); | |
13672 | 14321 |
13673 if (initialized == VAR_INIT_STATUS_UNINITIALIZED) | 14322 if (initialized == VAR_INIT_STATUS_UNINITIALIZED) |
13674 add_loc_descr (&result, new_loc_descr (DW_OP_GNU_uninit, 0, 0)); | 14323 add_loc_descr (&result, new_loc_descr (DW_OP_GNU_uninit, 0, 0)); |
13675 | 14324 |
13676 return result; | 14325 return result; |
13707 | 14356 |
13708 loc_result = loc_descriptor_from_tree (MEM_EXPR (mem), 1, NULL); | 14357 loc_result = loc_descriptor_from_tree (MEM_EXPR (mem), 1, NULL); |
13709 if (loc_result == NULL) | 14358 if (loc_result == NULL) |
13710 return NULL; | 14359 return NULL; |
13711 | 14360 |
13712 if (MEM_OFFSET (mem)) | 14361 if (maybe_ne (MEM_OFFSET (mem), 0)) |
13713 loc_descr_plus_const (&loc_result, MEM_OFFSET (mem)); | 14362 loc_descr_plus_const (&loc_result, MEM_OFFSET (mem)); |
13714 | 14363 |
13715 return loc_result; | 14364 return loc_result; |
13716 } | 14365 } |
13717 | 14366 |
13775 expansion_failed (NULL_TREE, rtl, | 14424 expansion_failed (NULL_TREE, rtl, |
13776 "UNSPEC hasn't been delegitimized.\n"); | 14425 "UNSPEC hasn't been delegitimized.\n"); |
13777 return false; | 14426 return false; |
13778 } | 14427 } |
13779 | 14428 |
14429 if (CONST_POLY_INT_P (rtl)) | |
14430 return false; | |
14431 | |
14432 if (targetm.const_not_ok_for_debug_p (rtl)) | |
14433 { | |
14434 expansion_failed (NULL_TREE, rtl, | |
14435 "Expression rejected for debug by the backend.\n"); | |
14436 return false; | |
14437 } | |
14438 | |
13780 /* FIXME: Refer to PR60655. It is possible for simplification | 14439 /* FIXME: Refer to PR60655. It is possible for simplification |
13781 of rtl expressions in var tracking to produce such expressions. | 14440 of rtl expressions in var tracking to produce such expressions. |
13782 We should really identify / validate expressions | 14441 We should really identify / validate expressions |
13783 enclosed in CONST that can be handled by assemblers on various | 14442 enclosed in CONST that can be handled by assemblers on various |
13784 targets and only handle legitimate cases here. */ | 14443 targets and only handle legitimate cases here. */ |
13785 if (GET_CODE (rtl) != SYMBOL_REF) | 14444 switch (GET_CODE (rtl)) |
13786 { | 14445 { |
13787 if (GET_CODE (rtl) == NOT) | 14446 case SYMBOL_REF: |
13788 return false; | 14447 break; |
14448 case NOT: | |
14449 case NEG: | |
14450 return false; | |
14451 default: | |
13789 return true; | 14452 return true; |
13790 } | 14453 } |
13791 | 14454 |
13792 if (CONSTANT_POOL_ADDRESS_P (rtl)) | 14455 if (CONSTANT_POOL_ADDRESS_P (rtl)) |
13793 { | 14456 { |
14545 { | 15208 { |
14546 rtx rtlop1 = XEXP (rtl, 1); | 15209 rtx rtlop1 = XEXP (rtl, 1); |
14547 dw_loc_descr_ref op0, op1, ret, mask[2] = { NULL, NULL }; | 15210 dw_loc_descr_ref op0, op1, ret, mask[2] = { NULL, NULL }; |
14548 int i; | 15211 int i; |
14549 | 15212 |
14550 if (GET_MODE (rtlop1) != VOIDmode | 15213 if (is_narrower_int_mode (GET_MODE (rtlop1), mode)) |
14551 && GET_MODE_BITSIZE (GET_MODE (rtlop1)) < GET_MODE_BITSIZE (mode)) | |
14552 rtlop1 = gen_rtx_ZERO_EXTEND (mode, rtlop1); | 15214 rtlop1 = gen_rtx_ZERO_EXTEND (mode, rtlop1); |
14553 op0 = mem_loc_descriptor (XEXP (rtl, 0), mode, mem_mode, | 15215 op0 = mem_loc_descriptor (XEXP (rtl, 0), mode, mem_mode, |
14554 VAR_INIT_STATUS_INITIALIZED); | 15216 VAR_INIT_STATUS_INITIALIZED); |
14555 op1 = mem_loc_descriptor (rtlop1, mode, mem_mode, | 15217 op1 = mem_loc_descriptor (rtlop1, mode, mem_mode, |
14556 VAR_INIT_STATUS_INITIALIZED); | 15218 VAR_INIT_STATUS_INITIALIZED); |
14661 { | 15323 { |
14662 dw_loc_descr_ref mem_loc_result = NULL; | 15324 dw_loc_descr_ref mem_loc_result = NULL; |
14663 enum dwarf_location_atom op; | 15325 enum dwarf_location_atom op; |
14664 dw_loc_descr_ref op0, op1; | 15326 dw_loc_descr_ref op0, op1; |
14665 rtx inner = NULL_RTX; | 15327 rtx inner = NULL_RTX; |
15328 poly_int64 offset; | |
14666 | 15329 |
14667 if (mode == VOIDmode) | 15330 if (mode == VOIDmode) |
14668 mode = GET_MODE (rtl); | 15331 mode = GET_MODE (rtl); |
14669 | 15332 |
14670 /* Note that for a dynamically sized array, the location we will generate a | 15333 /* Note that for a dynamically sized array, the location we will generate a |
14715 if (dwarf_strict && dwarf_version < 5) | 15378 if (dwarf_strict && dwarf_version < 5) |
14716 break; | 15379 break; |
14717 if (is_a <scalar_int_mode> (mode, &int_mode) | 15380 if (is_a <scalar_int_mode> (mode, &int_mode) |
14718 && is_a <scalar_int_mode> (GET_MODE (inner), &inner_mode) | 15381 && is_a <scalar_int_mode> (GET_MODE (inner), &inner_mode) |
14719 ? GET_MODE_SIZE (int_mode) <= GET_MODE_SIZE (inner_mode) | 15382 ? GET_MODE_SIZE (int_mode) <= GET_MODE_SIZE (inner_mode) |
14720 : GET_MODE_SIZE (mode) == GET_MODE_SIZE (GET_MODE (inner))) | 15383 : known_eq (GET_MODE_SIZE (mode), GET_MODE_SIZE (GET_MODE (inner)))) |
14721 { | 15384 { |
14722 dw_die_ref type_die; | 15385 dw_die_ref type_die; |
14723 dw_loc_descr_ref cvt; | 15386 dw_loc_descr_ref cvt; |
14724 | 15387 |
14725 mem_loc_result = mem_loc_descriptor (inner, | 15388 mem_loc_result = mem_loc_descriptor (inner, |
14731 if (type_die == NULL) | 15394 if (type_die == NULL) |
14732 { | 15395 { |
14733 mem_loc_result = NULL; | 15396 mem_loc_result = NULL; |
14734 break; | 15397 break; |
14735 } | 15398 } |
14736 if (GET_MODE_SIZE (mode) | 15399 if (maybe_ne (GET_MODE_SIZE (mode), GET_MODE_SIZE (GET_MODE (inner)))) |
14737 != GET_MODE_SIZE (GET_MODE (inner))) | |
14738 cvt = new_loc_descr (dwarf_OP (DW_OP_convert), 0, 0); | 15400 cvt = new_loc_descr (dwarf_OP (DW_OP_convert), 0, 0); |
14739 else | 15401 else |
14740 cvt = new_loc_descr (dwarf_OP (DW_OP_reinterpret), 0, 0); | 15402 cvt = new_loc_descr (dwarf_OP (DW_OP_reinterpret), 0, 0); |
14741 cvt->dw_loc_oprnd1.val_class = dw_val_class_die_ref; | 15403 cvt->dw_loc_oprnd1.val_class = dw_val_class_die_ref; |
14742 cvt->dw_loc_oprnd1.v.val_die_ref.die = type_die; | 15404 cvt->dw_loc_oprnd1.v.val_die_ref.die = type_die; |
14765 dw_die_ref type_die; | 15427 dw_die_ref type_die; |
14766 unsigned int dbx_regnum; | 15428 unsigned int dbx_regnum; |
14767 | 15429 |
14768 if (dwarf_strict && dwarf_version < 5) | 15430 if (dwarf_strict && dwarf_version < 5) |
14769 break; | 15431 break; |
14770 if (REGNO (rtl) > FIRST_PSEUDO_REGISTER) | 15432 if (REGNO (rtl) >= FIRST_PSEUDO_REGISTER) |
14771 break; | 15433 break; |
14772 type_die = base_type_for_mode (mode, SCALAR_INT_MODE_P (mode)); | 15434 type_die = base_type_for_mode (mode, SCALAR_INT_MODE_P (mode)); |
14773 if (type_die == NULL) | 15435 if (type_die == NULL) |
14774 break; | 15436 break; |
14775 | 15437 |
14893 if (!is_a <scalar_int_mode> (mode, &int_mode) | 15555 if (!is_a <scalar_int_mode> (mode, &int_mode) |
14894 || GET_MODE_SIZE (int_mode) > DWARF2_ADDR_SIZE) | 15556 || GET_MODE_SIZE (int_mode) > DWARF2_ADDR_SIZE) |
14895 { | 15557 { |
14896 dw_die_ref type_die; | 15558 dw_die_ref type_die; |
14897 dw_loc_descr_ref deref; | 15559 dw_loc_descr_ref deref; |
15560 HOST_WIDE_INT size; | |
14898 | 15561 |
14899 if (dwarf_strict && dwarf_version < 5) | 15562 if (dwarf_strict && dwarf_version < 5) |
15563 return NULL; | |
15564 if (!GET_MODE_SIZE (mode).is_constant (&size)) | |
14900 return NULL; | 15565 return NULL; |
14901 type_die | 15566 type_die |
14902 = base_type_for_mode (mode, SCALAR_INT_MODE_P (mode)); | 15567 = base_type_for_mode (mode, SCALAR_INT_MODE_P (mode)); |
14903 if (type_die == NULL) | 15568 if (type_die == NULL) |
14904 return NULL; | 15569 return NULL; |
14905 deref = new_loc_descr (dwarf_OP (DW_OP_deref_type), | 15570 deref = new_loc_descr (dwarf_OP (DW_OP_deref_type), size, 0); |
14906 GET_MODE_SIZE (mode), 0); | |
14907 deref->dw_loc_oprnd2.val_class = dw_val_class_die_ref; | 15571 deref->dw_loc_oprnd2.val_class = dw_val_class_die_ref; |
14908 deref->dw_loc_oprnd2.v.val_die_ref.die = type_die; | 15572 deref->dw_loc_oprnd2.v.val_die_ref.die = type_die; |
14909 deref->dw_loc_oprnd2.v.val_die_ref.external = 0; | 15573 deref->dw_loc_oprnd2.v.val_die_ref.external = 0; |
14910 add_loc_descr (&mem_loc_result, deref); | 15574 add_loc_descr (&mem_loc_result, deref); |
14911 } | 15575 } |
14957 } | 15621 } |
14958 | 15622 |
14959 if (!const_ok_for_output (rtl)) | 15623 if (!const_ok_for_output (rtl)) |
14960 { | 15624 { |
14961 if (GET_CODE (rtl) == CONST) | 15625 if (GET_CODE (rtl) == CONST) |
14962 mem_loc_result = mem_loc_descriptor (XEXP (rtl, 0), int_mode, | 15626 switch (GET_CODE (XEXP (rtl, 0))) |
14963 mem_mode, initialized); | 15627 { |
15628 case NOT: | |
15629 op = DW_OP_not; | |
15630 goto try_const_unop; | |
15631 case NEG: | |
15632 op = DW_OP_neg; | |
15633 goto try_const_unop; | |
15634 try_const_unop: | |
15635 rtx arg; | |
15636 arg = XEXP (XEXP (rtl, 0), 0); | |
15637 if (!CONSTANT_P (arg)) | |
15638 arg = gen_rtx_CONST (int_mode, arg); | |
15639 op0 = mem_loc_descriptor (arg, int_mode, mem_mode, | |
15640 initialized); | |
15641 if (op0) | |
15642 { | |
15643 mem_loc_result = op0; | |
15644 add_loc_descr (&mem_loc_result, new_loc_descr (op, 0, 0)); | |
15645 } | |
15646 break; | |
15647 default: | |
15648 mem_loc_result = mem_loc_descriptor (XEXP (rtl, 0), int_mode, | |
15649 mem_mode, initialized); | |
15650 break; | |
15651 } | |
14964 break; | 15652 break; |
14965 } | 15653 } |
14966 | 15654 |
14967 symref: | 15655 symref: |
14968 mem_loc_result = new_addr_loc_descr (rtl, dtprel_false); | 15656 mem_loc_result = new_addr_loc_descr (rtl, dtprel_false); |
15289 When it is an integer, a CONST_DOUBLE is used whenever | 15977 When it is an integer, a CONST_DOUBLE is used whenever |
15290 the constant requires 2 HWIs to be adequately represented. | 15978 the constant requires 2 HWIs to be adequately represented. |
15291 We output CONST_DOUBLEs as blocks. */ | 15979 We output CONST_DOUBLEs as blocks. */ |
15292 if (mode == VOIDmode | 15980 if (mode == VOIDmode |
15293 || (GET_MODE (rtl) == VOIDmode | 15981 || (GET_MODE (rtl) == VOIDmode |
15294 && GET_MODE_BITSIZE (mode) != HOST_BITS_PER_DOUBLE_INT)) | 15982 && maybe_ne (GET_MODE_BITSIZE (mode), |
15983 HOST_BITS_PER_DOUBLE_INT))) | |
15295 break; | 15984 break; |
15296 type_die = base_type_for_mode (mode, SCALAR_INT_MODE_P (mode)); | 15985 type_die = base_type_for_mode (mode, SCALAR_INT_MODE_P (mode)); |
15297 if (type_die == NULL) | 15986 if (type_die == NULL) |
15298 return NULL; | 15987 return NULL; |
15299 mem_loc_result = new_loc_descr (dwarf_OP (DW_OP_const_type), 0, 0); | 15988 mem_loc_result = new_loc_descr (dwarf_OP (DW_OP_const_type), 0, 0); |
15339 mem_loc_result->dw_loc_oprnd2.val_class | 16028 mem_loc_result->dw_loc_oprnd2.val_class |
15340 = dw_val_class_wide_int; | 16029 = dw_val_class_wide_int; |
15341 mem_loc_result->dw_loc_oprnd2.v.val_wide = ggc_alloc<wide_int> (); | 16030 mem_loc_result->dw_loc_oprnd2.v.val_wide = ggc_alloc<wide_int> (); |
15342 *mem_loc_result->dw_loc_oprnd2.v.val_wide = rtx_mode_t (rtl, mode); | 16031 *mem_loc_result->dw_loc_oprnd2.v.val_wide = rtx_mode_t (rtl, mode); |
15343 } | 16032 } |
16033 break; | |
16034 | |
16035 case CONST_POLY_INT: | |
16036 mem_loc_result = int_loc_descriptor (rtx_to_poly_int64 (rtl)); | |
15344 break; | 16037 break; |
15345 | 16038 |
15346 case EQ: | 16039 case EQ: |
15347 mem_loc_result = scompare_loc_descriptor (DW_OP_eq, rtl, mem_mode); | 16040 mem_loc_result = scompare_loc_descriptor (DW_OP_eq, rtl, mem_mode); |
15348 break; | 16041 break; |
15570 case ASM_OPERANDS: | 16263 case ASM_OPERANDS: |
15571 case VEC_MERGE: | 16264 case VEC_MERGE: |
15572 case VEC_SELECT: | 16265 case VEC_SELECT: |
15573 case VEC_CONCAT: | 16266 case VEC_CONCAT: |
15574 case VEC_DUPLICATE: | 16267 case VEC_DUPLICATE: |
16268 case VEC_SERIES: | |
15575 case UNSPEC: | 16269 case UNSPEC: |
15576 case HIGH: | 16270 case HIGH: |
15577 case FMA: | 16271 case FMA: |
15578 case STRICT_LOW_PART: | 16272 case STRICT_LOW_PART: |
15579 case CONST_VECTOR: | 16273 case CONST_VECTOR: |
15580 case CONST_FIXED: | 16274 case CONST_FIXED: |
15581 case CLRSB: | 16275 case CLRSB: |
15582 case CLOBBER: | 16276 case CLOBBER: |
16277 case CLOBBER_HIGH: | |
15583 /* If delegitimize_address couldn't do anything with the UNSPEC, we | 16278 /* If delegitimize_address couldn't do anything with the UNSPEC, we |
15584 can't express it in the debug info. This can happen e.g. with some | 16279 can't express it in the debug info. This can happen e.g. with some |
15585 TLS UNSPECs. */ | 16280 TLS UNSPECs. */ |
15586 break; | 16281 break; |
15587 | 16282 |
15648 This is typically a complex variable. */ | 16343 This is typically a complex variable. */ |
15649 | 16344 |
15650 static dw_loc_descr_ref | 16345 static dw_loc_descr_ref |
15651 concat_loc_descriptor (rtx x0, rtx x1, enum var_init_status initialized) | 16346 concat_loc_descriptor (rtx x0, rtx x1, enum var_init_status initialized) |
15652 { | 16347 { |
16348 /* At present we only track constant-sized pieces. */ | |
16349 unsigned int size0, size1; | |
16350 if (!GET_MODE_SIZE (GET_MODE (x0)).is_constant (&size0) | |
16351 || !GET_MODE_SIZE (GET_MODE (x1)).is_constant (&size1)) | |
16352 return 0; | |
16353 | |
15653 dw_loc_descr_ref cc_loc_result = NULL; | 16354 dw_loc_descr_ref cc_loc_result = NULL; |
15654 dw_loc_descr_ref x0_ref | 16355 dw_loc_descr_ref x0_ref |
15655 = loc_descriptor (x0, VOIDmode, VAR_INIT_STATUS_INITIALIZED); | 16356 = loc_descriptor (x0, VOIDmode, VAR_INIT_STATUS_INITIALIZED); |
15656 dw_loc_descr_ref x1_ref | 16357 dw_loc_descr_ref x1_ref |
15657 = loc_descriptor (x1, VOIDmode, VAR_INIT_STATUS_INITIALIZED); | 16358 = loc_descriptor (x1, VOIDmode, VAR_INIT_STATUS_INITIALIZED); |
15658 | 16359 |
15659 if (x0_ref == 0 || x1_ref == 0) | 16360 if (x0_ref == 0 || x1_ref == 0) |
15660 return 0; | 16361 return 0; |
15661 | 16362 |
15662 cc_loc_result = x0_ref; | 16363 cc_loc_result = x0_ref; |
15663 add_loc_descr_op_piece (&cc_loc_result, GET_MODE_SIZE (GET_MODE (x0))); | 16364 add_loc_descr_op_piece (&cc_loc_result, size0); |
15664 | 16365 |
15665 add_loc_descr (&cc_loc_result, x1_ref); | 16366 add_loc_descr (&cc_loc_result, x1_ref); |
15666 add_loc_descr_op_piece (&cc_loc_result, GET_MODE_SIZE (GET_MODE (x1))); | 16367 add_loc_descr_op_piece (&cc_loc_result, size1); |
15667 | 16368 |
15668 if (initialized == VAR_INIT_STATUS_UNINITIALIZED) | 16369 if (initialized == VAR_INIT_STATUS_UNINITIALIZED) |
15669 add_loc_descr (&cc_loc_result, new_loc_descr (DW_OP_GNU_uninit, 0, 0)); | 16370 add_loc_descr (&cc_loc_result, new_loc_descr (DW_OP_GNU_uninit, 0, 0)); |
15670 | 16371 |
15671 return cc_loc_result; | 16372 return cc_loc_result; |
15678 concatn_loc_descriptor (rtx concatn, enum var_init_status initialized) | 16379 concatn_loc_descriptor (rtx concatn, enum var_init_status initialized) |
15679 { | 16380 { |
15680 unsigned int i; | 16381 unsigned int i; |
15681 dw_loc_descr_ref cc_loc_result = NULL; | 16382 dw_loc_descr_ref cc_loc_result = NULL; |
15682 unsigned int n = XVECLEN (concatn, 0); | 16383 unsigned int n = XVECLEN (concatn, 0); |
16384 unsigned int size; | |
15683 | 16385 |
15684 for (i = 0; i < n; ++i) | 16386 for (i = 0; i < n; ++i) |
15685 { | 16387 { |
15686 dw_loc_descr_ref ref; | 16388 dw_loc_descr_ref ref; |
15687 rtx x = XVECEXP (concatn, 0, i); | 16389 rtx x = XVECEXP (concatn, 0, i); |
16390 | |
16391 /* At present we only track constant-sized pieces. */ | |
16392 if (!GET_MODE_SIZE (GET_MODE (x)).is_constant (&size)) | |
16393 return NULL; | |
15688 | 16394 |
15689 ref = loc_descriptor (x, VOIDmode, VAR_INIT_STATUS_INITIALIZED); | 16395 ref = loc_descriptor (x, VOIDmode, VAR_INIT_STATUS_INITIALIZED); |
15690 if (ref == NULL) | 16396 if (ref == NULL) |
15691 return NULL; | 16397 return NULL; |
15692 | 16398 |
15693 add_loc_descr (&cc_loc_result, ref); | 16399 add_loc_descr (&cc_loc_result, ref); |
15694 add_loc_descr_op_piece (&cc_loc_result, GET_MODE_SIZE (GET_MODE (x))); | 16400 add_loc_descr_op_piece (&cc_loc_result, size); |
15695 } | 16401 } |
15696 | 16402 |
15697 if (cc_loc_result && initialized == VAR_INIT_STATUS_UNINITIALIZED) | 16403 if (cc_loc_result && initialized == VAR_INIT_STATUS_UNINITIALIZED) |
15698 add_loc_descr (&cc_loc_result, new_loc_descr (DW_OP_GNU_uninit, 0, 0)); | 16404 add_loc_descr (&cc_loc_result, new_loc_descr (DW_OP_GNU_uninit, 0, 0)); |
15699 | 16405 |
15808 case PARALLEL: | 16514 case PARALLEL: |
15809 { | 16515 { |
15810 rtvec par_elems = XVEC (rtl, 0); | 16516 rtvec par_elems = XVEC (rtl, 0); |
15811 int num_elem = GET_NUM_ELEM (par_elems); | 16517 int num_elem = GET_NUM_ELEM (par_elems); |
15812 machine_mode mode; | 16518 machine_mode mode; |
15813 int i; | 16519 int i, size; |
15814 | 16520 |
15815 /* Create the first one, so we have something to add to. */ | 16521 /* Create the first one, so we have something to add to. */ |
15816 loc_result = loc_descriptor (XEXP (RTVEC_ELT (par_elems, 0), 0), | 16522 loc_result = loc_descriptor (XEXP (RTVEC_ELT (par_elems, 0), 0), |
15817 VOIDmode, initialized); | 16523 VOIDmode, initialized); |
15818 if (loc_result == NULL) | 16524 if (loc_result == NULL) |
15819 return NULL; | 16525 return NULL; |
15820 mode = GET_MODE (XEXP (RTVEC_ELT (par_elems, 0), 0)); | 16526 mode = GET_MODE (XEXP (RTVEC_ELT (par_elems, 0), 0)); |
15821 add_loc_descr_op_piece (&loc_result, GET_MODE_SIZE (mode)); | 16527 /* At present we only track constant-sized pieces. */ |
16528 if (!GET_MODE_SIZE (mode).is_constant (&size)) | |
16529 return NULL; | |
16530 add_loc_descr_op_piece (&loc_result, size); | |
15822 for (i = 1; i < num_elem; i++) | 16531 for (i = 1; i < num_elem; i++) |
15823 { | 16532 { |
15824 dw_loc_descr_ref temp; | 16533 dw_loc_descr_ref temp; |
15825 | 16534 |
15826 temp = loc_descriptor (XEXP (RTVEC_ELT (par_elems, i), 0), | 16535 temp = loc_descriptor (XEXP (RTVEC_ELT (par_elems, i), 0), |
15827 VOIDmode, initialized); | 16536 VOIDmode, initialized); |
15828 if (temp == NULL) | 16537 if (temp == NULL) |
15829 return NULL; | 16538 return NULL; |
15830 add_loc_descr (&loc_result, temp); | 16539 add_loc_descr (&loc_result, temp); |
15831 mode = GET_MODE (XEXP (RTVEC_ELT (par_elems, i), 0)); | 16540 mode = GET_MODE (XEXP (RTVEC_ELT (par_elems, i), 0)); |
15832 add_loc_descr_op_piece (&loc_result, GET_MODE_SIZE (mode)); | 16541 /* At present we only track constant-sized pieces. */ |
16542 if (!GET_MODE_SIZE (mode).is_constant (&size)) | |
16543 return NULL; | |
16544 add_loc_descr_op_piece (&loc_result, size); | |
15833 } | 16545 } |
15834 } | 16546 } |
15835 break; | 16547 break; |
15836 | 16548 |
15837 case CONST_INT: | 16549 case CONST_INT: |
15899 if (mode == VOIDmode) | 16611 if (mode == VOIDmode) |
15900 mode = GET_MODE (rtl); | 16612 mode = GET_MODE (rtl); |
15901 | 16613 |
15902 if (mode != VOIDmode && (dwarf_version >= 4 || !dwarf_strict)) | 16614 if (mode != VOIDmode && (dwarf_version >= 4 || !dwarf_strict)) |
15903 { | 16615 { |
16616 unsigned int length; | |
16617 if (!CONST_VECTOR_NUNITS (rtl).is_constant (&length)) | |
16618 return NULL; | |
16619 | |
15904 unsigned int elt_size = GET_MODE_UNIT_SIZE (GET_MODE (rtl)); | 16620 unsigned int elt_size = GET_MODE_UNIT_SIZE (GET_MODE (rtl)); |
15905 unsigned int length = CONST_VECTOR_NUNITS (rtl); | |
15906 unsigned char *array | 16621 unsigned char *array |
15907 = ggc_vec_alloc<unsigned char> (length * elt_size); | 16622 = ggc_vec_alloc<unsigned char> (length * elt_size); |
15908 unsigned int i; | 16623 unsigned int i; |
15909 unsigned char *p; | 16624 unsigned char *p; |
15910 machine_mode imode = GET_MODE_INNER (mode); | 16625 machine_mode imode = GET_MODE_INNER (mode); |
16267 or implicit location descriptions and empty location | 16982 or implicit location descriptions and empty location |
16268 descriptions, but for memory addresses needs big endian | 16983 descriptions, but for memory addresses needs big endian |
16269 adjustment. */ | 16984 adjustment. */ |
16270 if (MEM_P (varloc)) | 16985 if (MEM_P (varloc)) |
16271 { | 16986 { |
16272 unsigned HOST_WIDE_INT memsize | 16987 unsigned HOST_WIDE_INT memsize; |
16273 = MEM_SIZE (varloc) * BITS_PER_UNIT; | 16988 if (!poly_uint64 (MEM_SIZE (varloc)).is_constant (&memsize)) |
16989 goto discard_descr; | |
16990 memsize *= BITS_PER_UNIT; | |
16274 if (memsize != bitsize) | 16991 if (memsize != bitsize) |
16275 { | 16992 { |
16276 if (BYTES_BIG_ENDIAN != WORDS_BIG_ENDIAN | 16993 if (BYTES_BIG_ENDIAN != WORDS_BIG_ENDIAN |
16277 && (memsize > BITS_PER_WORD || bitsize > BITS_PER_WORD)) | 16994 && (memsize > BITS_PER_WORD || bitsize > BITS_PER_WORD)) |
16278 goto discard_descr; | 16995 goto discard_descr; |
16312 | 17029 |
16313 static dw_loc_list_ref | 17030 static dw_loc_list_ref |
16314 dw_loc_list (var_loc_list *loc_list, tree decl, int want_address) | 17031 dw_loc_list (var_loc_list *loc_list, tree decl, int want_address) |
16315 { | 17032 { |
16316 const char *endname, *secname; | 17033 const char *endname, *secname; |
17034 var_loc_view endview; | |
16317 rtx varloc; | 17035 rtx varloc; |
16318 enum var_init_status initialized; | 17036 enum var_init_status initialized; |
16319 struct var_loc_node *node; | 17037 struct var_loc_node *node; |
16320 dw_loc_descr_ref descr; | 17038 dw_loc_descr_ref descr; |
16321 char label_id[MAX_ARTIFICIAL_LABEL_BYTES]; | 17039 char label_id[MAX_ARTIFICIAL_LABEL_BYTES]; |
16331 (IE location changes), so to build the range, we use | 17049 (IE location changes), so to build the range, we use |
16332 the range [current location start, next location start]. | 17050 the range [current location start, next location start]. |
16333 This means we have to special case the last node, and generate | 17051 This means we have to special case the last node, and generate |
16334 a range of [last location start, end of function label]. */ | 17052 a range of [last location start, end of function label]. */ |
16335 | 17053 |
16336 secname = secname_for_decl (decl); | 17054 if (cfun && crtl->has_bb_partition) |
17055 { | |
17056 bool save_in_cold_section_p = in_cold_section_p; | |
17057 in_cold_section_p = first_function_block_is_cold; | |
17058 if (loc_list->last_before_switch == NULL) | |
17059 in_cold_section_p = !in_cold_section_p; | |
17060 secname = secname_for_decl (decl); | |
17061 in_cold_section_p = save_in_cold_section_p; | |
17062 } | |
17063 else | |
17064 secname = secname_for_decl (decl); | |
16337 | 17065 |
16338 for (node = loc_list->first; node; node = node->next) | 17066 for (node = loc_list->first; node; node = node->next) |
16339 if (GET_CODE (node->loc) == EXPR_LIST | 17067 { |
16340 || NOTE_VAR_LOCATION_LOC (node->loc) != NULL_RTX) | 17068 bool range_across_switch = false; |
16341 { | 17069 if (GET_CODE (node->loc) == EXPR_LIST |
16342 if (GET_CODE (node->loc) == EXPR_LIST) | 17070 || NOTE_VAR_LOCATION_LOC (node->loc) != NULL_RTX) |
16343 { | 17071 { |
16344 /* This requires DW_OP_{,bit_}piece, which is not usable | 17072 if (GET_CODE (node->loc) == EXPR_LIST) |
16345 inside DWARF expressions. */ | 17073 { |
16346 if (want_address != 2) | 17074 descr = NULL; |
16347 continue; | 17075 /* This requires DW_OP_{,bit_}piece, which is not usable |
17076 inside DWARF expressions. */ | |
17077 if (want_address == 2) | |
17078 descr = dw_sra_loc_expr (decl, node->loc); | |
17079 } | |
17080 else | |
17081 { | |
17082 initialized = NOTE_VAR_LOCATION_STATUS (node->loc); | |
17083 varloc = NOTE_VAR_LOCATION (node->loc); | |
17084 descr = dw_loc_list_1 (decl, varloc, want_address, initialized); | |
17085 } | |
17086 if (descr) | |
17087 { | |
17088 /* If section switch happens in between node->label | |
17089 and node->next->label (or end of function) and | |
17090 we can't emit it as a single entry list, | |
17091 emit two ranges, first one ending at the end | |
17092 of first partition and second one starting at the | |
17093 beginning of second partition. */ | |
17094 if (node == loc_list->last_before_switch | |
17095 && (node != loc_list->first || loc_list->first->next | |
17096 /* If we are to emit a view number, we will emit | |
17097 a loclist rather than a single location | |
17098 expression for the entire function (see | |
17099 loc_list_has_views), so we have to split the | |
17100 range that straddles across partitions. */ | |
17101 || !ZERO_VIEW_P (node->view)) | |
17102 && current_function_decl) | |
17103 { | |
17104 endname = cfun->fde->dw_fde_end; | |
17105 endview = 0; | |
17106 range_across_switch = true; | |
17107 } | |
17108 /* The variable has a location between NODE->LABEL and | |
17109 NODE->NEXT->LABEL. */ | |
17110 else if (node->next) | |
17111 endname = node->next->label, endview = node->next->view; | |
17112 /* If the variable has a location at the last label | |
17113 it keeps its location until the end of function. */ | |
17114 else if (!current_function_decl) | |
17115 endname = text_end_label, endview = 0; | |
17116 else | |
17117 { | |
17118 ASM_GENERATE_INTERNAL_LABEL (label_id, FUNC_END_LABEL, | |
17119 current_function_funcdef_no); | |
17120 endname = ggc_strdup (label_id); | |
17121 endview = 0; | |
17122 } | |
17123 | |
17124 *listp = new_loc_list (descr, node->label, node->view, | |
17125 endname, endview, secname); | |
17126 if (TREE_CODE (decl) == PARM_DECL | |
17127 && node == loc_list->first | |
17128 && NOTE_P (node->loc) | |
17129 && strcmp (node->label, endname) == 0) | |
17130 (*listp)->force = true; | |
17131 listp = &(*listp)->dw_loc_next; | |
17132 } | |
17133 } | |
17134 | |
17135 if (cfun | |
17136 && crtl->has_bb_partition | |
17137 && node == loc_list->last_before_switch) | |
17138 { | |
17139 bool save_in_cold_section_p = in_cold_section_p; | |
17140 in_cold_section_p = !first_function_block_is_cold; | |
17141 secname = secname_for_decl (decl); | |
17142 in_cold_section_p = save_in_cold_section_p; | |
17143 } | |
17144 | |
17145 if (range_across_switch) | |
17146 { | |
17147 if (GET_CODE (node->loc) == EXPR_LIST) | |
16348 descr = dw_sra_loc_expr (decl, node->loc); | 17148 descr = dw_sra_loc_expr (decl, node->loc); |
16349 if (descr == NULL) | 17149 else |
16350 continue; | 17150 { |
16351 } | 17151 initialized = NOTE_VAR_LOCATION_STATUS (node->loc); |
16352 else | 17152 varloc = NOTE_VAR_LOCATION (node->loc); |
16353 { | 17153 descr = dw_loc_list_1 (decl, varloc, want_address, |
16354 initialized = NOTE_VAR_LOCATION_STATUS (node->loc); | 17154 initialized); |
16355 varloc = NOTE_VAR_LOCATION (node->loc); | 17155 } |
16356 descr = dw_loc_list_1 (decl, varloc, want_address, initialized); | 17156 gcc_assert (descr); |
16357 } | 17157 /* The variable has a location between NODE->LABEL and |
16358 if (descr) | 17158 NODE->NEXT->LABEL. */ |
16359 { | 17159 if (node->next) |
16360 bool range_across_switch = false; | 17160 endname = node->next->label, endview = node->next->view; |
16361 /* If section switch happens in between node->label | 17161 else |
16362 and node->next->label (or end of function) and | 17162 endname = cfun->fde->dw_fde_second_end, endview = 0; |
16363 we can't emit it as a single entry list, | 17163 *listp = new_loc_list (descr, cfun->fde->dw_fde_second_begin, 0, |
16364 emit two ranges, first one ending at the end | 17164 endname, endview, secname); |
16365 of first partition and second one starting at the | 17165 listp = &(*listp)->dw_loc_next; |
16366 beginning of second partition. */ | 17166 } |
16367 if (node == loc_list->last_before_switch | 17167 } |
16368 && (node != loc_list->first || loc_list->first->next) | |
16369 && current_function_decl) | |
16370 { | |
16371 endname = cfun->fde->dw_fde_end; | |
16372 range_across_switch = true; | |
16373 } | |
16374 /* The variable has a location between NODE->LABEL and | |
16375 NODE->NEXT->LABEL. */ | |
16376 else if (node->next) | |
16377 endname = node->next->label; | |
16378 /* If the variable has a location at the last label | |
16379 it keeps its location until the end of function. */ | |
16380 else if (!current_function_decl) | |
16381 endname = text_end_label; | |
16382 else | |
16383 { | |
16384 ASM_GENERATE_INTERNAL_LABEL (label_id, FUNC_END_LABEL, | |
16385 current_function_funcdef_no); | |
16386 endname = ggc_strdup (label_id); | |
16387 } | |
16388 | |
16389 *listp = new_loc_list (descr, node->label, endname, secname); | |
16390 if (TREE_CODE (decl) == PARM_DECL | |
16391 && node == loc_list->first | |
16392 && NOTE_P (node->loc) | |
16393 && strcmp (node->label, endname) == 0) | |
16394 (*listp)->force = true; | |
16395 listp = &(*listp)->dw_loc_next; | |
16396 | |
16397 if (range_across_switch) | |
16398 { | |
16399 if (GET_CODE (node->loc) == EXPR_LIST) | |
16400 descr = dw_sra_loc_expr (decl, node->loc); | |
16401 else | |
16402 { | |
16403 initialized = NOTE_VAR_LOCATION_STATUS (node->loc); | |
16404 varloc = NOTE_VAR_LOCATION (node->loc); | |
16405 descr = dw_loc_list_1 (decl, varloc, want_address, | |
16406 initialized); | |
16407 } | |
16408 gcc_assert (descr); | |
16409 /* The variable has a location between NODE->LABEL and | |
16410 NODE->NEXT->LABEL. */ | |
16411 if (node->next) | |
16412 endname = node->next->label; | |
16413 else | |
16414 endname = cfun->fde->dw_fde_second_end; | |
16415 *listp = new_loc_list (descr, | |
16416 cfun->fde->dw_fde_second_begin, | |
16417 endname, secname); | |
16418 listp = &(*listp)->dw_loc_next; | |
16419 } | |
16420 } | |
16421 } | |
16422 | 17168 |
16423 /* Try to avoid the overhead of a location list emitting a location | 17169 /* Try to avoid the overhead of a location list emitting a location |
16424 expression instead, but only if we didn't have more than one | 17170 expression instead, but only if we didn't have more than one |
16425 location entry in the first place. If some entries were not | 17171 location entry in the first place. If some entries were not |
16426 representable, we don't want to pretend a single entry that was | 17172 representable, we don't want to pretend a single entry that was |
16427 applies to the entire scope in which the variable is | 17173 applies to the entire scope in which the variable is |
16428 available. */ | 17174 available. */ |
16429 if (list && loc_list->first->next) | 17175 if (list && loc_list->first->next) |
16430 gen_llsym (list); | 17176 gen_llsym (list); |
17177 else | |
17178 maybe_gen_llsym (list); | |
16431 | 17179 |
16432 return list; | 17180 return list; |
16433 } | 17181 } |
16434 | 17182 |
16435 /* Return if the loc_list has only single element and thus can be represented | 17183 /* Return if the loc_list has only single element and thus can be represented |
16568 static dw_loc_list_ref | 17316 static dw_loc_list_ref |
16569 loc_list_for_address_of_addr_expr_of_indirect_ref (tree loc, bool toplev, | 17317 loc_list_for_address_of_addr_expr_of_indirect_ref (tree loc, bool toplev, |
16570 loc_descr_context *context) | 17318 loc_descr_context *context) |
16571 { | 17319 { |
16572 tree obj, offset; | 17320 tree obj, offset; |
16573 HOST_WIDE_INT bitsize, bitpos, bytepos; | 17321 poly_int64 bitsize, bitpos, bytepos; |
16574 machine_mode mode; | 17322 machine_mode mode; |
16575 int unsignedp, reversep, volatilep = 0; | 17323 int unsignedp, reversep, volatilep = 0; |
16576 dw_loc_list_ref list_ret = NULL, list_ret1 = NULL; | 17324 dw_loc_list_ref list_ret = NULL, list_ret1 = NULL; |
16577 | 17325 |
16578 obj = get_inner_reference (TREE_OPERAND (loc, 0), | 17326 obj = get_inner_reference (TREE_OPERAND (loc, 0), |
16579 &bitsize, &bitpos, &offset, &mode, | 17327 &bitsize, &bitpos, &offset, &mode, |
16580 &unsignedp, &reversep, &volatilep); | 17328 &unsignedp, &reversep, &volatilep); |
16581 STRIP_NOPS (obj); | 17329 STRIP_NOPS (obj); |
16582 if (bitpos % BITS_PER_UNIT) | 17330 if (!multiple_p (bitpos, BITS_PER_UNIT, &bytepos)) |
16583 { | 17331 { |
16584 expansion_failed (loc, NULL_RTX, "bitfield access"); | 17332 expansion_failed (loc, NULL_RTX, "bitfield access"); |
16585 return 0; | 17333 return 0; |
16586 } | 17334 } |
16587 if (!INDIRECT_REF_P (obj)) | 17335 if (!INDIRECT_REF_P (obj)) |
16588 { | 17336 { |
16589 expansion_failed (obj, | 17337 expansion_failed (obj, |
16590 NULL_RTX, "no indirect ref in inner refrence"); | 17338 NULL_RTX, "no indirect ref in inner refrence"); |
16591 return 0; | 17339 return 0; |
16592 } | 17340 } |
16593 if (!offset && !bitpos) | 17341 if (!offset && known_eq (bitpos, 0)) |
16594 list_ret = loc_list_from_tree (TREE_OPERAND (obj, 0), toplev ? 2 : 1, | 17342 list_ret = loc_list_from_tree (TREE_OPERAND (obj, 0), toplev ? 2 : 1, |
16595 context); | 17343 context); |
16596 else if (toplev | 17344 else if (toplev |
16597 && int_size_in_bytes (TREE_TYPE (loc)) <= DWARF2_ADDR_SIZE | 17345 && int_size_in_bytes (TREE_TYPE (loc)) <= DWARF2_ADDR_SIZE |
16598 && (dwarf_version >= 4 || !dwarf_strict)) | 17346 && (dwarf_version >= 4 || !dwarf_strict)) |
16610 if (!list_ret) | 17358 if (!list_ret) |
16611 return 0; | 17359 return 0; |
16612 add_loc_descr_to_each (list_ret, | 17360 add_loc_descr_to_each (list_ret, |
16613 new_loc_descr (DW_OP_plus, 0, 0)); | 17361 new_loc_descr (DW_OP_plus, 0, 0)); |
16614 } | 17362 } |
16615 bytepos = bitpos / BITS_PER_UNIT; | 17363 HOST_WIDE_INT value; |
16616 if (bytepos > 0) | 17364 if (bytepos.is_constant (&value) && value > 0) |
16617 add_loc_descr_to_each (list_ret, | 17365 add_loc_descr_to_each (list_ret, |
16618 new_loc_descr (DW_OP_plus_uconst, | 17366 new_loc_descr (DW_OP_plus_uconst, value, 0)); |
16619 bytepos, 0)); | 17367 else if (maybe_ne (bytepos, 0)) |
16620 else if (bytepos < 0) | |
16621 loc_list_plus_const (list_ret, bytepos); | 17368 loc_list_plus_const (list_ret, bytepos); |
16622 add_loc_descr_to_each (list_ret, | 17369 add_loc_descr_to_each (list_ret, |
16623 new_loc_descr (DW_OP_stack_value, 0, 0)); | 17370 new_loc_descr (DW_OP_stack_value, 0, 0)); |
16624 } | 17371 } |
16625 return list_ret; | 17372 return list_ret; |
17245 && context->base_decl == loc | 17992 && context->base_decl == loc |
17246 && want_address == 0) | 17993 && want_address == 0) |
17247 { | 17994 { |
17248 if (dwarf_version >= 3 || !dwarf_strict) | 17995 if (dwarf_version >= 3 || !dwarf_strict) |
17249 return new_loc_list (new_loc_descr (DW_OP_push_object_address, 0, 0), | 17996 return new_loc_list (new_loc_descr (DW_OP_push_object_address, 0, 0), |
17250 NULL, NULL, NULL); | 17997 NULL, 0, NULL, 0, NULL); |
17251 else | 17998 else |
17252 return NULL; | 17999 return NULL; |
17253 } | 18000 } |
17254 | 18001 |
17255 switch (TREE_CODE (loc)) | 18002 switch (TREE_CODE (loc)) |
17585 case ARRAY_RANGE_REF: | 18332 case ARRAY_RANGE_REF: |
17586 case REALPART_EXPR: | 18333 case REALPART_EXPR: |
17587 case IMAGPART_EXPR: | 18334 case IMAGPART_EXPR: |
17588 { | 18335 { |
17589 tree obj, offset; | 18336 tree obj, offset; |
17590 HOST_WIDE_INT bitsize, bitpos, bytepos; | 18337 poly_int64 bitsize, bitpos, bytepos; |
17591 machine_mode mode; | 18338 machine_mode mode; |
17592 int unsignedp, reversep, volatilep = 0; | 18339 int unsignedp, reversep, volatilep = 0; |
17593 | 18340 |
17594 obj = get_inner_reference (loc, &bitsize, &bitpos, &offset, &mode, | 18341 obj = get_inner_reference (loc, &bitsize, &bitpos, &offset, &mode, |
17595 &unsignedp, &reversep, &volatilep); | 18342 &unsignedp, &reversep, &volatilep); |
17596 | 18343 |
17597 gcc_assert (obj != loc); | 18344 gcc_assert (obj != loc); |
17598 | 18345 |
17599 list_ret = loc_list_from_tree_1 (obj, | 18346 list_ret = loc_list_from_tree_1 (obj, |
17600 want_address == 2 | 18347 want_address == 2 |
17601 && !bitpos && !offset ? 2 : 1, | 18348 && known_eq (bitpos, 0) |
18349 && !offset ? 2 : 1, | |
17602 context); | 18350 context); |
17603 /* TODO: We can extract value of the small expression via shifting even | 18351 /* TODO: We can extract value of the small expression via shifting even |
17604 for nonzero bitpos. */ | 18352 for nonzero bitpos. */ |
17605 if (list_ret == 0) | 18353 if (list_ret == 0) |
17606 return 0; | 18354 return 0; |
17607 if (bitpos % BITS_PER_UNIT != 0 || bitsize % BITS_PER_UNIT != 0) | 18355 if (!multiple_p (bitpos, BITS_PER_UNIT, &bytepos) |
18356 || !multiple_p (bitsize, BITS_PER_UNIT)) | |
17608 { | 18357 { |
17609 expansion_failed (loc, NULL_RTX, | 18358 expansion_failed (loc, NULL_RTX, |
17610 "bitfield access"); | 18359 "bitfield access"); |
17611 return 0; | 18360 return 0; |
17612 } | 18361 } |
17621 if (!list_ret) | 18370 if (!list_ret) |
17622 return 0; | 18371 return 0; |
17623 add_loc_descr_to_each (list_ret, new_loc_descr (DW_OP_plus, 0, 0)); | 18372 add_loc_descr_to_each (list_ret, new_loc_descr (DW_OP_plus, 0, 0)); |
17624 } | 18373 } |
17625 | 18374 |
17626 bytepos = bitpos / BITS_PER_UNIT; | 18375 HOST_WIDE_INT value; |
17627 if (bytepos > 0) | 18376 if (bytepos.is_constant (&value) && value > 0) |
17628 add_loc_descr_to_each (list_ret, new_loc_descr (DW_OP_plus_uconst, bytepos, 0)); | 18377 add_loc_descr_to_each (list_ret, new_loc_descr (DW_OP_plus_uconst, |
17629 else if (bytepos < 0) | 18378 value, 0)); |
18379 else if (maybe_ne (bytepos, 0)) | |
17630 loc_list_plus_const (list_ret, bytepos); | 18380 loc_list_plus_const (list_ret, bytepos); |
17631 | 18381 |
17632 have_address = 1; | 18382 have_address = 1; |
17633 break; | 18383 break; |
17634 } | 18384 } |
18058 add_loc_descr (&ret, new_loc_descr (op, size, 0)); | 18808 add_loc_descr (&ret, new_loc_descr (op, size, 0)); |
18059 else | 18809 else |
18060 add_loc_descr_to_each (list_ret, new_loc_descr (op, size, 0)); | 18810 add_loc_descr_to_each (list_ret, new_loc_descr (op, size, 0)); |
18061 } | 18811 } |
18062 if (ret) | 18812 if (ret) |
18063 list_ret = new_loc_list (ret, NULL, NULL, NULL); | 18813 list_ret = new_loc_list (ret, NULL, 0, NULL, 0, NULL); |
18064 | 18814 |
18065 return list_ret; | 18815 return list_ret; |
18066 } | 18816 } |
18067 | 18817 |
18068 /* Likewise, but strip useless DW_OP_nop operations in the resulting | 18818 /* Likewise, but strip useless DW_OP_nop operations in the resulting |
18093 expansion_failed (loc, NULL_RTX, | 18843 expansion_failed (loc, NULL_RTX, |
18094 "Location list where only loc descriptor needed"); | 18844 "Location list where only loc descriptor needed"); |
18095 return NULL; | 18845 return NULL; |
18096 } | 18846 } |
18097 return ret->expr; | 18847 return ret->expr; |
18098 } | |
18099 | |
18100 /* Given a value, round it up to the lowest multiple of `boundary' | |
18101 which is not less than the value itself. */ | |
18102 | |
18103 static inline HOST_WIDE_INT | |
18104 ceiling (HOST_WIDE_INT value, unsigned int boundary) | |
18105 { | |
18106 return (((value + boundary - 1) / boundary) * boundary); | |
18107 } | 18848 } |
18108 | 18849 |
18109 /* Given a pointer to what is assumed to be a FIELD_DECL node, return a | 18850 /* Given a pointer to what is assumed to be a FIELD_DECL node, return a |
18110 pointer to the declared type for the relevant field variable, or return | 18851 pointer to the declared type for the relevant field variable, or return |
18111 `integer_type_node' if the given node turns out to be an | 18852 `integer_type_node' if the given node turns out to be an |
18382 | 19123 |
18383 static inline void | 19124 static inline void |
18384 add_AT_location_description (dw_die_ref die, enum dwarf_attribute attr_kind, | 19125 add_AT_location_description (dw_die_ref die, enum dwarf_attribute attr_kind, |
18385 dw_loc_list_ref descr) | 19126 dw_loc_list_ref descr) |
18386 { | 19127 { |
19128 bool check_no_locviews = true; | |
18387 if (descr == 0) | 19129 if (descr == 0) |
18388 return; | 19130 return; |
18389 if (single_element_loc_list_p (descr)) | 19131 if (single_element_loc_list_p (descr)) |
18390 add_AT_loc (die, attr_kind, descr->expr); | 19132 add_AT_loc (die, attr_kind, descr->expr); |
18391 else | 19133 else |
18392 add_AT_loc_list (die, attr_kind, descr); | 19134 { |
19135 add_AT_loc_list (die, attr_kind, descr); | |
19136 gcc_assert (descr->ll_symbol); | |
19137 if (attr_kind == DW_AT_location && descr->vl_symbol | |
19138 && dwarf2out_locviews_in_attribute ()) | |
19139 { | |
19140 add_AT_view_list (die, DW_AT_GNU_locviews); | |
19141 check_no_locviews = false; | |
19142 } | |
19143 } | |
19144 | |
19145 if (check_no_locviews) | |
19146 gcc_assert (!get_AT (die, DW_AT_GNU_locviews)); | |
18393 } | 19147 } |
18394 | 19148 |
18395 /* Add DW_AT_accessibility attribute to DIE if needed. */ | 19149 /* Add DW_AT_accessibility attribute to DIE if needed. */ |
18396 | 19150 |
18397 static void | 19151 static void |
18683 } | 19437 } |
18684 return true; | 19438 return true; |
18685 | 19439 |
18686 case CONST_VECTOR: | 19440 case CONST_VECTOR: |
18687 { | 19441 { |
19442 unsigned int length; | |
19443 if (!CONST_VECTOR_NUNITS (rtl).is_constant (&length)) | |
19444 return false; | |
19445 | |
18688 machine_mode mode = GET_MODE (rtl); | 19446 machine_mode mode = GET_MODE (rtl); |
18689 unsigned int elt_size = GET_MODE_UNIT_SIZE (mode); | 19447 unsigned int elt_size = GET_MODE_UNIT_SIZE (mode); |
18690 unsigned int length = CONST_VECTOR_NUNITS (rtl); | |
18691 unsigned char *array | 19448 unsigned char *array |
18692 = ggc_vec_alloc<unsigned char> (length * elt_size); | 19449 = ggc_vec_alloc<unsigned char> (length * elt_size); |
18693 unsigned int i; | 19450 unsigned int i; |
18694 unsigned char *p; | 19451 unsigned char *p; |
18695 machine_mode imode = GET_MODE_INNER (mode); | 19452 machine_mode imode = GET_MODE_INNER (mode); |
18841 scalar_int_mode mode; | 19598 scalar_int_mode mode; |
18842 | 19599 |
18843 if (is_int_mode (TYPE_MODE (enttype), &mode) | 19600 if (is_int_mode (TYPE_MODE (enttype), &mode) |
18844 && GET_MODE_SIZE (mode) == 1 | 19601 && GET_MODE_SIZE (mode) == 1 |
18845 && domain | 19602 && domain |
19603 && TYPE_MAX_VALUE (domain) | |
19604 && TREE_CODE (TYPE_MAX_VALUE (domain)) == INTEGER_CST | |
18846 && integer_zerop (TYPE_MIN_VALUE (domain)) | 19605 && integer_zerop (TYPE_MIN_VALUE (domain)) |
18847 && compare_tree_int (TYPE_MAX_VALUE (domain), | 19606 && compare_tree_int (TYPE_MAX_VALUE (domain), |
18848 TREE_STRING_LENGTH (init) - 1) == 0 | 19607 TREE_STRING_LENGTH (init) - 1) == 0 |
18849 && ((size_t) TREE_STRING_LENGTH (init) | 19608 && ((size_t) TREE_STRING_LENGTH (init) |
18850 == strlen (TREE_STRING_POINTER (init)) + 1)) | 19609 == strlen (TREE_STRING_POINTER (init)) + 1)) |
19037 all cases where (rtl == NULL_RTX) just below. */ | 19796 all cases where (rtl == NULL_RTX) just below. */ |
19038 if (dmode == pmode) | 19797 if (dmode == pmode) |
19039 rtl = DECL_INCOMING_RTL (decl); | 19798 rtl = DECL_INCOMING_RTL (decl); |
19040 else if ((rtl == NULL_RTX || is_pseudo_reg (rtl)) | 19799 else if ((rtl == NULL_RTX || is_pseudo_reg (rtl)) |
19041 && SCALAR_INT_MODE_P (dmode) | 19800 && SCALAR_INT_MODE_P (dmode) |
19042 && GET_MODE_SIZE (dmode) <= GET_MODE_SIZE (pmode) | 19801 && known_le (GET_MODE_SIZE (dmode), GET_MODE_SIZE (pmode)) |
19043 && DECL_INCOMING_RTL (decl)) | 19802 && DECL_INCOMING_RTL (decl)) |
19044 { | 19803 { |
19045 rtx inc = DECL_INCOMING_RTL (decl); | 19804 rtx inc = DECL_INCOMING_RTL (decl); |
19046 if (REG_P (inc)) | 19805 if (REG_P (inc)) |
19047 rtl = inc; | 19806 rtl = inc; |
19078 #endif | 19837 #endif |
19079 ) | 19838 ) |
19080 /* Big endian correction check. */ | 19839 /* Big endian correction check. */ |
19081 && BYTES_BIG_ENDIAN | 19840 && BYTES_BIG_ENDIAN |
19082 && TYPE_MODE (TREE_TYPE (decl)) != GET_MODE (rtl) | 19841 && TYPE_MODE (TREE_TYPE (decl)) != GET_MODE (rtl) |
19083 && (GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (decl))) | 19842 && known_lt (GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (decl))), |
19084 < UNITS_PER_WORD)) | 19843 UNITS_PER_WORD)) |
19085 { | 19844 { |
19086 machine_mode addr_mode = get_address_mode (rtl); | 19845 machine_mode addr_mode = get_address_mode (rtl); |
19087 int offset = (UNITS_PER_WORD | 19846 poly_int64 offset = (UNITS_PER_WORD |
19088 - GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (decl)))); | 19847 - GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (decl)))); |
19089 | 19848 |
19090 rtl = gen_rtx_MEM (TYPE_MODE (TREE_TYPE (decl)), | 19849 rtl = gen_rtx_MEM (TYPE_MODE (TREE_TYPE (decl)), |
19091 plus_constant (addr_mode, XEXP (rtl, 0), offset)); | 19850 plus_constant (addr_mode, XEXP (rtl, 0), offset)); |
19092 } | 19851 } |
19093 } | 19852 } |
19095 && rtl | 19854 && rtl |
19096 && MEM_P (rtl) | 19855 && MEM_P (rtl) |
19097 && GET_MODE (rtl) != TYPE_MODE (TREE_TYPE (decl))) | 19856 && GET_MODE (rtl) != TYPE_MODE (TREE_TYPE (decl))) |
19098 { | 19857 { |
19099 machine_mode addr_mode = get_address_mode (rtl); | 19858 machine_mode addr_mode = get_address_mode (rtl); |
19100 HOST_WIDE_INT offset = byte_lowpart_offset (TYPE_MODE (TREE_TYPE (decl)), | 19859 poly_int64 offset = byte_lowpart_offset (TYPE_MODE (TREE_TYPE (decl)), |
19101 GET_MODE (rtl)); | 19860 GET_MODE (rtl)); |
19102 | 19861 |
19103 /* If a variable is declared "register" yet is smaller than | 19862 /* If a variable is declared "register" yet is smaller than |
19104 a register, then if we store the variable to memory, it | 19863 a register, then if we store the variable to memory, it |
19105 looks like we're storing a register-sized value, when in | 19864 looks like we're storing a register-sized value, when in |
19106 fact we are not. We need to adjust the offset of the | 19865 fact we are not. We need to adjust the offset of the |
19107 storage location to reflect the actual value's bytes, | 19866 storage location to reflect the actual value's bytes, |
19108 else gdb will not be able to display it. */ | 19867 else gdb will not be able to display it. */ |
19109 if (offset != 0) | 19868 if (maybe_ne (offset, 0)) |
19110 rtl = gen_rtx_MEM (TYPE_MODE (TREE_TYPE (decl)), | 19869 rtl = gen_rtx_MEM (TYPE_MODE (TREE_TYPE (decl)), |
19111 plus_constant (addr_mode, XEXP (rtl, 0), offset)); | 19870 plus_constant (addr_mode, XEXP (rtl, 0), offset)); |
19112 } | 19871 } |
19113 | 19872 |
19114 /* A variable with no DECL_RTL but a DECL_INITIAL is a compile-time constant, | 19873 /* A variable with no DECL_RTL but a DECL_INITIAL is a compile-time constant, |
19128 | 19887 |
19129 /* Try harder to get a rtl. If this symbol ends up not being emitted | 19888 /* Try harder to get a rtl. If this symbol ends up not being emitted |
19130 in the current CU, resolve_addr will remove the expression referencing | 19889 in the current CU, resolve_addr will remove the expression referencing |
19131 it. */ | 19890 it. */ |
19132 if (rtl == NULL_RTX | 19891 if (rtl == NULL_RTX |
19892 && !(early_dwarf && (flag_generate_lto || flag_generate_offload)) | |
19133 && VAR_P (decl) | 19893 && VAR_P (decl) |
19134 && !DECL_EXTERNAL (decl) | 19894 && !DECL_EXTERNAL (decl) |
19135 && TREE_STATIC (decl) | 19895 && TREE_STATIC (decl) |
19136 && DECL_NAME (decl) | 19896 && DECL_NAME (decl) |
19137 && !DECL_HARD_REGISTER (decl) | 19897 && !DECL_HARD_REGISTER (decl) |
19154 static tree | 19914 static tree |
19155 fortran_common (tree decl, HOST_WIDE_INT *value) | 19915 fortran_common (tree decl, HOST_WIDE_INT *value) |
19156 { | 19916 { |
19157 tree val_expr, cvar; | 19917 tree val_expr, cvar; |
19158 machine_mode mode; | 19918 machine_mode mode; |
19159 HOST_WIDE_INT bitsize, bitpos; | 19919 poly_int64 bitsize, bitpos; |
19160 tree offset; | 19920 tree offset; |
19921 HOST_WIDE_INT cbitpos; | |
19161 int unsignedp, reversep, volatilep = 0; | 19922 int unsignedp, reversep, volatilep = 0; |
19162 | 19923 |
19163 /* If the decl isn't a VAR_DECL, or if it isn't static, or if | 19924 /* If the decl isn't a VAR_DECL, or if it isn't static, or if |
19164 it does not have a value (the offset into the common area), or if it | 19925 it does not have a value (the offset into the common area), or if it |
19165 is thread local (as opposed to global) then it isn't common, and shouldn't | 19926 is thread local (as opposed to global) then it isn't common, and shouldn't |
19178 &unsignedp, &reversep, &volatilep); | 19939 &unsignedp, &reversep, &volatilep); |
19179 | 19940 |
19180 if (cvar == NULL_TREE | 19941 if (cvar == NULL_TREE |
19181 || !VAR_P (cvar) | 19942 || !VAR_P (cvar) |
19182 || DECL_ARTIFICIAL (cvar) | 19943 || DECL_ARTIFICIAL (cvar) |
19183 || !TREE_PUBLIC (cvar)) | 19944 || !TREE_PUBLIC (cvar) |
19945 /* We don't expect to have to cope with variable offsets, | |
19946 since at present all static data must have a constant size. */ | |
19947 || !bitpos.is_constant (&cbitpos)) | |
19184 return NULL_TREE; | 19948 return NULL_TREE; |
19185 | 19949 |
19186 *value = 0; | 19950 *value = 0; |
19187 if (offset != NULL) | 19951 if (offset != NULL) |
19188 { | 19952 { |
19189 if (!tree_fits_shwi_p (offset)) | 19953 if (!tree_fits_shwi_p (offset)) |
19190 return NULL_TREE; | 19954 return NULL_TREE; |
19191 *value = tree_to_shwi (offset); | 19955 *value = tree_to_shwi (offset); |
19192 } | 19956 } |
19193 if (bitpos != 0) | 19957 if (cbitpos != 0) |
19194 *value += bitpos / BITS_PER_UNIT; | 19958 *value += cbitpos / BITS_PER_UNIT; |
19195 | 19959 |
19196 return cvar; | 19960 return cvar; |
19197 } | 19961 } |
19198 | 19962 |
19199 /* Generate *either* a DW_AT_location attribute or else a DW_AT_const_value | 19963 /* Generate *either* a DW_AT_location attribute or else a DW_AT_const_value |
19569 if (fde->dw_fde_second_begin && fde->dw_fde_switch_cfi_index == 0) | 20333 if (fde->dw_fde_second_begin && fde->dw_fde_switch_cfi_index == 0) |
19570 { | 20334 { |
19571 /* If the first partition contained no CFI adjustments, the | 20335 /* If the first partition contained no CFI adjustments, the |
19572 CIE opcodes apply to the whole first partition. */ | 20336 CIE opcodes apply to the whole first partition. */ |
19573 *list_tail = new_loc_list (build_cfa_loc (&last_cfa, offset), | 20337 *list_tail = new_loc_list (build_cfa_loc (&last_cfa, offset), |
19574 fde->dw_fde_begin, fde->dw_fde_end, section); | 20338 fde->dw_fde_begin, 0, fde->dw_fde_end, 0, section); |
19575 list_tail =&(*list_tail)->dw_loc_next; | 20339 list_tail =&(*list_tail)->dw_loc_next; |
19576 start_label = last_label = fde->dw_fde_second_begin; | 20340 start_label = last_label = fde->dw_fde_second_begin; |
19577 } | 20341 } |
19578 | 20342 |
19579 FOR_EACH_VEC_SAFE_ELT (fde->dw_fde_cfi, ix, cfi) | 20343 FOR_EACH_VEC_SAFE_ELT (fde->dw_fde_cfi, ix, cfi) |
19585 case DW_CFA_advance_loc2: | 20349 case DW_CFA_advance_loc2: |
19586 case DW_CFA_advance_loc4: | 20350 case DW_CFA_advance_loc4: |
19587 if (!cfa_equal_p (&last_cfa, &next_cfa)) | 20351 if (!cfa_equal_p (&last_cfa, &next_cfa)) |
19588 { | 20352 { |
19589 *list_tail = new_loc_list (build_cfa_loc (&last_cfa, offset), | 20353 *list_tail = new_loc_list (build_cfa_loc (&last_cfa, offset), |
19590 start_label, last_label, section); | 20354 start_label, 0, last_label, 0, section); |
19591 | 20355 |
19592 list_tail = &(*list_tail)->dw_loc_next; | 20356 list_tail = &(*list_tail)->dw_loc_next; |
19593 last_cfa = next_cfa; | 20357 last_cfa = next_cfa; |
19594 start_label = last_label; | 20358 start_label = last_label; |
19595 } | 20359 } |
19607 if (ix + 1 == fde->dw_fde_switch_cfi_index) | 20371 if (ix + 1 == fde->dw_fde_switch_cfi_index) |
19608 { | 20372 { |
19609 if (!cfa_equal_p (&last_cfa, &next_cfa)) | 20373 if (!cfa_equal_p (&last_cfa, &next_cfa)) |
19610 { | 20374 { |
19611 *list_tail = new_loc_list (build_cfa_loc (&last_cfa, offset), | 20375 *list_tail = new_loc_list (build_cfa_loc (&last_cfa, offset), |
19612 start_label, last_label, section); | 20376 start_label, 0, last_label, 0, section); |
19613 | 20377 |
19614 list_tail = &(*list_tail)->dw_loc_next; | 20378 list_tail = &(*list_tail)->dw_loc_next; |
19615 last_cfa = next_cfa; | 20379 last_cfa = next_cfa; |
19616 start_label = last_label; | 20380 start_label = last_label; |
19617 } | 20381 } |
19618 *list_tail = new_loc_list (build_cfa_loc (&last_cfa, offset), | 20382 *list_tail = new_loc_list (build_cfa_loc (&last_cfa, offset), |
19619 start_label, fde->dw_fde_end, section); | 20383 start_label, 0, fde->dw_fde_end, 0, section); |
19620 list_tail = &(*list_tail)->dw_loc_next; | 20384 list_tail = &(*list_tail)->dw_loc_next; |
19621 start_label = last_label = fde->dw_fde_second_begin; | 20385 start_label = last_label = fde->dw_fde_second_begin; |
19622 } | 20386 } |
19623 } | 20387 } |
19624 | 20388 |
19625 if (!cfa_equal_p (&last_cfa, &next_cfa)) | 20389 if (!cfa_equal_p (&last_cfa, &next_cfa)) |
19626 { | 20390 { |
19627 *list_tail = new_loc_list (build_cfa_loc (&last_cfa, offset), | 20391 *list_tail = new_loc_list (build_cfa_loc (&last_cfa, offset), |
19628 start_label, last_label, section); | 20392 start_label, 0, last_label, 0, section); |
19629 list_tail = &(*list_tail)->dw_loc_next; | 20393 list_tail = &(*list_tail)->dw_loc_next; |
19630 start_label = last_label; | 20394 start_label = last_label; |
19631 } | 20395 } |
19632 | 20396 |
19633 *list_tail = new_loc_list (build_cfa_loc (&next_cfa, offset), | 20397 *list_tail = new_loc_list (build_cfa_loc (&next_cfa, offset), |
19634 start_label, | 20398 start_label, 0, |
19635 fde->dw_fde_second_begin | 20399 fde->dw_fde_second_begin |
19636 ? fde->dw_fde_second_end : fde->dw_fde_end, | 20400 ? fde->dw_fde_second_end : fde->dw_fde_end, 0, |
19637 section); | 20401 section); |
19638 | 20402 |
19639 if (list && list->dw_loc_next) | 20403 maybe_gen_llsym (list); |
19640 gen_llsym (list); | |
19641 | 20404 |
19642 return list; | 20405 return list; |
19643 } | 20406 } |
19644 | 20407 |
19645 /* Compute a displacement from the "steady-state frame pointer" to the | 20408 /* Compute a displacement from the "steady-state frame pointer" to the |
19646 frame base (often the same as the CFA), and store it in | 20409 frame base (often the same as the CFA), and store it in |
19647 frame_pointer_fb_offset. OFFSET is added to the displacement | 20410 frame_pointer_fb_offset. OFFSET is added to the displacement |
19648 before the latter is negated. */ | 20411 before the latter is negated. */ |
19649 | 20412 |
19650 static void | 20413 static void |
19651 compute_frame_pointer_to_fb_displacement (HOST_WIDE_INT offset) | 20414 compute_frame_pointer_to_fb_displacement (poly_int64 offset) |
19652 { | 20415 { |
19653 rtx reg, elim; | 20416 rtx reg, elim; |
19654 | 20417 |
19655 #ifdef FRAME_POINTER_CFA_OFFSET | 20418 #ifdef FRAME_POINTER_CFA_OFFSET |
19656 reg = frame_pointer_rtx; | 20419 reg = frame_pointer_rtx; |
19661 #endif | 20424 #endif |
19662 | 20425 |
19663 elim = (ira_use_lra_p | 20426 elim = (ira_use_lra_p |
19664 ? lra_eliminate_regs (reg, VOIDmode, NULL_RTX) | 20427 ? lra_eliminate_regs (reg, VOIDmode, NULL_RTX) |
19665 : eliminate_regs (reg, VOIDmode, NULL_RTX)); | 20428 : eliminate_regs (reg, VOIDmode, NULL_RTX)); |
19666 if (GET_CODE (elim) == PLUS) | 20429 elim = strip_offset_and_add (elim, &offset); |
19667 { | |
19668 offset += INTVAL (XEXP (elim, 1)); | |
19669 elim = XEXP (elim, 0); | |
19670 } | |
19671 | 20430 |
19672 frame_pointer_fb_offset = -offset; | 20431 frame_pointer_fb_offset = -offset; |
19673 | 20432 |
19674 /* ??? AVR doesn't set up valid eliminations when there is no stack frame | 20433 /* ??? AVR doesn't set up valid eliminations when there is no stack frame |
19675 in which to eliminate. This is because it's stack pointer isn't | 20434 in which to eliminate. This is because it's stack pointer isn't |
19676 directly accessible as a register within the ISA. To work around | 20435 directly accessible as a register within the ISA. To work around |
19677 this, assume that while we cannot provide a proper value for | 20436 this, assume that while we cannot provide a proper value for |
19678 frame_pointer_fb_offset, we won't need one either. */ | 20437 frame_pointer_fb_offset, we won't need one either. We can use |
20438 hard frame pointer in debug info even if frame pointer isn't used | |
20439 since hard frame pointer in debug info is encoded with DW_OP_fbreg | |
20440 which uses the DW_AT_frame_base attribute, not hard frame pointer | |
20441 directly. */ | |
19679 frame_pointer_fb_offset_valid | 20442 frame_pointer_fb_offset_valid |
19680 = ((SUPPORTS_STACK_ALIGNMENT | 20443 = (elim == hard_frame_pointer_rtx || elim == stack_pointer_rtx); |
19681 && (elim == hard_frame_pointer_rtx | |
19682 || elim == stack_pointer_rtx)) | |
19683 || elim == (frame_pointer_needed | |
19684 ? hard_frame_pointer_rtx | |
19685 : stack_pointer_rtx)); | |
19686 } | 20444 } |
19687 | 20445 |
19688 /* Generate a DW_AT_name attribute given some string value to be included as | 20446 /* Generate a DW_AT_name attribute given some string value to be included as |
19689 the value of the attribute. */ | 20447 the value of the attribute. */ |
19690 | 20448 |
19695 { | 20453 { |
19696 if (demangle_name_func) | 20454 if (demangle_name_func) |
19697 name_string = (*demangle_name_func) (name_string); | 20455 name_string = (*demangle_name_func) (name_string); |
19698 | 20456 |
19699 add_AT_string (die, DW_AT_name, name_string); | 20457 add_AT_string (die, DW_AT_name, name_string); |
20458 } | |
20459 } | |
20460 | |
20461 /* Generate a DW_AT_description attribute given some string value to be included | |
20462 as the value of the attribute. */ | |
20463 | |
20464 static void | |
20465 add_desc_attribute (dw_die_ref die, const char *name_string) | |
20466 { | |
20467 if (!flag_describe_dies || (dwarf_version < 3 && dwarf_strict)) | |
20468 return; | |
20469 | |
20470 if (name_string == NULL || *name_string == 0) | |
20471 return; | |
20472 | |
20473 if (demangle_name_func) | |
20474 name_string = (*demangle_name_func) (name_string); | |
20475 | |
20476 add_AT_string (die, DW_AT_description, name_string); | |
20477 } | |
20478 | |
20479 /* Generate a DW_AT_description attribute given some decl to be included | |
20480 as the value of the attribute. */ | |
20481 | |
20482 static void | |
20483 add_desc_attribute (dw_die_ref die, tree decl) | |
20484 { | |
20485 tree decl_name; | |
20486 | |
20487 if (!flag_describe_dies || (dwarf_version < 3 && dwarf_strict)) | |
20488 return; | |
20489 | |
20490 if (decl == NULL_TREE || !DECL_P (decl)) | |
20491 return; | |
20492 decl_name = DECL_NAME (decl); | |
20493 | |
20494 if (decl_name != NULL && IDENTIFIER_POINTER (decl_name) != NULL) | |
20495 { | |
20496 const char *name = dwarf2_name (decl, 0); | |
20497 add_desc_attribute (die, name ? name : IDENTIFIER_POINTER (decl_name)); | |
20498 } | |
20499 else | |
20500 { | |
20501 char *desc = print_generic_expr_to_str (decl); | |
20502 add_desc_attribute (die, desc); | |
20503 free (desc); | |
19700 } | 20504 } |
19701 } | 20505 } |
19702 | 20506 |
19703 /* Retrieve the descriptive type of TYPE, if any, make sure it has a | 20507 /* Retrieve the descriptive type of TYPE, if any, make sure it has a |
19704 DIE and attach a DW_AT_GNAT_descriptive_type attribute to the DIE | 20508 DIE and attach a DW_AT_GNAT_descriptive_type attribute to the DIE |
19781 | 20585 |
19782 static void | 20586 static void |
19783 add_scalar_info (dw_die_ref die, enum dwarf_attribute attr, tree value, | 20587 add_scalar_info (dw_die_ref die, enum dwarf_attribute attr, tree value, |
19784 int forms, struct loc_descr_context *context) | 20588 int forms, struct loc_descr_context *context) |
19785 { | 20589 { |
19786 dw_die_ref context_die, decl_die; | 20590 dw_die_ref context_die, decl_die = NULL; |
19787 dw_loc_list_ref list; | 20591 dw_loc_list_ref list; |
19788 bool strip_conversions = true; | 20592 bool strip_conversions = true; |
19789 bool placeholder_seen = false; | 20593 bool placeholder_seen = false; |
19790 | 20594 |
19791 while (strip_conversions) | 20595 while (strip_conversions) |
19858 || TREE_CODE (value) == RESULT_DECL) | 20662 || TREE_CODE (value) == RESULT_DECL) |
19859 decl = value; | 20663 decl = value; |
19860 | 20664 |
19861 if (decl != NULL_TREE) | 20665 if (decl != NULL_TREE) |
19862 { | 20666 { |
19863 dw_die_ref decl_die = lookup_decl_die (decl); | 20667 decl_die = lookup_decl_die (decl); |
19864 | 20668 |
19865 /* ??? Can this happen, or should the variable have been bound | 20669 /* ??? Can this happen, or should the variable have been bound |
19866 first? Probably it can, since I imagine that we try to create | 20670 first? Probably it can, since I imagine that we try to create |
19867 the types of parameters in the order in which they exist in | 20671 the types of parameters in the order in which they exist in |
19868 the list, and won't have created a forward reference to a | 20672 the list, and won't have created a forward reference to a |
19869 later parameter. */ | 20673 later parameter. */ |
19870 if (decl_die != NULL) | 20674 if (decl_die != NULL) |
19871 { | 20675 { |
19872 add_AT_die_ref (die, attr, decl_die); | 20676 if (get_AT (decl_die, DW_AT_location) |
19873 return; | 20677 || get_AT (decl_die, DW_AT_const_value)) |
20678 { | |
20679 add_AT_die_ref (die, attr, decl_die); | |
20680 return; | |
20681 } | |
19874 } | 20682 } |
19875 } | 20683 } |
19876 } | 20684 } |
19877 | 20685 |
19878 /* Last chance: try to create a stack operation procedure to evaluate the | 20686 /* Last chance: try to create a stack operation procedure to evaluate the |
19912 if (list == NULL | 20720 if (list == NULL |
19913 || (forms & dw_scalar_form_reference) == 0 | 20721 || (forms & dw_scalar_form_reference) == 0 |
19914 || placeholder_seen) | 20722 || placeholder_seen) |
19915 return; | 20723 return; |
19916 | 20724 |
19917 if (current_function_decl == 0) | 20725 if (!decl_die) |
19918 context_die = comp_unit_die (); | 20726 { |
19919 else | 20727 if (current_function_decl == 0) |
19920 context_die = lookup_decl_die (current_function_decl); | 20728 context_die = comp_unit_die (); |
19921 | 20729 else |
19922 decl_die = new_die (DW_TAG_variable, context_die, value); | 20730 context_die = lookup_decl_die (current_function_decl); |
19923 add_AT_flag (decl_die, DW_AT_artificial, 1); | 20731 |
19924 add_type_attribute (decl_die, TREE_TYPE (value), TYPE_QUAL_CONST, false, | 20732 decl_die = new_die (DW_TAG_variable, context_die, value); |
19925 context_die); | 20733 add_AT_flag (decl_die, DW_AT_artificial, 1); |
20734 add_type_attribute (decl_die, TREE_TYPE (value), TYPE_QUAL_CONST, false, | |
20735 context_die); | |
20736 } | |
20737 | |
19926 add_AT_location_description (decl_die, DW_AT_location, list); | 20738 add_AT_location_description (decl_die, DW_AT_location, list); |
19927 add_AT_die_ref (die, attr, decl_die); | 20739 add_AT_die_ref (die, attr, decl_die); |
19928 } | 20740 } |
19929 | 20741 |
19930 /* Return the default for DW_AT_lower_bound, or -1 if there is not any | 20742 /* Return the default for DW_AT_lower_bound, or -1 if there is not any |
20105 to produce useful results, go ahead and output the lower | 20917 to produce useful results, go ahead and output the lower |
20106 bound solo, and hope the debugger can cope. */ | 20918 bound solo, and hope the debugger can cope. */ |
20107 | 20919 |
20108 if (!get_AT (subrange_die, DW_AT_lower_bound)) | 20920 if (!get_AT (subrange_die, DW_AT_lower_bound)) |
20109 add_bound_info (subrange_die, DW_AT_lower_bound, lower, NULL); | 20921 add_bound_info (subrange_die, DW_AT_lower_bound, lower, NULL); |
20110 if (upper && !get_AT (subrange_die, DW_AT_upper_bound)) | 20922 if (!get_AT (subrange_die, DW_AT_upper_bound) |
20111 add_bound_info (subrange_die, DW_AT_upper_bound, upper, NULL); | 20923 && !get_AT (subrange_die, DW_AT_count)) |
20924 { | |
20925 if (upper) | |
20926 add_bound_info (subrange_die, DW_AT_upper_bound, upper, NULL); | |
20927 else if ((is_c () || is_cxx ()) && COMPLETE_TYPE_P (type)) | |
20928 /* Zero-length array. */ | |
20929 add_bound_info (subrange_die, DW_AT_count, | |
20930 build_int_cst (TREE_TYPE (lower), 0), NULL); | |
20931 } | |
20112 } | 20932 } |
20113 | 20933 |
20114 /* Otherwise we have an array type with an unspecified length. The | 20934 /* Otherwise we have an array type with an unspecified length. The |
20115 DWARF-2 spec does not say how to handle this; let's just leave out the | 20935 DWARF-2 spec does not say how to handle this; let's just leave out the |
20116 bounds. */ | 20936 bounds. */ |
20305 | 21125 |
20306 /* Add an 'abstract_origin' attribute below a given DIE. The DIE is found | 21126 /* Add an 'abstract_origin' attribute below a given DIE. The DIE is found |
20307 by looking in the type declaration, the object declaration equate table or | 21127 by looking in the type declaration, the object declaration equate table or |
20308 the block mapping. */ | 21128 the block mapping. */ |
20309 | 21129 |
20310 static inline dw_die_ref | 21130 static inline void |
20311 add_abstract_origin_attribute (dw_die_ref die, tree origin) | 21131 add_abstract_origin_attribute (dw_die_ref die, tree origin) |
20312 { | 21132 { |
20313 dw_die_ref origin_die = NULL; | 21133 dw_die_ref origin_die = NULL; |
20314 | 21134 |
21135 /* For late LTO debug output we want to refer directly to the abstract | |
21136 DIE in the early debug rather to the possibly existing concrete | |
21137 instance and avoid creating that just for this purpose. */ | |
21138 sym_off_pair *desc; | |
21139 if (in_lto_p | |
21140 && external_die_map | |
21141 && (desc = external_die_map->get (origin))) | |
21142 { | |
21143 add_AT_external_die_ref (die, DW_AT_abstract_origin, | |
21144 desc->sym, desc->off); | |
21145 return; | |
21146 } | |
21147 | |
20315 if (DECL_P (origin)) | 21148 if (DECL_P (origin)) |
20316 { | 21149 origin_die = lookup_decl_die (origin); |
20317 dw_die_ref c; | |
20318 origin_die = lookup_decl_die (origin); | |
20319 /* "Unwrap" the decls DIE which we put in the imported unit context. | |
20320 We are looking for the abstract copy here. */ | |
20321 if (in_lto_p | |
20322 && origin_die | |
20323 && (c = get_AT_ref (origin_die, DW_AT_abstract_origin)) | |
20324 /* ??? Identify this better. */ | |
20325 && c->with_offset) | |
20326 origin_die = c; | |
20327 } | |
20328 else if (TYPE_P (origin)) | 21150 else if (TYPE_P (origin)) |
20329 origin_die = lookup_type_die (origin); | 21151 origin_die = lookup_type_die (origin); |
20330 else if (TREE_CODE (origin) == BLOCK) | 21152 else if (TREE_CODE (origin) == BLOCK) |
20331 origin_die = BLOCK_DIE (origin); | 21153 origin_die = lookup_block_die (origin); |
20332 | 21154 |
20333 /* XXX: Functions that are never lowered don't always have correct block | 21155 /* XXX: Functions that are never lowered don't always have correct block |
20334 trees (in the case of java, they simply have no block tree, in some other | 21156 trees (in the case of java, they simply have no block tree, in some other |
20335 languages). For these functions, there is nothing we can really do to | 21157 languages). For these functions, there is nothing we can really do to |
20336 output correct debug info for inlined functions in all cases. Rather | 21158 output correct debug info for inlined functions in all cases. Rather |
20339 functions are lowered, we should re-add a gcc_assert (origin_die) | 21161 functions are lowered, we should re-add a gcc_assert (origin_die) |
20340 here. */ | 21162 here. */ |
20341 | 21163 |
20342 if (origin_die) | 21164 if (origin_die) |
20343 add_AT_die_ref (die, DW_AT_abstract_origin, origin_die); | 21165 add_AT_die_ref (die, DW_AT_abstract_origin, origin_die); |
20344 return origin_die; | |
20345 } | 21166 } |
20346 | 21167 |
20347 /* We do not currently support the pure_virtual attribute. */ | 21168 /* We do not currently support the pure_virtual attribute. */ |
20348 | 21169 |
20349 static inline void | 21170 static inline void |
20448 if (decl_name != NULL && IDENTIFIER_POINTER (decl_name) != NULL) | 21269 if (decl_name != NULL && IDENTIFIER_POINTER (decl_name) != NULL) |
20449 { | 21270 { |
20450 const char *name = dwarf2_name (decl, 0); | 21271 const char *name = dwarf2_name (decl, 0); |
20451 if (name) | 21272 if (name) |
20452 add_name_attribute (die, name); | 21273 add_name_attribute (die, name); |
21274 else | |
21275 add_desc_attribute (die, decl); | |
21276 | |
20453 if (! DECL_ARTIFICIAL (decl)) | 21277 if (! DECL_ARTIFICIAL (decl)) |
20454 add_src_coords_attributes (die, decl); | 21278 add_src_coords_attributes (die, decl); |
20455 | 21279 |
20456 if (!no_linkage_name) | 21280 if (!no_linkage_name) |
20457 add_linkage_name (die, decl); | 21281 add_linkage_name (die, decl); |
20458 } | 21282 } |
21283 else | |
21284 add_desc_attribute (die, decl); | |
20459 | 21285 |
20460 #ifdef VMS_DEBUGGING_INFO | 21286 #ifdef VMS_DEBUGGING_INFO |
20461 /* Get the function's name, as described by its RTL. This may be different | 21287 /* Get the function's name, as described by its RTL. This may be different |
20462 from the DECL_NAME name used in the source file. */ | 21288 from the DECL_NAME name used in the source file. */ |
20463 if (TREE_CODE (decl) == FUNCTION_DECL && TREE_ASM_WRITTEN (decl)) | 21289 if (TREE_CODE (decl) == FUNCTION_DECL && TREE_ASM_WRITTEN (decl)) |
20536 comp_unit_die ()->die_child = die; | 21362 comp_unit_die ()->die_child = die; |
20537 } | 21363 } |
20538 } | 21364 } |
20539 #endif /* VMS_DEBUGGING_INFO */ | 21365 #endif /* VMS_DEBUGGING_INFO */ |
20540 | 21366 |
20541 /* Push a new declaration scope. */ | |
20542 | |
20543 static void | |
20544 push_decl_scope (tree scope) | |
20545 { | |
20546 vec_safe_push (decl_scope_table, scope); | |
20547 } | |
20548 | |
20549 /* Pop a declaration scope. */ | |
20550 | |
20551 static inline void | |
20552 pop_decl_scope (void) | |
20553 { | |
20554 decl_scope_table->pop (); | |
20555 } | |
20556 | |
20557 /* walk_tree helper function for uses_local_type, below. */ | 21367 /* walk_tree helper function for uses_local_type, below. */ |
20558 | 21368 |
20559 static tree | 21369 static tree |
20560 uses_local_type_r (tree *tp, int *walk_subtrees, void *data ATTRIBUTE_UNUSED) | 21370 uses_local_type_r (tree *tp, int *walk_subtrees, void *data ATTRIBUTE_UNUSED) |
20561 { | 21371 { |
20707 `void', so this only applies to function return types). */ | 21517 `void', so this only applies to function return types). */ |
20708 || code == VOID_TYPE) | 21518 || code == VOID_TYPE) |
20709 return; | 21519 return; |
20710 | 21520 |
20711 type_die = modified_type_die (type, | 21521 type_die = modified_type_die (type, |
20712 cv_quals | TYPE_QUALS_NO_ADDR_SPACE (type), | 21522 cv_quals | TYPE_QUALS (type), |
20713 reverse, | 21523 reverse, |
20714 context_die); | 21524 context_die); |
20715 | 21525 |
20716 if (type_die != NULL) | 21526 if (type_die != NULL) |
20717 add_AT_die_ref (object_die, DW_AT_type, type_die); | 21527 add_AT_die_ref (object_die, DW_AT_type, type_die); |
20937 && TREE_CODE (TREE_TYPE (type)) == ARRAY_TYPE | 21747 && TREE_CODE (TREE_TYPE (type)) == ARRAY_TYPE |
20938 && !TYPE_STRING_FLAG (TREE_TYPE (type))) | 21748 && !TYPE_STRING_FLAG (TREE_TYPE (type))) |
20939 add_AT_unsigned (array_die, DW_AT_ordering, DW_ORD_col_major); | 21749 add_AT_unsigned (array_die, DW_AT_ordering, DW_ORD_col_major); |
20940 | 21750 |
20941 #if 0 | 21751 #if 0 |
20942 /* We default the array ordering. SDB will probably do | 21752 /* We default the array ordering. Debuggers will probably do the right |
20943 the right things even if DW_AT_ordering is not present. It's not even | 21753 things even if DW_AT_ordering is not present. It's not even an issue |
20944 an issue until we start to get into multidimensional arrays anyway. If | 21754 until we start to get into multidimensional arrays anyway. If a debugger |
20945 SDB is ever caught doing the Wrong Thing for multi-dimensional arrays, | 21755 is ever caught doing the Wrong Thing for multi-dimensional arrays, |
20946 then we'll have to put the DW_AT_ordering attribute back in. (But if | 21756 then we'll have to put the DW_AT_ordering attribute back in. (But if |
20947 and when we find out that we need to put these in, we will only do so | 21757 and when we find out that we need to put these in, we will only do so |
20948 for multidimensional arrays. */ | 21758 for multidimensional arrays. */ |
20949 add_AT_unsigned (array_die, DW_AT_ordering, DW_ORD_row_major); | 21759 add_AT_unsigned (array_die, DW_AT_ordering, DW_ORD_row_major); |
20950 #endif | 21760 #endif |
21165 | 21975 |
21166 static dw_die_ref | 21976 static dw_die_ref |
21167 gen_enumeration_type_die (tree type, dw_die_ref context_die) | 21977 gen_enumeration_type_die (tree type, dw_die_ref context_die) |
21168 { | 21978 { |
21169 dw_die_ref type_die = lookup_type_die (type); | 21979 dw_die_ref type_die = lookup_type_die (type); |
21980 dw_die_ref orig_type_die = type_die; | |
21170 | 21981 |
21171 if (type_die == NULL) | 21982 if (type_die == NULL) |
21172 { | 21983 { |
21173 type_die = new_die (DW_TAG_enumeration_type, | 21984 type_die = new_die (DW_TAG_enumeration_type, |
21174 scope_die_for (type, context_die), type); | 21985 scope_die_for (type, context_die), type); |
21175 equate_type_number_to_die (type, type_die); | 21986 equate_type_number_to_die (type, type_die); |
21176 add_name_attribute (type_die, type_tag (type)); | 21987 add_name_attribute (type_die, type_tag (type)); |
21177 if (dwarf_version >= 4 || !dwarf_strict) | 21988 if ((dwarf_version >= 4 || !dwarf_strict) |
21178 { | 21989 && ENUM_IS_SCOPED (type)) |
21179 if (ENUM_IS_SCOPED (type)) | 21990 add_AT_flag (type_die, DW_AT_enum_class, 1); |
21180 add_AT_flag (type_die, DW_AT_enum_class, 1); | 21991 if (ENUM_IS_OPAQUE (type) && TYPE_SIZE (type)) |
21181 if (ENUM_IS_OPAQUE (type)) | 21992 add_AT_flag (type_die, DW_AT_declaration, 1); |
21182 add_AT_flag (type_die, DW_AT_declaration, 1); | |
21183 } | |
21184 if (!dwarf_strict) | 21993 if (!dwarf_strict) |
21185 add_AT_unsigned (type_die, DW_AT_encoding, | 21994 add_AT_unsigned (type_die, DW_AT_encoding, |
21186 TYPE_UNSIGNED (type) | 21995 TYPE_UNSIGNED (type) |
21187 ? DW_ATE_unsigned | 21996 ? DW_ATE_unsigned |
21188 : DW_ATE_signed); | 21997 : DW_ATE_signed); |
21189 } | 21998 } |
21190 else if (! TYPE_SIZE (type)) | 21999 else if (! TYPE_SIZE (type) || ENUM_IS_OPAQUE (type)) |
21191 return type_die; | 22000 return type_die; |
21192 else | 22001 else |
21193 remove_AT (type_die, DW_AT_declaration); | 22002 remove_AT (type_die, DW_AT_declaration); |
21194 | 22003 |
21195 /* Handle a GNU C/C++ extension, i.e. incomplete enum types. If the | 22004 /* Handle a GNU C/C++ extension, i.e. incomplete enum types. If the |
21197 attribute or the DW_AT_element_list attribute. */ | 22006 attribute or the DW_AT_element_list attribute. */ |
21198 if (TYPE_SIZE (type)) | 22007 if (TYPE_SIZE (type)) |
21199 { | 22008 { |
21200 tree link; | 22009 tree link; |
21201 | 22010 |
21202 TREE_ASM_WRITTEN (type) = 1; | 22011 if (!ENUM_IS_OPAQUE (type)) |
21203 add_byte_size_attribute (type_die, type); | 22012 TREE_ASM_WRITTEN (type) = 1; |
21204 add_alignment_attribute (type_die, type); | 22013 if (!orig_type_die || !get_AT (type_die, DW_AT_byte_size)) |
21205 if (dwarf_version >= 3 || !dwarf_strict) | 22014 add_byte_size_attribute (type_die, type); |
22015 if (!orig_type_die || !get_AT (type_die, DW_AT_alignment)) | |
22016 add_alignment_attribute (type_die, type); | |
22017 if ((dwarf_version >= 3 || !dwarf_strict) | |
22018 && (!orig_type_die || !get_AT (type_die, DW_AT_type))) | |
21206 { | 22019 { |
21207 tree underlying = lang_hooks.types.enum_underlying_base_type (type); | 22020 tree underlying = lang_hooks.types.enum_underlying_base_type (type); |
21208 add_type_attribute (type_die, underlying, TYPE_UNQUALIFIED, false, | 22021 add_type_attribute (type_die, underlying, TYPE_UNQUALIFIED, false, |
21209 context_die); | 22022 context_die); |
21210 } | 22023 } |
21211 if (TYPE_STUB_DECL (type) != NULL_TREE) | 22024 if (TYPE_STUB_DECL (type) != NULL_TREE) |
21212 { | 22025 { |
21213 add_src_coords_attributes (type_die, TYPE_STUB_DECL (type)); | 22026 if (!orig_type_die || !get_AT (type_die, DW_AT_decl_file)) |
21214 add_accessibility_attribute (type_die, TYPE_STUB_DECL (type)); | 22027 add_src_coords_attributes (type_die, TYPE_STUB_DECL (type)); |
22028 if (!orig_type_die || !get_AT (type_die, DW_AT_accessibility)) | |
22029 add_accessibility_attribute (type_die, TYPE_STUB_DECL (type)); | |
21215 } | 22030 } |
21216 | 22031 |
21217 /* If the first reference to this type was as the return type of an | 22032 /* If the first reference to this type was as the return type of an |
21218 inline function, then it may not have a parent. Fix this now. */ | 22033 inline function, then it may not have a parent. Fix this now. */ |
21219 if (type_die->die_parent == NULL) | 22034 if (type_die->die_parent == NULL) |
21223 link != NULL; link = TREE_CHAIN (link)) | 22038 link != NULL; link = TREE_CHAIN (link)) |
21224 { | 22039 { |
21225 dw_die_ref enum_die = new_die (DW_TAG_enumerator, type_die, link); | 22040 dw_die_ref enum_die = new_die (DW_TAG_enumerator, type_die, link); |
21226 tree value = TREE_VALUE (link); | 22041 tree value = TREE_VALUE (link); |
21227 | 22042 |
22043 gcc_assert (!ENUM_IS_OPAQUE (type)); | |
21228 add_name_attribute (enum_die, | 22044 add_name_attribute (enum_die, |
21229 IDENTIFIER_POINTER (TREE_PURPOSE (link))); | 22045 IDENTIFIER_POINTER (TREE_PURPOSE (link))); |
21230 | 22046 |
21231 if (TREE_CODE (value) == CONST_DECL) | 22047 if (TREE_CODE (value) == CONST_DECL) |
21232 value = DECL_INITIAL (value); | 22048 value = DECL_INITIAL (value); |
21252 signed/unsigned double tags for all cases. */ | 22068 signed/unsigned double tags for all cases. */ |
21253 add_AT_wide (enum_die, DW_AT_const_value, wi::to_wide (value)); | 22069 add_AT_wide (enum_die, DW_AT_const_value, wi::to_wide (value)); |
21254 } | 22070 } |
21255 | 22071 |
21256 add_gnat_descriptive_type_attribute (type_die, type, context_die); | 22072 add_gnat_descriptive_type_attribute (type_die, type, context_die); |
21257 if (TYPE_ARTIFICIAL (type)) | 22073 if (TYPE_ARTIFICIAL (type) |
22074 && (!orig_type_die || !get_AT (type_die, DW_AT_artificial))) | |
21258 add_AT_flag (type_die, DW_AT_artificial, 1); | 22075 add_AT_flag (type_die, DW_AT_artificial, 1); |
21259 } | 22076 } |
21260 else | 22077 else |
21261 add_AT_flag (type_die, DW_AT_declaration, 1); | 22078 add_AT_flag (type_die, DW_AT_declaration, 1); |
21262 | 22079 |
21476 formal_type = TREE_VALUE (link); | 22293 formal_type = TREE_VALUE (link); |
21477 if (formal_type == void_type_node) | 22294 if (formal_type == void_type_node) |
21478 break; | 22295 break; |
21479 | 22296 |
21480 /* Output a (nameless) DIE to represent the formal parameter itself. */ | 22297 /* Output a (nameless) DIE to represent the formal parameter itself. */ |
21481 if (!POINTER_BOUNDS_TYPE_P (formal_type)) | 22298 parm_die = gen_formal_parameter_die (formal_type, NULL, |
21482 { | 22299 true /* Emit name attribute. */, |
21483 parm_die = gen_formal_parameter_die (formal_type, NULL, | 22300 context_die); |
21484 true /* Emit name attribute. */, | 22301 if (TREE_CODE (function_or_method_type) == METHOD_TYPE |
21485 context_die); | 22302 && link == first_parm_type) |
21486 if (TREE_CODE (function_or_method_type) == METHOD_TYPE | 22303 { |
21487 && link == first_parm_type) | 22304 add_AT_flag (parm_die, DW_AT_artificial, 1); |
21488 { | 22305 if (dwarf_version >= 3 || !dwarf_strict) |
21489 add_AT_flag (parm_die, DW_AT_artificial, 1); | 22306 add_AT_die_ref (context_die, DW_AT_object_pointer, parm_die); |
21490 if (dwarf_version >= 3 || !dwarf_strict) | 22307 } |
21491 add_AT_die_ref (context_die, DW_AT_object_pointer, parm_die); | 22308 else if (arg && DECL_ARTIFICIAL (arg)) |
21492 } | 22309 add_AT_flag (parm_die, DW_AT_artificial, 1); |
21493 else if (arg && DECL_ARTIFICIAL (arg)) | |
21494 add_AT_flag (parm_die, DW_AT_artificial, 1); | |
21495 } | |
21496 | 22310 |
21497 link = TREE_CHAIN (link); | 22311 link = TREE_CHAIN (link); |
21498 if (arg) | 22312 if (arg) |
21499 arg = DECL_CHAIN (arg); | 22313 arg = DECL_CHAIN (arg); |
21500 } | 22314 } |
21530 && ! lookup_decl_die (member)) | 22344 && ! lookup_decl_die (member)) |
21531 { | 22345 { |
21532 dw_die_ref type_die; | 22346 dw_die_ref type_die; |
21533 gcc_assert (!decl_ultimate_origin (member)); | 22347 gcc_assert (!decl_ultimate_origin (member)); |
21534 | 22348 |
21535 push_decl_scope (type); | |
21536 type_die = lookup_type_die_strip_naming_typedef (type); | 22349 type_die = lookup_type_die_strip_naming_typedef (type); |
21537 if (TREE_CODE (member) == FUNCTION_DECL) | 22350 if (TREE_CODE (member) == FUNCTION_DECL) |
21538 gen_subprogram_die (member, type_die); | 22351 gen_subprogram_die (member, type_die); |
21539 else if (TREE_CODE (member) == FIELD_DECL) | 22352 else if (TREE_CODE (member) == FIELD_DECL) |
21540 { | 22353 { |
21552 gen_field_die (member, &vlr_ctx, type_die); | 22365 gen_field_die (member, &vlr_ctx, type_die); |
21553 } | 22366 } |
21554 } | 22367 } |
21555 else | 22368 else |
21556 gen_variable_die (member, NULL_TREE, type_die); | 22369 gen_variable_die (member, NULL_TREE, type_die); |
21557 | |
21558 pop_decl_scope (); | |
21559 } | 22370 } |
21560 } | 22371 } |
21561 | 22372 |
21562 /* Forward declare these functions, because they are mutually recursive | 22373 /* Forward declare these functions, because they are mutually recursive |
21563 with their set_block_* pairing functions. */ | 22374 with their set_block_* pairing functions. */ |
21645 decl = DECL_ORIGIN (decl); | 22456 decl = DECL_ORIGIN (decl); |
21646 | 22457 |
21647 if (DECL_IGNORED_P (decl)) | 22458 if (DECL_IGNORED_P (decl)) |
21648 return; | 22459 return; |
21649 | 22460 |
22461 /* In LTO we're all set. We already created abstract instances | |
22462 early and we want to avoid creating a concrete instance of that | |
22463 if we don't output it. */ | |
22464 if (in_lto_p) | |
22465 return; | |
22466 | |
21650 old_die = lookup_decl_die (decl); | 22467 old_die = lookup_decl_die (decl); |
21651 /* With early debug we always have an old DIE unless we are in LTO | |
21652 and the user did not compile but only link with debug. */ | |
21653 if (in_lto_p && ! old_die) | |
21654 return; | |
21655 gcc_assert (old_die != NULL); | 22468 gcc_assert (old_die != NULL); |
21656 if (get_AT (old_die, DW_AT_inline) | 22469 if (get_AT (old_die, DW_AT_inline)) |
21657 || get_AT (old_die, DW_AT_abstract_origin)) | |
21658 /* We've already generated the abstract instance. */ | 22470 /* We've already generated the abstract instance. */ |
21659 return; | 22471 return; |
21660 | 22472 |
21661 /* Go ahead and put DW_AT_inline on the DIE. */ | 22473 /* Go ahead and put DW_AT_inline on the DIE. */ |
21662 if (DECL_DECLARED_INLINE_P (decl)) | 22474 if (DECL_DECLARED_INLINE_P (decl)) |
21763 | 22575 |
21764 while (block | 22576 while (block |
21765 && block != DECL_INITIAL (decl) | 22577 && block != DECL_INITIAL (decl) |
21766 && TREE_CODE (block) == BLOCK) | 22578 && TREE_CODE (block) == BLOCK) |
21767 { | 22579 { |
21768 stmt_die = BLOCK_DIE (block); | 22580 stmt_die = lookup_block_die (block); |
21769 if (stmt_die) | 22581 if (stmt_die) |
21770 break; | 22582 break; |
21771 block = BLOCK_SUPERCONTEXT (block); | 22583 block = BLOCK_SUPERCONTEXT (block); |
21772 } | 22584 } |
21773 if (stmt_die == NULL) | 22585 if (stmt_die == NULL) |
21879 we will just annotate the location information now | 22691 we will just annotate the location information now |
21880 available. | 22692 available. |
21881 */ | 22693 */ |
21882 int declaration = (current_function_decl != decl | 22694 int declaration = (current_function_decl != decl |
21883 || class_or_namespace_scope_p (context_die)); | 22695 || class_or_namespace_scope_p (context_die)); |
22696 | |
22697 /* A declaration that has been previously dumped needs no | |
22698 additional information. */ | |
22699 if (old_die && declaration) | |
22700 return; | |
21884 | 22701 |
21885 /* Now that the C++ front end lazily declares artificial member fns, we | 22702 /* Now that the C++ front end lazily declares artificial member fns, we |
21886 might need to retrofit the declaration into its class. */ | 22703 might need to retrofit the declaration into its class. */ |
21887 if (!declaration && !origin && !old_die | 22704 if (!declaration && !origin && !old_die |
21888 && DECL_CONTEXT (decl) && TYPE_P (DECL_CONTEXT (decl)) | 22705 && DECL_CONTEXT (decl) && TYPE_P (DECL_CONTEXT (decl)) |
21920 } | 22737 } |
21921 /* A cached copy, possibly from early dwarf generation. Reuse as | 22738 /* A cached copy, possibly from early dwarf generation. Reuse as |
21922 much as possible. */ | 22739 much as possible. */ |
21923 else if (old_die) | 22740 else if (old_die) |
21924 { | 22741 { |
21925 /* A declaration that has been previously dumped needs no | |
21926 additional information. */ | |
21927 if (declaration) | |
21928 return; | |
21929 | |
21930 if (!get_AT_flag (old_die, DW_AT_declaration) | 22742 if (!get_AT_flag (old_die, DW_AT_declaration) |
21931 /* We can have a normal definition following an inline one in the | 22743 /* We can have a normal definition following an inline one in the |
21932 case of redefinition of GNU C extern inlines. | 22744 case of redefinition of GNU C extern inlines. |
21933 It seems reasonable to use AT_specification in this case. */ | 22745 It seems reasonable to use AT_specification in this case. */ |
21934 && !get_AT (old_die, DW_AT_inline)) | 22746 && !get_AT (old_die, DW_AT_inline)) |
21951 instances of inlines, since the spec requires the out-of-line copy | 22763 instances of inlines, since the spec requires the out-of-line copy |
21952 to have the same parent. For local class methods, this doesn't | 22764 to have the same parent. For local class methods, this doesn't |
21953 apply; we just use the old DIE. */ | 22765 apply; we just use the old DIE. */ |
21954 expanded_location s = expand_location (DECL_SOURCE_LOCATION (decl)); | 22766 expanded_location s = expand_location (DECL_SOURCE_LOCATION (decl)); |
21955 struct dwarf_file_data * file_index = lookup_filename (s.file); | 22767 struct dwarf_file_data * file_index = lookup_filename (s.file); |
21956 if ((is_cu_die (old_die->die_parent) | 22768 if (((is_unit_die (old_die->die_parent) |
21957 /* This condition fixes the inconsistency/ICE with the | 22769 /* This condition fixes the inconsistency/ICE with the |
21958 following Fortran test (or some derivative thereof) while | 22770 following Fortran test (or some derivative thereof) while |
21959 building libgfortran: | 22771 building libgfortran: |
21960 | 22772 |
21961 module some_m | 22773 module some_m |
21962 contains | 22774 contains |
21963 logical function funky (FLAG) | 22775 logical function funky (FLAG) |
21964 funky = .true. | 22776 funky = .true. |
21965 end function | 22777 end function |
21966 end module | 22778 end module |
21967 */ | 22779 */ |
21968 || (old_die->die_parent | 22780 || (old_die->die_parent |
21969 && old_die->die_parent->die_tag == DW_TAG_module) | 22781 && old_die->die_parent->die_tag == DW_TAG_module) |
21970 || context_die == NULL) | 22782 || local_scope_p (old_die->die_parent) |
22783 || context_die == NULL) | |
21971 && (DECL_ARTIFICIAL (decl) | 22784 && (DECL_ARTIFICIAL (decl) |
21972 /* The location attributes may be in the abstract origin | |
21973 which in the case of LTO might be not available to | |
21974 look at. */ | |
21975 || get_AT (old_die, DW_AT_abstract_origin) | |
21976 || (get_AT_file (old_die, DW_AT_decl_file) == file_index | 22785 || (get_AT_file (old_die, DW_AT_decl_file) == file_index |
21977 && (get_AT_unsigned (old_die, DW_AT_decl_line) | 22786 && (get_AT_unsigned (old_die, DW_AT_decl_line) |
21978 == (unsigned) s.line) | 22787 == (unsigned) s.line) |
21979 && (!debug_column_info | 22788 && (!debug_column_info |
21980 || s.column == 0 | 22789 || s.column == 0 |
21981 || (get_AT_unsigned (old_die, DW_AT_decl_column) | 22790 || (get_AT_unsigned (old_die, DW_AT_decl_column) |
21982 == (unsigned) s.column))))) | 22791 == (unsigned) s.column))))) |
22792 /* With LTO if there's an abstract instance for | |
22793 the old DIE, this is a concrete instance and | |
22794 thus re-use the DIE. */ | |
22795 || get_AT (old_die, DW_AT_abstract_origin)) | |
21983 { | 22796 { |
21984 subr_die = old_die; | 22797 subr_die = old_die; |
21985 | 22798 |
21986 /* Clear out the declaration attribute, but leave the | 22799 /* Clear out the declaration attribute, but leave the |
21987 parameters so they can be augmented with location | 22800 parameters so they can be augmented with location |
22357 if (generic_decl_parm | 23170 if (generic_decl_parm |
22358 && lang_hooks.function_parameter_pack_p (generic_decl_parm)) | 23171 && lang_hooks.function_parameter_pack_p (generic_decl_parm)) |
22359 gen_formal_parameter_pack_die (generic_decl_parm, | 23172 gen_formal_parameter_pack_die (generic_decl_parm, |
22360 parm, subr_die, | 23173 parm, subr_die, |
22361 &parm); | 23174 &parm); |
22362 else if (parm && !POINTER_BOUNDS_P (parm)) | 23175 else if (parm) |
22363 { | 23176 { |
22364 dw_die_ref parm_die = gen_decl_die (parm, NULL, NULL, subr_die); | 23177 dw_die_ref parm_die = gen_decl_die (parm, NULL, NULL, subr_die); |
22365 | 23178 |
22366 if (early_dwarf | 23179 if (early_dwarf |
22367 && parm == DECL_ARGUMENTS (decl) | 23180 && parm == DECL_ARGUMENTS (decl) |
22440 for (ca_loc = call_arg_locations; ca_loc; ca_loc = ca_loc->next) | 23253 for (ca_loc = call_arg_locations; ca_loc; ca_loc = ca_loc->next) |
22441 { | 23254 { |
22442 dw_die_ref die = NULL; | 23255 dw_die_ref die = NULL; |
22443 rtx tloc = NULL_RTX, tlocc = NULL_RTX; | 23256 rtx tloc = NULL_RTX, tlocc = NULL_RTX; |
22444 rtx arg, next_arg; | 23257 rtx arg, next_arg; |
23258 tree arg_decl = NULL_TREE; | |
22445 | 23259 |
22446 for (arg = (ca_loc->call_arg_loc_note != NULL_RTX | 23260 for (arg = (ca_loc->call_arg_loc_note != NULL_RTX |
22447 ? NOTE_VAR_LOCATION (ca_loc->call_arg_loc_note) | 23261 ? XEXP (ca_loc->call_arg_loc_note, 0) |
22448 : NULL_RTX); | 23262 : NULL_RTX); |
22449 arg; arg = next_arg) | 23263 arg; arg = next_arg) |
22450 { | 23264 { |
22451 dw_loc_descr_ref reg, val; | 23265 dw_loc_descr_ref reg, val; |
22452 machine_mode mode = GET_MODE (XEXP (XEXP (arg, 0), 1)); | 23266 machine_mode mode = GET_MODE (XEXP (XEXP (arg, 0), 1)); |
22504 tree tdecl | 23318 tree tdecl |
22505 = DEBUG_PARAMETER_REF_DECL (XEXP (XEXP (arg, 0), 0)); | 23319 = DEBUG_PARAMETER_REF_DECL (XEXP (XEXP (arg, 0), 0)); |
22506 tdie = lookup_decl_die (tdecl); | 23320 tdie = lookup_decl_die (tdecl); |
22507 if (tdie == NULL) | 23321 if (tdie == NULL) |
22508 continue; | 23322 continue; |
23323 arg_decl = tdecl; | |
22509 } | 23324 } |
22510 else | 23325 else |
22511 continue; | 23326 continue; |
22512 if (reg == NULL | 23327 if (reg == NULL |
22513 && GET_CODE (XEXP (XEXP (arg, 0), 0)) | 23328 && GET_CODE (XEXP (XEXP (arg, 0), 0)) |
22520 continue; | 23335 continue; |
22521 if (die == NULL) | 23336 if (die == NULL) |
22522 die = gen_call_site_die (decl, subr_die, ca_loc); | 23337 die = gen_call_site_die (decl, subr_die, ca_loc); |
22523 cdie = new_die (dwarf_TAG (DW_TAG_call_site_parameter), die, | 23338 cdie = new_die (dwarf_TAG (DW_TAG_call_site_parameter), die, |
22524 NULL_TREE); | 23339 NULL_TREE); |
23340 add_desc_attribute (cdie, arg_decl); | |
22525 if (reg != NULL) | 23341 if (reg != NULL) |
22526 add_AT_loc (cdie, DW_AT_location, reg); | 23342 add_AT_loc (cdie, DW_AT_location, reg); |
22527 else if (tdie != NULL) | 23343 else if (tdie != NULL) |
22528 add_AT_die_ref (cdie, dwarf_AT (DW_AT_call_parameter), | 23344 add_AT_die_ref (cdie, dwarf_AT (DW_AT_call_parameter), |
22529 tdie); | 23345 tdie); |
22613 block_die_hasher::equal (die_struct *x, die_struct *y) | 23429 block_die_hasher::equal (die_struct *x, die_struct *y) |
22614 { | 23430 { |
22615 return x->decl_id == y->decl_id && x->die_parent == y->die_parent; | 23431 return x->decl_id == y->decl_id && x->die_parent == y->die_parent; |
22616 } | 23432 } |
22617 | 23433 |
23434 /* Hold information about markers for inlined entry points. */ | |
23435 struct GTY ((for_user)) inline_entry_data | |
23436 { | |
23437 /* The block that's the inlined_function_outer_scope for an inlined | |
23438 function. */ | |
23439 tree block; | |
23440 | |
23441 /* The label at the inlined entry point. */ | |
23442 const char *label_pfx; | |
23443 unsigned int label_num; | |
23444 | |
23445 /* The view number to be used as the inlined entry point. */ | |
23446 var_loc_view view; | |
23447 }; | |
23448 | |
23449 struct inline_entry_data_hasher : ggc_ptr_hash <inline_entry_data> | |
23450 { | |
23451 typedef tree compare_type; | |
23452 static inline hashval_t hash (const inline_entry_data *); | |
23453 static inline bool equal (const inline_entry_data *, const_tree); | |
23454 }; | |
23455 | |
23456 /* Hash table routines for inline_entry_data. */ | |
23457 | |
23458 inline hashval_t | |
23459 inline_entry_data_hasher::hash (const inline_entry_data *data) | |
23460 { | |
23461 return htab_hash_pointer (data->block); | |
23462 } | |
23463 | |
23464 inline bool | |
23465 inline_entry_data_hasher::equal (const inline_entry_data *data, | |
23466 const_tree block) | |
23467 { | |
23468 return data->block == block; | |
23469 } | |
23470 | |
23471 /* Inlined entry points pending DIE creation in this compilation unit. */ | |
23472 | |
23473 static GTY(()) hash_table<inline_entry_data_hasher> *inline_entry_data_table; | |
23474 | |
23475 | |
22618 /* Return TRUE if DECL, which may have been previously generated as | 23476 /* Return TRUE if DECL, which may have been previously generated as |
22619 OLD_DIE, is a candidate for a DW_AT_specification. DECLARATION is | 23477 OLD_DIE, is a candidate for a DW_AT_specification. DECLARATION is |
22620 true if decl (or its origin) is either an extern declaration or a | 23478 true if decl (or its origin) is either an extern declaration or a |
22621 class/namespace scoped declaration. | 23479 class/namespace scoped declaration. |
22622 | 23480 |
22806 } | 23664 } |
22807 else if (origin && old_die->die_parent != context_die) | 23665 else if (origin && old_die->die_parent != context_die) |
22808 { | 23666 { |
22809 /* If we will be creating an inlined instance, we need a | 23667 /* If we will be creating an inlined instance, we need a |
22810 new DIE that will get annotated with | 23668 new DIE that will get annotated with |
22811 DW_AT_abstract_origin. Clear things so we can get a | 23669 DW_AT_abstract_origin. */ |
22812 new DIE. */ | |
22813 gcc_assert (!DECL_ABSTRACT_P (decl)); | 23670 gcc_assert (!DECL_ABSTRACT_P (decl)); |
22814 old_die = NULL; | |
22815 } | 23671 } |
22816 else | 23672 else |
22817 { | 23673 { |
22818 /* If a DIE was dumped early, it still needs location info. | 23674 /* If a DIE was dumped early, it still needs location info. |
22819 Skip to where we fill the location bits. */ | 23675 Skip to where we fill the location bits. */ |
22820 var_die = old_die; | 23676 var_die = old_die; |
22821 | 23677 |
22822 /* ??? In LTRANS we cannot annotate early created variably | 23678 /* ??? In LTRANS we cannot annotate early created variably |
22823 modified type DIEs without copying them and adjusting all | 23679 modified type DIEs without copying them and adjusting all |
22824 references to them. Thus we dumped them again, also add a | 23680 references to them. Thus we dumped them again. Also add a |
22825 reference to them. */ | 23681 reference to them but beware of -g0 compile and -g link |
23682 in which case the reference will be already present. */ | |
22826 tree type = TREE_TYPE (decl_or_origin); | 23683 tree type = TREE_TYPE (decl_or_origin); |
22827 if (in_lto_p | 23684 if (in_lto_p |
23685 && ! get_AT (var_die, DW_AT_type) | |
22828 && variably_modified_type_p | 23686 && variably_modified_type_p |
22829 (type, decl_function_context (decl_or_origin))) | 23687 (type, decl_function_context (decl_or_origin))) |
22830 { | 23688 { |
22831 if (decl_by_reference_p (decl_or_origin)) | 23689 if (decl_by_reference_p (decl_or_origin)) |
22832 add_type_attribute (var_die, TREE_TYPE (type), | 23690 add_type_attribute (var_die, TREE_TYPE (type), |
23047 function was called from. This is similar to add_src_coords_attributes. */ | 23905 function was called from. This is similar to add_src_coords_attributes. */ |
23048 | 23906 |
23049 static inline void | 23907 static inline void |
23050 add_call_src_coords_attributes (tree stmt, dw_die_ref die) | 23908 add_call_src_coords_attributes (tree stmt, dw_die_ref die) |
23051 { | 23909 { |
23910 /* We can end up with BUILTINS_LOCATION here. */ | |
23911 if (RESERVED_LOCATION_P (BLOCK_SOURCE_LOCATION (stmt))) | |
23912 return; | |
23913 | |
23052 expanded_location s = expand_location (BLOCK_SOURCE_LOCATION (stmt)); | 23914 expanded_location s = expand_location (BLOCK_SOURCE_LOCATION (stmt)); |
23053 | 23915 |
23054 if (dwarf_version >= 3 || !dwarf_strict) | 23916 if (dwarf_version >= 3 || !dwarf_strict) |
23055 { | 23917 { |
23056 add_AT_file (die, DW_AT_call_file, lookup_filename (s.file)); | 23918 add_AT_file (die, DW_AT_call_file, lookup_filename (s.file)); |
23067 static inline void | 23929 static inline void |
23068 add_high_low_attributes (tree stmt, dw_die_ref die) | 23930 add_high_low_attributes (tree stmt, dw_die_ref die) |
23069 { | 23931 { |
23070 char label[MAX_ARTIFICIAL_LABEL_BYTES]; | 23932 char label[MAX_ARTIFICIAL_LABEL_BYTES]; |
23071 | 23933 |
23934 if (inline_entry_data **iedp | |
23935 = !inline_entry_data_table ? NULL | |
23936 : inline_entry_data_table->find_slot_with_hash (stmt, | |
23937 htab_hash_pointer (stmt), | |
23938 NO_INSERT)) | |
23939 { | |
23940 inline_entry_data *ied = *iedp; | |
23941 gcc_assert (MAY_HAVE_DEBUG_MARKER_INSNS); | |
23942 gcc_assert (debug_inline_points); | |
23943 gcc_assert (inlined_function_outer_scope_p (stmt)); | |
23944 | |
23945 ASM_GENERATE_INTERNAL_LABEL (label, ied->label_pfx, ied->label_num); | |
23946 add_AT_lbl_id (die, DW_AT_entry_pc, label); | |
23947 | |
23948 if (debug_variable_location_views && !ZERO_VIEW_P (ied->view) | |
23949 && !dwarf_strict) | |
23950 { | |
23951 if (!output_asm_line_debug_info ()) | |
23952 add_AT_unsigned (die, DW_AT_GNU_entry_view, ied->view); | |
23953 else | |
23954 { | |
23955 ASM_GENERATE_INTERNAL_LABEL (label, "LVU", ied->view); | |
23956 /* FIXME: this will resolve to a small number. Could we | |
23957 possibly emit smaller data? Ideally we'd emit a | |
23958 uleb128, but that would make the size of DIEs | |
23959 impossible for the compiler to compute, since it's | |
23960 the assembler that computes the value of the view | |
23961 label in this case. Ideally, we'd have a single form | |
23962 encompassing both the address and the view, and | |
23963 indirecting them through a table might make things | |
23964 easier, but even that would be more wasteful, | |
23965 space-wise, than what we have now. */ | |
23966 add_AT_symview (die, DW_AT_GNU_entry_view, label); | |
23967 } | |
23968 } | |
23969 | |
23970 inline_entry_data_table->clear_slot (iedp); | |
23971 } | |
23972 | |
23072 if (BLOCK_FRAGMENT_CHAIN (stmt) | 23973 if (BLOCK_FRAGMENT_CHAIN (stmt) |
23073 && (dwarf_version >= 3 || !dwarf_strict)) | 23974 && (dwarf_version >= 3 || !dwarf_strict)) |
23074 { | 23975 { |
23075 tree chain, superblock = NULL_TREE; | 23976 tree chain, superblock = NULL_TREE; |
23076 dw_die_ref pdie; | 23977 dw_die_ref pdie; |
23077 dw_attr_node *attr = NULL; | 23978 dw_attr_node *attr = NULL; |
23078 | 23979 |
23079 if (inlined_function_outer_scope_p (stmt)) | 23980 if (!debug_inline_points && inlined_function_outer_scope_p (stmt)) |
23080 { | 23981 { |
23081 ASM_GENERATE_INTERNAL_LABEL (label, BLOCK_BEGIN_LABEL, | 23982 ASM_GENERATE_INTERNAL_LABEL (label, BLOCK_BEGIN_LABEL, |
23082 BLOCK_NUMBER (stmt)); | 23983 BLOCK_NUMBER (stmt)); |
23083 add_AT_lbl_id (die, DW_AT_entry_pc, label); | 23984 add_AT_lbl_id (die, DW_AT_entry_pc, label); |
23084 } | 23985 } |
23106 attr = new_attr; | 24007 attr = new_attr; |
23107 superblock = BLOCK_SUPERCONTEXT (chain); | 24008 superblock = BLOCK_SUPERCONTEXT (chain); |
23108 } | 24009 } |
23109 if (attr != NULL | 24010 if (attr != NULL |
23110 && ((*ranges_table)[attr->dw_attr_val.v.val_offset].num | 24011 && ((*ranges_table)[attr->dw_attr_val.v.val_offset].num |
23111 == BLOCK_NUMBER (superblock)) | 24012 == (int)BLOCK_NUMBER (superblock)) |
23112 && BLOCK_FRAGMENT_CHAIN (superblock)) | 24013 && BLOCK_FRAGMENT_CHAIN (superblock)) |
23113 { | 24014 { |
23114 unsigned long off = attr->dw_attr_val.v.val_offset; | 24015 unsigned long off = attr->dw_attr_val.v.val_offset; |
23115 unsigned long supercnt = 0, thiscnt = 0; | 24016 unsigned long supercnt = 0, thiscnt = 0; |
23116 for (chain = BLOCK_FRAGMENT_CHAIN (superblock); | 24017 for (chain = BLOCK_FRAGMENT_CHAIN (superblock); |
23117 chain; chain = BLOCK_FRAGMENT_CHAIN (chain)) | 24018 chain; chain = BLOCK_FRAGMENT_CHAIN (chain)) |
23118 { | 24019 { |
23119 ++supercnt; | 24020 ++supercnt; |
23120 gcc_checking_assert ((*ranges_table)[off + supercnt].num | 24021 gcc_checking_assert ((*ranges_table)[off + supercnt].num |
23121 == BLOCK_NUMBER (chain)); | 24022 == (int)BLOCK_NUMBER (chain)); |
23122 } | 24023 } |
23123 gcc_checking_assert ((*ranges_table)[off + supercnt + 1].num == 0); | 24024 gcc_checking_assert ((*ranges_table)[off + supercnt + 1].num == 0); |
23124 for (chain = BLOCK_FRAGMENT_CHAIN (stmt); | 24025 for (chain = BLOCK_FRAGMENT_CHAIN (stmt); |
23125 chain; chain = BLOCK_FRAGMENT_CHAIN (chain)) | 24026 chain; chain = BLOCK_FRAGMENT_CHAIN (chain)) |
23126 ++thiscnt; | 24027 ++thiscnt; |
23160 /* Generate a DIE for a lexical block. */ | 24061 /* Generate a DIE for a lexical block. */ |
23161 | 24062 |
23162 static void | 24063 static void |
23163 gen_lexical_block_die (tree stmt, dw_die_ref context_die) | 24064 gen_lexical_block_die (tree stmt, dw_die_ref context_die) |
23164 { | 24065 { |
23165 dw_die_ref old_die = BLOCK_DIE (stmt); | 24066 dw_die_ref old_die = lookup_block_die (stmt); |
23166 dw_die_ref stmt_die = NULL; | 24067 dw_die_ref stmt_die = NULL; |
23167 if (!old_die) | 24068 if (!old_die) |
23168 { | 24069 { |
23169 stmt_die = new_die (DW_TAG_lexical_block, context_die, stmt); | 24070 stmt_die = new_die (DW_TAG_lexical_block, context_die, stmt); |
23170 BLOCK_DIE (stmt) = stmt_die; | 24071 equate_block_to_die (stmt, stmt_die); |
23171 } | 24072 } |
23172 | 24073 |
23173 if (BLOCK_ABSTRACT (stmt)) | 24074 if (BLOCK_ABSTRACT_ORIGIN (stmt)) |
23174 { | 24075 { |
24076 /* If this is an inlined or conrecte instance, create a new lexical | |
24077 die for anything below to attach DW_AT_abstract_origin to. */ | |
23175 if (old_die) | 24078 if (old_die) |
23176 { | 24079 stmt_die = new_die (DW_TAG_lexical_block, context_die, stmt); |
23177 /* This must have been generated early and it won't even | |
23178 need location information since it's a DW_AT_inline | |
23179 function. */ | |
23180 if (flag_checking) | |
23181 for (dw_die_ref c = context_die; c; c = c->die_parent) | |
23182 if (c->die_tag == DW_TAG_inlined_subroutine | |
23183 || c->die_tag == DW_TAG_subprogram) | |
23184 { | |
23185 gcc_assert (get_AT (c, DW_AT_inline)); | |
23186 break; | |
23187 } | |
23188 return; | |
23189 } | |
23190 } | |
23191 else if (BLOCK_ABSTRACT_ORIGIN (stmt)) | |
23192 { | |
23193 /* If this is an inlined instance, create a new lexical die for | |
23194 anything below to attach DW_AT_abstract_origin to. */ | |
23195 if (old_die) | |
23196 { | |
23197 stmt_die = new_die (DW_TAG_lexical_block, context_die, stmt); | |
23198 BLOCK_DIE (stmt) = stmt_die; | |
23199 old_die = NULL; | |
23200 } | |
23201 | 24080 |
23202 tree origin = block_ultimate_origin (stmt); | 24081 tree origin = block_ultimate_origin (stmt); |
23203 if (origin != NULL_TREE && origin != stmt) | 24082 if (origin != NULL_TREE && (origin != stmt || old_die)) |
23204 add_abstract_origin_attribute (stmt_die, origin); | 24083 add_abstract_origin_attribute (stmt_die, origin); |
24084 | |
24085 old_die = NULL; | |
23205 } | 24086 } |
23206 | 24087 |
23207 if (old_die) | 24088 if (old_die) |
23208 stmt_die = old_die; | 24089 stmt_die = old_die; |
23209 | 24090 |
23210 /* A non abstract block whose blocks have already been reordered | 24091 /* A non abstract block whose blocks have already been reordered |
23211 should have the instruction range for this block. If so, set the | 24092 should have the instruction range for this block. If so, set the |
23212 high/low attributes. */ | 24093 high/low attributes. */ |
23213 if (!early_dwarf && !BLOCK_ABSTRACT (stmt) && TREE_ASM_WRITTEN (stmt)) | 24094 if (!early_dwarf && TREE_ASM_WRITTEN (stmt)) |
23214 { | 24095 { |
23215 gcc_assert (stmt_die); | 24096 gcc_assert (stmt_die); |
23216 add_high_low_attributes (stmt, stmt_die); | 24097 add_high_low_attributes (stmt, stmt_die); |
23217 } | 24098 } |
23218 | 24099 |
23222 /* Generate a DIE for an inlined subprogram. */ | 24103 /* Generate a DIE for an inlined subprogram. */ |
23223 | 24104 |
23224 static void | 24105 static void |
23225 gen_inlined_subroutine_die (tree stmt, dw_die_ref context_die) | 24106 gen_inlined_subroutine_die (tree stmt, dw_die_ref context_die) |
23226 { | 24107 { |
23227 tree decl; | 24108 tree decl = block_ultimate_origin (stmt); |
23228 | |
23229 /* The instance of function that is effectively being inlined shall not | |
23230 be abstract. */ | |
23231 gcc_assert (! BLOCK_ABSTRACT (stmt)); | |
23232 | |
23233 decl = block_ultimate_origin (stmt); | |
23234 | 24109 |
23235 /* Make sure any inlined functions are known to be inlineable. */ | 24110 /* Make sure any inlined functions are known to be inlineable. */ |
23236 gcc_checking_assert (DECL_ABSTRACT_P (decl) | 24111 gcc_checking_assert (DECL_ABSTRACT_P (decl) |
23237 || cgraph_function_possibly_inlined_p (decl)); | 24112 || cgraph_function_possibly_inlined_p (decl)); |
23238 | 24113 |
23239 if (! BLOCK_ABSTRACT (stmt)) | 24114 dw_die_ref subr_die = new_die (DW_TAG_inlined_subroutine, context_die, stmt); |
23240 { | 24115 |
23241 dw_die_ref subr_die | 24116 if (call_arg_locations || debug_inline_points) |
23242 = new_die (DW_TAG_inlined_subroutine, context_die, stmt); | 24117 equate_block_to_die (stmt, subr_die); |
23243 | 24118 add_abstract_origin_attribute (subr_die, decl); |
23244 if (call_arg_locations) | 24119 if (TREE_ASM_WRITTEN (stmt)) |
23245 BLOCK_DIE (stmt) = subr_die; | 24120 add_high_low_attributes (stmt, subr_die); |
23246 add_abstract_origin_attribute (subr_die, decl); | 24121 add_call_src_coords_attributes (stmt, subr_die); |
23247 if (TREE_ASM_WRITTEN (stmt)) | 24122 |
23248 add_high_low_attributes (stmt, subr_die); | 24123 /* The inliner creates an extra BLOCK for the parameter setup, |
23249 add_call_src_coords_attributes (stmt, subr_die); | 24124 we want to merge that with the actual outermost BLOCK of the |
23250 | 24125 inlined function to avoid duplicate locals in consumers. |
23251 decls_for_scope (stmt, subr_die); | 24126 Do that by doing the recursion to subblocks on the single subblock |
23252 } | 24127 of STMT. */ |
24128 bool unwrap_one = false; | |
24129 if (BLOCK_SUBBLOCKS (stmt) && !BLOCK_CHAIN (BLOCK_SUBBLOCKS (stmt))) | |
24130 { | |
24131 tree origin = block_ultimate_origin (BLOCK_SUBBLOCKS (stmt)); | |
24132 if (origin | |
24133 && TREE_CODE (origin) == BLOCK | |
24134 && BLOCK_SUPERCONTEXT (origin) == decl) | |
24135 unwrap_one = true; | |
24136 } | |
24137 decls_for_scope (stmt, subr_die, !unwrap_one); | |
24138 if (unwrap_one) | |
24139 decls_for_scope (BLOCK_SUBBLOCKS (stmt), subr_die); | |
23253 } | 24140 } |
23254 | 24141 |
23255 /* Generate a DIE for a field in a record, or structure. CTX is required: see | 24142 /* Generate a DIE for a field in a record, or structure. CTX is required: see |
23256 the comment for VLR_CONTEXT. */ | 24143 the comment for VLR_CONTEXT. */ |
23257 | 24144 |
23356 case OPT_D: | 24243 case OPT_D: |
23357 case OPT_I: | 24244 case OPT_I: |
23358 case OPT_U: | 24245 case OPT_U: |
23359 case OPT_SPECIAL_unknown: | 24246 case OPT_SPECIAL_unknown: |
23360 case OPT_SPECIAL_ignore: | 24247 case OPT_SPECIAL_ignore: |
24248 case OPT_SPECIAL_deprecated: | |
23361 case OPT_SPECIAL_program_name: | 24249 case OPT_SPECIAL_program_name: |
23362 case OPT_SPECIAL_input_file: | 24250 case OPT_SPECIAL_input_file: |
23363 case OPT_grecord_gcc_switches: | 24251 case OPT_grecord_gcc_switches: |
23364 case OPT__output_pch_: | 24252 case OPT__output_pch_: |
23365 case OPT_fdiagnostics_show_location_: | 24253 case OPT_fdiagnostics_show_location_: |
23366 case OPT_fdiagnostics_show_option: | 24254 case OPT_fdiagnostics_show_option: |
23367 case OPT_fdiagnostics_show_caret: | 24255 case OPT_fdiagnostics_show_caret: |
24256 case OPT_fdiagnostics_show_labels: | |
24257 case OPT_fdiagnostics_show_line_numbers: | |
23368 case OPT_fdiagnostics_color_: | 24258 case OPT_fdiagnostics_color_: |
23369 case OPT_fverbose_asm: | 24259 case OPT_fverbose_asm: |
23370 case OPT____: | 24260 case OPT____: |
23371 case OPT__sysroot_: | 24261 case OPT__sysroot_: |
23372 case OPT_nostdinc: | 24262 case OPT_nostdinc: |
23373 case OPT_nostdinc__: | 24263 case OPT_nostdinc__: |
23374 case OPT_fpreprocessed: | 24264 case OPT_fpreprocessed: |
23375 case OPT_fltrans_output_list_: | 24265 case OPT_fltrans_output_list_: |
23376 case OPT_fresolution_: | 24266 case OPT_fresolution_: |
23377 case OPT_fdebug_prefix_map_: | 24267 case OPT_fdebug_prefix_map_: |
24268 case OPT_fmacro_prefix_map_: | |
24269 case OPT_ffile_prefix_map_: | |
24270 case OPT_fcompare_debug: | |
24271 case OPT_fchecking: | |
24272 case OPT_fchecking_: | |
23378 /* Ignore these. */ | 24273 /* Ignore these. */ |
23379 continue; | 24274 continue; |
23380 default: | 24275 default: |
23381 if (cl_options[save_decoded_options[j].opt_index].flags | 24276 if (cl_options[save_decoded_options[j].opt_index].flags |
23382 & CL_NO_DWARF_RECORD) | 24277 & CL_NO_DWARF_RECORD) |
23432 if (strcmp ("GNU C++11", lang1) == 0 || strcmp ("GNU C++11", lang2) == 0) | 24327 if (strcmp ("GNU C++11", lang1) == 0 || strcmp ("GNU C++11", lang2) == 0) |
23433 return "GNU C++11"; | 24328 return "GNU C++11"; |
23434 if (strcmp ("GNU C++98", lang1) == 0 || strcmp ("GNU C++98", lang2) == 0) | 24329 if (strcmp ("GNU C++98", lang1) == 0 || strcmp ("GNU C++98", lang2) == 0) |
23435 return "GNU C++98"; | 24330 return "GNU C++98"; |
23436 | 24331 |
24332 if (strcmp ("GNU C2X", lang1) == 0 || strcmp ("GNU C2X", lang2) == 0) | |
24333 return "GNU C2X"; | |
24334 if (strcmp ("GNU C17", lang1) == 0 || strcmp ("GNU C17", lang2) == 0) | |
24335 return "GNU C17"; | |
23437 if (strcmp ("GNU C11", lang1) == 0 || strcmp ("GNU C11", lang2) == 0) | 24336 if (strcmp ("GNU C11", lang1) == 0 || strcmp ("GNU C11", lang2) == 0) |
23438 return "GNU C11"; | 24337 return "GNU C11"; |
23439 if (strcmp ("GNU C99", lang1) == 0 || strcmp ("GNU C99", lang2) == 0) | 24338 if (strcmp ("GNU C99", lang1) == 0 || strcmp ("GNU C99", lang2) == 0) |
23440 return "GNU C99"; | 24339 return "GNU C99"; |
23441 if (strcmp ("GNU C89", lang1) == 0 || strcmp ("GNU C89", lang2) == 0) | 24340 if (strcmp ("GNU C89", lang1) == 0 || strcmp ("GNU C89", lang2) == 0) |
23508 { | 24407 { |
23509 if (strcmp (language_string, "GNU C89") != 0) | 24408 if (strcmp (language_string, "GNU C89") != 0) |
23510 language = DW_LANG_C99; | 24409 language = DW_LANG_C99; |
23511 | 24410 |
23512 if (dwarf_version >= 5 /* || !dwarf_strict */) | 24411 if (dwarf_version >= 5 /* || !dwarf_strict */) |
23513 if (strcmp (language_string, "GNU C11") == 0) | 24412 if (strcmp (language_string, "GNU C11") == 0 |
24413 || strcmp (language_string, "GNU C17") == 0 | |
24414 || strcmp (language_string, "GNU C2X")) | |
23514 language = DW_LANG_C11; | 24415 language = DW_LANG_C11; |
23515 } | 24416 } |
23516 } | 24417 } |
23517 else if (strncmp (language_string, "GNU C++", 7) == 0) | 24418 else if (strncmp (language_string, "GNU C++", 7) == 0) |
23518 { | 24419 { |
23556 } | 24457 } |
23557 } | 24458 } |
23558 /* Use a degraded Fortran setting in strict DWARF2 so is_fortran works. */ | 24459 /* Use a degraded Fortran setting in strict DWARF2 so is_fortran works. */ |
23559 else if (strncmp (language_string, "GNU Fortran", 11) == 0) | 24460 else if (strncmp (language_string, "GNU Fortran", 11) == 0) |
23560 language = DW_LANG_Fortran90; | 24461 language = DW_LANG_Fortran90; |
24462 /* Likewise for Ada. */ | |
24463 else if (strcmp (language_string, "GNU Ada") == 0) | |
24464 language = DW_LANG_Ada83; | |
23561 | 24465 |
23562 add_AT_unsigned (die, DW_AT_language, language); | 24466 add_AT_unsigned (die, DW_AT_language, language); |
23563 | 24467 |
23564 switch (language) | 24468 switch (language) |
23565 { | 24469 { |
24232 /* If the first reference to this type was as the return type of an | 25136 /* If the first reference to this type was as the return type of an |
24233 inline function, then it may not have a parent. Fix this now. */ | 25137 inline function, then it may not have a parent. Fix this now. */ |
24234 if (type_die->die_parent == NULL) | 25138 if (type_die->die_parent == NULL) |
24235 add_child_die (scope_die, type_die); | 25139 add_child_die (scope_die, type_die); |
24236 | 25140 |
24237 push_decl_scope (type); | |
24238 gen_member_die (type, type_die); | 25141 gen_member_die (type, type_die); |
24239 pop_decl_scope (); | |
24240 | 25142 |
24241 add_gnat_descriptive_type_attribute (type_die, type, context_die); | 25143 add_gnat_descriptive_type_attribute (type_die, type, context_die); |
24242 if (TYPE_ARTIFICIAL (type)) | 25144 if (TYPE_ARTIFICIAL (type)) |
24243 add_AT_flag (type_die, DW_AT_artificial, 1); | 25145 add_AT_flag (type_die, DW_AT_artificial, 1); |
24244 | 25146 |
24388 static void | 25290 static void |
24389 gen_tagged_type_die (tree type, | 25291 gen_tagged_type_die (tree type, |
24390 dw_die_ref context_die, | 25292 dw_die_ref context_die, |
24391 enum debug_info_usage usage) | 25293 enum debug_info_usage usage) |
24392 { | 25294 { |
24393 int need_pop; | |
24394 | |
24395 if (type == NULL_TREE | 25295 if (type == NULL_TREE |
24396 || !is_tagged_type (type)) | 25296 || !is_tagged_type (type)) |
24397 return; | 25297 return; |
24398 | 25298 |
24399 if (TREE_ASM_WRITTEN (type)) | 25299 if (TREE_ASM_WRITTEN (type)) |
24400 need_pop = 0; | 25300 ; |
24401 /* If this is a nested type whose containing class hasn't been written | 25301 /* If this is a nested type whose containing class hasn't been written |
24402 out yet, writing it out will cover this one, too. This does not apply | 25302 out yet, writing it out will cover this one, too. This does not apply |
24403 to instantiations of member class templates; they need to be added to | 25303 to instantiations of member class templates; they need to be added to |
24404 the containing class as they are generated. FIXME: This hurts the | 25304 the containing class as they are generated. FIXME: This hurts the |
24405 idea of combining type decls from multiple TUs, since we can't predict | 25305 idea of combining type decls from multiple TUs, since we can't predict |
24412 | 25312 |
24413 if (TREE_ASM_WRITTEN (type)) | 25313 if (TREE_ASM_WRITTEN (type)) |
24414 return; | 25314 return; |
24415 | 25315 |
24416 /* If that failed, attach ourselves to the stub. */ | 25316 /* If that failed, attach ourselves to the stub. */ |
24417 push_decl_scope (TYPE_CONTEXT (type)); | |
24418 context_die = lookup_type_die (TYPE_CONTEXT (type)); | 25317 context_die = lookup_type_die (TYPE_CONTEXT (type)); |
24419 need_pop = 1; | |
24420 } | 25318 } |
24421 else if (TYPE_CONTEXT (type) != NULL_TREE | 25319 else if (TYPE_CONTEXT (type) != NULL_TREE |
24422 && (TREE_CODE (TYPE_CONTEXT (type)) == FUNCTION_DECL)) | 25320 && (TREE_CODE (TYPE_CONTEXT (type)) == FUNCTION_DECL)) |
24423 { | 25321 { |
24424 /* If this type is local to a function that hasn't been written | 25322 /* If this type is local to a function that hasn't been written |
24427 context_die = lookup_decl_die (TYPE_CONTEXT (type)); | 25325 context_die = lookup_decl_die (TYPE_CONTEXT (type)); |
24428 /* A declaration DIE doesn't count; nested types need to go in the | 25326 /* A declaration DIE doesn't count; nested types need to go in the |
24429 specification. */ | 25327 specification. */ |
24430 if (context_die && is_declaration_die (context_die)) | 25328 if (context_die && is_declaration_die (context_die)) |
24431 context_die = NULL; | 25329 context_die = NULL; |
24432 need_pop = 0; | |
24433 } | 25330 } |
24434 else | 25331 else |
24435 { | 25332 context_die = declare_in_namespace (type, context_die); |
24436 context_die = declare_in_namespace (type, context_die); | |
24437 need_pop = 0; | |
24438 } | |
24439 | 25333 |
24440 if (TREE_CODE (type) == ENUMERAL_TYPE) | 25334 if (TREE_CODE (type) == ENUMERAL_TYPE) |
24441 { | 25335 { |
24442 /* This might have been written out by the call to | 25336 /* This might have been written out by the call to |
24443 declare_in_namespace. */ | 25337 declare_in_namespace. */ |
24444 if (!TREE_ASM_WRITTEN (type)) | 25338 if (!TREE_ASM_WRITTEN (type)) |
24445 gen_enumeration_type_die (type, context_die); | 25339 gen_enumeration_type_die (type, context_die); |
24446 } | 25340 } |
24447 else | 25341 else |
24448 gen_struct_or_union_type_die (type, context_die, usage); | 25342 gen_struct_or_union_type_die (type, context_die, usage); |
24449 | |
24450 if (need_pop) | |
24451 pop_decl_scope (); | |
24452 | 25343 |
24453 /* Don't set TREE_ASM_WRITTEN on an incomplete struct; we want to fix | 25344 /* Don't set TREE_ASM_WRITTEN on an incomplete struct; we want to fix |
24454 it up if it is ever completed. gen_*_type_die will set it for us | 25345 it up if it is ever completed. gen_*_type_die will set it for us |
24455 when appropriate. */ | 25346 when appropriate. */ |
24456 } | 25347 } |
24508 | 25399 |
24509 /* If type is an anonymous tagged type named by a typedef, let's | 25400 /* If type is an anonymous tagged type named by a typedef, let's |
24510 generate debug info for the typedef. */ | 25401 generate debug info for the typedef. */ |
24511 if (is_naming_typedef_decl (TYPE_NAME (type))) | 25402 if (is_naming_typedef_decl (TYPE_NAME (type))) |
24512 { | 25403 { |
24513 /* Use the DIE of the containing namespace as the parent DIE of | 25404 /* Give typedefs the right scope. */ |
24514 the type description DIE we want to generate. */ | 25405 context_die = scope_die_for (type, context_die); |
24515 if (DECL_CONTEXT (TYPE_NAME (type)) | |
24516 && TREE_CODE (DECL_CONTEXT (TYPE_NAME (type))) == NAMESPACE_DECL) | |
24517 context_die = get_context_die (DECL_CONTEXT (TYPE_NAME (type))); | |
24518 | 25406 |
24519 gen_decl_die (TYPE_NAME (type), NULL, NULL, context_die); | 25407 gen_decl_die (TYPE_NAME (type), NULL, NULL, context_die); |
24520 return; | 25408 return; |
24521 } | 25409 } |
24522 | 25410 |
24653 case INTEGER_TYPE: | 25541 case INTEGER_TYPE: |
24654 case REAL_TYPE: | 25542 case REAL_TYPE: |
24655 case FIXED_POINT_TYPE: | 25543 case FIXED_POINT_TYPE: |
24656 case COMPLEX_TYPE: | 25544 case COMPLEX_TYPE: |
24657 case BOOLEAN_TYPE: | 25545 case BOOLEAN_TYPE: |
24658 case POINTER_BOUNDS_TYPE: | |
24659 /* No DIEs needed for fundamental types. */ | 25546 /* No DIEs needed for fundamental types. */ |
24660 break; | 25547 break; |
24661 | 25548 |
24662 case NULLPTR_TYPE: | 25549 case NULLPTR_TYPE: |
24663 case LANG_TYPE: | 25550 case LANG_TYPE: |
24743 block. */ | 25630 block. */ |
24744 if (inlined_func) | 25631 if (inlined_func) |
24745 /* The outer scopes for inlinings *must* always be represented. We | 25632 /* The outer scopes for inlinings *must* always be represented. We |
24746 generate DW_TAG_inlined_subroutine DIEs for them. (See below.) */ | 25633 generate DW_TAG_inlined_subroutine DIEs for them. (See below.) */ |
24747 must_output_die = 1; | 25634 must_output_die = 1; |
24748 else | 25635 else if (lookup_block_die (stmt)) |
25636 /* If we already have a DIE then it was filled early. Meanwhile | |
25637 we might have pruned all BLOCK_VARS as optimized out but we | |
25638 still want to generate high/low PC attributes so output it. */ | |
25639 must_output_die = 1; | |
25640 else if (TREE_USED (stmt) | |
25641 || TREE_ASM_WRITTEN (stmt)) | |
24749 { | 25642 { |
24750 /* Determine if this block directly contains any "significant" | 25643 /* Determine if this block directly contains any "significant" |
24751 local declarations which we will need to output DIEs for. */ | 25644 local declarations which we will need to output DIEs for. */ |
24752 if (debug_info_level > DINFO_LEVEL_TERSE) | 25645 if (debug_info_level > DINFO_LEVEL_TERSE) |
24753 /* We are not in terse mode so *any* local declaration counts | 25646 { |
24754 as being a "significant" one. */ | 25647 /* We are not in terse mode so any local declaration that |
24755 must_output_die = ((BLOCK_VARS (stmt) != NULL | 25648 is not ignored for debug purposes counts as being a |
24756 || BLOCK_NUM_NONLOCALIZED_VARS (stmt)) | 25649 "significant" one. */ |
24757 && (TREE_USED (stmt) | 25650 if (BLOCK_NUM_NONLOCALIZED_VARS (stmt)) |
24758 || TREE_ASM_WRITTEN (stmt) | 25651 must_output_die = 1; |
24759 || BLOCK_ABSTRACT (stmt))); | 25652 else |
24760 else if ((TREE_USED (stmt) | 25653 for (tree var = BLOCK_VARS (stmt); var; var = DECL_CHAIN (var)) |
24761 || TREE_ASM_WRITTEN (stmt) | 25654 if (!DECL_IGNORED_P (var)) |
24762 || BLOCK_ABSTRACT (stmt)) | 25655 { |
24763 && !dwarf2out_ignore_block (stmt)) | 25656 must_output_die = 1; |
25657 break; | |
25658 } | |
25659 } | |
25660 else if (!dwarf2out_ignore_block (stmt)) | |
24764 must_output_die = 1; | 25661 must_output_die = 1; |
24765 } | 25662 } |
24766 | 25663 |
24767 /* It would be a waste of space to generate a Dwarf DW_TAG_lexical_block | 25664 /* It would be a waste of space to generate a Dwarf DW_TAG_lexical_block |
24768 DIE for any block which contains no significant local declarations at | 25665 DIE for any block which contains no significant local declarations at |
24772 local declaration gets restricted to include only inlined function | 25669 local declaration gets restricted to include only inlined function |
24773 instances and local (nested) function definitions. */ | 25670 instances and local (nested) function definitions. */ |
24774 if (must_output_die) | 25671 if (must_output_die) |
24775 { | 25672 { |
24776 if (inlined_func) | 25673 if (inlined_func) |
24777 { | 25674 gen_inlined_subroutine_die (stmt, context_die); |
24778 /* If STMT block is abstract, that means we have been called | |
24779 indirectly from dwarf2out_abstract_function. | |
24780 That function rightfully marks the descendent blocks (of | |
24781 the abstract function it is dealing with) as being abstract, | |
24782 precisely to prevent us from emitting any | |
24783 DW_TAG_inlined_subroutine DIE as a descendent | |
24784 of an abstract function instance. So in that case, we should | |
24785 not call gen_inlined_subroutine_die. | |
24786 | |
24787 Later though, when cgraph asks dwarf2out to emit info | |
24788 for the concrete instance of the function decl into which | |
24789 the concrete instance of STMT got inlined, the later will lead | |
24790 to the generation of a DW_TAG_inlined_subroutine DIE. */ | |
24791 if (! BLOCK_ABSTRACT (stmt)) | |
24792 gen_inlined_subroutine_die (stmt, context_die); | |
24793 } | |
24794 else | 25675 else |
24795 gen_lexical_block_die (stmt, context_die); | 25676 gen_lexical_block_die (stmt, context_die); |
24796 } | 25677 } |
24797 else | 25678 else |
24798 decls_for_scope (stmt, context_die); | 25679 decls_for_scope (stmt, context_die); |
24866 | 25747 |
24867 /* Generate all of the decls declared within a given scope and (recursively) | 25748 /* Generate all of the decls declared within a given scope and (recursively) |
24868 all of its sub-blocks. */ | 25749 all of its sub-blocks. */ |
24869 | 25750 |
24870 static void | 25751 static void |
24871 decls_for_scope (tree stmt, dw_die_ref context_die) | 25752 decls_for_scope (tree stmt, dw_die_ref context_die, bool recurse) |
24872 { | 25753 { |
24873 tree decl; | 25754 tree decl; |
24874 unsigned int i; | 25755 unsigned int i; |
24875 tree subblocks; | 25756 tree subblocks; |
24876 | 25757 |
24909 /* Even if we're at -g1, we need to process the subblocks in order to get | 25790 /* Even if we're at -g1, we need to process the subblocks in order to get |
24910 inlined call information. */ | 25791 inlined call information. */ |
24911 | 25792 |
24912 /* Output the DIEs to represent all sub-blocks (and the items declared | 25793 /* Output the DIEs to represent all sub-blocks (and the items declared |
24913 therein) of this block. */ | 25794 therein) of this block. */ |
24914 for (subblocks = BLOCK_SUBBLOCKS (stmt); | 25795 if (recurse) |
24915 subblocks != NULL; | 25796 for (subblocks = BLOCK_SUBBLOCKS (stmt); |
24916 subblocks = BLOCK_CHAIN (subblocks)) | 25797 subblocks != NULL; |
24917 gen_block_die (subblocks, context_die); | 25798 subblocks = BLOCK_CHAIN (subblocks)) |
25799 gen_block_die (subblocks, context_die); | |
24918 } | 25800 } |
24919 | 25801 |
24920 /* Is this a typedef we can avoid emitting? */ | 25802 /* Is this a typedef we can avoid emitting? */ |
24921 | 25803 |
24922 bool | 25804 static bool |
24923 is_redundant_typedef (const_tree decl) | 25805 is_redundant_typedef (const_tree decl) |
24924 { | 25806 { |
24925 if (TYPE_DECL_IS_STUB (decl)) | 25807 if (TYPE_DECL_IS_STUB (decl)) |
24926 return true; | 25808 return true; |
24927 | 25809 |
25231 { | 26113 { |
25232 tree decl_or_origin = decl ? decl : origin; | 26114 tree decl_or_origin = decl ? decl : origin; |
25233 tree class_origin = NULL, ultimate_origin; | 26115 tree class_origin = NULL, ultimate_origin; |
25234 | 26116 |
25235 if (DECL_P (decl_or_origin) && DECL_IGNORED_P (decl_or_origin)) | 26117 if (DECL_P (decl_or_origin) && DECL_IGNORED_P (decl_or_origin)) |
25236 return NULL; | |
25237 | |
25238 /* Ignore pointer bounds decls. */ | |
25239 if (DECL_P (decl_or_origin) | |
25240 && TREE_TYPE (decl_or_origin) | |
25241 && POINTER_BOUNDS_P (decl_or_origin)) | |
25242 return NULL; | 26118 return NULL; |
25243 | 26119 |
25244 switch (TREE_CODE (decl_or_origin)) | 26120 switch (TREE_CODE (decl_or_origin)) |
25245 { | 26121 { |
25246 case ERROR_MARK: | 26122 case ERROR_MARK: |
25547 dwarf2out_decl (decl); | 26423 dwarf2out_decl (decl); |
25548 } | 26424 } |
25549 symtab->global_info_ready = save; | 26425 symtab->global_info_ready = save; |
25550 } | 26426 } |
25551 | 26427 |
26428 /* Return whether EXPR is an expression with the following pattern: | |
26429 INDIRECT_REF (NOP_EXPR (INTEGER_CST)). */ | |
26430 | |
26431 static bool | |
26432 is_trivial_indirect_ref (tree expr) | |
26433 { | |
26434 if (expr == NULL_TREE || TREE_CODE (expr) != INDIRECT_REF) | |
26435 return false; | |
26436 | |
26437 tree nop = TREE_OPERAND (expr, 0); | |
26438 if (nop == NULL_TREE || TREE_CODE (nop) != NOP_EXPR) | |
26439 return false; | |
26440 | |
26441 tree int_cst = TREE_OPERAND (nop, 0); | |
26442 return int_cst != NULL_TREE && TREE_CODE (int_cst) == INTEGER_CST; | |
26443 } | |
26444 | |
25552 /* Output debug information for global decl DECL. Called from | 26445 /* Output debug information for global decl DECL. Called from |
25553 toplev.c after compilation proper has finished. */ | 26446 toplev.c after compilation proper has finished. */ |
25554 | 26447 |
25555 static void | 26448 static void |
25556 dwarf2out_late_global_decl (tree decl) | 26449 dwarf2out_late_global_decl (tree decl) |
25557 { | 26450 { |
25558 /* Fill-in any location information we were unable to determine | 26451 /* Fill-in any location information we were unable to determine |
25559 on the first pass. */ | 26452 on the first pass. */ |
25560 if (VAR_P (decl) && !POINTER_BOUNDS_P (decl)) | 26453 if (VAR_P (decl)) |
25561 { | 26454 { |
25562 dw_die_ref die = lookup_decl_die (decl); | 26455 dw_die_ref die = lookup_decl_die (decl); |
25563 | 26456 |
25564 /* We may have to generate early debug late for LTO in case debug | 26457 /* We may have to generate early debug late for LTO in case debug |
25565 was not enabled at compile-time or the target doesn't support | 26458 was not enabled at compile-time or the target doesn't support |
25571 } | 26464 } |
25572 | 26465 |
25573 if (die) | 26466 if (die) |
25574 { | 26467 { |
25575 /* We get called via the symtab code invoking late_global_decl | 26468 /* We get called via the symtab code invoking late_global_decl |
25576 for symbols that are optimized out. Do not add locations | 26469 for symbols that are optimized out. |
25577 for those, except if they have a DECL_VALUE_EXPR, in which case | 26470 |
25578 they are relevant for debuggers. */ | 26471 Do not add locations for those, except if they have a |
26472 DECL_VALUE_EXPR, in which case they are relevant for debuggers. | |
26473 Still don't add a location if the DECL_VALUE_EXPR is not a trivial | |
26474 INDIRECT_REF expression, as this could generate relocations to | |
26475 text symbols in LTO object files, which is invalid. */ | |
25579 varpool_node *node = varpool_node::get (decl); | 26476 varpool_node *node = varpool_node::get (decl); |
25580 if ((! node || ! node->definition) && ! DECL_HAS_VALUE_EXPR_P (decl)) | 26477 if ((! node || ! node->definition) |
26478 && ! (DECL_HAS_VALUE_EXPR_P (decl) | |
26479 && is_trivial_indirect_ref (DECL_VALUE_EXPR (decl)))) | |
25581 tree_add_const_value_attribute_for_decl (die, decl); | 26480 tree_add_const_value_attribute_for_decl (die, decl); |
25582 else | 26481 else |
25583 add_location_or_const_value_attribute (die, decl, false); | 26482 add_location_or_const_value_attribute (die, decl, false); |
25584 } | 26483 } |
25585 } | 26484 } |
25798 return; | 26697 return; |
25799 | 26698 |
25800 case FUNCTION_DECL: | 26699 case FUNCTION_DECL: |
25801 /* If we're a nested function, initially use a parent of NULL; if we're | 26700 /* If we're a nested function, initially use a parent of NULL; if we're |
25802 a plain function, this will be fixed up in decls_for_scope. If | 26701 a plain function, this will be fixed up in decls_for_scope. If |
25803 we're a method, it will be ignored, since we already have a DIE. */ | 26702 we're a method, it will be ignored, since we already have a DIE. |
25804 if (decl_function_context (decl) | 26703 Avoid doing this late though since clones of class methods may |
26704 otherwise end up in limbo and create type DIEs late. */ | |
26705 if (early_dwarf | |
26706 && decl_function_context (decl) | |
25805 /* But if we're in terse mode, we don't care about scope. */ | 26707 /* But if we're in terse mode, we don't care about scope. */ |
25806 && debug_info_level > DINFO_LEVEL_TERSE) | 26708 && debug_info_level > DINFO_LEVEL_TERSE) |
25807 context_die = NULL; | 26709 context_die = NULL; |
25808 break; | 26710 break; |
25809 | 26711 |
25995 fd->emitted_number = last_emitted_file->emitted_number + 1; | 26897 fd->emitted_number = last_emitted_file->emitted_number + 1; |
25996 else | 26898 else |
25997 fd->emitted_number = 1; | 26899 fd->emitted_number = 1; |
25998 last_emitted_file = fd; | 26900 last_emitted_file = fd; |
25999 | 26901 |
26000 if (DWARF2_ASM_LINE_DEBUG_INFO) | 26902 if (output_asm_line_debug_info ()) |
26001 { | 26903 { |
26002 fprintf (asm_out_file, "\t.file %u ", fd->emitted_number); | 26904 fprintf (asm_out_file, "\t.file %u ", fd->emitted_number); |
26003 output_quoted_string (asm_out_file, | 26905 output_quoted_string (asm_out_file, |
26004 remap_debug_filename (fd->filename)); | 26906 remap_debug_filename (fd->filename)); |
26005 fputc ('\n', asm_out_file); | 26907 fputc ('\n', asm_out_file); |
26156 before first real instruction at address equal to .Ltext0. */ | 27058 before first real instruction at address equal to .Ltext0. */ |
26157 static bool maybe_at_text_label_p = true; | 27059 static bool maybe_at_text_label_p = true; |
26158 /* One above highest N where .LVLN label might be equal to .Ltext0 label. */ | 27060 /* One above highest N where .LVLN label might be equal to .Ltext0 label. */ |
26159 static unsigned int first_loclabel_num_not_at_text_label; | 27061 static unsigned int first_loclabel_num_not_at_text_label; |
26160 | 27062 |
27063 /* Look ahead for a real insn, or for a begin stmt marker. */ | |
27064 | |
27065 static rtx_insn * | |
27066 dwarf2out_next_real_insn (rtx_insn *loc_note) | |
27067 { | |
27068 rtx_insn *next_real = NEXT_INSN (loc_note); | |
27069 | |
27070 while (next_real) | |
27071 if (INSN_P (next_real)) | |
27072 break; | |
27073 else | |
27074 next_real = NEXT_INSN (next_real); | |
27075 | |
27076 return next_real; | |
27077 } | |
27078 | |
26161 /* Called by the final INSN scan whenever we see a var location. We | 27079 /* Called by the final INSN scan whenever we see a var location. We |
26162 use it to drop labels in the right places, and throw the location in | 27080 use it to drop labels in the right places, and throw the location in |
26163 our lookup table. */ | 27081 our lookup table. */ |
26164 | 27082 |
26165 static void | 27083 static void |
26173 static const char *last_postcall_label; | 27091 static const char *last_postcall_label; |
26174 static bool last_in_cold_section_p; | 27092 static bool last_in_cold_section_p; |
26175 static rtx_insn *expected_next_loc_note; | 27093 static rtx_insn *expected_next_loc_note; |
26176 tree decl; | 27094 tree decl; |
26177 bool var_loc_p; | 27095 bool var_loc_p; |
27096 var_loc_view view = 0; | |
26178 | 27097 |
26179 if (!NOTE_P (loc_note)) | 27098 if (!NOTE_P (loc_note)) |
26180 { | 27099 { |
26181 if (CALL_P (loc_note)) | 27100 if (CALL_P (loc_note)) |
26182 { | 27101 { |
27102 maybe_reset_location_view (loc_note, cur_line_info_table); | |
26183 call_site_count++; | 27103 call_site_count++; |
26184 if (SIBLING_CALL_P (loc_note)) | 27104 if (SIBLING_CALL_P (loc_note)) |
26185 tail_call_site_count++; | 27105 tail_call_site_count++; |
27106 if (find_reg_note (loc_note, REG_CALL_ARG_LOCATION, NULL_RTX)) | |
27107 { | |
27108 call_insn = loc_note; | |
27109 loc_note = NULL; | |
27110 var_loc_p = false; | |
27111 | |
27112 next_real = dwarf2out_next_real_insn (call_insn); | |
27113 next_note = NULL; | |
27114 cached_next_real_insn = NULL; | |
27115 goto create_label; | |
27116 } | |
26186 if (optimize == 0 && !flag_var_tracking) | 27117 if (optimize == 0 && !flag_var_tracking) |
26187 { | 27118 { |
26188 /* When the var-tracking pass is not running, there is no note | 27119 /* When the var-tracking pass is not running, there is no note |
26189 for indirect calls whose target is compile-time known. In this | 27120 for indirect calls whose target is compile-time known. In this |
26190 case, process such calls specifically so that we generate call | 27121 case, process such calls specifically so that we generate call |
26204 { | 27135 { |
26205 call_insn = loc_note; | 27136 call_insn = loc_note; |
26206 loc_note = NULL; | 27137 loc_note = NULL; |
26207 var_loc_p = false; | 27138 var_loc_p = false; |
26208 | 27139 |
26209 next_real = next_real_insn (call_insn); | 27140 next_real = dwarf2out_next_real_insn (call_insn); |
26210 next_note = NULL; | 27141 next_note = NULL; |
26211 cached_next_real_insn = NULL; | 27142 cached_next_real_insn = NULL; |
26212 goto create_label; | 27143 goto create_label; |
26213 } | 27144 } |
26214 } | 27145 } |
26215 } | 27146 } |
27147 else if (!debug_variable_location_views) | |
27148 gcc_unreachable (); | |
27149 else | |
27150 maybe_reset_location_view (loc_note, cur_line_info_table); | |
27151 | |
26216 return; | 27152 return; |
26217 } | 27153 } |
26218 | 27154 |
26219 var_loc_p = NOTE_KIND (loc_note) == NOTE_INSN_VAR_LOCATION; | 27155 var_loc_p = NOTE_KIND (loc_note) == NOTE_INSN_VAR_LOCATION; |
26220 if (var_loc_p && !DECL_P (NOTE_VAR_LOCATION_DECL (loc_note))) | 27156 if (var_loc_p && !DECL_P (NOTE_VAR_LOCATION_DECL (loc_note))) |
26234 next_note = NEXT_INSN (loc_note); | 27170 next_note = NEXT_INSN (loc_note); |
26235 if (! next_note | 27171 if (! next_note |
26236 || next_note->deleted () | 27172 || next_note->deleted () |
26237 || ! NOTE_P (next_note) | 27173 || ! NOTE_P (next_note) |
26238 || (NOTE_KIND (next_note) != NOTE_INSN_VAR_LOCATION | 27174 || (NOTE_KIND (next_note) != NOTE_INSN_VAR_LOCATION |
26239 && NOTE_KIND (next_note) != NOTE_INSN_CALL_ARG_LOCATION)) | 27175 && NOTE_KIND (next_note) != NOTE_INSN_BEGIN_STMT |
27176 && NOTE_KIND (next_note) != NOTE_INSN_INLINE_ENTRY)) | |
26240 next_note = NULL; | 27177 next_note = NULL; |
26241 | 27178 |
26242 if (! next_real) | 27179 if (! next_real) |
26243 next_real = next_real_insn (loc_note); | 27180 next_real = dwarf2out_next_real_insn (loc_note); |
26244 | 27181 |
26245 if (next_note) | 27182 if (next_note) |
26246 { | 27183 { |
26247 expected_next_loc_note = next_note; | 27184 expected_next_loc_note = next_note; |
26248 cached_next_real_insn = next_real; | 27185 cached_next_real_insn = next_real; |
26273 last_postcall_label = NULL; | 27210 last_postcall_label = NULL; |
26274 } | 27211 } |
26275 | 27212 |
26276 if (var_loc_p) | 27213 if (var_loc_p) |
26277 { | 27214 { |
27215 const char *label | |
27216 = NOTE_DURING_CALL_P (loc_note) ? last_postcall_label : last_label; | |
27217 view = cur_line_info_table->view; | |
26278 decl = NOTE_VAR_LOCATION_DECL (loc_note); | 27218 decl = NOTE_VAR_LOCATION_DECL (loc_note); |
26279 newloc = add_var_loc_to_decl (decl, loc_note, | 27219 newloc = add_var_loc_to_decl (decl, loc_note, label, view); |
26280 NOTE_DURING_CALL_P (loc_note) | |
26281 ? last_postcall_label : last_label); | |
26282 if (newloc == NULL) | 27220 if (newloc == NULL) |
26283 return; | 27221 return; |
26284 } | 27222 } |
26285 else | 27223 else |
26286 { | 27224 { |
26317 continue; | 27255 continue; |
26318 /* Inline asm could occupy zero bytes. */ | 27256 /* Inline asm could occupy zero bytes. */ |
26319 else if (GET_CODE (body) == ASM_INPUT | 27257 else if (GET_CODE (body) == ASM_INPUT |
26320 || asm_noperands (body) >= 0) | 27258 || asm_noperands (body) >= 0) |
26321 continue; | 27259 continue; |
26322 #ifdef HAVE_attr_length | 27260 #ifdef HAVE_ATTR_length /* ??? We don't include insn-attr.h. */ |
26323 else if (get_attr_min_length (insn) == 0) | 27261 else if (HAVE_ATTR_length && get_attr_min_length (insn) == 0) |
26324 continue; | 27262 continue; |
26325 #endif | 27263 #endif |
26326 else | 27264 else |
26327 { | 27265 { |
26328 /* Assume insn has non-zero length. */ | 27266 /* Assume insn has non-zero length. */ |
26343 | 27281 |
26344 if (!var_loc_p) | 27282 if (!var_loc_p) |
26345 { | 27283 { |
26346 struct call_arg_loc_node *ca_loc | 27284 struct call_arg_loc_node *ca_loc |
26347 = ggc_cleared_alloc<call_arg_loc_node> (); | 27285 = ggc_cleared_alloc<call_arg_loc_node> (); |
26348 rtx_insn *prev | 27286 rtx_insn *prev = call_insn; |
26349 = loc_note != NULL_RTX ? prev_real_insn (loc_note) : call_insn; | 27287 |
26350 | 27288 ca_loc->call_arg_loc_note |
26351 ca_loc->call_arg_loc_note = loc_note; | 27289 = find_reg_note (call_insn, REG_CALL_ARG_LOCATION, NULL_RTX); |
26352 ca_loc->next = NULL; | 27290 ca_loc->next = NULL; |
26353 ca_loc->label = last_label; | 27291 ca_loc->label = last_label; |
26354 gcc_assert (prev | 27292 gcc_assert (prev |
26355 && (CALL_P (prev) | 27293 && (CALL_P (prev) |
26356 || (NONJUMP_INSN_P (prev) | 27294 || (NONJUMP_INSN_P (prev) |
26386 else | 27324 else |
26387 call_arg_locations = ca_loc; | 27325 call_arg_locations = ca_loc; |
26388 call_arg_loc_last = ca_loc; | 27326 call_arg_loc_last = ca_loc; |
26389 } | 27327 } |
26390 else if (loc_note != NULL_RTX && !NOTE_DURING_CALL_P (loc_note)) | 27328 else if (loc_note != NULL_RTX && !NOTE_DURING_CALL_P (loc_note)) |
26391 newloc->label = last_label; | 27329 { |
27330 newloc->label = last_label; | |
27331 newloc->view = view; | |
27332 } | |
26392 else | 27333 else |
26393 { | 27334 { |
26394 if (!last_postcall_label) | 27335 if (!last_postcall_label) |
26395 { | 27336 { |
26396 sprintf (loclabel, "%s-1", last_label); | 27337 sprintf (loclabel, "%s-1", last_label); |
26397 last_postcall_label = ggc_strdup (loclabel); | 27338 last_postcall_label = ggc_strdup (loclabel); |
26398 } | 27339 } |
26399 newloc->label = last_postcall_label; | 27340 newloc->label = last_postcall_label; |
27341 /* ??? This view is at last_label, not last_label-1, but we | |
27342 could only assume view at last_label-1 is zero if we could | |
27343 assume calls always have length greater than one. This is | |
27344 probably true in general, though there might be a rare | |
27345 exception to this rule, e.g. if a call insn is optimized out | |
27346 by target magic. Then, even the -1 in the label will be | |
27347 wrong, which might invalidate the range. Anyway, using view, | |
27348 though technically possibly incorrect, will work as far as | |
27349 ranges go: since L-1 is in the middle of the call insn, | |
27350 (L-1).0 and (L-1).V shouldn't make any difference, and having | |
27351 the loclist entry refer to the .loc entry might be useful, so | |
27352 leave it like this. */ | |
27353 newloc->view = view; | |
27354 } | |
27355 | |
27356 if (var_loc_p && flag_debug_asm) | |
27357 { | |
27358 const char *name, *sep, *patstr; | |
27359 if (decl && DECL_NAME (decl)) | |
27360 name = IDENTIFIER_POINTER (DECL_NAME (decl)); | |
27361 else | |
27362 name = ""; | |
27363 if (NOTE_VAR_LOCATION_LOC (loc_note)) | |
27364 { | |
27365 sep = " => "; | |
27366 patstr = str_pattern_slim (NOTE_VAR_LOCATION_LOC (loc_note)); | |
27367 } | |
27368 else | |
27369 { | |
27370 sep = " "; | |
27371 patstr = "RESET"; | |
27372 } | |
27373 fprintf (asm_out_file, "\t%s DEBUG %s%s%s\n", ASM_COMMENT_START, | |
27374 name, sep, patstr); | |
26400 } | 27375 } |
26401 | 27376 |
26402 last_var_location_insn = next_real; | 27377 last_var_location_insn = next_real; |
26403 last_in_cold_section_p = in_cold_section_p; | 27378 last_in_cold_section_p = in_cold_section_p; |
27379 } | |
27380 | |
27381 /* Check whether BLOCK, a lexical block, is nested within OUTER, or is | |
27382 OUTER itself. If BOTHWAYS, check not only that BLOCK can reach | |
27383 OUTER through BLOCK_SUPERCONTEXT links, but also that there is a | |
27384 path from OUTER to BLOCK through BLOCK_SUBBLOCKs and | |
27385 BLOCK_FRAGMENT_ORIGIN links. */ | |
27386 static bool | |
27387 block_within_block_p (tree block, tree outer, bool bothways) | |
27388 { | |
27389 if (block == outer) | |
27390 return true; | |
27391 | |
27392 /* Quickly check that OUTER is up BLOCK's supercontext chain. */ | |
27393 for (tree context = BLOCK_SUPERCONTEXT (block); | |
27394 context != outer; | |
27395 context = BLOCK_SUPERCONTEXT (context)) | |
27396 if (!context || TREE_CODE (context) != BLOCK) | |
27397 return false; | |
27398 | |
27399 if (!bothways) | |
27400 return true; | |
27401 | |
27402 /* Now check that each block is actually referenced by its | |
27403 parent. */ | |
27404 for (tree context = BLOCK_SUPERCONTEXT (block); ; | |
27405 context = BLOCK_SUPERCONTEXT (context)) | |
27406 { | |
27407 if (BLOCK_FRAGMENT_ORIGIN (context)) | |
27408 { | |
27409 gcc_assert (!BLOCK_SUBBLOCKS (context)); | |
27410 context = BLOCK_FRAGMENT_ORIGIN (context); | |
27411 } | |
27412 for (tree sub = BLOCK_SUBBLOCKS (context); | |
27413 sub != block; | |
27414 sub = BLOCK_CHAIN (sub)) | |
27415 if (!sub) | |
27416 return false; | |
27417 if (context == outer) | |
27418 return true; | |
27419 else | |
27420 block = context; | |
27421 } | |
27422 } | |
27423 | |
27424 /* Called during final while assembling the marker of the entry point | |
27425 for an inlined function. */ | |
27426 | |
27427 static void | |
27428 dwarf2out_inline_entry (tree block) | |
27429 { | |
27430 gcc_assert (debug_inline_points); | |
27431 | |
27432 /* If we can't represent it, don't bother. */ | |
27433 if (!(dwarf_version >= 3 || !dwarf_strict)) | |
27434 return; | |
27435 | |
27436 gcc_assert (DECL_P (block_ultimate_origin (block))); | |
27437 | |
27438 /* Sanity check the block tree. This would catch a case in which | |
27439 BLOCK got removed from the tree reachable from the outermost | |
27440 lexical block, but got retained in markers. It would still link | |
27441 back to its parents, but some ancestor would be missing a link | |
27442 down the path to the sub BLOCK. If the block got removed, its | |
27443 BLOCK_NUMBER will not be a usable value. */ | |
27444 if (flag_checking) | |
27445 gcc_assert (block_within_block_p (block, | |
27446 DECL_INITIAL (current_function_decl), | |
27447 true)); | |
27448 | |
27449 gcc_assert (inlined_function_outer_scope_p (block)); | |
27450 gcc_assert (!lookup_block_die (block)); | |
27451 | |
27452 if (BLOCK_FRAGMENT_ORIGIN (block)) | |
27453 block = BLOCK_FRAGMENT_ORIGIN (block); | |
27454 /* Can the entry point ever not be at the beginning of an | |
27455 unfragmented lexical block? */ | |
27456 else if (!(BLOCK_FRAGMENT_CHAIN (block) | |
27457 || (cur_line_info_table | |
27458 && !ZERO_VIEW_P (cur_line_info_table->view)))) | |
27459 return; | |
27460 | |
27461 if (!inline_entry_data_table) | |
27462 inline_entry_data_table | |
27463 = hash_table<inline_entry_data_hasher>::create_ggc (10); | |
27464 | |
27465 | |
27466 inline_entry_data **iedp | |
27467 = inline_entry_data_table->find_slot_with_hash (block, | |
27468 htab_hash_pointer (block), | |
27469 INSERT); | |
27470 if (*iedp) | |
27471 /* ??? Ideally, we'd record all entry points for the same inlined | |
27472 function (some may have been duplicated by e.g. unrolling), but | |
27473 we have no way to represent that ATM. */ | |
27474 return; | |
27475 | |
27476 inline_entry_data *ied = *iedp = ggc_cleared_alloc<inline_entry_data> (); | |
27477 ied->block = block; | |
27478 ied->label_pfx = BLOCK_INLINE_ENTRY_LABEL; | |
27479 ied->label_num = BLOCK_NUMBER (block); | |
27480 if (cur_line_info_table) | |
27481 ied->view = cur_line_info_table->view; | |
27482 | |
27483 char label[MAX_ARTIFICIAL_LABEL_BYTES]; | |
27484 | |
27485 ASM_GENERATE_INTERNAL_LABEL (label, BLOCK_INLINE_ENTRY_LABEL, | |
27486 BLOCK_NUMBER (block)); | |
27487 ASM_OUTPUT_LABEL (asm_out_file, label); | |
26404 } | 27488 } |
26405 | 27489 |
26406 /* Called from finalize_size_functions for size functions so that their body | 27490 /* Called from finalize_size_functions for size functions so that their body |
26407 can be encoded in the debug info to describe the layout of variable-length | 27491 can be encoded in the debug info to describe the layout of variable-length |
26408 structures. */ | 27492 structures. */ |
26445 | 27529 |
26446 table = ggc_cleared_alloc<dw_line_info_table> (); | 27530 table = ggc_cleared_alloc<dw_line_info_table> (); |
26447 table->file_num = 1; | 27531 table->file_num = 1; |
26448 table->line_num = 1; | 27532 table->line_num = 1; |
26449 table->is_stmt = DWARF_LINE_DEFAULT_IS_STMT_START; | 27533 table->is_stmt = DWARF_LINE_DEFAULT_IS_STMT_START; |
27534 FORCE_RESET_NEXT_VIEW (table->view); | |
27535 table->symviews_since_reset = 0; | |
26450 | 27536 |
26451 return table; | 27537 return table; |
26452 } | 27538 } |
26453 | 27539 |
26454 /* Lookup the "current" table into which we emit line info, so | 27540 /* Lookup the "current" table into which we emit line info, so |
26493 table->end_label = end_label; | 27579 table->end_label = end_label; |
26494 | 27580 |
26495 vec_safe_push (separate_line_info, table); | 27581 vec_safe_push (separate_line_info, table); |
26496 } | 27582 } |
26497 | 27583 |
26498 if (DWARF2_ASM_LINE_DEBUG_INFO) | 27584 if (output_asm_line_debug_info ()) |
26499 table->is_stmt = (cur_line_info_table | 27585 table->is_stmt = (cur_line_info_table |
26500 ? cur_line_info_table->is_stmt | 27586 ? cur_line_info_table->is_stmt |
26501 : DWARF_LINE_DEFAULT_IS_STMT_START); | 27587 : DWARF_LINE_DEFAULT_IS_STMT_START); |
26502 cur_line_info_table = table; | 27588 cur_line_info_table = table; |
26503 } | 27589 } |
26528 dwarf2out_note_section_used (); | 27614 dwarf2out_note_section_used (); |
26529 call_site_count = 0; | 27615 call_site_count = 0; |
26530 tail_call_site_count = 0; | 27616 tail_call_site_count = 0; |
26531 | 27617 |
26532 set_cur_line_info_table (sec); | 27618 set_cur_line_info_table (sec); |
27619 FORCE_RESET_NEXT_VIEW (cur_line_info_table->view); | |
26533 } | 27620 } |
26534 | 27621 |
26535 /* Helper function of dwarf2out_end_function, called only after emitting | 27622 /* Helper function of dwarf2out_end_function, called only after emitting |
26536 the very first function into assembly. Check if some .debug_loc range | 27623 the very first function into assembly. Check if some .debug_loc range |
26537 might end with a .LVL* label that could be equal to .Ltext0. | 27624 might end with a .LVL* label that could be equal to .Ltext0. |
26625 const char *filename, | 27712 const char *filename, |
26626 int discriminator, bool is_stmt) | 27713 int discriminator, bool is_stmt) |
26627 { | 27714 { |
26628 unsigned int file_num; | 27715 unsigned int file_num; |
26629 dw_line_info_table *table; | 27716 dw_line_info_table *table; |
26630 | 27717 static var_loc_view lvugid; |
26631 if (debug_info_level < DINFO_LEVEL_TERSE || line == 0) | 27718 |
27719 if (debug_info_level < DINFO_LEVEL_TERSE) | |
26632 return; | 27720 return; |
27721 | |
27722 table = cur_line_info_table; | |
27723 | |
27724 if (line == 0) | |
27725 { | |
27726 if (debug_variable_location_views | |
27727 && output_asm_line_debug_info () | |
27728 && table && !RESETTING_VIEW_P (table->view)) | |
27729 { | |
27730 /* If we're using the assembler to compute view numbers, we | |
27731 can't issue a .loc directive for line zero, so we can't | |
27732 get a view number at this point. We might attempt to | |
27733 compute it from the previous view, or equate it to a | |
27734 subsequent view (though it might not be there!), but | |
27735 since we're omitting the line number entry, we might as | |
27736 well omit the view number as well. That means pretending | |
27737 it's a view number zero, which might very well turn out | |
27738 to be correct. ??? Extend the assembler so that the | |
27739 compiler could emit e.g. ".locview .LVU#", to output a | |
27740 view without changing line number information. We'd then | |
27741 have to count it in symviews_since_reset; when it's omitted, | |
27742 it doesn't count. */ | |
27743 if (!zero_view_p) | |
27744 zero_view_p = BITMAP_GGC_ALLOC (); | |
27745 bitmap_set_bit (zero_view_p, table->view); | |
27746 if (flag_debug_asm) | |
27747 { | |
27748 char label[MAX_ARTIFICIAL_LABEL_BYTES]; | |
27749 ASM_GENERATE_INTERNAL_LABEL (label, "LVU", table->view); | |
27750 fprintf (asm_out_file, "\t%s line 0, omitted view ", | |
27751 ASM_COMMENT_START); | |
27752 assemble_name (asm_out_file, label); | |
27753 putc ('\n', asm_out_file); | |
27754 } | |
27755 table->view = ++lvugid; | |
27756 } | |
27757 return; | |
27758 } | |
26633 | 27759 |
26634 /* The discriminator column was added in dwarf4. Simplify the below | 27760 /* The discriminator column was added in dwarf4. Simplify the below |
26635 by simply removing it if we're not supposed to output it. */ | 27761 by simply removing it if we're not supposed to output it. */ |
26636 if (dwarf_version < 4 && dwarf_strict) | 27762 if (dwarf_version < 4 && dwarf_strict) |
26637 discriminator = 0; | 27763 discriminator = 0; |
26638 | 27764 |
26639 if (!debug_column_info) | 27765 if (!debug_column_info) |
26640 column = 0; | 27766 column = 0; |
26641 | 27767 |
26642 table = cur_line_info_table; | |
26643 file_num = maybe_emit_file (lookup_filename (filename)); | 27768 file_num = maybe_emit_file (lookup_filename (filename)); |
26644 | 27769 |
26645 /* ??? TODO: Elide duplicate line number entries. Traditionally, | 27770 /* ??? TODO: Elide duplicate line number entries. Traditionally, |
26646 the debugger has used the second (possibly duplicate) line number | 27771 the debugger has used the second (possibly duplicate) line number |
26647 at the beginning of the function to mark the end of the prologue. | 27772 at the beginning of the function to mark the end of the prologue. |
26674 else | 27799 else |
26675 fprintf (asm_out_file, "\t%s %s:%d\n", ASM_COMMENT_START, | 27800 fprintf (asm_out_file, "\t%s %s:%d\n", ASM_COMMENT_START, |
26676 filename, line); | 27801 filename, line); |
26677 } | 27802 } |
26678 | 27803 |
26679 if (DWARF2_ASM_LINE_DEBUG_INFO) | 27804 if (output_asm_line_debug_info ()) |
26680 { | 27805 { |
26681 /* Emit the .loc directive understood by GNU as. */ | 27806 /* Emit the .loc directive understood by GNU as. */ |
26682 /* "\t.loc %u %u 0 is_stmt %u discriminator %u", | 27807 /* "\t.loc %u %u 0 is_stmt %u discriminator %u", |
26683 file_num, line, is_stmt, discriminator */ | 27808 file_num, line, is_stmt, discriminator */ |
26684 fputs ("\t.loc ", asm_out_file); | 27809 fputs ("\t.loc ", asm_out_file); |
26688 putc (' ', asm_out_file); | 27813 putc (' ', asm_out_file); |
26689 fprint_ul (asm_out_file, column); | 27814 fprint_ul (asm_out_file, column); |
26690 | 27815 |
26691 if (is_stmt != table->is_stmt) | 27816 if (is_stmt != table->is_stmt) |
26692 { | 27817 { |
27818 #if HAVE_GAS_LOC_STMT | |
26693 fputs (" is_stmt ", asm_out_file); | 27819 fputs (" is_stmt ", asm_out_file); |
26694 putc (is_stmt ? '1' : '0', asm_out_file); | 27820 putc (is_stmt ? '1' : '0', asm_out_file); |
27821 #endif | |
26695 } | 27822 } |
26696 if (SUPPORTS_DISCRIMINATOR && discriminator != 0) | 27823 if (SUPPORTS_DISCRIMINATOR && discriminator != 0) |
26697 { | 27824 { |
26698 gcc_assert (discriminator > 0); | 27825 gcc_assert (discriminator > 0); |
26699 fputs (" discriminator ", asm_out_file); | 27826 fputs (" discriminator ", asm_out_file); |
26700 fprint_ul (asm_out_file, (unsigned long) discriminator); | 27827 fprint_ul (asm_out_file, (unsigned long) discriminator); |
26701 } | 27828 } |
27829 if (debug_variable_location_views) | |
27830 { | |
27831 if (!RESETTING_VIEW_P (table->view)) | |
27832 { | |
27833 table->symviews_since_reset++; | |
27834 if (table->symviews_since_reset > symview_upper_bound) | |
27835 symview_upper_bound = table->symviews_since_reset; | |
27836 /* When we're using the assembler to compute view | |
27837 numbers, we output symbolic labels after "view" in | |
27838 .loc directives, and the assembler will set them for | |
27839 us, so that we can refer to the view numbers in | |
27840 location lists. The only exceptions are when we know | |
27841 a view will be zero: "-0" is a forced reset, used | |
27842 e.g. in the beginning of functions, whereas "0" tells | |
27843 the assembler to check that there was a PC change | |
27844 since the previous view, in a way that implicitly | |
27845 resets the next view. */ | |
27846 fputs (" view ", asm_out_file); | |
27847 char label[MAX_ARTIFICIAL_LABEL_BYTES]; | |
27848 ASM_GENERATE_INTERNAL_LABEL (label, "LVU", table->view); | |
27849 assemble_name (asm_out_file, label); | |
27850 table->view = ++lvugid; | |
27851 } | |
27852 else | |
27853 { | |
27854 table->symviews_since_reset = 0; | |
27855 if (FORCE_RESETTING_VIEW_P (table->view)) | |
27856 fputs (" view -0", asm_out_file); | |
27857 else | |
27858 fputs (" view 0", asm_out_file); | |
27859 /* Mark the present view as a zero view. Earlier debug | |
27860 binds may have already added its id to loclists to be | |
27861 emitted later, so we can't reuse the id for something | |
27862 else. However, it's good to know whether a view is | |
27863 known to be zero, because then we may be able to | |
27864 optimize out locviews that are all zeros, so take | |
27865 note of it in zero_view_p. */ | |
27866 if (!zero_view_p) | |
27867 zero_view_p = BITMAP_GGC_ALLOC (); | |
27868 bitmap_set_bit (zero_view_p, lvugid); | |
27869 table->view = ++lvugid; | |
27870 } | |
27871 } | |
26702 putc ('\n', asm_out_file); | 27872 putc ('\n', asm_out_file); |
26703 } | 27873 } |
26704 else | 27874 else |
26705 { | 27875 { |
26706 unsigned int label_num = ++line_info_label_num; | 27876 unsigned int label_num = ++line_info_label_num; |
26707 | 27877 |
26708 targetm.asm_out.internal_label (asm_out_file, LINE_CODE_LABEL, label_num); | 27878 targetm.asm_out.internal_label (asm_out_file, LINE_CODE_LABEL, label_num); |
26709 | 27879 |
26710 push_dw_line_info_entry (table, LI_set_address, label_num); | 27880 if (debug_variable_location_views && !RESETTING_VIEW_P (table->view)) |
27881 push_dw_line_info_entry (table, LI_adv_address, label_num); | |
27882 else | |
27883 push_dw_line_info_entry (table, LI_set_address, label_num); | |
27884 if (debug_variable_location_views) | |
27885 { | |
27886 bool resetting = FORCE_RESETTING_VIEW_P (table->view); | |
27887 if (resetting) | |
27888 table->view = 0; | |
27889 | |
27890 if (flag_debug_asm) | |
27891 fprintf (asm_out_file, "\t%s view %s%d\n", | |
27892 ASM_COMMENT_START, | |
27893 resetting ? "-" : "", | |
27894 table->view); | |
27895 | |
27896 table->view++; | |
27897 } | |
26711 if (file_num != table->file_num) | 27898 if (file_num != table->file_num) |
26712 push_dw_line_info_entry (table, LI_set_file, file_num); | 27899 push_dw_line_info_entry (table, LI_set_file, file_num); |
26713 if (discriminator != table->discrim_num) | 27900 if (discriminator != table->discrim_num) |
26714 push_dw_line_info_entry (table, LI_set_discriminator, discriminator); | 27901 push_dw_line_info_entry (table, LI_set_discriminator, discriminator); |
26715 if (is_stmt != table->is_stmt) | 27902 if (is_stmt != table->is_stmt) |
26882 case DW_MACRO_define_strp: | 28069 case DW_MACRO_define_strp: |
26883 case DW_MACRO_undef_strp: | 28070 case DW_MACRO_undef_strp: |
26884 node = find_AT_string (ref->info); | 28071 node = find_AT_string (ref->info); |
26885 gcc_assert (node | 28072 gcc_assert (node |
26886 && (node->form == DW_FORM_strp | 28073 && (node->form == DW_FORM_strp |
26887 || node->form == DW_FORM_GNU_str_index)); | 28074 || node->form == dwarf_FORM (DW_FORM_strx))); |
26888 dw2_asm_output_data (1, ref->code, | 28075 dw2_asm_output_data (1, ref->code, |
26889 ref->code == DW_MACRO_define_strp | 28076 ref->code == DW_MACRO_define_strp |
26890 ? "Define macro strp" | 28077 ? "Define macro strp" |
26891 : "Undefine macro strp"); | 28078 : "Undefine macro strp"); |
26892 dw2_asm_output_data_uleb128 (ref->lineno, "At line number %lu", | 28079 dw2_asm_output_data_uleb128 (ref->lineno, "At line number %lu", |
27062 && len > DWARF_OFFSET_SIZE | 28249 && len > DWARF_OFFSET_SIZE |
27063 && !DWARF2_INDIRECT_STRING_SUPPORT_MISSING_ON_TARGET | 28250 && !DWARF2_INDIRECT_STRING_SUPPORT_MISSING_ON_TARGET |
27064 && (debug_str_section->common.flags & SECTION_MERGE) != 0) | 28251 && (debug_str_section->common.flags & SECTION_MERGE) != 0) |
27065 set_indirect_string (find_AT_string (ref->info)); | 28252 set_indirect_string (find_AT_string (ref->info)); |
27066 break; | 28253 break; |
28254 case DW_MACINFO_start_file: | |
28255 /* -gsplit-dwarf -g3 will also output filename as indirect | |
28256 string. */ | |
28257 if (!dwarf_split_debug_info) | |
28258 break; | |
28259 /* Fall through. */ | |
27067 case DW_MACRO_define_strp: | 28260 case DW_MACRO_define_strp: |
27068 case DW_MACRO_undef_strp: | 28261 case DW_MACRO_undef_strp: |
27069 set_indirect_string (find_AT_string (ref->info)); | 28262 set_indirect_string (find_AT_string (ref->info)); |
27070 break; | 28263 break; |
27071 default: | 28264 default: |
27217 | 28410 |
27218 macinfo_label_base += macinfo_label_base_adj; | 28411 macinfo_label_base += macinfo_label_base_adj; |
27219 } | 28412 } |
27220 | 28413 |
27221 /* Initialize the various sections and labels for dwarf output and prefix | 28414 /* Initialize the various sections and labels for dwarf output and prefix |
27222 them with PREFIX if non-NULL. */ | 28415 them with PREFIX if non-NULL. Returns the generation (zero based |
27223 | 28416 number of times function was called). */ |
27224 static void | 28417 |
28418 static unsigned | |
27225 init_sections_and_labels (bool early_lto_debug) | 28419 init_sections_and_labels (bool early_lto_debug) |
27226 { | 28420 { |
27227 /* As we may get called multiple times have a generation count for | 28421 /* As we may get called multiple times have a generation count for |
27228 labels. */ | 28422 labels. */ |
27229 static unsigned generation = 0; | 28423 static unsigned generation = 0; |
27242 = ((dwarf_strict && dwarf_version < 5) | 28436 = ((dwarf_strict && dwarf_version < 5) |
27243 ? DEBUG_LTO_MACINFO_SECTION : DEBUG_LTO_MACRO_SECTION); | 28437 ? DEBUG_LTO_MACINFO_SECTION : DEBUG_LTO_MACRO_SECTION); |
27244 debug_macinfo_section = get_section (debug_macinfo_section_name, | 28438 debug_macinfo_section = get_section (debug_macinfo_section_name, |
27245 SECTION_DEBUG | 28439 SECTION_DEBUG |
27246 | SECTION_EXCLUDE, NULL); | 28440 | SECTION_EXCLUDE, NULL); |
27247 /* For macro info we have to refer to a debug_line section, so | |
27248 similar to split-dwarf emit a skeleton one for early debug. */ | |
27249 debug_skeleton_line_section | |
27250 = get_section (DEBUG_LTO_LINE_SECTION, | |
27251 SECTION_DEBUG | SECTION_EXCLUDE, NULL); | |
27252 ASM_GENERATE_INTERNAL_LABEL (debug_skeleton_line_section_label, | |
27253 DEBUG_SKELETON_LINE_SECTION_LABEL, | |
27254 generation); | |
27255 } | 28441 } |
27256 else | 28442 else |
27257 { | 28443 { |
27258 /* ??? Which of the following do we need early? */ | 28444 /* ??? Which of the following do we need early? */ |
27259 debug_info_section = get_section (DEBUG_LTO_DWO_INFO_SECTION, | 28445 debug_info_section = get_section (DEBUG_LTO_DWO_INFO_SECTION, |
27296 ? DEBUG_LTO_DWO_MACINFO_SECTION : DEBUG_LTO_DWO_MACRO_SECTION); | 28482 ? DEBUG_LTO_DWO_MACINFO_SECTION : DEBUG_LTO_DWO_MACRO_SECTION); |
27297 debug_macinfo_section = get_section (debug_macinfo_section_name, | 28483 debug_macinfo_section = get_section (debug_macinfo_section_name, |
27298 SECTION_DEBUG | SECTION_EXCLUDE, | 28484 SECTION_DEBUG | SECTION_EXCLUDE, |
27299 NULL); | 28485 NULL); |
27300 } | 28486 } |
28487 /* For macro info and the file table we have to refer to a | |
28488 debug_line section. */ | |
28489 debug_line_section = get_section (DEBUG_LTO_LINE_SECTION, | |
28490 SECTION_DEBUG | SECTION_EXCLUDE, NULL); | |
28491 ASM_GENERATE_INTERNAL_LABEL (debug_line_section_label, | |
28492 DEBUG_LINE_SECTION_LABEL, generation); | |
28493 | |
27301 debug_str_section = get_section (DEBUG_LTO_STR_SECTION, | 28494 debug_str_section = get_section (DEBUG_LTO_STR_SECTION, |
27302 DEBUG_STR_SECTION_FLAGS | 28495 DEBUG_STR_SECTION_FLAGS |
27303 | SECTION_EXCLUDE, NULL); | 28496 | SECTION_EXCLUDE, NULL); |
27304 if (!dwarf_split_debug_info && !DWARF2_ASM_LINE_DEBUG_INFO) | 28497 if (!dwarf_split_debug_info) |
27305 debug_line_str_section | 28498 debug_line_str_section |
27306 = get_section (DEBUG_LTO_LINE_STR_SECTION, | 28499 = get_section (DEBUG_LTO_LINE_STR_SECTION, |
27307 DEBUG_STR_SECTION_FLAGS | SECTION_EXCLUDE, NULL); | 28500 DEBUG_STR_SECTION_FLAGS | SECTION_EXCLUDE, NULL); |
27308 } | 28501 } |
27309 else | 28502 else |
27380 SECTION_DEBUG, NULL); | 28573 SECTION_DEBUG, NULL); |
27381 debug_pubtypes_section = get_section (DEBUG_PUBTYPES_SECTION, | 28574 debug_pubtypes_section = get_section (DEBUG_PUBTYPES_SECTION, |
27382 SECTION_DEBUG, NULL); | 28575 SECTION_DEBUG, NULL); |
27383 debug_str_section = get_section (DEBUG_STR_SECTION, | 28576 debug_str_section = get_section (DEBUG_STR_SECTION, |
27384 DEBUG_STR_SECTION_FLAGS, NULL); | 28577 DEBUG_STR_SECTION_FLAGS, NULL); |
27385 if (!dwarf_split_debug_info && !DWARF2_ASM_LINE_DEBUG_INFO) | 28578 if (!dwarf_split_debug_info && !output_asm_line_debug_info ()) |
27386 debug_line_str_section = get_section (DEBUG_LINE_STR_SECTION, | 28579 debug_line_str_section = get_section (DEBUG_LINE_STR_SECTION, |
27387 DEBUG_STR_SECTION_FLAGS, NULL); | 28580 DEBUG_STR_SECTION_FLAGS, NULL); |
28581 | |
27388 debug_ranges_section = get_section (dwarf_version >= 5 | 28582 debug_ranges_section = get_section (dwarf_version >= 5 |
27389 ? DEBUG_RNGLISTS_SECTION | 28583 ? DEBUG_RNGLISTS_SECTION |
27390 : DEBUG_RANGES_SECTION, | 28584 : DEBUG_RANGES_SECTION, |
27391 SECTION_DEBUG, NULL); | 28585 SECTION_DEBUG, NULL); |
27392 debug_frame_section = get_section (DEBUG_FRAME_SECTION, | 28586 debug_frame_section = get_section (DEBUG_FRAME_SECTION, |
27398 ASM_GENERATE_INTERNAL_LABEL (debug_info_section_label, | 28592 ASM_GENERATE_INTERNAL_LABEL (debug_info_section_label, |
27399 DEBUG_INFO_SECTION_LABEL, generation); | 28593 DEBUG_INFO_SECTION_LABEL, generation); |
27400 info_section_emitted = false; | 28594 info_section_emitted = false; |
27401 ASM_GENERATE_INTERNAL_LABEL (debug_line_section_label, | 28595 ASM_GENERATE_INTERNAL_LABEL (debug_line_section_label, |
27402 DEBUG_LINE_SECTION_LABEL, generation); | 28596 DEBUG_LINE_SECTION_LABEL, generation); |
28597 /* There are up to 4 unique ranges labels per generation. | |
28598 See also output_rnglists. */ | |
27403 ASM_GENERATE_INTERNAL_LABEL (ranges_section_label, | 28599 ASM_GENERATE_INTERNAL_LABEL (ranges_section_label, |
27404 DEBUG_RANGES_SECTION_LABEL, generation); | 28600 DEBUG_RANGES_SECTION_LABEL, generation * 4); |
27405 if (dwarf_version >= 5 && dwarf_split_debug_info) | 28601 if (dwarf_version >= 5 && dwarf_split_debug_info) |
27406 ASM_GENERATE_INTERNAL_LABEL (ranges_base_label, | 28602 ASM_GENERATE_INTERNAL_LABEL (ranges_base_label, |
27407 DEBUG_RANGES_SECTION_LABEL, 2 + generation); | 28603 DEBUG_RANGES_SECTION_LABEL, |
28604 1 + generation * 4); | |
27408 ASM_GENERATE_INTERNAL_LABEL (debug_addr_section_label, | 28605 ASM_GENERATE_INTERNAL_LABEL (debug_addr_section_label, |
27409 DEBUG_ADDR_SECTION_LABEL, generation); | 28606 DEBUG_ADDR_SECTION_LABEL, generation); |
27410 ASM_GENERATE_INTERNAL_LABEL (macinfo_section_label, | 28607 ASM_GENERATE_INTERNAL_LABEL (macinfo_section_label, |
27411 (dwarf_strict && dwarf_version < 5) | 28608 (dwarf_strict && dwarf_version < 5) |
27412 ? DEBUG_MACINFO_SECTION_LABEL | 28609 ? DEBUG_MACINFO_SECTION_LABEL |
27413 : DEBUG_MACRO_SECTION_LABEL, generation); | 28610 : DEBUG_MACRO_SECTION_LABEL, generation); |
27414 ASM_GENERATE_INTERNAL_LABEL (loc_section_label, DEBUG_LOC_SECTION_LABEL, | 28611 ASM_GENERATE_INTERNAL_LABEL (loc_section_label, DEBUG_LOC_SECTION_LABEL, |
27415 generation); | 28612 generation); |
27416 | 28613 |
27417 ++generation; | 28614 ++generation; |
28615 return generation - 1; | |
27418 } | 28616 } |
27419 | 28617 |
27420 /* Set up for Dwarf output at the start of compilation. */ | 28618 /* Set up for Dwarf output at the start of compilation. */ |
27421 | 28619 |
27422 static void | 28620 static void |
27432 /* Allocate the decl_loc_table. */ | 28630 /* Allocate the decl_loc_table. */ |
27433 decl_loc_table = hash_table<decl_loc_hasher>::create_ggc (10); | 28631 decl_loc_table = hash_table<decl_loc_hasher>::create_ggc (10); |
27434 | 28632 |
27435 /* Allocate the cached_dw_loc_list_table. */ | 28633 /* Allocate the cached_dw_loc_list_table. */ |
27436 cached_dw_loc_list_table = hash_table<dw_loc_list_hasher>::create_ggc (10); | 28634 cached_dw_loc_list_table = hash_table<dw_loc_list_hasher>::create_ggc (10); |
27437 | |
27438 /* Allocate the initial hunk of the decl_scope_table. */ | |
27439 vec_alloc (decl_scope_table, 256); | |
27440 | 28635 |
27441 /* Allocate the initial hunk of the abbrev_die_table. */ | 28636 /* Allocate the initial hunk of the abbrev_die_table. */ |
27442 vec_alloc (abbrev_die_table, 256); | 28637 vec_alloc (abbrev_die_table, 256); |
27443 /* Zero-th entry is allocated, but unused. */ | 28638 /* Zero-th entry is allocated, but unused. */ |
27444 abbrev_die_table->quick_push (NULL); | 28639 abbrev_die_table->quick_push (NULL); |
27468 and toplevel asms into assembly. */ | 28663 and toplevel asms into assembly. */ |
27469 | 28664 |
27470 static void | 28665 static void |
27471 dwarf2out_assembly_start (void) | 28666 dwarf2out_assembly_start (void) |
27472 { | 28667 { |
28668 if (text_section_line_info) | |
28669 return; | |
28670 | |
27473 #ifndef DWARF2_LINENO_DEBUGGING_INFO | 28671 #ifndef DWARF2_LINENO_DEBUGGING_INFO |
27474 ASM_GENERATE_INTERNAL_LABEL (text_section_label, TEXT_SECTION_LABEL, 0); | 28672 ASM_GENERATE_INTERNAL_LABEL (text_section_label, TEXT_SECTION_LABEL, 0); |
27475 ASM_GENERATE_INTERNAL_LABEL (text_end_label, TEXT_END_LABEL, 0); | 28673 ASM_GENERATE_INTERNAL_LABEL (text_end_label, TEXT_END_LABEL, 0); |
27476 ASM_GENERATE_INTERNAL_LABEL (cold_text_section_label, | 28674 ASM_GENERATE_INTERNAL_LABEL (cold_text_section_label, |
27477 COLD_TEXT_SECTION_LABEL, 0); | 28675 COLD_TEXT_SECTION_LABEL, 0); |
27489 cur_line_info_table = text_section_line_info; | 28687 cur_line_info_table = text_section_line_info; |
27490 #endif | 28688 #endif |
27491 | 28689 |
27492 if (HAVE_GAS_CFI_SECTIONS_DIRECTIVE | 28690 if (HAVE_GAS_CFI_SECTIONS_DIRECTIVE |
27493 && dwarf2out_do_cfi_asm () | 28691 && dwarf2out_do_cfi_asm () |
27494 && (!(flag_unwind_tables || flag_exceptions) | 28692 && !dwarf2out_do_eh_frame ()) |
27495 || targetm_common.except_unwind_info (&global_options) != UI_DWARF2)) | |
27496 fprintf (asm_out_file, "\t.cfi_sections\t.debug_frame\n"); | 28693 fprintf (asm_out_file, "\t.cfi_sections\t.debug_frame\n"); |
27497 } | 28694 } |
27498 | 28695 |
27499 /* A helper function for dwarf2out_finish called through | 28696 /* A helper function for dwarf2out_finish called through |
27500 htab_traverse. Assign a string its index. All strings must be | 28697 htab_traverse. Assign a string its index. All strings must be |
27506 index_string (indirect_string_node **h, unsigned int *index) | 28703 index_string (indirect_string_node **h, unsigned int *index) |
27507 { | 28704 { |
27508 indirect_string_node *node = *h; | 28705 indirect_string_node *node = *h; |
27509 | 28706 |
27510 find_string_form (node); | 28707 find_string_form (node); |
27511 if (node->form == DW_FORM_GNU_str_index && node->refcount > 0) | 28708 if (node->form == dwarf_FORM (DW_FORM_strx) && node->refcount > 0) |
27512 { | 28709 { |
27513 gcc_assert (node->index == NO_INDEX_ASSIGNED); | 28710 gcc_assert (node->index == NO_INDEX_ASSIGNED); |
27514 node->index = *index; | 28711 node->index = *index; |
27515 *index += 1; | 28712 *index += 1; |
27516 } | 28713 } |
27524 int | 28721 int |
27525 output_index_string_offset (indirect_string_node **h, unsigned int *offset) | 28722 output_index_string_offset (indirect_string_node **h, unsigned int *offset) |
27526 { | 28723 { |
27527 indirect_string_node *node = *h; | 28724 indirect_string_node *node = *h; |
27528 | 28725 |
27529 if (node->form == DW_FORM_GNU_str_index && node->refcount > 0) | 28726 if (node->form == dwarf_FORM (DW_FORM_strx) && node->refcount > 0) |
27530 { | 28727 { |
27531 /* Assert that this node has been assigned an index. */ | 28728 /* Assert that this node has been assigned an index. */ |
27532 gcc_assert (node->index != NO_INDEX_ASSIGNED | 28729 gcc_assert (node->index != NO_INDEX_ASSIGNED |
27533 && node->index != NOT_INDEXED); | 28730 && node->index != NOT_INDEXED); |
27534 dw2_asm_output_data (DWARF_OFFSET_SIZE, *offset, | 28731 dw2_asm_output_data (DWARF_OFFSET_SIZE, *offset, |
27544 int | 28741 int |
27545 output_index_string (indirect_string_node **h, unsigned int *cur_idx) | 28742 output_index_string (indirect_string_node **h, unsigned int *cur_idx) |
27546 { | 28743 { |
27547 struct indirect_string_node *node = *h; | 28744 struct indirect_string_node *node = *h; |
27548 | 28745 |
27549 if (node->form == DW_FORM_GNU_str_index && node->refcount > 0) | 28746 if (node->form == dwarf_FORM (DW_FORM_strx) && node->refcount > 0) |
27550 { | 28747 { |
27551 /* Assert that the strings are output in the same order as their | 28748 /* Assert that the strings are output in the same order as their |
27552 indexes were assigned. */ | 28749 indexes were assigned. */ |
27553 gcc_assert (*cur_idx == node->index); | 28750 gcc_assert (*cur_idx == node->index); |
27554 assemble_string (node->str, strlen (node->str) + 1); | 28751 assemble_string (node->str, strlen (node->str) + 1); |
27555 *cur_idx += 1; | 28752 *cur_idx += 1; |
27556 } | 28753 } |
27557 return 1; | 28754 return 1; |
27558 } | 28755 } |
27559 | 28756 |
28757 /* A helper function for output_indirect_strings. Counts the number | |
28758 of index strings offsets. Must match the logic of the functions | |
28759 output_index_string[_offsets] above. */ | |
28760 int | |
28761 count_index_strings (indirect_string_node **h, unsigned int *last_idx) | |
28762 { | |
28763 struct indirect_string_node *node = *h; | |
28764 | |
28765 if (node->form == dwarf_FORM (DW_FORM_strx) && node->refcount > 0) | |
28766 *last_idx += 1; | |
28767 return 1; | |
28768 } | |
28769 | |
27560 /* A helper function for dwarf2out_finish called through | 28770 /* A helper function for dwarf2out_finish called through |
27561 htab_traverse. Emit one queued .debug_str string. */ | 28771 htab_traverse. Emit one queued .debug_str string. */ |
27562 | 28772 |
27563 int | 28773 int |
27564 output_indirect_string (indirect_string_node **h, enum dwarf_form form) | 28774 output_indirect_string (indirect_string_node **h, enum dwarf_form form) |
27587 else | 28797 else |
27588 { | 28798 { |
27589 unsigned int offset = 0; | 28799 unsigned int offset = 0; |
27590 unsigned int cur_idx = 0; | 28800 unsigned int cur_idx = 0; |
27591 | 28801 |
27592 skeleton_debug_str_hash->traverse<enum dwarf_form, | 28802 if (skeleton_debug_str_hash) |
27593 output_indirect_string> (DW_FORM_strp); | 28803 skeleton_debug_str_hash->traverse<enum dwarf_form, |
28804 output_indirect_string> (DW_FORM_strp); | |
27594 | 28805 |
27595 switch_to_section (debug_str_offsets_section); | 28806 switch_to_section (debug_str_offsets_section); |
28807 /* For DWARF5 the .debug_str_offsets[.dwo] section needs a unit | |
28808 header. Note that we don't need to generate a label to the | |
28809 actual index table following the header here, because this is | |
28810 for the split dwarf case only. In an .dwo file there is only | |
28811 one string offsets table (and one debug info section). But | |
28812 if we would start using string offset tables for the main (or | |
28813 skeleton) unit, then we have to add a DW_AT_str_offsets_base | |
28814 pointing to the actual index after the header. Split dwarf | |
28815 units will never have a string offsets base attribute. When | |
28816 a split unit is moved into a .dwp file the string offsets can | |
28817 be found through the .debug_cu_index section table. */ | |
28818 if (dwarf_version >= 5) | |
28819 { | |
28820 unsigned int last_idx = 0; | |
28821 unsigned long str_offsets_length; | |
28822 | |
28823 debug_str_hash->traverse_noresize | |
28824 <unsigned int *, count_index_strings> (&last_idx); | |
28825 str_offsets_length = last_idx * DWARF_OFFSET_SIZE + 4; | |
28826 if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4) | |
28827 dw2_asm_output_data (4, 0xffffffff, | |
28828 "Escape value for 64-bit DWARF extension"); | |
28829 dw2_asm_output_data (DWARF_OFFSET_SIZE, str_offsets_length, | |
28830 "Length of string offsets unit"); | |
28831 dw2_asm_output_data (2, 5, "DWARF string offsets version"); | |
28832 dw2_asm_output_data (2, 0, "Header zero padding"); | |
28833 } | |
27596 debug_str_hash->traverse_noresize | 28834 debug_str_hash->traverse_noresize |
27597 <unsigned int *, output_index_string_offset> (&offset); | 28835 <unsigned int *, output_index_string_offset> (&offset); |
27598 switch_to_section (debug_str_dwo_section); | 28836 switch_to_section (debug_str_dwo_section); |
27599 debug_str_hash->traverse_noresize<unsigned int *, output_index_string> | 28837 debug_str_hash->traverse_noresize<unsigned int *, output_index_string> |
27600 (&cur_idx); | 28838 (&cur_idx); |
27637 "0x%x", entry->index); | 28875 "0x%x", entry->index); |
27638 break; | 28876 break; |
27639 default: | 28877 default: |
27640 gcc_unreachable (); | 28878 gcc_unreachable (); |
27641 } | 28879 } |
28880 return 1; | |
28881 } | |
28882 | |
28883 /* A helper function for dwarf2out_finish. Counts the number | |
28884 of indexed addresses. Must match the logic of the functions | |
28885 output_addr_table_entry above. */ | |
28886 int | |
28887 count_index_addrs (addr_table_entry **slot, unsigned int *last_idx) | |
28888 { | |
28889 addr_table_entry *entry = *slot; | |
28890 | |
28891 if (entry->refcount > 0) | |
28892 *last_idx += 1; | |
27642 return 1; | 28893 return 1; |
27643 } | 28894 } |
27644 | 28895 |
27645 /* Produce the .debug_addr section. */ | 28896 /* Produce the .debug_addr section. */ |
27646 | 28897 |
27761 list != NULL; | 29012 list != NULL; |
27762 list = list->dw_loc_next) | 29013 list = list->dw_loc_next) |
27763 prune_unused_types_walk_loc_descr (list->expr); | 29014 prune_unused_types_walk_loc_descr (list->expr); |
27764 break; | 29015 break; |
27765 | 29016 |
29017 case dw_val_class_view_list: | |
29018 /* This points to a loc_list in another attribute, so it's | |
29019 already covered. */ | |
29020 break; | |
29021 | |
27766 case dw_val_class_die_ref: | 29022 case dw_val_class_die_ref: |
27767 /* A reference to another DIE. | 29023 /* A reference to another DIE. |
27768 Make sure that it will get emitted. | 29024 Make sure that it will get emitted. |
27769 If it was broken out into a comdat group, don't follow it. */ | 29025 If it was broken out into a comdat group, don't follow it. */ |
27770 if (! AT_ref (a)->comdat_type_p | 29026 if (! AT_ref (a)->comdat_type_p |
28499 break; | 29755 break; |
28500 return false; | 29756 return false; |
28501 } | 29757 } |
28502 break; | 29758 break; |
28503 case DW_OP_GNU_addr_index: | 29759 case DW_OP_GNU_addr_index: |
29760 case DW_OP_addrx: | |
28504 case DW_OP_GNU_const_index: | 29761 case DW_OP_GNU_const_index: |
28505 if (loc->dw_loc_opc == DW_OP_GNU_addr_index | 29762 case DW_OP_constx: |
28506 || (loc->dw_loc_opc == DW_OP_GNU_const_index && loc->dtprel)) | 29763 if ((loc->dw_loc_opc == DW_OP_GNU_addr_index |
29764 || loc->dw_loc_opc == DW_OP_addrx) | |
29765 || ((loc->dw_loc_opc == DW_OP_GNU_const_index | |
29766 || loc->dw_loc_opc == DW_OP_constx) | |
29767 && loc->dtprel)) | |
28507 { | 29768 { |
28508 rtx rtl = loc->dw_loc_oprnd1.val_entry->addr.rtl; | 29769 rtx rtl = loc->dw_loc_oprnd1.val_entry->addr.rtl; |
28509 if (!resolve_one_addr (&rtl)) | 29770 if (!resolve_one_addr (&rtl)) |
28510 return false; | 29771 return false; |
28511 remove_addr_table_entry (loc->dw_loc_oprnd1.val_entry); | 29772 remove_addr_table_entry (loc->dw_loc_oprnd1.val_entry); |
28860 case dw_val_class_loc_list: | 30121 case dw_val_class_loc_list: |
28861 for (d = AT_loc_list (av); d != NULL; d = d->dw_loc_next) | 30122 for (d = AT_loc_list (av); d != NULL; d = d->dw_loc_next) |
28862 if (d->expr && non_dwarf_expression (d->expr)) | 30123 if (d->expr && non_dwarf_expression (d->expr)) |
28863 non_dwarf_expr = true; | 30124 non_dwarf_expr = true; |
28864 break; | 30125 break; |
30126 case dw_val_class_view_list: | |
30127 gcc_unreachable (); | |
28865 case dw_val_class_loc: | 30128 case dw_val_class_loc: |
28866 lv = AT_loc (av); | 30129 lv = AT_loc (av); |
28867 if (lv == NULL) | 30130 if (lv == NULL) |
28868 return dwarf_strict ? -1 : 0; | 30131 return dwarf_strict ? -1 : 0; |
28869 if (non_dwarf_expression (lv)) | 30132 if (non_dwarf_expression (lv)) |
28904 for (d = AT_loc_list (av); d != NULL; d = d->dw_loc_next) | 30167 for (d = AT_loc_list (av); d != NULL; d = d->dw_loc_next) |
28905 { | 30168 { |
28906 lv = copy_deref_exprloc (d->expr); | 30169 lv = copy_deref_exprloc (d->expr); |
28907 if (lv) | 30170 if (lv) |
28908 { | 30171 { |
28909 *p = new_loc_list (lv, d->begin, d->end, d->section); | 30172 *p = new_loc_list (lv, d->begin, d->vbegin, d->end, d->vend, d->section); |
28910 p = &(*p)->dw_loc_next; | 30173 p = &(*p)->dw_loc_next; |
28911 } | 30174 } |
28912 else if (!dwarf_strict && d->expr) | 30175 else if (!dwarf_strict && d->expr) |
28913 return 0; | 30176 return 0; |
28914 } | 30177 } |
28974 | 30237 |
28975 if (next && (*curr)->ll_symbol) | 30238 if (next && (*curr)->ll_symbol) |
28976 { | 30239 { |
28977 gcc_assert (!next->ll_symbol); | 30240 gcc_assert (!next->ll_symbol); |
28978 next->ll_symbol = (*curr)->ll_symbol; | 30241 next->ll_symbol = (*curr)->ll_symbol; |
30242 next->vl_symbol = (*curr)->vl_symbol; | |
28979 } | 30243 } |
28980 if (dwarf_split_debug_info) | 30244 if (dwarf_split_debug_info) |
28981 remove_loc_list_addr_table_entries (l); | 30245 remove_loc_list_addr_table_entries (l); |
28982 *curr = next; | 30246 *curr = next; |
28983 } | 30247 } |
28999 { | 30263 { |
29000 remove_AT (die, a->dw_attr); | 30264 remove_AT (die, a->dw_attr); |
29001 ix--; | 30265 ix--; |
29002 } | 30266 } |
29003 break; | 30267 break; |
30268 case dw_val_class_view_list: | |
30269 { | |
30270 gcc_checking_assert (a->dw_attr == DW_AT_GNU_locviews); | |
30271 gcc_checking_assert (dwarf2out_locviews_in_attribute ()); | |
30272 dw_val_node *llnode | |
30273 = view_list_to_loc_list_val_node (&a->dw_attr_val); | |
30274 /* If we no longer have a loclist, or it no longer needs | |
30275 views, drop this attribute. */ | |
30276 if (!llnode || !llnode->v.val_loc_list->vl_symbol) | |
30277 { | |
30278 remove_AT (die, a->dw_attr); | |
30279 ix--; | |
30280 } | |
30281 break; | |
30282 } | |
29004 case dw_val_class_loc: | 30283 case dw_val_class_loc: |
29005 { | 30284 { |
29006 dw_loc_descr_ref l = AT_loc (a); | 30285 dw_loc_descr_ref l = AT_loc (a); |
29007 /* DW_OP_GNU_variable_value DW_OP_stack_value or | 30286 /* DW_OP_GNU_variable_value DW_OP_stack_value or |
29008 DW_OP_GNU_variable_value in DW_AT_string_length can be converted | 30287 DW_OP_GNU_variable_value in DW_AT_string_length can be converted |
29269 hstate.add_object (dtprel); | 30548 hstate.add_object (dtprel); |
29270 } | 30549 } |
29271 inchash::add_rtx (val1->v.val_addr, hstate); | 30550 inchash::add_rtx (val1->v.val_addr, hstate); |
29272 break; | 30551 break; |
29273 case DW_OP_GNU_addr_index: | 30552 case DW_OP_GNU_addr_index: |
30553 case DW_OP_addrx: | |
29274 case DW_OP_GNU_const_index: | 30554 case DW_OP_GNU_const_index: |
30555 case DW_OP_constx: | |
29275 { | 30556 { |
29276 if (loc->dtprel) | 30557 if (loc->dtprel) |
29277 { | 30558 { |
29278 unsigned char dtprel = 0xd1; | 30559 unsigned char dtprel = 0xd1; |
29279 hstate.add_object (dtprel); | 30560 hstate.add_object (dtprel); |
29395 | 30676 |
29396 for (curr = list_head; curr != NULL; curr = curr->dw_loc_next) | 30677 for (curr = list_head; curr != NULL; curr = curr->dw_loc_next) |
29397 { | 30678 { |
29398 hstate.add (curr->begin, strlen (curr->begin) + 1); | 30679 hstate.add (curr->begin, strlen (curr->begin) + 1); |
29399 hstate.add (curr->end, strlen (curr->end) + 1); | 30680 hstate.add (curr->end, strlen (curr->end) + 1); |
30681 hstate.add_object (curr->vbegin); | |
30682 hstate.add_object (curr->vend); | |
29400 if (curr->section) | 30683 if (curr->section) |
29401 hstate.add (curr->section, strlen (curr->section) + 1); | 30684 hstate.add (curr->section, strlen (curr->section) + 1); |
29402 hash_locs (curr->expr, hstate); | 30685 hash_locs (curr->expr, hstate); |
29403 } | 30686 } |
29404 list_head->hash = hstate.end (); | 30687 list_head->hash = hstate.end (); |
29508 && valx2->v.val_int == valy2->v.val_int; | 30791 && valx2->v.val_int == valy2->v.val_int; |
29509 case DW_OP_addr: | 30792 case DW_OP_addr: |
29510 hash_addr: | 30793 hash_addr: |
29511 return rtx_equal_p (valx1->v.val_addr, valy1->v.val_addr); | 30794 return rtx_equal_p (valx1->v.val_addr, valy1->v.val_addr); |
29512 case DW_OP_GNU_addr_index: | 30795 case DW_OP_GNU_addr_index: |
30796 case DW_OP_addrx: | |
29513 case DW_OP_GNU_const_index: | 30797 case DW_OP_GNU_const_index: |
30798 case DW_OP_constx: | |
29514 { | 30799 { |
29515 rtx ax1 = valx1->val_entry->addr.rtl; | 30800 rtx ax1 = valx1->val_entry->addr.rtl; |
29516 rtx ay1 = valy1->val_entry->addr.rtl; | 30801 rtx ay1 = valy1->val_entry->addr.rtl; |
29517 return rtx_equal_p (ax1, ay1); | 30802 return rtx_equal_p (ax1, ay1); |
29518 } | 30803 } |
29616 for (; a != NULL && b != NULL; a = a->dw_loc_next, b = b->dw_loc_next) | 30901 for (; a != NULL && b != NULL; a = a->dw_loc_next, b = b->dw_loc_next) |
29617 if (strcmp (a->begin, b->begin) != 0 | 30902 if (strcmp (a->begin, b->begin) != 0 |
29618 || strcmp (a->end, b->end) != 0 | 30903 || strcmp (a->end, b->end) != 0 |
29619 || (a->section == NULL) != (b->section == NULL) | 30904 || (a->section == NULL) != (b->section == NULL) |
29620 || (a->section && strcmp (a->section, b->section) != 0) | 30905 || (a->section && strcmp (a->section, b->section) != 0) |
30906 || a->vbegin != b->vbegin || a->vend != b->vend | |
29621 || !compare_locs (a->expr, b->expr)) | 30907 || !compare_locs (a->expr, b->expr)) |
29622 break; | 30908 break; |
29623 return a == NULL && b == NULL; | 30909 return a == NULL && b == NULL; |
29624 } | 30910 } |
29625 | 30911 |
29634 { | 30920 { |
29635 dw_die_ref c; | 30921 dw_die_ref c; |
29636 dw_attr_node *a; | 30922 dw_attr_node *a; |
29637 unsigned ix; | 30923 unsigned ix; |
29638 dw_loc_list_struct **slot; | 30924 dw_loc_list_struct **slot; |
30925 bool drop_locviews = false; | |
30926 bool has_locviews = false; | |
29639 | 30927 |
29640 FOR_EACH_VEC_SAFE_ELT (die->die_attr, ix, a) | 30928 FOR_EACH_VEC_SAFE_ELT (die->die_attr, ix, a) |
29641 if (AT_class (a) == dw_val_class_loc_list) | 30929 if (AT_class (a) == dw_val_class_loc_list) |
29642 { | 30930 { |
29643 dw_loc_list_ref list = AT_loc_list (a); | 30931 dw_loc_list_ref list = AT_loc_list (a); |
29644 /* TODO: perform some optimizations here, before hashing | 30932 /* TODO: perform some optimizations here, before hashing |
29645 it and storing into the hash table. */ | 30933 it and storing into the hash table. */ |
29646 hash_loc_list (list); | 30934 hash_loc_list (list); |
29647 slot = htab->find_slot_with_hash (list, list->hash, INSERT); | 30935 slot = htab->find_slot_with_hash (list, list->hash, INSERT); |
29648 if (*slot == NULL) | 30936 if (*slot == NULL) |
29649 *slot = list; | 30937 { |
30938 *slot = list; | |
30939 if (loc_list_has_views (list)) | |
30940 gcc_assert (list->vl_symbol); | |
30941 else if (list->vl_symbol) | |
30942 { | |
30943 drop_locviews = true; | |
30944 list->vl_symbol = NULL; | |
30945 } | |
30946 } | |
29650 else | 30947 else |
29651 a->dw_attr_val.v.val_loc_list = *slot; | 30948 { |
30949 if (list->vl_symbol && !(*slot)->vl_symbol) | |
30950 drop_locviews = true; | |
30951 a->dw_attr_val.v.val_loc_list = *slot; | |
30952 } | |
29652 } | 30953 } |
30954 else if (AT_class (a) == dw_val_class_view_list) | |
30955 { | |
30956 gcc_checking_assert (a->dw_attr == DW_AT_GNU_locviews); | |
30957 has_locviews = true; | |
30958 } | |
30959 | |
30960 | |
30961 if (drop_locviews && has_locviews) | |
30962 remove_AT (die, DW_AT_GNU_locviews); | |
29653 | 30963 |
29654 FOR_EACH_CHILD (die, c, optimize_location_lists_1 (c, htab)); | 30964 FOR_EACH_CHILD (die, c, optimize_location_lists_1 (c, htab)); |
29655 } | 30965 } |
29656 | 30966 |
29657 | 30967 |
29671 dw_loc_list_ref list = AT_loc_list (a); | 30981 dw_loc_list_ref list = AT_loc_list (a); |
29672 dw_loc_list_ref curr; | 30982 dw_loc_list_ref curr; |
29673 for (curr = list; curr != NULL; curr = curr->dw_loc_next) | 30983 for (curr = list; curr != NULL; curr = curr->dw_loc_next) |
29674 { | 30984 { |
29675 /* Don't index an entry that has already been indexed | 30985 /* Don't index an entry that has already been indexed |
29676 or won't be output. */ | 30986 or won't be output. Make sure skip_loc_list_entry doesn't |
30987 call size_of_locs, because that might cause circular dependency, | |
30988 index_location_lists requiring address table indexes to be | |
30989 computed, but adding new indexes through add_addr_table_entry | |
30990 and address table index computation requiring no new additions | |
30991 to the hash table. In the rare case of DWARF[234] >= 64KB | |
30992 location expression, we'll just waste unused address table entry | |
30993 for it. */ | |
29677 if (curr->begin_entry != NULL | 30994 if (curr->begin_entry != NULL |
29678 || (strcmp (curr->begin, curr->end) == 0 && !curr->force)) | 30995 || skip_loc_list_entry (curr)) |
29679 continue; | 30996 continue; |
29680 | 30997 |
29681 curr->begin_entry | 30998 curr->begin_entry |
29682 = add_addr_table_entry (xstrdup (curr->begin), ate_kind_label); | 30999 = add_addr_table_entry (xstrdup (curr->begin), ate_kind_label); |
29683 } | 31000 } |
29771 | 31088 |
29772 /* Output stuff that dwarf requires at the end of every file, | 31089 /* Output stuff that dwarf requires at the end of every file, |
29773 and generate the DWARF-2 debugging info. */ | 31090 and generate the DWARF-2 debugging info. */ |
29774 | 31091 |
29775 static void | 31092 static void |
29776 dwarf2out_finish (const char *) | 31093 dwarf2out_finish (const char *filename) |
29777 { | 31094 { |
29778 comdat_type_node *ctnode; | 31095 comdat_type_node *ctnode; |
29779 dw_die_ref main_comp_unit_die; | 31096 dw_die_ref main_comp_unit_die; |
29780 unsigned char checksum[16]; | 31097 unsigned char checksum[16]; |
29781 char dl_section_ref[MAX_ARTIFICIAL_LABEL_BYTES]; | 31098 char dl_section_ref[MAX_ARTIFICIAL_LABEL_BYTES]; |
29782 | 31099 |
29783 /* Flush out any latecomers to the limbo party. */ | 31100 /* Flush out any latecomers to the limbo party. */ |
29784 flush_limbo_die_list (); | 31101 flush_limbo_die_list (); |
31102 | |
31103 if (inline_entry_data_table) | |
31104 gcc_assert (inline_entry_data_table->elements () == 0); | |
29785 | 31105 |
29786 if (flag_checking) | 31106 if (flag_checking) |
29787 { | 31107 { |
29788 verify_die (comp_unit_die ()); | 31108 verify_die (comp_unit_die ()); |
29789 for (limbo_die_node *node = cu_die_list; node; node = node->next) | 31109 for (limbo_die_node *node = cu_die_list; node; node = node->next) |
29814 | 31134 |
29815 /* Don't reset types twice. */ | 31135 /* Don't reset types twice. */ |
29816 if (*slot != HTAB_EMPTY_ENTRY) | 31136 if (*slot != HTAB_EMPTY_ENTRY) |
29817 continue; | 31137 continue; |
29818 | 31138 |
29819 /* Add a pointer to the line table for the main compilation unit | 31139 /* Remove the pointer to the line table. */ |
29820 so that the debugger can make sense of DW_AT_decl_file | 31140 remove_AT (ctnode->root_die, DW_AT_stmt_list); |
29821 attributes. */ | 31141 |
29822 if (debug_info_level >= DINFO_LEVEL_TERSE) | 31142 if (debug_info_level >= DINFO_LEVEL_TERSE) |
29823 reset_dies (ctnode->root_die); | 31143 reset_dies (ctnode->root_die); |
29824 | 31144 |
29825 *slot = ctnode; | 31145 *slot = ctnode; |
29826 } | 31146 } |
29827 | 31147 |
29828 /* Reset die CU symbol so we don't output it twice. */ | 31148 /* Reset die CU symbol so we don't output it twice. */ |
29829 comp_unit_die ()->die_id.die_symbol = NULL; | 31149 comp_unit_die ()->die_id.die_symbol = NULL; |
29830 | 31150 |
29831 /* Remove DW_AT_macro from the early output. */ | 31151 /* Remove DW_AT_macro and DW_AT_stmt_list from the early output. */ |
31152 remove_AT (comp_unit_die (), DW_AT_stmt_list); | |
29832 if (have_macinfo) | 31153 if (have_macinfo) |
29833 remove_AT (comp_unit_die (), DEBUG_MACRO_ATTRIBUTE); | 31154 remove_AT (comp_unit_die (), DEBUG_MACRO_ATTRIBUTE); |
29834 | 31155 |
29835 /* Remove indirect string decisions. */ | 31156 /* Remove indirect string decisions. */ |
29836 debug_str_hash->traverse<void *, reset_indirect_string> (NULL); | 31157 debug_str_hash->traverse<void *, reset_indirect_string> (NULL); |
31158 if (debug_line_str_hash) | |
31159 { | |
31160 debug_line_str_hash->traverse<void *, reset_indirect_string> (NULL); | |
31161 debug_line_str_hash = NULL; | |
31162 } | |
29837 } | 31163 } |
29838 | 31164 |
29839 #if ENABLE_ASSERT_CHECKING | 31165 #if ENABLE_ASSERT_CHECKING |
29840 { | 31166 { |
29841 dw_die_ref die = comp_unit_die (), c; | 31167 dw_die_ref die = comp_unit_die (), c; |
29843 } | 31169 } |
29844 #endif | 31170 #endif |
29845 resolve_addr (comp_unit_die ()); | 31171 resolve_addr (comp_unit_die ()); |
29846 move_marked_base_types (); | 31172 move_marked_base_types (); |
29847 | 31173 |
31174 if (dump_file) | |
31175 { | |
31176 fprintf (dump_file, "DWARF for %s\n", filename); | |
31177 print_die (comp_unit_die (), dump_file); | |
31178 } | |
31179 | |
29848 /* Initialize sections and labels used for actual assembler output. */ | 31180 /* Initialize sections and labels used for actual assembler output. */ |
29849 init_sections_and_labels (false); | 31181 unsigned generation = init_sections_and_labels (false); |
29850 | 31182 |
29851 /* Traverse the DIE's and add sibling attributes to those DIE's that | 31183 /* Traverse the DIE's and add sibling attributes to those DIE's that |
29852 have children. */ | 31184 have children. */ |
29853 add_sibling_attributes (comp_unit_die ()); | 31185 add_sibling_attributes (comp_unit_die ()); |
29854 limbo_die_node *node; | 31186 limbo_die_node *node; |
29952 | 31284 |
29953 if (dwarf_split_debug_info) | 31285 if (dwarf_split_debug_info) |
29954 { | 31286 { |
29955 if (have_location_lists) | 31287 if (have_location_lists) |
29956 { | 31288 { |
29957 if (dwarf_version >= 5) | 31289 /* Since we generate the loclists in the split DWARF .dwo |
29958 add_AT_loclistsptr (comp_unit_die (), DW_AT_loclists_base, | 31290 file itself, we don't need to generate a loclists_base |
29959 loc_section_label); | 31291 attribute for the split compile unit DIE. That attribute |
31292 (and using relocatable sec_offset FORMs) isn't allowed | |
31293 for a split compile unit. Only if the .debug_loclists | |
31294 section was in the main file, would we need to generate a | |
31295 loclists_base attribute here (for the full or skeleton | |
31296 unit DIE). */ | |
31297 | |
29960 /* optimize_location_lists calculates the size of the lists, | 31298 /* optimize_location_lists calculates the size of the lists, |
29961 so index them first, and assign indices to the entries. | 31299 so index them first, and assign indices to the entries. |
29962 Although optimize_location_lists will remove entries from | 31300 Although optimize_location_lists will remove entries from |
29963 the table, it only does so for duplicates, and therefore | 31301 the table, it only does so for duplicates, and therefore |
29964 only reduces ref_counts to 1. */ | 31302 only reduces ref_counts to 1. */ |
30059 add_AT_lineptr (main_comp_unit_die, DW_AT_GNU_ranges_base, | 31397 add_AT_lineptr (main_comp_unit_die, DW_AT_GNU_ranges_base, |
30060 ranges_section_label); | 31398 ranges_section_label); |
30061 } | 31399 } |
30062 | 31400 |
30063 switch_to_section (debug_addr_section); | 31401 switch_to_section (debug_addr_section); |
31402 /* GNU DebugFission https://gcc.gnu.org/wiki/DebugFission | |
31403 which GCC uses to implement -gsplit-dwarf as DWARF GNU extension | |
31404 before DWARF5, didn't have a header for .debug_addr units. | |
31405 DWARF5 specifies a small header when address tables are used. */ | |
31406 if (dwarf_version >= 5) | |
31407 { | |
31408 unsigned int last_idx = 0; | |
31409 unsigned long addrs_length; | |
31410 | |
31411 addr_index_table->traverse_noresize | |
31412 <unsigned int *, count_index_addrs> (&last_idx); | |
31413 addrs_length = last_idx * DWARF2_ADDR_SIZE + 4; | |
31414 | |
31415 if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4) | |
31416 dw2_asm_output_data (4, 0xffffffff, | |
31417 "Escape value for 64-bit DWARF extension"); | |
31418 dw2_asm_output_data (DWARF_OFFSET_SIZE, addrs_length, | |
31419 "Length of Address Unit"); | |
31420 dw2_asm_output_data (2, 5, "DWARF addr version"); | |
31421 dw2_asm_output_data (1, DWARF2_ADDR_SIZE, "Size of Address"); | |
31422 dw2_asm_output_data (1, 0, "Size of Segment Descriptor"); | |
31423 } | |
30064 ASM_OUTPUT_LABEL (asm_out_file, debug_addr_section_label); | 31424 ASM_OUTPUT_LABEL (asm_out_file, debug_addr_section_label); |
30065 output_addr_table (); | 31425 output_addr_table (); |
30066 } | 31426 } |
30067 | 31427 |
30068 /* Output the main compilation unit if non-empty or if .debug_macinfo | 31428 /* Output the main compilation unit if non-empty or if .debug_macinfo |
30088 char l2[MAX_ARTIFICIAL_LABEL_BYTES]; | 31448 char l2[MAX_ARTIFICIAL_LABEL_BYTES]; |
30089 /* Output the location lists info. */ | 31449 /* Output the location lists info. */ |
30090 switch_to_section (debug_loc_section); | 31450 switch_to_section (debug_loc_section); |
30091 if (dwarf_version >= 5) | 31451 if (dwarf_version >= 5) |
30092 { | 31452 { |
30093 ASM_GENERATE_INTERNAL_LABEL (l1, DEBUG_LOC_SECTION_LABEL, 1); | 31453 ASM_GENERATE_INTERNAL_LABEL (l1, DEBUG_LOC_SECTION_LABEL, 2); |
30094 ASM_GENERATE_INTERNAL_LABEL (l2, DEBUG_LOC_SECTION_LABEL, 2); | 31454 ASM_GENERATE_INTERNAL_LABEL (l2, DEBUG_LOC_SECTION_LABEL, 3); |
30095 if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4) | 31455 if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4) |
30096 dw2_asm_output_data (4, 0xffffffff, | 31456 dw2_asm_output_data (4, 0xffffffff, |
30097 "Initial length escape value indicating " | 31457 "Initial length escape value indicating " |
30098 "64-bit DWARF extension"); | 31458 "64-bit DWARF extension"); |
30099 dw2_asm_output_delta (DWARF_OFFSET_SIZE, l2, l1, | 31459 dw2_asm_output_delta (DWARF_OFFSET_SIZE, l2, l1, |
30100 "Length of Location Lists"); | 31460 "Length of Location Lists"); |
30101 ASM_OUTPUT_LABEL (asm_out_file, l1); | 31461 ASM_OUTPUT_LABEL (asm_out_file, l1); |
30102 dw2_asm_output_data (2, dwarf_version, "DWARF Version"); | 31462 output_dwarf_version (); |
30103 dw2_asm_output_data (1, DWARF2_ADDR_SIZE, "Address Size"); | 31463 dw2_asm_output_data (1, DWARF2_ADDR_SIZE, "Address Size"); |
30104 dw2_asm_output_data (1, 0, "Segment Size"); | 31464 dw2_asm_output_data (1, 0, "Segment Size"); |
30105 dw2_asm_output_data (4, dwarf_split_debug_info ? loc_list_idx : 0, | 31465 dw2_asm_output_data (4, dwarf_split_debug_info ? loc_list_idx : 0, |
30106 "Offset Entry Count"); | 31466 "Offset Entry Count"); |
30107 } | 31467 } |
30133 | 31493 |
30134 /* Output ranges section if necessary. */ | 31494 /* Output ranges section if necessary. */ |
30135 if (!vec_safe_is_empty (ranges_table)) | 31495 if (!vec_safe_is_empty (ranges_table)) |
30136 { | 31496 { |
30137 if (dwarf_version >= 5) | 31497 if (dwarf_version >= 5) |
30138 output_rnglists (); | 31498 output_rnglists (generation); |
30139 else | 31499 else |
30140 output_ranges (); | 31500 output_ranges (); |
30141 } | 31501 } |
30142 | 31502 |
30143 /* Have to end the macro section. */ | 31503 /* Have to end the macro section. */ |
30156 .debug_info section. IRIX 6.5 `nm' will then complain when | 31516 .debug_info section. IRIX 6.5 `nm' will then complain when |
30157 examining the file. This is done late so that any filenames | 31517 examining the file. This is done late so that any filenames |
30158 used by the debug_info section are marked as 'used'. */ | 31518 used by the debug_info section are marked as 'used'. */ |
30159 switch_to_section (debug_line_section); | 31519 switch_to_section (debug_line_section); |
30160 ASM_OUTPUT_LABEL (asm_out_file, debug_line_section_label); | 31520 ASM_OUTPUT_LABEL (asm_out_file, debug_line_section_label); |
30161 if (! DWARF2_ASM_LINE_DEBUG_INFO) | 31521 if (! output_asm_line_debug_info ()) |
30162 output_line_info (false); | 31522 output_line_info (false); |
30163 | 31523 |
30164 if (dwarf_split_debug_info && info_section_emitted) | 31524 if (dwarf_split_debug_info && info_section_emitted) |
30165 { | 31525 { |
30166 switch_to_section (debug_skeleton_line_section); | 31526 switch_to_section (debug_skeleton_line_section); |
30176 switch_to_section (debug_line_str_section); | 31536 switch_to_section (debug_line_str_section); |
30177 const enum dwarf_form form = DW_FORM_line_strp; | 31537 const enum dwarf_form form = DW_FORM_line_strp; |
30178 debug_line_str_hash->traverse<enum dwarf_form, | 31538 debug_line_str_hash->traverse<enum dwarf_form, |
30179 output_indirect_string> (form); | 31539 output_indirect_string> (form); |
30180 } | 31540 } |
31541 | |
31542 /* ??? Move lvugid out of dwarf2out_source_line and reset it too? */ | |
31543 symview_upper_bound = 0; | |
31544 if (zero_view_p) | |
31545 bitmap_clear (zero_view_p); | |
30181 } | 31546 } |
30182 | 31547 |
30183 /* Returns a hash value for X (which really is a variable_value_struct). */ | 31548 /* Returns a hash value for X (which really is a variable_value_struct). */ |
30184 | 31549 |
30185 inline hashval_t | 31550 inline hashval_t |
30457 | 31822 |
30458 static void | 31823 static void |
30459 dwarf2out_early_finish (const char *filename) | 31824 dwarf2out_early_finish (const char *filename) |
30460 { | 31825 { |
30461 set_early_dwarf s; | 31826 set_early_dwarf s; |
31827 char dl_section_ref[MAX_ARTIFICIAL_LABEL_BYTES]; | |
30462 | 31828 |
30463 /* PCH might result in DW_AT_producer string being restored from the | 31829 /* PCH might result in DW_AT_producer string being restored from the |
30464 header compilation, so always fill it with empty string initially | 31830 header compilation, so always fill it with empty string initially |
30465 and overwrite only here. */ | 31831 and overwrite only here. */ |
30466 dw_attr_node *producer = get_AT (comp_unit_die (), DW_AT_producer); | 31832 dw_attr_node *producer = get_AT (comp_unit_die (), DW_AT_producer); |
30473 add_name_attribute (comp_unit_die (), remap_debug_filename (filename)); | 31839 add_name_attribute (comp_unit_die (), remap_debug_filename (filename)); |
30474 add_comp_dir_attribute (comp_unit_die ()); | 31840 add_comp_dir_attribute (comp_unit_die ()); |
30475 | 31841 |
30476 /* When emitting DWARF5 .debug_line_str, move DW_AT_name and | 31842 /* When emitting DWARF5 .debug_line_str, move DW_AT_name and |
30477 DW_AT_comp_dir into .debug_line_str section. */ | 31843 DW_AT_comp_dir into .debug_line_str section. */ |
30478 if (!DWARF2_ASM_LINE_DEBUG_INFO | 31844 if (!output_asm_line_debug_info () |
30479 && dwarf_version >= 5 | 31845 && dwarf_version >= 5 |
30480 && DWARF5_USE_DEBUG_LINE_STR) | 31846 && DWARF5_USE_DEBUG_LINE_STR) |
30481 { | 31847 { |
30482 for (int i = 0; i < 2; i++) | 31848 for (int i = 0; i < 2; i++) |
30483 { | 31849 { |
30503 | 31869 |
30504 /* With LTO early dwarf was really finished at compile-time, so make | 31870 /* With LTO early dwarf was really finished at compile-time, so make |
30505 sure to adjust the phase after annotating the LTRANS CU DIE. */ | 31871 sure to adjust the phase after annotating the LTRANS CU DIE. */ |
30506 if (in_lto_p) | 31872 if (in_lto_p) |
30507 { | 31873 { |
31874 /* Force DW_TAG_imported_unit to be created now, otherwise | |
31875 we might end up without it or ordered after DW_TAG_inlined_subroutine | |
31876 referencing DIEs from it. */ | |
31877 if (! flag_wpa && flag_incremental_link != INCREMENTAL_LINK_LTO) | |
31878 { | |
31879 unsigned i; | |
31880 tree tu; | |
31881 if (external_die_map) | |
31882 FOR_EACH_VEC_SAFE_ELT (all_translation_units, i, tu) | |
31883 if (sym_off_pair *desc = external_die_map->get (tu)) | |
31884 { | |
31885 dw_die_ref import = new_die (DW_TAG_imported_unit, | |
31886 comp_unit_die (), NULL_TREE); | |
31887 add_AT_external_die_ref (import, DW_AT_import, | |
31888 desc->sym, desc->off); | |
31889 } | |
31890 } | |
31891 | |
30508 early_dwarf_finished = true; | 31892 early_dwarf_finished = true; |
31893 if (dump_file) | |
31894 { | |
31895 fprintf (dump_file, "LTO EARLY DWARF for %s\n", filename); | |
31896 print_die (comp_unit_die (), dump_file); | |
31897 } | |
30509 return; | 31898 return; |
30510 } | 31899 } |
30511 | 31900 |
30512 /* Walk through the list of incomplete types again, trying once more to | 31901 /* Walk through the list of incomplete types again, trying once more to |
30513 emit full debugging info for them. */ | 31902 emit full debugging info for them. */ |
30581 if (!dwarf_split_debug_info) | 31970 if (!dwarf_split_debug_info) |
30582 add_AT_pubnames (comp_unit_die ()); | 31971 add_AT_pubnames (comp_unit_die ()); |
30583 | 31972 |
30584 /* The early debug phase is now finished. */ | 31973 /* The early debug phase is now finished. */ |
30585 early_dwarf_finished = true; | 31974 early_dwarf_finished = true; |
31975 if (dump_file) | |
31976 { | |
31977 fprintf (dump_file, "EARLY DWARF for %s\n", filename); | |
31978 print_die (comp_unit_die (), dump_file); | |
31979 } | |
30586 | 31980 |
30587 /* Do not generate DWARF assembler now when not producing LTO bytecode. */ | 31981 /* Do not generate DWARF assembler now when not producing LTO bytecode. */ |
30588 if (!flag_generate_lto && !flag_generate_offload) | 31982 if ((!flag_generate_lto && !flag_generate_offload) |
31983 /* FIXME: Disable debug info generation for (PE-)COFF targets since the | |
31984 copy_lto_debug_sections operation of the simple object support in | |
31985 libiberty is not implemented for them yet. */ | |
31986 || TARGET_PECOFF || TARGET_COFF) | |
30589 return; | 31987 return; |
30590 | 31988 |
30591 /* Now as we are going to output for LTO initialize sections and labels | 31989 /* Now as we are going to output for LTO initialize sections and labels |
30592 to the LTO variants. We don't need a random-seed postfix as other | 31990 to the LTO variants. We don't need a random-seed postfix as other |
30593 LTO sections as linking the LTO debug sections into one in a partial | 31991 LTO sections as linking the LTO debug sections into one in a partial |
30605 add_sibling_attributes (node->die); | 32003 add_sibling_attributes (node->die); |
30606 for (comdat_type_node *ctnode = comdat_type_list; | 32004 for (comdat_type_node *ctnode = comdat_type_list; |
30607 ctnode != NULL; ctnode = ctnode->next) | 32005 ctnode != NULL; ctnode = ctnode->next) |
30608 add_sibling_attributes (ctnode->root_die); | 32006 add_sibling_attributes (ctnode->root_die); |
30609 | 32007 |
32008 /* AIX Assembler inserts the length, so adjust the reference to match the | |
32009 offset expected by debuggers. */ | |
32010 strcpy (dl_section_ref, debug_line_section_label); | |
32011 if (XCOFF_DEBUGGING_INFO) | |
32012 strcat (dl_section_ref, DWARF_INITIAL_LENGTH_SIZE_STR); | |
32013 | |
32014 if (debug_info_level >= DINFO_LEVEL_TERSE) | |
32015 add_AT_lineptr (comp_unit_die (), DW_AT_stmt_list, dl_section_ref); | |
32016 | |
30610 if (have_macinfo) | 32017 if (have_macinfo) |
30611 add_AT_macptr (comp_unit_die (), DEBUG_MACRO_ATTRIBUTE, | 32018 add_AT_macptr (comp_unit_die (), DEBUG_MACRO_ATTRIBUTE, |
30612 macinfo_section_label); | 32019 macinfo_section_label); |
30613 | 32020 |
30614 save_macinfo_strings (); | 32021 save_macinfo_strings (); |
32022 | |
32023 if (dwarf_split_debug_info) | |
32024 { | |
32025 unsigned int index = 0; | |
32026 debug_str_hash->traverse_noresize<unsigned int *, index_string> (&index); | |
32027 } | |
30615 | 32028 |
30616 /* Output all of the compilation units. We put the main one last so that | 32029 /* Output all of the compilation units. We put the main one last so that |
30617 the offsets are available to output_pubnames. */ | 32030 the offsets are available to output_pubnames. */ |
30618 for (limbo_die_node *node = limbo_die_list; node; node = node->next) | 32031 for (limbo_die_node *node = limbo_die_list; node; node = node->next) |
30619 output_comp_unit (node->die, 0, NULL); | 32032 output_comp_unit (node->die, 0, NULL); |
30665 if (flag_fat_lto_objects) | 32078 if (flag_fat_lto_objects) |
30666 macinfo_table = macinfo_table->copy (); | 32079 macinfo_table = macinfo_table->copy (); |
30667 | 32080 |
30668 switch_to_section (debug_macinfo_section); | 32081 switch_to_section (debug_macinfo_section); |
30669 ASM_OUTPUT_LABEL (asm_out_file, macinfo_section_label); | 32082 ASM_OUTPUT_LABEL (asm_out_file, macinfo_section_label); |
30670 output_macinfo (debug_skeleton_line_section_label, true); | 32083 output_macinfo (debug_line_section_label, true); |
30671 dw2_asm_output_data (1, 0, "End compilation unit"); | 32084 dw2_asm_output_data (1, 0, "End compilation unit"); |
30672 | |
30673 /* Emit a skeleton debug_line section. */ | |
30674 switch_to_section (debug_skeleton_line_section); | |
30675 ASM_OUTPUT_LABEL (asm_out_file, debug_skeleton_line_section_label); | |
30676 output_line_info (true); | |
30677 | 32085 |
30678 if (flag_fat_lto_objects) | 32086 if (flag_fat_lto_objects) |
30679 { | 32087 { |
30680 vec_free (macinfo_table); | 32088 vec_free (macinfo_table); |
30681 macinfo_table = saved_macinfo_table; | 32089 macinfo_table = saved_macinfo_table; |
30682 } | 32090 } |
30683 } | 32091 } |
30684 | 32092 |
32093 /* Emit a skeleton debug_line section. */ | |
32094 switch_to_section (debug_line_section); | |
32095 ASM_OUTPUT_LABEL (asm_out_file, debug_line_section_label); | |
32096 output_line_info (true); | |
30685 | 32097 |
30686 /* If we emitted any indirect strings, output the string table too. */ | 32098 /* If we emitted any indirect strings, output the string table too. */ |
30687 if (debug_str_hash || skeleton_debug_str_hash) | 32099 if (debug_str_hash || skeleton_debug_str_hash) |
30688 output_indirect_strings (); | 32100 output_indirect_strings (); |
32101 if (debug_line_str_hash) | |
32102 { | |
32103 switch_to_section (debug_line_str_section); | |
32104 const enum dwarf_form form = DW_FORM_line_strp; | |
32105 debug_line_str_hash->traverse<enum dwarf_form, | |
32106 output_indirect_string> (form); | |
32107 } | |
30689 | 32108 |
30690 /* Switch back to the text section. */ | 32109 /* Switch back to the text section. */ |
30691 switch_to_section (text_section); | 32110 switch_to_section (text_section); |
30692 } | 32111 } |
30693 | 32112 |
30699 { | 32118 { |
30700 last_var_location_insn = NULL; | 32119 last_var_location_insn = NULL; |
30701 cached_next_real_insn = NULL; | 32120 cached_next_real_insn = NULL; |
30702 used_rtx_array = NULL; | 32121 used_rtx_array = NULL; |
30703 incomplete_types = NULL; | 32122 incomplete_types = NULL; |
30704 decl_scope_table = NULL; | |
30705 debug_info_section = NULL; | 32123 debug_info_section = NULL; |
30706 debug_skeleton_info_section = NULL; | 32124 debug_skeleton_info_section = NULL; |
30707 debug_abbrev_section = NULL; | 32125 debug_abbrev_section = NULL; |
30708 debug_skeleton_abbrev_section = NULL; | 32126 debug_skeleton_abbrev_section = NULL; |
30709 debug_aranges_section = NULL; | 32127 debug_aranges_section = NULL; |