1 /* Output Dwarf2 format symbol table information from GCC.
2 Copyright (C) 1992, 1993, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
3 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
4 Free Software Foundation, Inc.
5 Contributed by Gary Funck (gary@intrepid.com).
6 Derived from DWARF 1 implementation of Ron Guilmette (rfg@monkeys.com).
7 Extensively modified by Jason Merrill (jason@cygnus.com).
9 This file is part of GCC.
11 GCC is free software; you can redistribute it and/or modify it under
12 the terms of the GNU General Public License as published by the Free
13 Software Foundation; either version 3, or (at your option) any later
16 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
17 WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with GCC; see the file COPYING3. If not see
23 <http://www.gnu.org/licenses/>. */
25 /* TODO: Emit .debug_line header even when there are no functions, since
26 the file numbers are used by .debug_info. Alternately, leave
27 out locations for types and decls.
28 Avoid talking about ctors and op= for PODs.
29 Factor out common prologue sequences into multiple CIEs. */
31 /* The first part of this file deals with the DWARF 2 frame unwind
32 information, which is also used by the GCC efficient exception handling
33 mechanism. The second part, controlled only by an #ifdef
34 DWARF2_DEBUGGING_INFO, deals with the other DWARF 2 debugging
37 /* DWARF2 Abbreviation Glossary:
39 CFA = Canonical Frame Address
40 a fixed address on the stack which identifies a call frame.
41 We define it to be the value of SP just before the call insn.
42 The CFA register and offset, which may change during the course
43 of the function, are used to calculate its value at runtime.
45 CFI = Call Frame Instruction
46 an instruction for the DWARF2 abstract machine
48 CIE = Common Information Entry
49 information describing information common to one or more FDEs
51 DIE = Debugging Information Entry
53 FDE = Frame Description Entry
54 information describing the stack call frame, in particular,
55 how to restore registers
57 DW_CFA_... = DWARF2 CFA call frame instruction
58 DW_TAG_... = DWARF2 DIE tag */
62 #include "coretypes.h"
68 #include "hard-reg-set.h"
70 #include "insn-config.h"
78 #include "dwarf2out.h"
79 #include "dwarf2asm.h"
84 #include "diagnostic.h"
85 #include "tree-pretty-print.h"
88 #include "common/common-target.h"
89 #include "langhooks.h"
94 #include "tree-pass.h"
95 #include "tree-flow.h"
96 #include "cfglayout.h"
99 static void dwarf2out_source_line (unsigned int, const char *, int, bool);
100 static rtx last_var_location_insn;
101 static rtx cached_next_real_insn;
103 #ifdef VMS_DEBUGGING_INFO
104 int vms_file_stats_name (const char *, long long *, long *, char *, int *);
106 /* Define this macro to be a nonzero value if the directory specifications
107 which are output in the debug info should end with a separator. */
108 #define DWARF2_DIR_SHOULD_END_WITH_SEPARATOR 1
109 /* Define this macro to evaluate to a nonzero value if GCC should refrain
110 from generating indirect strings in DWARF2 debug information, for instance
111 if your target is stuck with an old version of GDB that is unable to
112 process them properly or uses VMS Debug. */
113 #define DWARF2_INDIRECT_STRING_SUPPORT_MISSING_ON_TARGET 1
115 #define DWARF2_DIR_SHOULD_END_WITH_SEPARATOR 0
116 #define DWARF2_INDIRECT_STRING_SUPPORT_MISSING_ON_TARGET 0
119 /* ??? Poison these here until it can be done generically. They've been
120 totally replaced in this file; make sure it stays that way. */
121 #undef DWARF2_UNWIND_INFO
122 #undef DWARF2_FRAME_INFO
123 #if (GCC_VERSION >= 3000)
124 #pragma GCC poison DWARF2_UNWIND_INFO DWARF2_FRAME_INFO
127 /* The size of the target's pointer type. */
129 #define PTR_SIZE (POINTER_SIZE / BITS_PER_UNIT)
132 /* Array of RTXes referenced by the debugging information, which therefore
133 must be kept around forever. */
134 static GTY(()) VEC(rtx,gc) *used_rtx_array;
136 /* A pointer to the base of a list of incomplete types which might be
137 completed at some later time. incomplete_types_list needs to be a
138 VEC(tree,gc) because we want to tell the garbage collector about
140 static GTY(()) VEC(tree,gc) *incomplete_types;
142 /* A pointer to the base of a table of references to declaration
143 scopes. This table is a display which tracks the nesting
144 of declaration scopes at the current scope and containing
145 scopes. This table is used to find the proper place to
146 define type declaration DIE's. */
147 static GTY(()) VEC(tree,gc) *decl_scope_table;
149 /* Pointers to various DWARF2 sections. */
150 static GTY(()) section *debug_info_section;
151 static GTY(()) section *debug_abbrev_section;
152 static GTY(()) section *debug_aranges_section;
153 static GTY(()) section *debug_macinfo_section;
154 static GTY(()) section *debug_line_section;
155 static GTY(()) section *debug_loc_section;
156 static GTY(()) section *debug_pubnames_section;
157 static GTY(()) section *debug_pubtypes_section;
158 static GTY(()) section *debug_str_section;
159 static GTY(()) section *debug_ranges_section;
160 static GTY(()) section *debug_frame_section;
162 /* Maximum size (in bytes) of an artificially generated label. */
163 #define MAX_ARTIFICIAL_LABEL_BYTES 30
165 /* According to the (draft) DWARF 3 specification, the initial length
166 should either be 4 or 12 bytes. When it's 12 bytes, the first 4
167 bytes are 0xffffffff, followed by the length stored in the next 8
170 However, the SGI/MIPS ABI uses an initial length which is equal to
171 DWARF_OFFSET_SIZE. It is defined (elsewhere) accordingly. */
173 #ifndef DWARF_INITIAL_LENGTH_SIZE
174 #define DWARF_INITIAL_LENGTH_SIZE (DWARF_OFFSET_SIZE == 4 ? 4 : 12)
177 /* Round SIZE up to the nearest BOUNDARY. */
178 #define DWARF_ROUND(SIZE,BOUNDARY) \
179 ((((SIZE) + (BOUNDARY) - 1) / (BOUNDARY)) * (BOUNDARY))
181 /* CIE identifier. */
182 #if HOST_BITS_PER_WIDE_INT >= 64
183 #define DWARF_CIE_ID \
184 (unsigned HOST_WIDE_INT) (DWARF_OFFSET_SIZE == 4 ? DW_CIE_ID : DW64_CIE_ID)
186 #define DWARF_CIE_ID DW_CIE_ID
189 DEF_VEC_P (dw_fde_ref);
190 DEF_VEC_ALLOC_P (dw_fde_ref, gc);
192 /* A vector for a table that contains frame description
193 information for each routine. */
194 static GTY(()) VEC(dw_fde_ref, gc) *fde_vec;
196 struct GTY(()) indirect_string_node {
198 unsigned int refcount;
199 enum dwarf_form form;
203 static GTY ((param_is (struct indirect_string_node))) htab_t debug_str_hash;
205 static GTY(()) int dw2_string_counter;
207 /* True if the compilation unit places functions in more than one section. */
208 static GTY(()) bool have_multiple_function_sections = false;
210 /* Whether the default text and cold text sections have been used at all. */
212 static GTY(()) bool text_section_used = false;
213 static GTY(()) bool cold_text_section_used = false;
215 /* The default cold text section. */
216 static GTY(()) section *cold_text_section;
218 /* Forward declarations for functions defined in this file. */
220 static char *stripattributes (const char *);
221 static void output_call_frame_info (int);
222 static void dwarf2out_note_section_used (void);
224 /* Personality decl of current unit. Used only when assembler does not support
226 static GTY(()) rtx current_unit_personality;
228 /* Data and reference forms for relocatable data. */
229 #define DW_FORM_data (DWARF_OFFSET_SIZE == 8 ? DW_FORM_data8 : DW_FORM_data4)
230 #define DW_FORM_ref (DWARF_OFFSET_SIZE == 8 ? DW_FORM_ref8 : DW_FORM_ref4)
232 #ifndef DEBUG_FRAME_SECTION
233 #define DEBUG_FRAME_SECTION ".debug_frame"
236 #ifndef FUNC_BEGIN_LABEL
237 #define FUNC_BEGIN_LABEL "LFB"
240 #ifndef FUNC_END_LABEL
241 #define FUNC_END_LABEL "LFE"
244 #ifndef PROLOGUE_END_LABEL
245 #define PROLOGUE_END_LABEL "LPE"
248 #ifndef EPILOGUE_BEGIN_LABEL
249 #define EPILOGUE_BEGIN_LABEL "LEB"
252 #ifndef FRAME_BEGIN_LABEL
253 #define FRAME_BEGIN_LABEL "Lframe"
255 #define CIE_AFTER_SIZE_LABEL "LSCIE"
256 #define CIE_END_LABEL "LECIE"
257 #define FDE_LABEL "LSFDE"
258 #define FDE_AFTER_SIZE_LABEL "LASFDE"
259 #define FDE_END_LABEL "LEFDE"
260 #define LINE_NUMBER_BEGIN_LABEL "LSLT"
261 #define LINE_NUMBER_END_LABEL "LELT"
262 #define LN_PROLOG_AS_LABEL "LASLTP"
263 #define LN_PROLOG_END_LABEL "LELTP"
264 #define DIE_LABEL_PREFIX "DW"
266 /* Match the base name of a file to the base name of a compilation unit. */
269 matches_main_base (const char *path)
271 /* Cache the last query. */
272 static const char *last_path = NULL;
273 static int last_match = 0;
274 if (path != last_path)
277 int length = base_of_path (path, &base);
279 last_match = (length == main_input_baselength
280 && memcmp (base, main_input_basename, length) == 0);
285 #ifdef DEBUG_DEBUG_STRUCT
288 dump_struct_debug (tree type, enum debug_info_usage usage,
289 enum debug_struct_file criterion, int generic,
290 int matches, int result)
292 /* Find the type name. */
293 tree type_decl = TYPE_STUB_DECL (type);
295 const char *name = 0;
296 if (TREE_CODE (t) == TYPE_DECL)
299 name = IDENTIFIER_POINTER (t);
301 fprintf (stderr, " struct %d %s %s %s %s %d %p %s\n",
303 DECL_IN_SYSTEM_HEADER (type_decl) ? "sys" : "usr",
304 matches ? "bas" : "hdr",
305 generic ? "gen" : "ord",
306 usage == DINFO_USAGE_DFN ? ";" :
307 usage == DINFO_USAGE_DIR_USE ? "." : "*",
309 (void*) type_decl, name);
312 #define DUMP_GSTRUCT(type, usage, criterion, generic, matches, result) \
313 dump_struct_debug (type, usage, criterion, generic, matches, result)
317 #define DUMP_GSTRUCT(type, usage, criterion, generic, matches, result) \
323 should_emit_struct_debug (tree type, enum debug_info_usage usage)
325 enum debug_struct_file criterion;
327 bool generic = lang_hooks.types.generic_p (type);
330 criterion = debug_struct_generic[usage];
332 criterion = debug_struct_ordinary[usage];
334 if (criterion == DINFO_STRUCT_FILE_NONE)
335 return DUMP_GSTRUCT (type, usage, criterion, generic, false, false);
336 if (criterion == DINFO_STRUCT_FILE_ANY)
337 return DUMP_GSTRUCT (type, usage, criterion, generic, false, true);
339 type_decl = TYPE_STUB_DECL (TYPE_MAIN_VARIANT (type));
341 if (criterion == DINFO_STRUCT_FILE_SYS && DECL_IN_SYSTEM_HEADER (type_decl))
342 return DUMP_GSTRUCT (type, usage, criterion, generic, false, true);
344 if (matches_main_base (DECL_SOURCE_FILE (type_decl)))
345 return DUMP_GSTRUCT (type, usage, criterion, generic, true, true);
346 return DUMP_GSTRUCT (type, usage, criterion, generic, false, false);
349 /* Return a pointer to a copy of the section string name S with all
350 attributes stripped off, and an asterisk prepended (for assemble_name). */
353 stripattributes (const char *s)
355 char *stripped = XNEWVEC (char, strlen (s) + 2);
360 while (*s && *s != ',')
367 /* Switch [BACK] to eh_frame_section. If we don't have an eh_frame_section,
368 switch to the data section instead, and write out a synthetic start label
369 for collect2 the first time around. */
372 switch_to_eh_frame_section (bool back)
376 #ifdef EH_FRAME_SECTION_NAME
377 if (eh_frame_section == 0)
381 if (EH_TABLES_CAN_BE_READ_ONLY)
387 fde_encoding = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/1,
389 per_encoding = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/2,
391 lsda_encoding = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/0,
394 || ((fde_encoding & 0x70) != DW_EH_PE_absptr
395 && (fde_encoding & 0x70) != DW_EH_PE_aligned
396 && (per_encoding & 0x70) != DW_EH_PE_absptr
397 && (per_encoding & 0x70) != DW_EH_PE_aligned
398 && (lsda_encoding & 0x70) != DW_EH_PE_absptr
399 && (lsda_encoding & 0x70) != DW_EH_PE_aligned))
400 ? 0 : SECTION_WRITE);
403 flags = SECTION_WRITE;
404 eh_frame_section = get_section (EH_FRAME_SECTION_NAME, flags, NULL);
406 #endif /* EH_FRAME_SECTION_NAME */
408 if (eh_frame_section)
409 switch_to_section (eh_frame_section);
412 /* We have no special eh_frame section. Put the information in
413 the data section and emit special labels to guide collect2. */
414 switch_to_section (data_section);
418 label = get_file_function_name ("F");
419 ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (PTR_SIZE));
420 targetm.asm_out.globalize_label (asm_out_file,
421 IDENTIFIER_POINTER (label));
422 ASM_OUTPUT_LABEL (asm_out_file, IDENTIFIER_POINTER (label));
427 /* Switch [BACK] to the eh or debug frame table section, depending on
431 switch_to_frame_table_section (int for_eh, bool back)
434 switch_to_eh_frame_section (back);
437 if (!debug_frame_section)
438 debug_frame_section = get_section (DEBUG_FRAME_SECTION,
439 SECTION_DEBUG, NULL);
440 switch_to_section (debug_frame_section);
444 /* Describe for the GTY machinery what parts of dw_cfi_oprnd1 are used. */
446 enum dw_cfi_oprnd_type
447 dw_cfi_oprnd1_desc (enum dwarf_call_frame_info cfi)
452 case DW_CFA_GNU_window_save:
453 case DW_CFA_remember_state:
454 case DW_CFA_restore_state:
455 return dw_cfi_oprnd_unused;
458 case DW_CFA_advance_loc1:
459 case DW_CFA_advance_loc2:
460 case DW_CFA_advance_loc4:
461 case DW_CFA_MIPS_advance_loc8:
462 return dw_cfi_oprnd_addr;
465 case DW_CFA_offset_extended:
467 case DW_CFA_offset_extended_sf:
468 case DW_CFA_def_cfa_sf:
470 case DW_CFA_restore_extended:
471 case DW_CFA_undefined:
472 case DW_CFA_same_value:
473 case DW_CFA_def_cfa_register:
474 case DW_CFA_register:
475 case DW_CFA_expression:
476 return dw_cfi_oprnd_reg_num;
478 case DW_CFA_def_cfa_offset:
479 case DW_CFA_GNU_args_size:
480 case DW_CFA_def_cfa_offset_sf:
481 return dw_cfi_oprnd_offset;
483 case DW_CFA_def_cfa_expression:
484 return dw_cfi_oprnd_loc;
491 /* Describe for the GTY machinery what parts of dw_cfi_oprnd2 are used. */
493 enum dw_cfi_oprnd_type
494 dw_cfi_oprnd2_desc (enum dwarf_call_frame_info cfi)
499 case DW_CFA_def_cfa_sf:
501 case DW_CFA_offset_extended_sf:
502 case DW_CFA_offset_extended:
503 return dw_cfi_oprnd_offset;
505 case DW_CFA_register:
506 return dw_cfi_oprnd_reg_num;
508 case DW_CFA_expression:
509 return dw_cfi_oprnd_loc;
512 return dw_cfi_oprnd_unused;
516 /* Output one FDE. */
519 output_fde (dw_fde_ref fde, bool for_eh, bool second,
520 char *section_start_label, int fde_encoding, char *augmentation,
521 bool any_lsda_needed, int lsda_encoding)
523 const char *begin, *end;
524 static unsigned int j;
527 targetm.asm_out.emit_unwind_label (asm_out_file, fde->decl, for_eh,
529 targetm.asm_out.internal_label (asm_out_file, FDE_LABEL,
531 ASM_GENERATE_INTERNAL_LABEL (l1, FDE_AFTER_SIZE_LABEL, for_eh + j);
532 ASM_GENERATE_INTERNAL_LABEL (l2, FDE_END_LABEL, for_eh + j);
533 if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4 && !for_eh)
534 dw2_asm_output_data (4, 0xffffffff, "Initial length escape value"
535 " indicating 64-bit DWARF extension");
536 dw2_asm_output_delta (for_eh ? 4 : DWARF_OFFSET_SIZE, l2, l1,
538 ASM_OUTPUT_LABEL (asm_out_file, l1);
541 dw2_asm_output_delta (4, l1, section_start_label, "FDE CIE offset");
543 dw2_asm_output_offset (DWARF_OFFSET_SIZE, section_start_label,
544 debug_frame_section, "FDE CIE offset");
546 begin = second ? fde->dw_fde_second_begin : fde->dw_fde_begin;
547 end = second ? fde->dw_fde_second_end : fde->dw_fde_end;
551 rtx sym_ref = gen_rtx_SYMBOL_REF (Pmode, begin);
552 SYMBOL_REF_FLAGS (sym_ref) |= SYMBOL_FLAG_LOCAL;
553 dw2_asm_output_encoded_addr_rtx (fde_encoding, sym_ref, false,
554 "FDE initial location");
555 dw2_asm_output_delta (size_of_encoded_value (fde_encoding),
556 end, begin, "FDE address range");
560 dw2_asm_output_addr (DWARF2_ADDR_SIZE, begin, "FDE initial location");
561 dw2_asm_output_delta (DWARF2_ADDR_SIZE, end, begin, "FDE address range");
568 int size = size_of_encoded_value (lsda_encoding);
570 if (lsda_encoding == DW_EH_PE_aligned)
572 int offset = ( 4 /* Length */
574 + 2 * size_of_encoded_value (fde_encoding)
575 + 1 /* Augmentation size */ );
576 int pad = -offset & (PTR_SIZE - 1);
579 gcc_assert (size_of_uleb128 (size) == 1);
582 dw2_asm_output_data_uleb128 (size, "Augmentation size");
584 if (fde->uses_eh_lsda)
586 ASM_GENERATE_INTERNAL_LABEL (l1, second ? "LLSDAC" : "LLSDA",
587 fde->funcdef_number);
588 dw2_asm_output_encoded_addr_rtx (lsda_encoding,
589 gen_rtx_SYMBOL_REF (Pmode, l1),
591 "Language Specific Data Area");
595 if (lsda_encoding == DW_EH_PE_aligned)
596 ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (PTR_SIZE));
597 dw2_asm_output_data (size_of_encoded_value (lsda_encoding), 0,
598 "Language Specific Data Area (none)");
602 dw2_asm_output_data_uleb128 (0, "Augmentation size");
605 /* Loop through the Call Frame Instructions associated with this FDE. */
606 fde->dw_fde_current_label = begin;
608 size_t from, until, i;
611 until = VEC_length (dw_cfi_ref, fde->dw_fde_cfi);
613 if (fde->dw_fde_second_begin == NULL)
616 until = fde->dw_fde_switch_cfi_index;
618 from = fde->dw_fde_switch_cfi_index;
620 for (i = from; i < until; i++)
621 output_cfi (VEC_index (dw_cfi_ref, fde->dw_fde_cfi, i), fde, for_eh);
624 /* If we are to emit a ref/link from function bodies to their frame tables,
625 do it now. This is typically performed to make sure that tables
626 associated with functions are dragged with them and not discarded in
627 garbage collecting links. We need to do this on a per function basis to
628 cope with -ffunction-sections. */
630 #ifdef ASM_OUTPUT_DWARF_TABLE_REF
631 /* Switch to the function section, emit the ref to the tables, and
632 switch *back* into the table section. */
633 switch_to_section (function_section (fde->decl));
634 ASM_OUTPUT_DWARF_TABLE_REF (section_start_label);
635 switch_to_frame_table_section (for_eh, true);
638 /* Pad the FDE out to an address sized boundary. */
639 ASM_OUTPUT_ALIGN (asm_out_file,
640 floor_log2 ((for_eh ? PTR_SIZE : DWARF2_ADDR_SIZE)));
641 ASM_OUTPUT_LABEL (asm_out_file, l2);
646 /* Return true if frame description entry FDE is needed for EH. */
649 fde_needed_for_eh_p (dw_fde_ref fde)
651 if (flag_asynchronous_unwind_tables)
654 if (TARGET_USES_WEAK_UNWIND_INFO && DECL_WEAK (fde->decl))
657 if (fde->uses_eh_lsda)
660 /* If exceptions are enabled, we have collected nothrow info. */
661 if (flag_exceptions && (fde->all_throwers_are_sibcalls || fde->nothrow))
667 /* Output the call frame information used to record information
668 that relates to calculating the frame pointer, and records the
669 location of saved registers. */
672 output_call_frame_info (int for_eh)
677 char l1[20], l2[20], section_start_label[20];
678 bool any_lsda_needed = false;
679 char augmentation[6];
680 int augmentation_size;
681 int fde_encoding = DW_EH_PE_absptr;
682 int per_encoding = DW_EH_PE_absptr;
683 int lsda_encoding = DW_EH_PE_absptr;
685 rtx personality = NULL;
688 /* Don't emit a CIE if there won't be any FDEs. */
692 /* Nothing to do if the assembler's doing it all. */
693 if (dwarf2out_do_cfi_asm ())
696 /* If we don't have any functions we'll want to unwind out of, don't emit
697 any EH unwind information. If we make FDEs linkonce, we may have to
698 emit an empty label for an FDE that wouldn't otherwise be emitted. We
699 want to avoid having an FDE kept around when the function it refers to
700 is discarded. Example where this matters: a primary function template
701 in C++ requires EH information, an explicit specialization doesn't. */
704 bool any_eh_needed = false;
706 FOR_EACH_VEC_ELT (dw_fde_ref, fde_vec, i, fde)
708 if (fde->uses_eh_lsda)
709 any_eh_needed = any_lsda_needed = true;
710 else if (fde_needed_for_eh_p (fde))
711 any_eh_needed = true;
712 else if (TARGET_USES_WEAK_UNWIND_INFO)
713 targetm.asm_out.emit_unwind_label (asm_out_file, fde->decl, 1, 1);
720 /* We're going to be generating comments, so turn on app. */
724 /* Switch to the proper frame section, first time. */
725 switch_to_frame_table_section (for_eh, false);
727 ASM_GENERATE_INTERNAL_LABEL (section_start_label, FRAME_BEGIN_LABEL, for_eh);
728 ASM_OUTPUT_LABEL (asm_out_file, section_start_label);
730 /* Output the CIE. */
731 ASM_GENERATE_INTERNAL_LABEL (l1, CIE_AFTER_SIZE_LABEL, for_eh);
732 ASM_GENERATE_INTERNAL_LABEL (l2, CIE_END_LABEL, for_eh);
733 if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4 && !for_eh)
734 dw2_asm_output_data (4, 0xffffffff,
735 "Initial length escape value indicating 64-bit DWARF extension");
736 dw2_asm_output_delta (for_eh ? 4 : DWARF_OFFSET_SIZE, l2, l1,
737 "Length of Common Information Entry");
738 ASM_OUTPUT_LABEL (asm_out_file, l1);
740 /* Now that the CIE pointer is PC-relative for EH,
741 use 0 to identify the CIE. */
742 dw2_asm_output_data ((for_eh ? 4 : DWARF_OFFSET_SIZE),
743 (for_eh ? 0 : DWARF_CIE_ID),
744 "CIE Identifier Tag");
746 /* Use the CIE version 3 for DWARF3; allow DWARF2 to continue to
747 use CIE version 1, unless that would produce incorrect results
748 due to overflowing the return register column. */
749 return_reg = DWARF2_FRAME_REG_OUT (DWARF_FRAME_RETURN_COLUMN, for_eh);
751 if (return_reg >= 256 || dwarf_version > 2)
753 dw2_asm_output_data (1, dw_cie_version, "CIE Version");
756 augmentation_size = 0;
758 personality = current_unit_personality;
764 z Indicates that a uleb128 is present to size the
765 augmentation section.
766 L Indicates the encoding (and thus presence) of
767 an LSDA pointer in the FDE augmentation.
768 R Indicates a non-default pointer encoding for
770 P Indicates the presence of an encoding + language
771 personality routine in the CIE augmentation. */
773 fde_encoding = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/1, /*global=*/0);
774 per_encoding = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/2, /*global=*/1);
775 lsda_encoding = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/0, /*global=*/0);
777 p = augmentation + 1;
781 augmentation_size += 1 + size_of_encoded_value (per_encoding);
782 assemble_external_libcall (personality);
787 augmentation_size += 1;
789 if (fde_encoding != DW_EH_PE_absptr)
792 augmentation_size += 1;
794 if (p > augmentation + 1)
796 augmentation[0] = 'z';
800 /* Ug. Some platforms can't do unaligned dynamic relocations at all. */
801 if (personality && per_encoding == DW_EH_PE_aligned)
803 int offset = ( 4 /* Length */
805 + 1 /* CIE version */
806 + strlen (augmentation) + 1 /* Augmentation */
807 + size_of_uleb128 (1) /* Code alignment */
808 + size_of_sleb128 (DWARF_CIE_DATA_ALIGNMENT)
810 + 1 /* Augmentation size */
811 + 1 /* Personality encoding */ );
812 int pad = -offset & (PTR_SIZE - 1);
814 augmentation_size += pad;
816 /* Augmentations should be small, so there's scarce need to
817 iterate for a solution. Die if we exceed one uleb128 byte. */
818 gcc_assert (size_of_uleb128 (augmentation_size) == 1);
822 dw2_asm_output_nstring (augmentation, -1, "CIE Augmentation");
823 if (dw_cie_version >= 4)
825 dw2_asm_output_data (1, DWARF2_ADDR_SIZE, "CIE Address Size");
826 dw2_asm_output_data (1, 0, "CIE Segment Size");
828 dw2_asm_output_data_uleb128 (1, "CIE Code Alignment Factor");
829 dw2_asm_output_data_sleb128 (DWARF_CIE_DATA_ALIGNMENT,
830 "CIE Data Alignment Factor");
832 if (dw_cie_version == 1)
833 dw2_asm_output_data (1, return_reg, "CIE RA Column");
835 dw2_asm_output_data_uleb128 (return_reg, "CIE RA Column");
839 dw2_asm_output_data_uleb128 (augmentation_size, "Augmentation size");
842 dw2_asm_output_data (1, per_encoding, "Personality (%s)",
843 eh_data_format_name (per_encoding));
844 dw2_asm_output_encoded_addr_rtx (per_encoding,
850 dw2_asm_output_data (1, lsda_encoding, "LSDA Encoding (%s)",
851 eh_data_format_name (lsda_encoding));
853 if (fde_encoding != DW_EH_PE_absptr)
854 dw2_asm_output_data (1, fde_encoding, "FDE Encoding (%s)",
855 eh_data_format_name (fde_encoding));
858 FOR_EACH_VEC_ELT (dw_cfi_ref, cie_cfi_vec, i, cfi)
859 output_cfi (cfi, NULL, for_eh);
861 /* Pad the CIE out to an address sized boundary. */
862 ASM_OUTPUT_ALIGN (asm_out_file,
863 floor_log2 (for_eh ? PTR_SIZE : DWARF2_ADDR_SIZE));
864 ASM_OUTPUT_LABEL (asm_out_file, l2);
866 /* Loop through all of the FDE's. */
867 FOR_EACH_VEC_ELT (dw_fde_ref, fde_vec, i, fde)
871 /* Don't emit EH unwind info for leaf functions that don't need it. */
872 if (for_eh && !fde_needed_for_eh_p (fde))
875 for (k = 0; k < (fde->dw_fde_second_begin ? 2 : 1); k++)
876 output_fde (fde, for_eh, k, section_start_label, fde_encoding,
877 augmentation, any_lsda_needed, lsda_encoding);
880 if (for_eh && targetm.terminate_dw2_eh_frame_info)
881 dw2_asm_output_data (4, 0, "End of Table");
882 #ifdef MIPS_DEBUGGING_INFO
883 /* Work around Irix 6 assembler bug whereby labels at the end of a section
884 get a value of 0. Putting .align 0 after the label fixes it. */
885 ASM_OUTPUT_ALIGN (asm_out_file, 0);
888 /* Turn off app to make assembly quicker. */
893 /* Emit .cfi_startproc and .cfi_personality/.cfi_lsda if needed. */
896 dwarf2out_do_cfi_startproc (bool second)
900 rtx personality = get_personality_function (current_function_decl);
902 fprintf (asm_out_file, "\t.cfi_startproc\n");
906 enc = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/2, /*global=*/1);
909 /* ??? The GAS support isn't entirely consistent. We have to
910 handle indirect support ourselves, but PC-relative is done
911 in the assembler. Further, the assembler can't handle any
912 of the weirder relocation types. */
913 if (enc & DW_EH_PE_indirect)
914 ref = dw2_force_const_mem (ref, true);
916 fprintf (asm_out_file, "\t.cfi_personality %#x,", enc);
917 output_addr_const (asm_out_file, ref);
918 fputc ('\n', asm_out_file);
921 if (crtl->uses_eh_lsda)
925 enc = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/0, /*global=*/0);
926 ASM_GENERATE_INTERNAL_LABEL (lab, second ? "LLSDAC" : "LLSDA",
927 current_function_funcdef_no);
928 ref = gen_rtx_SYMBOL_REF (Pmode, lab);
929 SYMBOL_REF_FLAGS (ref) = SYMBOL_FLAG_LOCAL;
931 if (enc & DW_EH_PE_indirect)
932 ref = dw2_force_const_mem (ref, true);
934 fprintf (asm_out_file, "\t.cfi_lsda %#x,", enc);
935 output_addr_const (asm_out_file, ref);
936 fputc ('\n', asm_out_file);
940 /* Allocate CURRENT_FDE. Immediately initialize all we can, noting that
941 this allocation may be done before pass_final. */
944 dwarf2out_alloc_current_fde (void)
948 fde = ggc_alloc_cleared_dw_fde_node ();
949 fde->decl = current_function_decl;
950 fde->funcdef_number = current_function_funcdef_no;
951 fde->fde_index = VEC_length (dw_fde_ref, fde_vec);
952 fde->all_throwers_are_sibcalls = crtl->all_throwers_are_sibcalls;
953 fde->uses_eh_lsda = crtl->uses_eh_lsda;
954 fde->nothrow = crtl->nothrow;
955 fde->drap_reg = INVALID_REGNUM;
956 fde->vdrap_reg = INVALID_REGNUM;
958 /* Record the FDE associated with this function. */
960 VEC_safe_push (dw_fde_ref, gc, fde_vec, fde);
965 /* Output a marker (i.e. a label) for the beginning of a function, before
969 dwarf2out_begin_prologue (unsigned int line ATTRIBUTE_UNUSED,
970 const char *file ATTRIBUTE_UNUSED)
972 char label[MAX_ARTIFICIAL_LABEL_BYTES];
978 current_function_func_begin_label = NULL;
980 do_frame = dwarf2out_do_frame ();
982 /* ??? current_function_func_begin_label is also used by except.c for
983 call-site information. We must emit this label if it might be used. */
986 || targetm_common.except_unwind_info (&global_options) != UI_TARGET))
989 fnsec = function_section (current_function_decl);
990 switch_to_section (fnsec);
991 ASM_GENERATE_INTERNAL_LABEL (label, FUNC_BEGIN_LABEL,
992 current_function_funcdef_no);
993 ASM_OUTPUT_DEBUG_LABEL (asm_out_file, FUNC_BEGIN_LABEL,
994 current_function_funcdef_no);
995 dup_label = xstrdup (label);
996 current_function_func_begin_label = dup_label;
998 /* We can elide the fde allocation if we're not emitting debug info. */
1002 /* Cater to the various TARGET_ASM_OUTPUT_MI_THUNK implementations that
1003 emit insns as rtx but bypass the bulk of rest_of_compilation, which
1004 would include pass_dwarf2_frame. If we've not created the FDE yet,
1008 fde = dwarf2out_alloc_current_fde ();
1010 /* Initialize the bits of CURRENT_FDE that were not available earlier. */
1011 fde->dw_fde_begin = dup_label;
1012 fde->dw_fde_current_label = dup_label;
1013 fde->in_std_section = (fnsec == text_section
1014 || (cold_text_section && fnsec == cold_text_section));
1016 /* We only want to output line number information for the genuine dwarf2
1017 prologue case, not the eh frame case. */
1018 #ifdef DWARF2_DEBUGGING_INFO
1020 dwarf2out_source_line (line, file, 0, true);
1023 if (dwarf2out_do_cfi_asm ())
1024 dwarf2out_do_cfi_startproc (false);
1027 rtx personality = get_personality_function (current_function_decl);
1028 if (!current_unit_personality)
1029 current_unit_personality = personality;
1031 /* We cannot keep a current personality per function as without CFI
1032 asm, at the point where we emit the CFI data, there is no current
1033 function anymore. */
1034 if (personality && current_unit_personality != personality)
1035 sorry ("multiple EH personalities are supported only with assemblers "
1036 "supporting .cfi_personality directive");
1040 /* Output a marker (i.e. a label) for the end of the generated code
1041 for a function prologue. This gets called *after* the prologue code has
1045 dwarf2out_vms_end_prologue (unsigned int line ATTRIBUTE_UNUSED,
1046 const char *file ATTRIBUTE_UNUSED)
1048 char label[MAX_ARTIFICIAL_LABEL_BYTES];
1050 /* Output a label to mark the endpoint of the code generated for this
1052 ASM_GENERATE_INTERNAL_LABEL (label, PROLOGUE_END_LABEL,
1053 current_function_funcdef_no);
1054 ASM_OUTPUT_DEBUG_LABEL (asm_out_file, PROLOGUE_END_LABEL,
1055 current_function_funcdef_no);
1056 cfun->fde->dw_fde_vms_end_prologue = xstrdup (label);
1059 /* Output a marker (i.e. a label) for the beginning of the generated code
1060 for a function epilogue. This gets called *before* the prologue code has
1064 dwarf2out_vms_begin_epilogue (unsigned int line ATTRIBUTE_UNUSED,
1065 const char *file ATTRIBUTE_UNUSED)
1067 dw_fde_ref fde = cfun->fde;
1068 char label[MAX_ARTIFICIAL_LABEL_BYTES];
1070 if (fde->dw_fde_vms_begin_epilogue)
1073 /* Output a label to mark the endpoint of the code generated for this
1075 ASM_GENERATE_INTERNAL_LABEL (label, EPILOGUE_BEGIN_LABEL,
1076 current_function_funcdef_no);
1077 ASM_OUTPUT_DEBUG_LABEL (asm_out_file, EPILOGUE_BEGIN_LABEL,
1078 current_function_funcdef_no);
1079 fde->dw_fde_vms_begin_epilogue = xstrdup (label);
1082 /* Output a marker (i.e. a label) for the absolute end of the generated code
1083 for a function definition. This gets called *after* the epilogue code has
1087 dwarf2out_end_epilogue (unsigned int line ATTRIBUTE_UNUSED,
1088 const char *file ATTRIBUTE_UNUSED)
1091 char label[MAX_ARTIFICIAL_LABEL_BYTES];
1093 last_var_location_insn = NULL_RTX;
1094 cached_next_real_insn = NULL_RTX;
1096 if (dwarf2out_do_cfi_asm ())
1097 fprintf (asm_out_file, "\t.cfi_endproc\n");
1099 /* Output a label to mark the endpoint of the code generated for this
1101 ASM_GENERATE_INTERNAL_LABEL (label, FUNC_END_LABEL,
1102 current_function_funcdef_no);
1103 ASM_OUTPUT_LABEL (asm_out_file, label);
1105 gcc_assert (fde != NULL);
1106 if (fde->dw_fde_second_begin == NULL)
1107 fde->dw_fde_end = xstrdup (label);
1111 dwarf2out_frame_finish (void)
1113 /* Output call frame information. */
1114 if (targetm.debug_unwind_info () == UI_DWARF2)
1115 output_call_frame_info (0);
1117 /* Output another copy for the unwinder. */
1118 if ((flag_unwind_tables || flag_exceptions)
1119 && targetm_common.except_unwind_info (&global_options) == UI_DWARF2)
1120 output_call_frame_info (1);
1123 /* Note that the current function section is being used for code. */
1126 dwarf2out_note_section_used (void)
1128 section *sec = current_function_section ();
1129 if (sec == text_section)
1130 text_section_used = true;
1131 else if (sec == cold_text_section)
1132 cold_text_section_used = true;
1135 static void var_location_switch_text_section (void);
1136 static void set_cur_line_info_table (section *);
1139 dwarf2out_switch_text_section (void)
1142 dw_fde_ref fde = cfun->fde;
1144 gcc_assert (cfun && fde && fde->dw_fde_second_begin == NULL);
1146 if (!in_cold_section_p)
1148 fde->dw_fde_end = crtl->subsections.cold_section_end_label;
1149 fde->dw_fde_second_begin = crtl->subsections.hot_section_label;
1150 fde->dw_fde_second_end = crtl->subsections.hot_section_end_label;
1154 fde->dw_fde_end = crtl->subsections.hot_section_end_label;
1155 fde->dw_fde_second_begin = crtl->subsections.cold_section_label;
1156 fde->dw_fde_second_end = crtl->subsections.cold_section_end_label;
1158 have_multiple_function_sections = true;
1160 /* There is no need to mark used sections when not debugging. */
1161 if (cold_text_section != NULL)
1162 dwarf2out_note_section_used ();
1164 if (dwarf2out_do_cfi_asm ())
1165 fprintf (asm_out_file, "\t.cfi_endproc\n");
1167 /* Now do the real section switch. */
1168 sect = current_function_section ();
1169 switch_to_section (sect);
1171 fde->second_in_std_section
1172 = (sect == text_section
1173 || (cold_text_section && sect == cold_text_section));
1175 if (dwarf2out_do_cfi_asm ())
1176 dwarf2out_do_cfi_startproc (true);
1178 var_location_switch_text_section ();
1180 set_cur_line_info_table (sect);
1183 /* And now, the subset of the debugging information support code necessary
1184 for emitting location expressions. */
1186 /* Data about a single source file. */
1187 struct GTY(()) dwarf_file_data {
1188 const char * filename;
1192 typedef struct GTY(()) deferred_locations_struct
1196 } deferred_locations;
1198 DEF_VEC_O(deferred_locations);
1199 DEF_VEC_ALLOC_O(deferred_locations,gc);
1201 static GTY(()) VEC(deferred_locations, gc) *deferred_locations_list;
1203 DEF_VEC_P(dw_die_ref);
1204 DEF_VEC_ALLOC_P(dw_die_ref,heap);
1206 /* Location lists are ranges + location descriptions for that range,
1207 so you can track variables that are in different places over
1208 their entire life. */
1209 typedef struct GTY(()) dw_loc_list_struct {
1210 dw_loc_list_ref dw_loc_next;
1211 const char *begin; /* Label for begin address of range */
1212 const char *end; /* Label for end address of range */
1213 char *ll_symbol; /* Label for beginning of location list.
1214 Only on head of list */
1215 const char *section; /* Section this loclist is relative to */
1216 dw_loc_descr_ref expr;
1218 /* True if all addresses in this and subsequent lists are known to be
1221 /* True if this list has been replaced by dw_loc_next. */
1224 /* True if the range should be emitted even if begin and end
1229 static dw_loc_descr_ref int_loc_descriptor (HOST_WIDE_INT);
1231 /* Convert a DWARF stack opcode into its string name. */
1234 dwarf_stack_op_name (unsigned int op)
1239 return "DW_OP_addr";
1241 return "DW_OP_deref";
1243 return "DW_OP_const1u";
1245 return "DW_OP_const1s";
1247 return "DW_OP_const2u";
1249 return "DW_OP_const2s";
1251 return "DW_OP_const4u";
1253 return "DW_OP_const4s";
1255 return "DW_OP_const8u";
1257 return "DW_OP_const8s";
1259 return "DW_OP_constu";
1261 return "DW_OP_consts";
1265 return "DW_OP_drop";
1267 return "DW_OP_over";
1269 return "DW_OP_pick";
1271 return "DW_OP_swap";
1275 return "DW_OP_xderef";
1283 return "DW_OP_minus";
1295 return "DW_OP_plus";
1296 case DW_OP_plus_uconst:
1297 return "DW_OP_plus_uconst";
1303 return "DW_OP_shra";
1321 return "DW_OP_skip";
1323 return "DW_OP_lit0";
1325 return "DW_OP_lit1";
1327 return "DW_OP_lit2";
1329 return "DW_OP_lit3";
1331 return "DW_OP_lit4";
1333 return "DW_OP_lit5";
1335 return "DW_OP_lit6";
1337 return "DW_OP_lit7";
1339 return "DW_OP_lit8";
1341 return "DW_OP_lit9";
1343 return "DW_OP_lit10";
1345 return "DW_OP_lit11";
1347 return "DW_OP_lit12";
1349 return "DW_OP_lit13";
1351 return "DW_OP_lit14";
1353 return "DW_OP_lit15";
1355 return "DW_OP_lit16";
1357 return "DW_OP_lit17";
1359 return "DW_OP_lit18";
1361 return "DW_OP_lit19";
1363 return "DW_OP_lit20";
1365 return "DW_OP_lit21";
1367 return "DW_OP_lit22";
1369 return "DW_OP_lit23";
1371 return "DW_OP_lit24";
1373 return "DW_OP_lit25";
1375 return "DW_OP_lit26";
1377 return "DW_OP_lit27";
1379 return "DW_OP_lit28";
1381 return "DW_OP_lit29";
1383 return "DW_OP_lit30";
1385 return "DW_OP_lit31";
1387 return "DW_OP_reg0";
1389 return "DW_OP_reg1";
1391 return "DW_OP_reg2";
1393 return "DW_OP_reg3";
1395 return "DW_OP_reg4";
1397 return "DW_OP_reg5";
1399 return "DW_OP_reg6";
1401 return "DW_OP_reg7";
1403 return "DW_OP_reg8";
1405 return "DW_OP_reg9";
1407 return "DW_OP_reg10";
1409 return "DW_OP_reg11";
1411 return "DW_OP_reg12";
1413 return "DW_OP_reg13";
1415 return "DW_OP_reg14";
1417 return "DW_OP_reg15";
1419 return "DW_OP_reg16";
1421 return "DW_OP_reg17";
1423 return "DW_OP_reg18";
1425 return "DW_OP_reg19";
1427 return "DW_OP_reg20";
1429 return "DW_OP_reg21";
1431 return "DW_OP_reg22";
1433 return "DW_OP_reg23";
1435 return "DW_OP_reg24";
1437 return "DW_OP_reg25";
1439 return "DW_OP_reg26";
1441 return "DW_OP_reg27";
1443 return "DW_OP_reg28";
1445 return "DW_OP_reg29";
1447 return "DW_OP_reg30";
1449 return "DW_OP_reg31";
1451 return "DW_OP_breg0";
1453 return "DW_OP_breg1";
1455 return "DW_OP_breg2";
1457 return "DW_OP_breg3";
1459 return "DW_OP_breg4";
1461 return "DW_OP_breg5";
1463 return "DW_OP_breg6";
1465 return "DW_OP_breg7";
1467 return "DW_OP_breg8";
1469 return "DW_OP_breg9";
1471 return "DW_OP_breg10";
1473 return "DW_OP_breg11";
1475 return "DW_OP_breg12";
1477 return "DW_OP_breg13";
1479 return "DW_OP_breg14";
1481 return "DW_OP_breg15";
1483 return "DW_OP_breg16";
1485 return "DW_OP_breg17";
1487 return "DW_OP_breg18";
1489 return "DW_OP_breg19";
1491 return "DW_OP_breg20";
1493 return "DW_OP_breg21";
1495 return "DW_OP_breg22";
1497 return "DW_OP_breg23";
1499 return "DW_OP_breg24";
1501 return "DW_OP_breg25";
1503 return "DW_OP_breg26";
1505 return "DW_OP_breg27";
1507 return "DW_OP_breg28";
1509 return "DW_OP_breg29";
1511 return "DW_OP_breg30";
1513 return "DW_OP_breg31";
1515 return "DW_OP_regx";
1517 return "DW_OP_fbreg";
1519 return "DW_OP_bregx";
1521 return "DW_OP_piece";
1522 case DW_OP_deref_size:
1523 return "DW_OP_deref_size";
1524 case DW_OP_xderef_size:
1525 return "DW_OP_xderef_size";
1529 case DW_OP_push_object_address:
1530 return "DW_OP_push_object_address";
1532 return "DW_OP_call2";
1534 return "DW_OP_call4";
1535 case DW_OP_call_ref:
1536 return "DW_OP_call_ref";
1537 case DW_OP_implicit_value:
1538 return "DW_OP_implicit_value";
1539 case DW_OP_stack_value:
1540 return "DW_OP_stack_value";
1541 case DW_OP_form_tls_address:
1542 return "DW_OP_form_tls_address";
1543 case DW_OP_call_frame_cfa:
1544 return "DW_OP_call_frame_cfa";
1545 case DW_OP_bit_piece:
1546 return "DW_OP_bit_piece";
1548 case DW_OP_GNU_push_tls_address:
1549 return "DW_OP_GNU_push_tls_address";
1550 case DW_OP_GNU_uninit:
1551 return "DW_OP_GNU_uninit";
1552 case DW_OP_GNU_encoded_addr:
1553 return "DW_OP_GNU_encoded_addr";
1554 case DW_OP_GNU_implicit_pointer:
1555 return "DW_OP_GNU_implicit_pointer";
1556 case DW_OP_GNU_entry_value:
1557 return "DW_OP_GNU_entry_value";
1558 case DW_OP_GNU_const_type:
1559 return "DW_OP_GNU_const_type";
1560 case DW_OP_GNU_regval_type:
1561 return "DW_OP_GNU_regval_type";
1562 case DW_OP_GNU_deref_type:
1563 return "DW_OP_GNU_deref_type";
1564 case DW_OP_GNU_convert:
1565 return "DW_OP_GNU_convert";
1566 case DW_OP_GNU_reinterpret:
1567 return "DW_OP_GNU_reinterpret";
1568 case DW_OP_GNU_parameter_ref:
1569 return "DW_OP_GNU_parameter_ref";
1572 return "OP_<unknown>";
1576 /* Return a pointer to a newly allocated location description. Location
1577 descriptions are simple expression terms that can be strung
1578 together to form more complicated location (address) descriptions. */
1580 static inline dw_loc_descr_ref
1581 new_loc_descr (enum dwarf_location_atom op, unsigned HOST_WIDE_INT oprnd1,
1582 unsigned HOST_WIDE_INT oprnd2)
1584 dw_loc_descr_ref descr = ggc_alloc_cleared_dw_loc_descr_node ();
1586 descr->dw_loc_opc = op;
1587 descr->dw_loc_oprnd1.val_class = dw_val_class_unsigned_const;
1588 descr->dw_loc_oprnd1.v.val_unsigned = oprnd1;
1589 descr->dw_loc_oprnd2.val_class = dw_val_class_unsigned_const;
1590 descr->dw_loc_oprnd2.v.val_unsigned = oprnd2;
1595 /* Return a pointer to a newly allocated location description for
1598 static inline dw_loc_descr_ref
1599 new_reg_loc_descr (unsigned int reg, unsigned HOST_WIDE_INT offset)
1602 return new_loc_descr ((enum dwarf_location_atom) (DW_OP_breg0 + reg),
1605 return new_loc_descr (DW_OP_bregx, reg, offset);
1608 /* Add a location description term to a location description expression. */
1611 add_loc_descr (dw_loc_descr_ref *list_head, dw_loc_descr_ref descr)
1613 dw_loc_descr_ref *d;
1615 /* Find the end of the chain. */
1616 for (d = list_head; (*d) != NULL; d = &(*d)->dw_loc_next)
1622 /* Compare two location operands for exact equality. */
1625 dw_val_equal_p (dw_val_node *a, dw_val_node *b)
1627 if (a->val_class != b->val_class)
1629 switch (a->val_class)
1631 case dw_val_class_none:
1633 case dw_val_class_addr:
1634 return rtx_equal_p (a->v.val_addr, b->v.val_addr);
1636 case dw_val_class_offset:
1637 case dw_val_class_unsigned_const:
1638 case dw_val_class_const:
1639 case dw_val_class_range_list:
1640 case dw_val_class_lineptr:
1641 case dw_val_class_macptr:
1642 /* These are all HOST_WIDE_INT, signed or unsigned. */
1643 return a->v.val_unsigned == b->v.val_unsigned;
1645 case dw_val_class_loc:
1646 return a->v.val_loc == b->v.val_loc;
1647 case dw_val_class_loc_list:
1648 return a->v.val_loc_list == b->v.val_loc_list;
1649 case dw_val_class_die_ref:
1650 return a->v.val_die_ref.die == b->v.val_die_ref.die;
1651 case dw_val_class_fde_ref:
1652 return a->v.val_fde_index == b->v.val_fde_index;
1653 case dw_val_class_lbl_id:
1654 return strcmp (a->v.val_lbl_id, b->v.val_lbl_id) == 0;
1655 case dw_val_class_str:
1656 return a->v.val_str == b->v.val_str;
1657 case dw_val_class_flag:
1658 return a->v.val_flag == b->v.val_flag;
1659 case dw_val_class_file:
1660 return a->v.val_file == b->v.val_file;
1661 case dw_val_class_decl_ref:
1662 return a->v.val_decl_ref == b->v.val_decl_ref;
1664 case dw_val_class_const_double:
1665 return (a->v.val_double.high == b->v.val_double.high
1666 && a->v.val_double.low == b->v.val_double.low);
1668 case dw_val_class_vec:
1670 size_t a_len = a->v.val_vec.elt_size * a->v.val_vec.length;
1671 size_t b_len = b->v.val_vec.elt_size * b->v.val_vec.length;
1673 return (a_len == b_len
1674 && !memcmp (a->v.val_vec.array, b->v.val_vec.array, a_len));
1677 case dw_val_class_data8:
1678 return memcmp (a->v.val_data8, b->v.val_data8, 8) == 0;
1680 case dw_val_class_vms_delta:
1681 return (!strcmp (a->v.val_vms_delta.lbl1, b->v.val_vms_delta.lbl1)
1682 && !strcmp (a->v.val_vms_delta.lbl1, b->v.val_vms_delta.lbl1));
1687 /* Compare two location atoms for exact equality. */
1690 loc_descr_equal_p_1 (dw_loc_descr_ref a, dw_loc_descr_ref b)
1692 if (a->dw_loc_opc != b->dw_loc_opc)
1695 /* ??? This is only ever set for DW_OP_constNu, for N equal to the
1696 address size, but since we always allocate cleared storage it
1697 should be zero for other types of locations. */
1698 if (a->dtprel != b->dtprel)
1701 return (dw_val_equal_p (&a->dw_loc_oprnd1, &b->dw_loc_oprnd1)
1702 && dw_val_equal_p (&a->dw_loc_oprnd2, &b->dw_loc_oprnd2));
1705 /* Compare two complete location expressions for exact equality. */
1708 loc_descr_equal_p (dw_loc_descr_ref a, dw_loc_descr_ref b)
1714 if (a == NULL || b == NULL)
1716 if (!loc_descr_equal_p_1 (a, b))
1725 /* Add a constant OFFSET to a location expression. */
1728 loc_descr_plus_const (dw_loc_descr_ref *list_head, HOST_WIDE_INT offset)
1730 dw_loc_descr_ref loc;
1733 gcc_assert (*list_head != NULL);
1738 /* Find the end of the chain. */
1739 for (loc = *list_head; loc->dw_loc_next != NULL; loc = loc->dw_loc_next)
1743 if (loc->dw_loc_opc == DW_OP_fbreg
1744 || (loc->dw_loc_opc >= DW_OP_breg0 && loc->dw_loc_opc <= DW_OP_breg31))
1745 p = &loc->dw_loc_oprnd1.v.val_int;
1746 else if (loc->dw_loc_opc == DW_OP_bregx)
1747 p = &loc->dw_loc_oprnd2.v.val_int;
1749 /* If the last operation is fbreg, breg{0..31,x}, optimize by adjusting its
1750 offset. Don't optimize if an signed integer overflow would happen. */
1752 && ((offset > 0 && *p <= INTTYPE_MAXIMUM (HOST_WIDE_INT) - offset)
1753 || (offset < 0 && *p >= INTTYPE_MINIMUM (HOST_WIDE_INT) - offset)))
1756 else if (offset > 0)
1757 loc->dw_loc_next = new_loc_descr (DW_OP_plus_uconst, offset, 0);
1761 loc->dw_loc_next = int_loc_descriptor (-offset);
1762 add_loc_descr (&loc->dw_loc_next, new_loc_descr (DW_OP_minus, 0, 0));
1766 /* Add a constant OFFSET to a location list. */
1769 loc_list_plus_const (dw_loc_list_ref list_head, HOST_WIDE_INT offset)
1772 for (d = list_head; d != NULL; d = d->dw_loc_next)
1773 loc_descr_plus_const (&d->expr, offset);
1776 #define DWARF_REF_SIZE \
1777 (dwarf_version == 2 ? DWARF2_ADDR_SIZE : DWARF_OFFSET_SIZE)
1779 static unsigned long int get_base_type_offset (dw_die_ref);
1781 /* Return the size of a location descriptor. */
1783 static unsigned long
1784 size_of_loc_descr (dw_loc_descr_ref loc)
1786 unsigned long size = 1;
1788 switch (loc->dw_loc_opc)
1791 size += DWARF2_ADDR_SIZE;
1810 size += size_of_uleb128 (loc->dw_loc_oprnd1.v.val_unsigned);
1813 size += size_of_sleb128 (loc->dw_loc_oprnd1.v.val_int);
1818 case DW_OP_plus_uconst:
1819 size += size_of_uleb128 (loc->dw_loc_oprnd1.v.val_unsigned);
1857 size += size_of_sleb128 (loc->dw_loc_oprnd1.v.val_int);
1860 size += size_of_uleb128 (loc->dw_loc_oprnd1.v.val_unsigned);
1863 size += size_of_sleb128 (loc->dw_loc_oprnd1.v.val_int);
1866 size += size_of_uleb128 (loc->dw_loc_oprnd1.v.val_unsigned);
1867 size += size_of_sleb128 (loc->dw_loc_oprnd2.v.val_int);
1870 size += size_of_uleb128 (loc->dw_loc_oprnd1.v.val_unsigned);
1872 case DW_OP_bit_piece:
1873 size += size_of_uleb128 (loc->dw_loc_oprnd1.v.val_unsigned);
1874 size += size_of_uleb128 (loc->dw_loc_oprnd2.v.val_unsigned);
1876 case DW_OP_deref_size:
1877 case DW_OP_xderef_size:
1886 case DW_OP_call_ref:
1887 size += DWARF_REF_SIZE;
1889 case DW_OP_implicit_value:
1890 size += size_of_uleb128 (loc->dw_loc_oprnd1.v.val_unsigned)
1891 + loc->dw_loc_oprnd1.v.val_unsigned;
1893 case DW_OP_GNU_implicit_pointer:
1894 size += DWARF_REF_SIZE + size_of_sleb128 (loc->dw_loc_oprnd2.v.val_int);
1896 case DW_OP_GNU_entry_value:
1898 unsigned long op_size = size_of_locs (loc->dw_loc_oprnd1.v.val_loc);
1899 size += size_of_uleb128 (op_size) + op_size;
1902 case DW_OP_GNU_const_type:
1905 = get_base_type_offset (loc->dw_loc_oprnd1.v.val_die_ref.die);
1906 size += size_of_uleb128 (o) + 1;
1907 switch (loc->dw_loc_oprnd2.val_class)
1909 case dw_val_class_vec:
1910 size += loc->dw_loc_oprnd2.v.val_vec.length
1911 * loc->dw_loc_oprnd2.v.val_vec.elt_size;
1913 case dw_val_class_const:
1914 size += HOST_BITS_PER_WIDE_INT / BITS_PER_UNIT;
1916 case dw_val_class_const_double:
1917 size += 2 * HOST_BITS_PER_WIDE_INT / BITS_PER_UNIT;
1924 case DW_OP_GNU_regval_type:
1927 = get_base_type_offset (loc->dw_loc_oprnd2.v.val_die_ref.die);
1928 size += size_of_uleb128 (loc->dw_loc_oprnd1.v.val_unsigned)
1929 + size_of_uleb128 (o);
1932 case DW_OP_GNU_deref_type:
1935 = get_base_type_offset (loc->dw_loc_oprnd2.v.val_die_ref.die);
1936 size += 1 + size_of_uleb128 (o);
1939 case DW_OP_GNU_convert:
1940 case DW_OP_GNU_reinterpret:
1941 if (loc->dw_loc_oprnd1.val_class == dw_val_class_unsigned_const)
1942 size += size_of_uleb128 (loc->dw_loc_oprnd1.v.val_unsigned);
1946 = get_base_type_offset (loc->dw_loc_oprnd1.v.val_die_ref.die);
1947 size += size_of_uleb128 (o);
1950 case DW_OP_GNU_parameter_ref:
1960 /* Return the size of a series of location descriptors. */
1963 size_of_locs (dw_loc_descr_ref loc)
1968 /* If there are no skip or bra opcodes, don't fill in the dw_loc_addr
1969 field, to avoid writing to a PCH file. */
1970 for (size = 0, l = loc; l != NULL; l = l->dw_loc_next)
1972 if (l->dw_loc_opc == DW_OP_skip || l->dw_loc_opc == DW_OP_bra)
1974 size += size_of_loc_descr (l);
1979 for (size = 0, l = loc; l != NULL; l = l->dw_loc_next)
1981 l->dw_loc_addr = size;
1982 size += size_of_loc_descr (l);
1988 static HOST_WIDE_INT extract_int (const unsigned char *, unsigned);
1989 static void get_ref_die_offset_label (char *, dw_die_ref);
1990 static unsigned long int get_ref_die_offset (dw_die_ref);
1992 /* Output location description stack opcode's operands (if any).
1993 The for_eh_or_skip parameter controls whether register numbers are
1994 converted using DWARF2_FRAME_REG_OUT, which is needed in the case that
1995 hard reg numbers have been processed via DWARF_FRAME_REGNUM (i.e. for unwind
1996 info). This should be suppressed for the cases that have not been converted
1997 (i.e. symbolic debug info), by setting the parameter < 0. See PR47324. */
2000 output_loc_operands (dw_loc_descr_ref loc, int for_eh_or_skip)
2002 dw_val_ref val1 = &loc->dw_loc_oprnd1;
2003 dw_val_ref val2 = &loc->dw_loc_oprnd2;
2005 switch (loc->dw_loc_opc)
2007 #ifdef DWARF2_DEBUGGING_INFO
2010 dw2_asm_output_data (2, val1->v.val_int, NULL);
2015 gcc_assert (targetm.asm_out.output_dwarf_dtprel);
2016 targetm.asm_out.output_dwarf_dtprel (asm_out_file, 4,
2018 fputc ('\n', asm_out_file);
2023 dw2_asm_output_data (4, val1->v.val_int, NULL);
2028 gcc_assert (targetm.asm_out.output_dwarf_dtprel);
2029 targetm.asm_out.output_dwarf_dtprel (asm_out_file, 8,
2031 fputc ('\n', asm_out_file);
2036 gcc_assert (HOST_BITS_PER_WIDE_INT >= 64);
2037 dw2_asm_output_data (8, val1->v.val_int, NULL);
2044 gcc_assert (val1->val_class == dw_val_class_loc);
2045 offset = val1->v.val_loc->dw_loc_addr - (loc->dw_loc_addr + 3);
2047 dw2_asm_output_data (2, offset, NULL);
2050 case DW_OP_implicit_value:
2051 dw2_asm_output_data_uleb128 (val1->v.val_unsigned, NULL);
2052 switch (val2->val_class)
2054 case dw_val_class_const:
2055 dw2_asm_output_data (val1->v.val_unsigned, val2->v.val_int, NULL);
2057 case dw_val_class_vec:
2059 unsigned int elt_size = val2->v.val_vec.elt_size;
2060 unsigned int len = val2->v.val_vec.length;
2064 if (elt_size > sizeof (HOST_WIDE_INT))
2069 for (i = 0, p = val2->v.val_vec.array;
2072 dw2_asm_output_data (elt_size, extract_int (p, elt_size),
2073 "fp or vector constant word %u", i);
2076 case dw_val_class_const_double:
2078 unsigned HOST_WIDE_INT first, second;
2080 if (WORDS_BIG_ENDIAN)
2082 first = val2->v.val_double.high;
2083 second = val2->v.val_double.low;
2087 first = val2->v.val_double.low;
2088 second = val2->v.val_double.high;
2090 dw2_asm_output_data (HOST_BITS_PER_WIDE_INT / HOST_BITS_PER_CHAR,
2092 dw2_asm_output_data (HOST_BITS_PER_WIDE_INT / HOST_BITS_PER_CHAR,
2096 case dw_val_class_addr:
2097 gcc_assert (val1->v.val_unsigned == DWARF2_ADDR_SIZE);
2098 dw2_asm_output_addr_rtx (DWARF2_ADDR_SIZE, val2->v.val_addr, NULL);
2113 case DW_OP_implicit_value:
2114 /* We currently don't make any attempt to make sure these are
2115 aligned properly like we do for the main unwind info, so
2116 don't support emitting things larger than a byte if we're
2117 only doing unwinding. */
2122 dw2_asm_output_data (1, val1->v.val_int, NULL);
2125 dw2_asm_output_data_uleb128 (val1->v.val_unsigned, NULL);
2128 dw2_asm_output_data_sleb128 (val1->v.val_int, NULL);
2131 dw2_asm_output_data (1, val1->v.val_int, NULL);
2133 case DW_OP_plus_uconst:
2134 dw2_asm_output_data_uleb128 (val1->v.val_unsigned, NULL);
2168 dw2_asm_output_data_sleb128 (val1->v.val_int, NULL);
2172 unsigned r = val1->v.val_unsigned;
2173 if (for_eh_or_skip >= 0)
2174 r = DWARF2_FRAME_REG_OUT (r, for_eh_or_skip);
2175 gcc_assert (size_of_uleb128 (r)
2176 == size_of_uleb128 (val1->v.val_unsigned));
2177 dw2_asm_output_data_uleb128 (r, NULL);
2181 dw2_asm_output_data_sleb128 (val1->v.val_int, NULL);
2185 unsigned r = val1->v.val_unsigned;
2186 if (for_eh_or_skip >= 0)
2187 r = DWARF2_FRAME_REG_OUT (r, for_eh_or_skip);
2188 gcc_assert (size_of_uleb128 (r)
2189 == size_of_uleb128 (val1->v.val_unsigned));
2190 dw2_asm_output_data_uleb128 (r, NULL);
2191 dw2_asm_output_data_sleb128 (val2->v.val_int, NULL);
2195 dw2_asm_output_data_uleb128 (val1->v.val_unsigned, NULL);
2197 case DW_OP_bit_piece:
2198 dw2_asm_output_data_uleb128 (val1->v.val_unsigned, NULL);
2199 dw2_asm_output_data_uleb128 (val2->v.val_unsigned, NULL);
2201 case DW_OP_deref_size:
2202 case DW_OP_xderef_size:
2203 dw2_asm_output_data (1, val1->v.val_int, NULL);
2209 if (targetm.asm_out.output_dwarf_dtprel)
2211 targetm.asm_out.output_dwarf_dtprel (asm_out_file,
2214 fputc ('\n', asm_out_file);
2221 #ifdef DWARF2_DEBUGGING_INFO
2222 dw2_asm_output_addr_rtx (DWARF2_ADDR_SIZE, val1->v.val_addr, NULL);
2229 case DW_OP_GNU_implicit_pointer:
2231 char label[MAX_ARTIFICIAL_LABEL_BYTES
2232 + HOST_BITS_PER_WIDE_INT / 2 + 2];
2233 gcc_assert (val1->val_class == dw_val_class_die_ref);
2234 get_ref_die_offset_label (label, val1->v.val_die_ref.die);
2235 dw2_asm_output_offset (DWARF_REF_SIZE, label, debug_info_section, NULL);
2236 dw2_asm_output_data_sleb128 (val2->v.val_int, NULL);
2240 case DW_OP_GNU_entry_value:
2241 dw2_asm_output_data_uleb128 (size_of_locs (val1->v.val_loc), NULL);
2242 output_loc_sequence (val1->v.val_loc, for_eh_or_skip);
2245 case DW_OP_GNU_const_type:
2247 unsigned long o = get_base_type_offset (val1->v.val_die_ref.die), l;
2249 dw2_asm_output_data_uleb128 (o, NULL);
2250 switch (val2->val_class)
2252 case dw_val_class_const:
2253 l = HOST_BITS_PER_WIDE_INT / HOST_BITS_PER_CHAR;
2254 dw2_asm_output_data (1, l, NULL);
2255 dw2_asm_output_data (l, val2->v.val_int, NULL);
2257 case dw_val_class_vec:
2259 unsigned int elt_size = val2->v.val_vec.elt_size;
2260 unsigned int len = val2->v.val_vec.length;
2265 dw2_asm_output_data (1, l, NULL);
2266 if (elt_size > sizeof (HOST_WIDE_INT))
2271 for (i = 0, p = val2->v.val_vec.array;
2274 dw2_asm_output_data (elt_size, extract_int (p, elt_size),
2275 "fp or vector constant word %u", i);
2278 case dw_val_class_const_double:
2280 unsigned HOST_WIDE_INT first, second;
2281 l = HOST_BITS_PER_WIDE_INT / HOST_BITS_PER_CHAR;
2283 dw2_asm_output_data (1, 2 * l, NULL);
2284 if (WORDS_BIG_ENDIAN)
2286 first = val2->v.val_double.high;
2287 second = val2->v.val_double.low;
2291 first = val2->v.val_double.low;
2292 second = val2->v.val_double.high;
2294 dw2_asm_output_data (l, first, NULL);
2295 dw2_asm_output_data (l, second, NULL);
2303 case DW_OP_GNU_regval_type:
2305 unsigned r = val1->v.val_unsigned;
2306 unsigned long o = get_base_type_offset (val2->v.val_die_ref.die);
2308 if (for_eh_or_skip >= 0)
2310 r = DWARF2_FRAME_REG_OUT (r, for_eh_or_skip);
2311 gcc_assert (size_of_uleb128 (r)
2312 == size_of_uleb128 (val1->v.val_unsigned));
2314 dw2_asm_output_data_uleb128 (r, NULL);
2315 dw2_asm_output_data_uleb128 (o, NULL);
2318 case DW_OP_GNU_deref_type:
2320 unsigned long o = get_base_type_offset (val2->v.val_die_ref.die);
2322 dw2_asm_output_data (1, val1->v.val_int, NULL);
2323 dw2_asm_output_data_uleb128 (o, NULL);
2326 case DW_OP_GNU_convert:
2327 case DW_OP_GNU_reinterpret:
2328 if (loc->dw_loc_oprnd1.val_class == dw_val_class_unsigned_const)
2329 dw2_asm_output_data_uleb128 (val1->v.val_unsigned, NULL);
2332 unsigned long o = get_base_type_offset (val1->v.val_die_ref.die);
2334 dw2_asm_output_data_uleb128 (o, NULL);
2338 case DW_OP_GNU_parameter_ref:
2341 gcc_assert (val1->val_class == dw_val_class_die_ref);
2342 o = get_ref_die_offset (val1->v.val_die_ref.die);
2343 dw2_asm_output_data (4, o, NULL);
2348 /* Other codes have no operands. */
2353 /* Output a sequence of location operations.
2354 The for_eh_or_skip parameter controls whether register numbers are
2355 converted using DWARF2_FRAME_REG_OUT, which is needed in the case that
2356 hard reg numbers have been processed via DWARF_FRAME_REGNUM (i.e. for unwind
2357 info). This should be suppressed for the cases that have not been converted
2358 (i.e. symbolic debug info), by setting the parameter < 0. See PR47324. */
2361 output_loc_sequence (dw_loc_descr_ref loc, int for_eh_or_skip)
2363 for (; loc != NULL; loc = loc->dw_loc_next)
2365 enum dwarf_location_atom opc = loc->dw_loc_opc;
2366 /* Output the opcode. */
2367 if (for_eh_or_skip >= 0
2368 && opc >= DW_OP_breg0 && opc <= DW_OP_breg31)
2370 unsigned r = (opc - DW_OP_breg0);
2371 r = DWARF2_FRAME_REG_OUT (r, for_eh_or_skip);
2372 gcc_assert (r <= 31);
2373 opc = (enum dwarf_location_atom) (DW_OP_breg0 + r);
2375 else if (for_eh_or_skip >= 0
2376 && opc >= DW_OP_reg0 && opc <= DW_OP_reg31)
2378 unsigned r = (opc - DW_OP_reg0);
2379 r = DWARF2_FRAME_REG_OUT (r, for_eh_or_skip);
2380 gcc_assert (r <= 31);
2381 opc = (enum dwarf_location_atom) (DW_OP_reg0 + r);
2384 dw2_asm_output_data (1, opc,
2385 "%s", dwarf_stack_op_name (opc));
2387 /* Output the operand(s) (if any). */
2388 output_loc_operands (loc, for_eh_or_skip);
2392 /* Output location description stack opcode's operands (if any).
2393 The output is single bytes on a line, suitable for .cfi_escape. */
2396 output_loc_operands_raw (dw_loc_descr_ref loc)
2398 dw_val_ref val1 = &loc->dw_loc_oprnd1;
2399 dw_val_ref val2 = &loc->dw_loc_oprnd2;
2401 switch (loc->dw_loc_opc)
2404 case DW_OP_implicit_value:
2405 /* We cannot output addresses in .cfi_escape, only bytes. */
2411 case DW_OP_deref_size:
2412 case DW_OP_xderef_size:
2413 fputc (',', asm_out_file);
2414 dw2_asm_output_data_raw (1, val1->v.val_int);
2419 fputc (',', asm_out_file);
2420 dw2_asm_output_data_raw (2, val1->v.val_int);
2425 fputc (',', asm_out_file);
2426 dw2_asm_output_data_raw (4, val1->v.val_int);
2431 gcc_assert (HOST_BITS_PER_WIDE_INT >= 64);
2432 fputc (',', asm_out_file);
2433 dw2_asm_output_data_raw (8, val1->v.val_int);
2441 gcc_assert (val1->val_class == dw_val_class_loc);
2442 offset = val1->v.val_loc->dw_loc_addr - (loc->dw_loc_addr + 3);
2444 fputc (',', asm_out_file);
2445 dw2_asm_output_data_raw (2, offset);
2451 unsigned r = DWARF2_FRAME_REG_OUT (val1->v.val_unsigned, 1);
2452 gcc_assert (size_of_uleb128 (r)
2453 == size_of_uleb128 (val1->v.val_unsigned));
2454 fputc (',', asm_out_file);
2455 dw2_asm_output_data_uleb128_raw (r);
2460 case DW_OP_plus_uconst:
2462 fputc (',', asm_out_file);
2463 dw2_asm_output_data_uleb128_raw (val1->v.val_unsigned);
2466 case DW_OP_bit_piece:
2467 fputc (',', asm_out_file);
2468 dw2_asm_output_data_uleb128_raw (val1->v.val_unsigned);
2469 dw2_asm_output_data_uleb128_raw (val2->v.val_unsigned);
2506 fputc (',', asm_out_file);
2507 dw2_asm_output_data_sleb128_raw (val1->v.val_int);
2512 unsigned r = DWARF2_FRAME_REG_OUT (val1->v.val_unsigned, 1);
2513 gcc_assert (size_of_uleb128 (r)
2514 == size_of_uleb128 (val1->v.val_unsigned));
2515 fputc (',', asm_out_file);
2516 dw2_asm_output_data_uleb128_raw (r);
2517 fputc (',', asm_out_file);
2518 dw2_asm_output_data_sleb128_raw (val2->v.val_int);
2522 case DW_OP_GNU_implicit_pointer:
2523 case DW_OP_GNU_entry_value:
2524 case DW_OP_GNU_const_type:
2525 case DW_OP_GNU_regval_type:
2526 case DW_OP_GNU_deref_type:
2527 case DW_OP_GNU_convert:
2528 case DW_OP_GNU_reinterpret:
2529 case DW_OP_GNU_parameter_ref:
2534 /* Other codes have no operands. */
2540 output_loc_sequence_raw (dw_loc_descr_ref loc)
2544 enum dwarf_location_atom opc = loc->dw_loc_opc;
2545 /* Output the opcode. */
2546 if (opc >= DW_OP_breg0 && opc <= DW_OP_breg31)
2548 unsigned r = (opc - DW_OP_breg0);
2549 r = DWARF2_FRAME_REG_OUT (r, 1);
2550 gcc_assert (r <= 31);
2551 opc = (enum dwarf_location_atom) (DW_OP_breg0 + r);
2553 else if (opc >= DW_OP_reg0 && opc <= DW_OP_reg31)
2555 unsigned r = (opc - DW_OP_reg0);
2556 r = DWARF2_FRAME_REG_OUT (r, 1);
2557 gcc_assert (r <= 31);
2558 opc = (enum dwarf_location_atom) (DW_OP_reg0 + r);
2560 /* Output the opcode. */
2561 fprintf (asm_out_file, "%#x", opc);
2562 output_loc_operands_raw (loc);
2564 if (!loc->dw_loc_next)
2566 loc = loc->dw_loc_next;
2568 fputc (',', asm_out_file);
2572 /* This function builds a dwarf location descriptor sequence from a
2573 dw_cfa_location, adding the given OFFSET to the result of the
2576 struct dw_loc_descr_struct *
2577 build_cfa_loc (dw_cfa_location *cfa, HOST_WIDE_INT offset)
2579 struct dw_loc_descr_struct *head, *tmp;
2581 offset += cfa->offset;
2585 head = new_reg_loc_descr (cfa->reg, cfa->base_offset);
2586 head->dw_loc_oprnd1.val_class = dw_val_class_const;
2587 tmp = new_loc_descr (DW_OP_deref, 0, 0);
2588 add_loc_descr (&head, tmp);
2591 tmp = new_loc_descr (DW_OP_plus_uconst, offset, 0);
2592 add_loc_descr (&head, tmp);
2596 head = new_reg_loc_descr (cfa->reg, offset);
2601 /* This function builds a dwarf location descriptor sequence for
2602 the address at OFFSET from the CFA when stack is aligned to
2605 struct dw_loc_descr_struct *
2606 build_cfa_aligned_loc (dw_cfa_location *cfa,
2607 HOST_WIDE_INT offset, HOST_WIDE_INT alignment)
2609 struct dw_loc_descr_struct *head;
2610 unsigned int dwarf_fp
2611 = DWARF_FRAME_REGNUM (HARD_FRAME_POINTER_REGNUM);
2613 /* When CFA is defined as FP+OFFSET, emulate stack alignment. */
2614 if (cfa->reg == HARD_FRAME_POINTER_REGNUM && cfa->indirect == 0)
2616 head = new_reg_loc_descr (dwarf_fp, 0);
2617 add_loc_descr (&head, int_loc_descriptor (alignment));
2618 add_loc_descr (&head, new_loc_descr (DW_OP_and, 0, 0));
2619 loc_descr_plus_const (&head, offset);
2622 head = new_reg_loc_descr (dwarf_fp, offset);
2626 /* And now, the support for symbolic debugging information. */
2628 /* .debug_str support. */
2629 static int output_indirect_string (void **, void *);
2631 static void dwarf2out_init (const char *);
2632 static void dwarf2out_finish (const char *);
2633 static void dwarf2out_assembly_start (void);
2634 static void dwarf2out_define (unsigned int, const char *);
2635 static void dwarf2out_undef (unsigned int, const char *);
2636 static void dwarf2out_start_source_file (unsigned, const char *);
2637 static void dwarf2out_end_source_file (unsigned);
2638 static void dwarf2out_function_decl (tree);
2639 static void dwarf2out_begin_block (unsigned, unsigned);
2640 static void dwarf2out_end_block (unsigned, unsigned);
2641 static bool dwarf2out_ignore_block (const_tree);
2642 static void dwarf2out_global_decl (tree);
2643 static void dwarf2out_type_decl (tree, int);
2644 static void dwarf2out_imported_module_or_decl (tree, tree, tree, bool);
2645 static void dwarf2out_imported_module_or_decl_1 (tree, tree, tree,
2647 static void dwarf2out_abstract_function (tree);
2648 static void dwarf2out_var_location (rtx);
2649 static void dwarf2out_begin_function (tree);
2650 static void dwarf2out_set_name (tree, tree);
2652 /* The debug hooks structure. */
2654 const struct gcc_debug_hooks dwarf2_debug_hooks =
2658 dwarf2out_assembly_start,
2661 dwarf2out_start_source_file,
2662 dwarf2out_end_source_file,
2663 dwarf2out_begin_block,
2664 dwarf2out_end_block,
2665 dwarf2out_ignore_block,
2666 dwarf2out_source_line,
2667 dwarf2out_begin_prologue,
2668 #if VMS_DEBUGGING_INFO
2669 dwarf2out_vms_end_prologue,
2670 dwarf2out_vms_begin_epilogue,
2672 debug_nothing_int_charstar,
2673 debug_nothing_int_charstar,
2675 dwarf2out_end_epilogue,
2676 dwarf2out_begin_function,
2677 debug_nothing_int, /* end_function */
2678 dwarf2out_function_decl, /* function_decl */
2679 dwarf2out_global_decl,
2680 dwarf2out_type_decl, /* type_decl */
2681 dwarf2out_imported_module_or_decl,
2682 debug_nothing_tree, /* deferred_inline_function */
2683 /* The DWARF 2 backend tries to reduce debugging bloat by not
2684 emitting the abstract description of inline functions until
2685 something tries to reference them. */
2686 dwarf2out_abstract_function, /* outlining_inline_function */
2687 debug_nothing_rtx, /* label */
2688 debug_nothing_int, /* handle_pch */
2689 dwarf2out_var_location,
2690 dwarf2out_switch_text_section,
2692 1, /* start_end_main_source_file */
2693 TYPE_SYMTAB_IS_DIE /* tree_type_symtab_field */
2696 /* NOTE: In the comments in this file, many references are made to
2697 "Debugging Information Entries". This term is abbreviated as `DIE'
2698 throughout the remainder of this file. */
2700 /* An internal representation of the DWARF output is built, and then
2701 walked to generate the DWARF debugging info. The walk of the internal
2702 representation is done after the entire program has been compiled.
2703 The types below are used to describe the internal representation. */
2705 /* Whether to put type DIEs into their own section .debug_types instead
2706 of making them part of the .debug_info section. Only supported for
2707 Dwarf V4 or higher and the user didn't disable them through
2708 -fno-debug-types-section. It is more efficient to put them in a
2709 separate comdat sections since the linker will then be able to
2710 remove duplicates. But not all tools support .debug_types sections
2713 #define use_debug_types (dwarf_version >= 4 && flag_debug_types_section)
2715 /* Various DIE's use offsets relative to the beginning of the
2716 .debug_info section to refer to each other. */
2718 typedef long int dw_offset;
2720 /* Define typedefs here to avoid circular dependencies. */
2722 typedef struct dw_attr_struct *dw_attr_ref;
2723 typedef struct dw_line_info_struct *dw_line_info_ref;
2724 typedef struct pubname_struct *pubname_ref;
2725 typedef struct dw_ranges_struct *dw_ranges_ref;
2726 typedef struct dw_ranges_by_label_struct *dw_ranges_by_label_ref;
2727 typedef struct comdat_type_struct *comdat_type_node_ref;
2729 /* The entries in the line_info table more-or-less mirror the opcodes
2730 that are used in the real dwarf line table. Arrays of these entries
2731 are collected per section when DWARF2_ASM_LINE_DEBUG_INFO is not
2734 enum dw_line_info_opcode {
2735 /* Emit DW_LNE_set_address; the operand is the label index. */
2738 /* Emit a row to the matrix with the given line. This may be done
2739 via any combination of DW_LNS_copy, DW_LNS_advance_line, and
2743 /* Emit a DW_LNS_set_file. */
2746 /* Emit a DW_LNS_set_column. */
2749 /* Emit a DW_LNS_negate_stmt; the operand is ignored. */
2752 /* Emit a DW_LNS_set_prologue_end/epilogue_begin; the operand is ignored. */
2753 LI_set_prologue_end,
2754 LI_set_epilogue_begin,
2756 /* Emit a DW_LNE_set_discriminator. */
2757 LI_set_discriminator
2760 typedef struct GTY(()) dw_line_info_struct {
2761 enum dw_line_info_opcode opcode;
2763 } dw_line_info_entry;
2765 DEF_VEC_O(dw_line_info_entry);
2766 DEF_VEC_ALLOC_O(dw_line_info_entry, gc);
2768 typedef struct GTY(()) dw_line_info_table_struct {
2769 /* The label that marks the end of this section. */
2770 const char *end_label;
2772 /* The values for the last row of the matrix, as collected in the table.
2773 These are used to minimize the changes to the next row. */
2774 unsigned int file_num;
2775 unsigned int line_num;
2776 unsigned int column_num;
2781 VEC(dw_line_info_entry, gc) *entries;
2782 } dw_line_info_table;
2784 typedef dw_line_info_table *dw_line_info_table_p;
2786 DEF_VEC_P(dw_line_info_table_p);
2787 DEF_VEC_ALLOC_P(dw_line_info_table_p, gc);
2789 /* Each DIE attribute has a field specifying the attribute kind,
2790 a link to the next attribute in the chain, and an attribute value.
2791 Attributes are typically linked below the DIE they modify. */
2793 typedef struct GTY(()) dw_attr_struct {
2794 enum dwarf_attribute dw_attr;
2795 dw_val_node dw_attr_val;
2799 DEF_VEC_O(dw_attr_node);
2800 DEF_VEC_ALLOC_O(dw_attr_node,gc);
2802 /* The Debugging Information Entry (DIE) structure. DIEs form a tree.
2803 The children of each node form a circular list linked by
2804 die_sib. die_child points to the node *before* the "first" child node. */
2806 typedef struct GTY((chain_circular ("%h.die_sib"))) die_struct {
2807 union die_symbol_or_type_node
2809 char * GTY ((tag ("0"))) die_symbol;
2810 comdat_type_node_ref GTY ((tag ("1"))) die_type_node;
2812 GTY ((desc ("use_debug_types"))) die_id;
2813 VEC(dw_attr_node,gc) * die_attr;
2814 dw_die_ref die_parent;
2815 dw_die_ref die_child;
2817 dw_die_ref die_definition; /* ref from a specification to its definition */
2818 dw_offset die_offset;
2819 unsigned long die_abbrev;
2821 /* Die is used and must not be pruned as unused. */
2822 int die_perennial_p;
2823 unsigned int decl_id;
2824 enum dwarf_tag die_tag;
2828 /* Evaluate 'expr' while 'c' is set to each child of DIE in order. */
2829 #define FOR_EACH_CHILD(die, c, expr) do { \
2830 c = die->die_child; \
2834 } while (c != die->die_child); \
2837 /* The pubname structure */
2839 typedef struct GTY(()) pubname_struct {
2845 DEF_VEC_O(pubname_entry);
2846 DEF_VEC_ALLOC_O(pubname_entry, gc);
2848 struct GTY(()) dw_ranges_struct {
2849 /* If this is positive, it's a block number, otherwise it's a
2850 bitwise-negated index into dw_ranges_by_label. */
2854 /* A structure to hold a macinfo entry. */
2856 typedef struct GTY(()) macinfo_struct {
2858 unsigned HOST_WIDE_INT lineno;
2863 DEF_VEC_O(macinfo_entry);
2864 DEF_VEC_ALLOC_O(macinfo_entry, gc);
2866 struct GTY(()) dw_ranges_by_label_struct {
2871 /* The comdat type node structure. */
2872 typedef struct GTY(()) comdat_type_struct
2874 dw_die_ref root_die;
2875 dw_die_ref type_die;
2876 char signature[DWARF_TYPE_SIGNATURE_SIZE];
2877 struct comdat_type_struct *next;
2881 /* The limbo die list structure. */
2882 typedef struct GTY(()) limbo_die_struct {
2885 struct limbo_die_struct *next;
2889 typedef struct skeleton_chain_struct
2893 struct skeleton_chain_struct *parent;
2895 skeleton_chain_node;
2897 /* Define a macro which returns nonzero for a TYPE_DECL which was
2898 implicitly generated for a type.
2900 Note that, unlike the C front-end (which generates a NULL named
2901 TYPE_DECL node for each complete tagged type, each array type,
2902 and each function type node created) the C++ front-end generates
2903 a _named_ TYPE_DECL node for each tagged type node created.
2904 These TYPE_DECLs have DECL_ARTIFICIAL set, so we know not to
2905 generate a DW_TAG_typedef DIE for them. Likewise with the Ada
2906 front-end, but for each type, tagged or not. */
2908 #define TYPE_DECL_IS_STUB(decl) \
2909 (DECL_NAME (decl) == NULL_TREE \
2910 || (DECL_ARTIFICIAL (decl) \
2911 && ((decl == TYPE_STUB_DECL (TREE_TYPE (decl))) \
2912 /* This is necessary for stub decls that \
2913 appear in nested inline functions. */ \
2914 || (DECL_ABSTRACT_ORIGIN (decl) != NULL_TREE \
2915 && (decl_ultimate_origin (decl) \
2916 == TYPE_STUB_DECL (TREE_TYPE (decl)))))))
2918 /* Information concerning the compilation unit's programming
2919 language, and compiler version. */
2921 /* Fixed size portion of the DWARF compilation unit header. */
2922 #define DWARF_COMPILE_UNIT_HEADER_SIZE \
2923 (DWARF_INITIAL_LENGTH_SIZE + DWARF_OFFSET_SIZE + 3)
2925 /* Fixed size portion of the DWARF comdat type unit header. */
2926 #define DWARF_COMDAT_TYPE_UNIT_HEADER_SIZE \
2927 (DWARF_COMPILE_UNIT_HEADER_SIZE + DWARF_TYPE_SIGNATURE_SIZE \
2928 + DWARF_OFFSET_SIZE)
2930 /* Fixed size portion of public names info. */
2931 #define DWARF_PUBNAMES_HEADER_SIZE (2 * DWARF_OFFSET_SIZE + 2)
2933 /* Fixed size portion of the address range info. */
2934 #define DWARF_ARANGES_HEADER_SIZE \
2935 (DWARF_ROUND (DWARF_INITIAL_LENGTH_SIZE + DWARF_OFFSET_SIZE + 4, \
2936 DWARF2_ADDR_SIZE * 2) \
2937 - DWARF_INITIAL_LENGTH_SIZE)
2939 /* Size of padding portion in the address range info. It must be
2940 aligned to twice the pointer size. */
2941 #define DWARF_ARANGES_PAD_SIZE \
2942 (DWARF_ROUND (DWARF_INITIAL_LENGTH_SIZE + DWARF_OFFSET_SIZE + 4, \
2943 DWARF2_ADDR_SIZE * 2) \
2944 - (DWARF_INITIAL_LENGTH_SIZE + DWARF_OFFSET_SIZE + 4))
2946 /* Use assembler line directives if available. */
2947 #ifndef DWARF2_ASM_LINE_DEBUG_INFO
2948 #ifdef HAVE_AS_DWARF2_DEBUG_LINE
2949 #define DWARF2_ASM_LINE_DEBUG_INFO 1
2951 #define DWARF2_ASM_LINE_DEBUG_INFO 0
2955 /* Minimum line offset in a special line info. opcode.
2956 This value was chosen to give a reasonable range of values. */
2957 #define DWARF_LINE_BASE -10
2959 /* First special line opcode - leave room for the standard opcodes. */
2960 #define DWARF_LINE_OPCODE_BASE ((int)DW_LNS_set_isa + 1)
2962 /* Range of line offsets in a special line info. opcode. */
2963 #define DWARF_LINE_RANGE (254-DWARF_LINE_OPCODE_BASE+1)
2965 /* Flag that indicates the initial value of the is_stmt_start flag.
2966 In the present implementation, we do not mark any lines as
2967 the beginning of a source statement, because that information
2968 is not made available by the GCC front-end. */
2969 #define DWARF_LINE_DEFAULT_IS_STMT_START 1
2971 /* Maximum number of operations per instruction bundle. */
2972 #ifndef DWARF_LINE_DEFAULT_MAX_OPS_PER_INSN
2973 #define DWARF_LINE_DEFAULT_MAX_OPS_PER_INSN 1
2976 /* This location is used by calc_die_sizes() to keep track
2977 the offset of each DIE within the .debug_info section. */
2978 static unsigned long next_die_offset;
2980 /* Record the root of the DIE's built for the current compilation unit. */
2981 static GTY(()) dw_die_ref single_comp_unit_die;
2983 /* A list of type DIEs that have been separated into comdat sections. */
2984 static GTY(()) comdat_type_node *comdat_type_list;
2986 /* A list of DIEs with a NULL parent waiting to be relocated. */
2987 static GTY(()) limbo_die_node *limbo_die_list;
2989 /* A list of DIEs for which we may have to generate
2990 DW_AT_{,MIPS_}linkage_name once their DECL_ASSEMBLER_NAMEs are set. */
2991 static GTY(()) limbo_die_node *deferred_asm_name;
2993 /* Filenames referenced by this compilation unit. */
2994 static GTY((param_is (struct dwarf_file_data))) htab_t file_table;
2996 /* A hash table of references to DIE's that describe declarations.
2997 The key is a DECL_UID() which is a unique number identifying each decl. */
2998 static GTY ((param_is (struct die_struct))) htab_t decl_die_table;
3000 /* A hash table of references to DIE's that describe COMMON blocks.
3001 The key is DECL_UID() ^ die_parent. */
3002 static GTY ((param_is (struct die_struct))) htab_t common_block_die_table;
3004 typedef struct GTY(()) die_arg_entry_struct {
3009 DEF_VEC_O(die_arg_entry);
3010 DEF_VEC_ALLOC_O(die_arg_entry,gc);
3012 /* Node of the variable location list. */
3013 struct GTY ((chain_next ("%h.next"))) var_loc_node {
3014 /* Either NOTE_INSN_VAR_LOCATION, or, for SRA optimized variables,
3015 EXPR_LIST chain. For small bitsizes, bitsize is encoded
3016 in mode of the EXPR_LIST node and first EXPR_LIST operand
3017 is either NOTE_INSN_VAR_LOCATION for a piece with a known
3018 location or NULL for padding. For larger bitsizes,
3019 mode is 0 and first operand is a CONCAT with bitsize
3020 as first CONCAT operand and NOTE_INSN_VAR_LOCATION resp.
3021 NULL as second operand. */
3023 const char * GTY (()) label;
3024 struct var_loc_node * GTY (()) next;
3027 /* Variable location list. */
3028 struct GTY (()) var_loc_list_def {
3029 struct var_loc_node * GTY (()) first;
3031 /* Pointer to the last but one or last element of the
3032 chained list. If the list is empty, both first and
3033 last are NULL, if the list contains just one node
3034 or the last node certainly is not redundant, it points
3035 to the last node, otherwise points to the last but one.
3036 Do not mark it for GC because it is marked through the chain. */
3037 struct var_loc_node * GTY ((skip ("%h"))) last;
3039 /* Pointer to the last element before section switch,
3040 if NULL, either sections weren't switched or first
3041 is after section switch. */
3042 struct var_loc_node * GTY ((skip ("%h"))) last_before_switch;
3044 /* DECL_UID of the variable decl. */
3045 unsigned int decl_id;
3047 typedef struct var_loc_list_def var_loc_list;
3049 /* Call argument location list. */
3050 struct GTY ((chain_next ("%h.next"))) call_arg_loc_node {
3051 rtx GTY (()) call_arg_loc_note;
3052 const char * GTY (()) label;
3053 tree GTY (()) block;
3055 rtx GTY (()) symbol_ref;
3056 struct call_arg_loc_node * GTY (()) next;
3060 /* Table of decl location linked lists. */
3061 static GTY ((param_is (var_loc_list))) htab_t decl_loc_table;
3063 /* Head and tail of call_arg_loc chain. */
3064 static GTY (()) struct call_arg_loc_node *call_arg_locations;
3065 static struct call_arg_loc_node *call_arg_loc_last;
3067 /* Number of call sites in the current function. */
3068 static int call_site_count = -1;
3069 /* Number of tail call sites in the current function. */
3070 static int tail_call_site_count = -1;
3072 /* Vector mapping block numbers to DW_TAG_{lexical_block,inlined_subroutine}
3074 static VEC (dw_die_ref, heap) *block_map;
3076 /* A cached location list. */
3077 struct GTY (()) cached_dw_loc_list_def {
3078 /* The DECL_UID of the decl that this entry describes. */
3079 unsigned int decl_id;
3081 /* The cached location list. */
3082 dw_loc_list_ref loc_list;
3084 typedef struct cached_dw_loc_list_def cached_dw_loc_list;
3086 /* Table of cached location lists. */
3087 static GTY ((param_is (cached_dw_loc_list))) htab_t cached_dw_loc_list_table;
3089 /* A pointer to the base of a list of references to DIE's that
3090 are uniquely identified by their tag, presence/absence of
3091 children DIE's, and list of attribute/value pairs. */
3092 static GTY((length ("abbrev_die_table_allocated")))
3093 dw_die_ref *abbrev_die_table;
3095 /* Number of elements currently allocated for abbrev_die_table. */
3096 static GTY(()) unsigned abbrev_die_table_allocated;
3098 /* Number of elements in type_die_table currently in use. */
3099 static GTY(()) unsigned abbrev_die_table_in_use;
3101 /* Size (in elements) of increments by which we may expand the
3102 abbrev_die_table. */
3103 #define ABBREV_DIE_TABLE_INCREMENT 256
3105 /* A global counter for generating labels for line number data. */
3106 static unsigned int line_info_label_num;
3108 /* The current table to which we should emit line number information
3109 for the current function. This will be set up at the beginning of
3110 assembly for the function. */
3111 static dw_line_info_table *cur_line_info_table;
3113 /* The two default tables of line number info. */
3114 static GTY(()) dw_line_info_table *text_section_line_info;
3115 static GTY(()) dw_line_info_table *cold_text_section_line_info;
3117 /* The set of all non-default tables of line number info. */
3118 static GTY(()) VEC (dw_line_info_table_p, gc) *separate_line_info;
3120 /* A flag to tell pubnames/types export if there is an info section to
3122 static bool info_section_emitted;
3124 /* A pointer to the base of a table that contains a list of publicly
3125 accessible names. */
3126 static GTY (()) VEC (pubname_entry, gc) * pubname_table;
3128 /* A pointer to the base of a table that contains a list of publicly
3129 accessible types. */
3130 static GTY (()) VEC (pubname_entry, gc) * pubtype_table;
3132 /* A pointer to the base of a table that contains a list of macro
3133 defines/undefines (and file start/end markers). */
3134 static GTY (()) VEC (macinfo_entry, gc) * macinfo_table;
3136 /* Array of dies for which we should generate .debug_ranges info. */
3137 static GTY ((length ("ranges_table_allocated"))) dw_ranges_ref ranges_table;
3139 /* Number of elements currently allocated for ranges_table. */
3140 static GTY(()) unsigned ranges_table_allocated;
3142 /* Number of elements in ranges_table currently in use. */
3143 static GTY(()) unsigned ranges_table_in_use;
3145 /* Array of pairs of labels referenced in ranges_table. */
3146 static GTY ((length ("ranges_by_label_allocated")))
3147 dw_ranges_by_label_ref ranges_by_label;
3149 /* Number of elements currently allocated for ranges_by_label. */
3150 static GTY(()) unsigned ranges_by_label_allocated;
3152 /* Number of elements in ranges_by_label currently in use. */
3153 static GTY(()) unsigned ranges_by_label_in_use;
3155 /* Size (in elements) of increments by which we may expand the
3157 #define RANGES_TABLE_INCREMENT 64
3159 /* Whether we have location lists that need outputting */
3160 static GTY(()) bool have_location_lists;
3162 /* Unique label counter. */
3163 static GTY(()) unsigned int loclabel_num;
3165 /* Unique label counter for point-of-call tables. */
3166 static GTY(()) unsigned int poc_label_num;
3168 /* Record whether the function being analyzed contains inlined functions. */
3169 static int current_function_has_inlines;
3171 /* The last file entry emitted by maybe_emit_file(). */
3172 static GTY(()) struct dwarf_file_data * last_emitted_file;
3174 /* Number of internal labels generated by gen_internal_sym(). */
3175 static GTY(()) int label_num;
3177 /* Cached result of previous call to lookup_filename. */
3178 static GTY(()) struct dwarf_file_data * file_table_last_lookup;
3180 static GTY(()) VEC(die_arg_entry,gc) *tmpl_value_parm_die_table;
3182 /* Instances of generic types for which we need to generate debug
3183 info that describe their generic parameters and arguments. That
3184 generation needs to happen once all types are properly laid out so
3185 we do it at the end of compilation. */
3186 static GTY(()) VEC(tree,gc) *generic_type_instances;
3188 /* Offset from the "steady-state frame pointer" to the frame base,
3189 within the current function. */
3190 static HOST_WIDE_INT frame_pointer_fb_offset;
3191 static bool frame_pointer_fb_offset_valid;
3193 static VEC (dw_die_ref, heap) *base_types;
3195 /* Forward declarations for functions defined in this file. */
3197 static int is_pseudo_reg (const_rtx);
3198 static tree type_main_variant (tree);
3199 static int is_tagged_type (const_tree);
3200 static const char *dwarf_tag_name (unsigned);
3201 static const char *dwarf_attr_name (unsigned);
3202 static const char *dwarf_form_name (unsigned);
3203 static tree decl_ultimate_origin (const_tree);
3204 static tree decl_class_context (tree);
3205 static void add_dwarf_attr (dw_die_ref, dw_attr_ref);
3206 static inline enum dw_val_class AT_class (dw_attr_ref);
3207 static void add_AT_flag (dw_die_ref, enum dwarf_attribute, unsigned);
3208 static inline unsigned AT_flag (dw_attr_ref);
3209 static void add_AT_int (dw_die_ref, enum dwarf_attribute, HOST_WIDE_INT);
3210 static inline HOST_WIDE_INT AT_int (dw_attr_ref);
3211 static void add_AT_unsigned (dw_die_ref, enum dwarf_attribute, unsigned HOST_WIDE_INT);
3212 static inline unsigned HOST_WIDE_INT AT_unsigned (dw_attr_ref);
3213 static void add_AT_double (dw_die_ref, enum dwarf_attribute,
3214 HOST_WIDE_INT, unsigned HOST_WIDE_INT);
3215 static inline void add_AT_vec (dw_die_ref, enum dwarf_attribute, unsigned int,
3216 unsigned int, unsigned char *);
3217 static void add_AT_data8 (dw_die_ref, enum dwarf_attribute, unsigned char *);
3218 static hashval_t debug_str_do_hash (const void *);
3219 static int debug_str_eq (const void *, const void *);
3220 static void add_AT_string (dw_die_ref, enum dwarf_attribute, const char *);
3221 static inline const char *AT_string (dw_attr_ref);
3222 static enum dwarf_form AT_string_form (dw_attr_ref);
3223 static void add_AT_die_ref (dw_die_ref, enum dwarf_attribute, dw_die_ref);
3224 static void add_AT_specification (dw_die_ref, dw_die_ref);
3225 static inline dw_die_ref AT_ref (dw_attr_ref);
3226 static inline int AT_ref_external (dw_attr_ref);
3227 static inline void set_AT_ref_external (dw_attr_ref, int);
3228 static void add_AT_fde_ref (dw_die_ref, enum dwarf_attribute, unsigned);
3229 static void add_AT_loc (dw_die_ref, enum dwarf_attribute, dw_loc_descr_ref);
3230 static inline dw_loc_descr_ref AT_loc (dw_attr_ref);
3231 static void add_AT_loc_list (dw_die_ref, enum dwarf_attribute,
3233 static inline dw_loc_list_ref AT_loc_list (dw_attr_ref);
3234 static void add_AT_addr (dw_die_ref, enum dwarf_attribute, rtx);
3235 static inline rtx AT_addr (dw_attr_ref);
3236 static void add_AT_lbl_id (dw_die_ref, enum dwarf_attribute, const char *);
3237 static void add_AT_lineptr (dw_die_ref, enum dwarf_attribute, const char *);
3238 static void add_AT_macptr (dw_die_ref, enum dwarf_attribute, const char *);
3239 static void add_AT_offset (dw_die_ref, enum dwarf_attribute,
3240 unsigned HOST_WIDE_INT);
3241 static void add_AT_range_list (dw_die_ref, enum dwarf_attribute,
3243 static inline const char *AT_lbl (dw_attr_ref);
3244 static dw_attr_ref get_AT (dw_die_ref, enum dwarf_attribute);
3245 static const char *get_AT_low_pc (dw_die_ref);
3246 static const char *get_AT_hi_pc (dw_die_ref);
3247 static const char *get_AT_string (dw_die_ref, enum dwarf_attribute);
3248 static int get_AT_flag (dw_die_ref, enum dwarf_attribute);
3249 static unsigned get_AT_unsigned (dw_die_ref, enum dwarf_attribute);
3250 static inline dw_die_ref get_AT_ref (dw_die_ref, enum dwarf_attribute);
3251 static bool is_cxx (void);
3252 static bool is_fortran (void);
3253 static bool is_ada (void);
3254 static void remove_AT (dw_die_ref, enum dwarf_attribute);
3255 static void remove_child_TAG (dw_die_ref, enum dwarf_tag);
3256 static void add_child_die (dw_die_ref, dw_die_ref);
3257 static dw_die_ref new_die (enum dwarf_tag, dw_die_ref, tree);
3258 static dw_die_ref lookup_type_die (tree);
3259 static dw_die_ref strip_naming_typedef (tree, dw_die_ref);
3260 static dw_die_ref lookup_type_die_strip_naming_typedef (tree);
3261 static void equate_type_number_to_die (tree, dw_die_ref);
3262 static hashval_t decl_die_table_hash (const void *);
3263 static int decl_die_table_eq (const void *, const void *);
3264 static dw_die_ref lookup_decl_die (tree);
3265 static hashval_t common_block_die_table_hash (const void *);
3266 static int common_block_die_table_eq (const void *, const void *);
3267 static hashval_t decl_loc_table_hash (const void *);
3268 static int decl_loc_table_eq (const void *, const void *);
3269 static var_loc_list *lookup_decl_loc (const_tree);
3270 static void equate_decl_number_to_die (tree, dw_die_ref);
3271 static struct var_loc_node *add_var_loc_to_decl (tree, rtx, const char *);
3272 static void print_spaces (FILE *);
3273 static void print_die (dw_die_ref, FILE *);
3274 static dw_die_ref push_new_compile_unit (dw_die_ref, dw_die_ref);
3275 static dw_die_ref pop_compile_unit (dw_die_ref);
3276 static void loc_checksum (dw_loc_descr_ref, struct md5_ctx *);
3277 static void attr_checksum (dw_attr_ref, struct md5_ctx *, int *);
3278 static void die_checksum (dw_die_ref, struct md5_ctx *, int *);
3279 static void checksum_sleb128 (HOST_WIDE_INT, struct md5_ctx *);
3280 static void checksum_uleb128 (unsigned HOST_WIDE_INT, struct md5_ctx *);
3281 static void loc_checksum_ordered (dw_loc_descr_ref, struct md5_ctx *);
3282 static void attr_checksum_ordered (enum dwarf_tag, dw_attr_ref,
3283 struct md5_ctx *, int *);
3284 struct checksum_attributes;
3285 static void collect_checksum_attributes (struct checksum_attributes *, dw_die_ref);
3286 static void die_checksum_ordered (dw_die_ref, struct md5_ctx *, int *);
3287 static void checksum_die_context (dw_die_ref, struct md5_ctx *);
3288 static void generate_type_signature (dw_die_ref, comdat_type_node *);
3289 static int same_loc_p (dw_loc_descr_ref, dw_loc_descr_ref, int *);
3290 static int same_dw_val_p (const dw_val_node *, const dw_val_node *, int *);
3291 static int same_attr_p (dw_attr_ref, dw_attr_ref, int *);
3292 static int same_die_p (dw_die_ref, dw_die_ref, int *);
3293 static int same_die_p_wrap (dw_die_ref, dw_die_ref);
3294 static void compute_section_prefix (dw_die_ref);
3295 static int is_type_die (dw_die_ref);
3296 static int is_comdat_die (dw_die_ref);
3297 static int is_symbol_die (dw_die_ref);
3298 static void assign_symbol_names (dw_die_ref);
3299 static void break_out_includes (dw_die_ref);
3300 static int is_declaration_die (dw_die_ref);
3301 static int should_move_die_to_comdat (dw_die_ref);
3302 static dw_die_ref clone_as_declaration (dw_die_ref);
3303 static dw_die_ref clone_die (dw_die_ref);
3304 static dw_die_ref clone_tree (dw_die_ref);
3305 static void copy_declaration_context (dw_die_ref, dw_die_ref);
3306 static void generate_skeleton_ancestor_tree (skeleton_chain_node *);
3307 static void generate_skeleton_bottom_up (skeleton_chain_node *);
3308 static dw_die_ref generate_skeleton (dw_die_ref);
3309 static dw_die_ref remove_child_or_replace_with_skeleton (dw_die_ref,
3311 static void break_out_comdat_types (dw_die_ref);
3312 static dw_die_ref copy_ancestor_tree (dw_die_ref, dw_die_ref, htab_t);
3313 static void copy_decls_walk (dw_die_ref, dw_die_ref, htab_t);
3314 static void copy_decls_for_unworthy_types (dw_die_ref);
3316 static hashval_t htab_cu_hash (const void *);
3317 static int htab_cu_eq (const void *, const void *);
3318 static void htab_cu_del (void *);
3319 static int check_duplicate_cu (dw_die_ref, htab_t, unsigned *);
3320 static void record_comdat_symbol_number (dw_die_ref, htab_t, unsigned);
3321 static void add_sibling_attributes (dw_die_ref);
3322 static void build_abbrev_table (dw_die_ref);
3323 static void output_location_lists (dw_die_ref);
3324 static int constant_size (unsigned HOST_WIDE_INT);
3325 static unsigned long size_of_die (dw_die_ref);
3326 static void calc_die_sizes (dw_die_ref);
3327 static void calc_base_type_die_sizes (void);
3328 static void mark_dies (dw_die_ref);
3329 static void unmark_dies (dw_die_ref);
3330 static void unmark_all_dies (dw_die_ref);
3331 static unsigned long size_of_pubnames (VEC (pubname_entry,gc) *);
3332 static unsigned long size_of_aranges (void);
3333 static enum dwarf_form value_format (dw_attr_ref);
3334 static void output_value_format (dw_attr_ref);
3335 static void output_abbrev_section (void);
3336 static void output_die_symbol (dw_die_ref);
3337 static void output_die (dw_die_ref);
3338 static void output_compilation_unit_header (void);
3339 static void output_comp_unit (dw_die_ref, int);
3340 static void output_comdat_type_unit (comdat_type_node *);
3341 static const char *dwarf2_name (tree, int);
3342 static void add_pubname (tree, dw_die_ref);
3343 static void add_pubname_string (const char *, dw_die_ref);
3344 static void add_pubtype (tree, dw_die_ref);
3345 static void output_pubnames (VEC (pubname_entry,gc) *);
3346 static void output_aranges (unsigned long);
3347 static unsigned int add_ranges_num (int);
3348 static unsigned int add_ranges (const_tree);
3349 static void add_ranges_by_labels (dw_die_ref, const char *, const char *,
3351 static void output_ranges (void);
3352 static dw_line_info_table *new_line_info_table (void);
3353 static void output_line_info (void);
3354 static void output_file_names (void);
3355 static dw_die_ref base_type_die (tree);
3356 static int is_base_type (tree);
3357 static dw_die_ref subrange_type_die (tree, tree, tree, dw_die_ref);
3358 static dw_die_ref modified_type_die (tree, int, int, dw_die_ref);
3359 static dw_die_ref generic_parameter_die (tree, tree, bool, dw_die_ref);
3360 static dw_die_ref template_parameter_pack_die (tree, tree, dw_die_ref);
3361 static int type_is_enum (const_tree);
3362 static unsigned int dbx_reg_number (const_rtx);
3363 static void add_loc_descr_op_piece (dw_loc_descr_ref *, int);
3364 static dw_loc_descr_ref reg_loc_descriptor (rtx, enum var_init_status);
3365 static dw_loc_descr_ref one_reg_loc_descriptor (unsigned int,
3366 enum var_init_status);
3367 static dw_loc_descr_ref multiple_reg_loc_descriptor (rtx, rtx,
3368 enum var_init_status);
3369 static dw_loc_descr_ref based_loc_descr (rtx, HOST_WIDE_INT,
3370 enum var_init_status);
3371 static int is_based_loc (const_rtx);
3372 static int resolve_one_addr (rtx *, void *);
3373 static dw_loc_descr_ref concat_loc_descriptor (rtx, rtx,
3374 enum var_init_status);
3375 static dw_loc_descr_ref loc_descriptor (rtx, enum machine_mode mode,
3376 enum var_init_status);
3377 static dw_loc_list_ref loc_list_from_tree (tree, int);
3378 static dw_loc_descr_ref loc_descriptor_from_tree (tree, int);
3379 static HOST_WIDE_INT ceiling (HOST_WIDE_INT, unsigned int);
3380 static tree field_type (const_tree);
3381 static unsigned int simple_type_align_in_bits (const_tree);
3382 static unsigned int simple_decl_align_in_bits (const_tree);
3383 static unsigned HOST_WIDE_INT simple_type_size_in_bits (const_tree);
3384 static HOST_WIDE_INT field_byte_offset (const_tree);
3385 static void add_AT_location_description (dw_die_ref, enum dwarf_attribute,
3387 static void add_data_member_location_attribute (dw_die_ref, tree);
3388 static bool add_const_value_attribute (dw_die_ref, rtx);
3389 static void insert_int (HOST_WIDE_INT, unsigned, unsigned char *);
3390 static void insert_double (double_int, unsigned char *);
3391 static void insert_float (const_rtx, unsigned char *);
3392 static rtx rtl_for_decl_location (tree);
3393 static bool add_location_or_const_value_attribute (dw_die_ref, tree, bool,
3394 enum dwarf_attribute);
3395 static bool tree_add_const_value_attribute (dw_die_ref, tree);
3396 static bool tree_add_const_value_attribute_for_decl (dw_die_ref, tree);
3397 static void add_name_attribute (dw_die_ref, const char *);
3398 static void add_gnat_descriptive_type_attribute (dw_die_ref, tree, dw_die_ref);
3399 static void add_comp_dir_attribute (dw_die_ref);
3400 static void add_bound_info (dw_die_ref, enum dwarf_attribute, tree);
3401 static void add_subscript_info (dw_die_ref, tree, bool);
3402 static void add_byte_size_attribute (dw_die_ref, tree);
3403 static void add_bit_offset_attribute (dw_die_ref, tree);
3404 static void add_bit_size_attribute (dw_die_ref, tree);
3405 static void add_prototyped_attribute (dw_die_ref, tree);
3406 static dw_die_ref add_abstract_origin_attribute (dw_die_ref, tree);
3407 static void add_pure_or_virtual_attribute (dw_die_ref, tree);
3408 static void add_src_coords_attributes (dw_die_ref, tree);
3409 static void add_name_and_src_coords_attributes (dw_die_ref, tree);
3410 static void push_decl_scope (tree);
3411 static void pop_decl_scope (void);
3412 static dw_die_ref scope_die_for (tree, dw_die_ref);
3413 static inline int local_scope_p (dw_die_ref);
3414 static inline int class_scope_p (dw_die_ref);
3415 static inline int class_or_namespace_scope_p (dw_die_ref);
3416 static void add_type_attribute (dw_die_ref, tree, int, int, dw_die_ref);
3417 static void add_calling_convention_attribute (dw_die_ref, tree);
3418 static const char *type_tag (const_tree);
3419 static tree member_declared_type (const_tree);
3421 static const char *decl_start_label (tree);
3423 static void gen_array_type_die (tree, dw_die_ref);
3424 static void gen_descr_array_type_die (tree, struct array_descr_info *, dw_die_ref);
3426 static void gen_entry_point_die (tree, dw_die_ref);
3428 static dw_die_ref gen_enumeration_type_die (tree, dw_die_ref);
3429 static dw_die_ref gen_formal_parameter_die (tree, tree, bool, dw_die_ref);
3430 static dw_die_ref gen_formal_parameter_pack_die (tree, tree, dw_die_ref, tree*);
3431 static void gen_unspecified_parameters_die (tree, dw_die_ref);
3432 static void gen_formal_types_die (tree, dw_die_ref);
3433 static void gen_subprogram_die (tree, dw_die_ref);
3434 static void gen_variable_die (tree, tree, dw_die_ref);
3435 static void gen_const_die (tree, dw_die_ref);
3436 static void gen_label_die (tree, dw_die_ref);
3437 static void gen_lexical_block_die (tree, dw_die_ref, int);
3438 static void gen_inlined_subroutine_die (tree, dw_die_ref, int);
3439 static void gen_field_die (tree, dw_die_ref);
3440 static void gen_ptr_to_mbr_type_die (tree, dw_die_ref);
3441 static dw_die_ref gen_compile_unit_die (const char *);
3442 static void gen_inheritance_die (tree, tree, dw_die_ref);
3443 static void gen_member_die (tree, dw_die_ref);
3444 static void gen_struct_or_union_type_die (tree, dw_die_ref,
3445 enum debug_info_usage);
3446 static void gen_subroutine_type_die (tree, dw_die_ref);
3447 static void gen_typedef_die (tree, dw_die_ref);
3448 static void gen_type_die (tree, dw_die_ref);
3449 static void gen_block_die (tree, dw_die_ref, int);
3450 static void decls_for_scope (tree, dw_die_ref, int);
3451 static inline int is_redundant_typedef (const_tree);
3452 static bool is_naming_typedef_decl (const_tree);
3453 static inline dw_die_ref get_context_die (tree);
3454 static void gen_namespace_die (tree, dw_die_ref);
3455 static dw_die_ref gen_decl_die (tree, tree, dw_die_ref);
3456 static dw_die_ref force_decl_die (tree);
3457 static dw_die_ref force_type_die (tree);
3458 static dw_die_ref setup_namespace_context (tree, dw_die_ref);
3459 static dw_die_ref declare_in_namespace (tree, dw_die_ref);
3460 static struct dwarf_file_data * lookup_filename (const char *);
3461 static void retry_incomplete_types (void);
3462 static void gen_type_die_for_member (tree, tree, dw_die_ref);
3463 static void gen_generic_params_dies (tree);
3464 static void gen_tagged_type_die (tree, dw_die_ref, enum debug_info_usage);
3465 static void gen_type_die_with_usage (tree, dw_die_ref, enum debug_info_usage);
3466 static void splice_child_die (dw_die_ref, dw_die_ref);
3467 static int file_info_cmp (const void *, const void *);
3468 static dw_loc_list_ref new_loc_list (dw_loc_descr_ref, const char *,
3469 const char *, const char *);
3470 static void output_loc_list (dw_loc_list_ref);
3471 static char *gen_internal_sym (const char *);
3473 static void prune_unmark_dies (dw_die_ref);
3474 static void prune_unused_types_mark_generic_parms_dies (dw_die_ref);
3475 static void prune_unused_types_mark (dw_die_ref, int);
3476 static void prune_unused_types_walk (dw_die_ref);
3477 static void prune_unused_types_walk_attribs (dw_die_ref);
3478 static void prune_unused_types_prune (dw_die_ref);
3479 static void prune_unused_types (void);
3480 static int maybe_emit_file (struct dwarf_file_data *fd);
3481 static inline const char *AT_vms_delta1 (dw_attr_ref);
3482 static inline const char *AT_vms_delta2 (dw_attr_ref);
3483 static inline void add_AT_vms_delta (dw_die_ref, enum dwarf_attribute,
3484 const char *, const char *);
3485 static void append_entry_to_tmpl_value_parm_die_table (dw_die_ref, tree);
3486 static void gen_remaining_tmpl_value_param_die_attribute (void);
3487 static bool generic_type_p (tree);
3488 static void schedule_generic_params_dies_gen (tree t);
3489 static void gen_scheduled_generic_parms_dies (void);
3491 /* Section names used to hold DWARF debugging information. */
3492 #ifndef DEBUG_INFO_SECTION
3493 #define DEBUG_INFO_SECTION ".debug_info"
3495 #ifndef DEBUG_ABBREV_SECTION
3496 #define DEBUG_ABBREV_SECTION ".debug_abbrev"
3498 #ifndef DEBUG_ARANGES_SECTION
3499 #define DEBUG_ARANGES_SECTION ".debug_aranges"
3501 #ifndef DEBUG_MACINFO_SECTION
3502 #define DEBUG_MACINFO_SECTION ".debug_macinfo"
3504 #ifndef DEBUG_MACRO_SECTION
3505 #define DEBUG_MACRO_SECTION ".debug_macro"
3507 #ifndef DEBUG_LINE_SECTION
3508 #define DEBUG_LINE_SECTION ".debug_line"
3510 #ifndef DEBUG_LOC_SECTION
3511 #define DEBUG_LOC_SECTION ".debug_loc"
3513 #ifndef DEBUG_PUBNAMES_SECTION
3514 #define DEBUG_PUBNAMES_SECTION ".debug_pubnames"
3516 #ifndef DEBUG_PUBTYPES_SECTION
3517 #define DEBUG_PUBTYPES_SECTION ".debug_pubtypes"
3519 #ifndef DEBUG_STR_SECTION
3520 #define DEBUG_STR_SECTION ".debug_str"
3522 #ifndef DEBUG_RANGES_SECTION
3523 #define DEBUG_RANGES_SECTION ".debug_ranges"
3526 /* Standard ELF section names for compiled code and data. */
3527 #ifndef TEXT_SECTION_NAME
3528 #define TEXT_SECTION_NAME ".text"
3531 /* Section flags for .debug_str section. */
3532 #define DEBUG_STR_SECTION_FLAGS \
3533 (HAVE_GAS_SHF_MERGE && flag_merge_debug_strings \
3534 ? SECTION_DEBUG | SECTION_MERGE | SECTION_STRINGS | 1 \
3537 /* Labels we insert at beginning sections we can reference instead of
3538 the section names themselves. */
3540 #ifndef TEXT_SECTION_LABEL
3541 #define TEXT_SECTION_LABEL "Ltext"
3543 #ifndef COLD_TEXT_SECTION_LABEL
3544 #define COLD_TEXT_SECTION_LABEL "Ltext_cold"
3546 #ifndef DEBUG_LINE_SECTION_LABEL
3547 #define DEBUG_LINE_SECTION_LABEL "Ldebug_line"
3549 #ifndef DEBUG_INFO_SECTION_LABEL
3550 #define DEBUG_INFO_SECTION_LABEL "Ldebug_info"
3552 #ifndef DEBUG_ABBREV_SECTION_LABEL
3553 #define DEBUG_ABBREV_SECTION_LABEL "Ldebug_abbrev"
3555 #ifndef DEBUG_LOC_SECTION_LABEL
3556 #define DEBUG_LOC_SECTION_LABEL "Ldebug_loc"
3558 #ifndef DEBUG_RANGES_SECTION_LABEL
3559 #define DEBUG_RANGES_SECTION_LABEL "Ldebug_ranges"
3561 #ifndef DEBUG_MACINFO_SECTION_LABEL
3562 #define DEBUG_MACINFO_SECTION_LABEL "Ldebug_macinfo"
3564 #ifndef DEBUG_MACRO_SECTION_LABEL
3565 #define DEBUG_MACRO_SECTION_LABEL "Ldebug_macro"
3569 /* Definitions of defaults for formats and names of various special
3570 (artificial) labels which may be generated within this file (when the -g
3571 options is used and DWARF2_DEBUGGING_INFO is in effect.
3572 If necessary, these may be overridden from within the tm.h file, but
3573 typically, overriding these defaults is unnecessary. */
3575 static char text_end_label[MAX_ARTIFICIAL_LABEL_BYTES];
3576 static char text_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
3577 static char cold_text_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
3578 static char cold_end_label[MAX_ARTIFICIAL_LABEL_BYTES];
3579 static char abbrev_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
3580 static char debug_info_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
3581 static char debug_line_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
3582 static char macinfo_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
3583 static char loc_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
3584 static char ranges_section_label[2 * MAX_ARTIFICIAL_LABEL_BYTES];
3586 #ifndef TEXT_END_LABEL
3587 #define TEXT_END_LABEL "Letext"
3589 #ifndef COLD_END_LABEL
3590 #define COLD_END_LABEL "Letext_cold"
3592 #ifndef BLOCK_BEGIN_LABEL
3593 #define BLOCK_BEGIN_LABEL "LBB"
3595 #ifndef BLOCK_END_LABEL
3596 #define BLOCK_END_LABEL "LBE"
3598 #ifndef LINE_CODE_LABEL
3599 #define LINE_CODE_LABEL "LM"
3603 /* Return the root of the DIE's built for the current compilation unit. */
3605 comp_unit_die (void)
3607 if (!single_comp_unit_die)
3608 single_comp_unit_die = gen_compile_unit_die (NULL);
3609 return single_comp_unit_die;
3612 /* We allow a language front-end to designate a function that is to be
3613 called to "demangle" any name before it is put into a DIE. */
3615 static const char *(*demangle_name_func) (const char *);
3618 dwarf2out_set_demangle_name_func (const char *(*func) (const char *))
3620 demangle_name_func = func;
3623 /* Test if rtl node points to a pseudo register. */