#include "tree-pass.h"
#include "tree-flow.h"
-#ifdef DWARF2_DEBUGGING_INFO
static void dwarf2out_source_line (unsigned int, const char *, int, bool);
-
static rtx last_var_location_insn;
-#endif
#ifdef VMS_DEBUGGING_INFO
int vms_file_stats_name (const char *, long long *, long *, char *, int *);
#define DWARF2_INDIRECT_STRING_SUPPORT_MISSING_ON_TARGET 0
#endif
-#ifndef DWARF2_FRAME_INFO
-# ifdef DWARF2_DEBUGGING_INFO
-# define DWARF2_FRAME_INFO \
- (write_symbols == DWARF2_DEBUG || write_symbols == VMS_AND_DWARF2_DEBUG)
-# else
-# define DWARF2_FRAME_INFO 0
-# endif
+/* ??? Poison these here until it can be done generically. They've been
+ totally replaced in this file; make sure it stays that way. */
+#undef DWARF2_UNWIND_INFO
+#undef DWARF2_FRAME_INFO
+#if (GCC_VERSION >= 3000)
+ #pragma GCC poison DWARF2_UNWIND_INFO DWARF2_FRAME_INFO
+#endif
+
+#ifndef INCOMING_RETURN_ADDR_RTX
+#define INCOMING_RETURN_ADDR_RTX (gcc_unreachable (), NULL_RTX)
#endif
/* Map register numbers held in the call frame info that gcc has
/* We want to emit correct CFA location expressions or lists, so we
have to return true if we're going to output debug info, even if
we're not going to output frame or unwind info. */
- return (write_symbols == DWARF2_DEBUG
- || write_symbols == VMS_AND_DWARF2_DEBUG
- || DWARF2_FRAME_INFO || saved_do_cfi_asm
-#ifdef DWARF2_UNWIND_INFO
- || (DWARF2_UNWIND_INFO
- && (flag_unwind_tables
- || (flag_exceptions && ! USING_SJLJ_EXCEPTIONS)))
-#endif
- );
+ if (write_symbols == DWARF2_DEBUG || write_symbols == VMS_AND_DWARF2_DEBUG)
+ return true;
+
+ if (saved_do_cfi_asm)
+ return true;
+
+ if (targetm.debug_unwind_info () == UI_DWARF2)
+ return true;
+
+ if ((flag_unwind_tables || flag_exceptions)
+ && targetm.except_unwind_info (&global_options) == UI_DWARF2)
+ return true;
+
+ return false;
}
/* Decide whether to emit frame unwind via assembler directives. */
#ifdef MIPS_DEBUGGING_INFO
return false;
#endif
- if (!flag_dwarf2_cfi_asm || !dwarf2out_do_frame ())
- return false;
if (saved_do_cfi_asm)
return true;
+ if (!flag_dwarf2_cfi_asm || !dwarf2out_do_frame ())
+ return false;
if (!HAVE_GAS_CFI_PERSONALITY_DIRECTIVE)
return false;
if ((enc & 0x70) != 0 && (enc & 0x70) != DW_EH_PE_pcrel)
return false;
- if (!HAVE_GAS_CFI_SECTIONS_DIRECTIVE)
- {
-#ifdef TARGET_UNWIND_INFO
- return false;
-#else
- if (USING_SJLJ_EXCEPTIONS || (!flag_unwind_tables && !flag_exceptions))
- return false;
-#endif
- }
+ /* If we can't get the assembler to emit only .debug_frame, and we don't need
+ dwarf2 unwind info for exceptions, then emit .debug_frame by hand. */
+ if (!HAVE_GAS_CFI_SECTIONS_DIRECTIVE
+ && !flag_unwind_tables && !flag_exceptions
+ && targetm.except_unwind_info (&global_options) != UI_DWARF2)
+ return false;
saved_do_cfi_asm = true;
return true;
It can now be either REG + CFA_OFFSET or *(REG + BASE_OFFSET) + CFA_OFFSET.
Instead of passing around REG and OFFSET, we pass a copy
of this structure. */
-typedef struct GTY(()) cfa_loc {
+typedef struct cfa_loc {
HOST_WIDE_INT offset;
HOST_WIDE_INT base_offset;
unsigned int reg;
const char *dw_fde_begin;
const char *dw_fde_current_label;
const char *dw_fde_end;
+ const char *dw_fde_vms_end_prologue;
+ const char *dw_fde_vms_begin_epilogue;
const char *dw_fde_hot_section_label;
const char *dw_fde_hot_section_end_label;
const char *dw_fde_unlikely_section_label;
const char *dw_fde_unlikely_section_end_label;
dw_cfi_ref dw_fde_cfi;
dw_cfi_ref dw_fde_switch_cfi; /* Last CFI before switching sections. */
- unsigned funcdef_number;
HOST_WIDE_INT stack_realignment;
+ unsigned funcdef_number;
/* Dynamic realign argument pointer register. */
unsigned int drap_reg;
/* Virtual dynamic realign argument pointer register. */
/* A list of call frame insns for the CIE. */
static GTY(()) dw_cfi_ref cie_cfi_head;
-#if defined (DWARF2_DEBUGGING_INFO) || defined (DWARF2_UNWIND_INFO)
/* Some DWARF extensions (e.g., MIPS/SGI) implement a subprogram
attribute that accelerates the lookup of the FDE associated
with the subprogram. This variable holds the table index of the FDE
associated with the current function (body) definition. */
static unsigned current_funcdef_fde;
-#endif
struct GTY(()) indirect_string_node {
const char *str;
/* The default cold text section. */
static GTY(()) section *cold_text_section;
-#if defined (DWARF2_DEBUGGING_INFO) || defined (DWARF2_UNWIND_INFO)
-
/* Forward declarations for functions defined in this file. */
static char *stripattributes (const char *);
static void lookup_cfa_1 (dw_cfi_ref, dw_cfa_location *, dw_cfa_location *);
static void lookup_cfa (dw_cfa_location *);
static void reg_save (const char *, unsigned, unsigned, HOST_WIDE_INT);
-#ifdef DWARF2_UNWIND_INFO
static void initial_return_save (rtx);
-#endif
static HOST_WIDE_INT stack_adjust_offset (const_rtx, HOST_WIDE_INT,
HOST_WIDE_INT);
static void output_cfi (dw_cfi_ref, dw_fde_ref, int);
static void output_cfi_directive (dw_cfi_ref);
static void output_call_frame_info (int);
static void dwarf2out_note_section_used (void);
-static void flush_queued_reg_saves (void);
static bool clobbers_queued_reg_save (const_rtx);
static void dwarf2out_frame_debug_expr (rtx, const char *);
static struct dw_loc_descr_struct *build_cfa_aligned_loc
(HOST_WIDE_INT, HOST_WIDE_INT);
static void def_cfa_1 (const char *, dw_cfa_location *);
+static struct dw_loc_descr_struct *mem_loc_descriptor
+ (rtx, enum machine_mode mode, enum var_init_status);
/* How to start an assembler comment. */
#ifndef ASM_COMMENT_START
#define FUNC_END_LABEL "LFE"
#endif
+#ifndef PROLOGUE_END_LABEL
+#define PROLOGUE_END_LABEL "LPE"
+#endif
+
+#ifndef EPILOGUE_BEGIN_LABEL
+#define EPILOGUE_BEGIN_LABEL "LEB"
+#endif
+
#ifndef FRAME_BEGIN_LABEL
#define FRAME_BEGIN_LABEL "Lframe"
#endif
#define DWARF_FRAME_REGNUM(REG) DBX_REGISTER_NUMBER (REG)
#endif
\f
+/* Match the base name of a file to the base name of a compilation unit. */
+
+static int
+matches_main_base (const char *path)
+{
+ /* Cache the last query. */
+ static const char *last_path = NULL;
+ static int last_match = 0;
+ if (path != last_path)
+ {
+ const char *base;
+ int length = base_of_path (path, &base);
+ last_path = path;
+ last_match = (length == main_input_baselength
+ && memcmp (base, main_input_basename, length) == 0);
+ }
+ return last_match;
+}
+
+#ifdef DEBUG_DEBUG_STRUCT
+
+static int
+dump_struct_debug (tree type, enum debug_info_usage usage,
+ enum debug_struct_file criterion, int generic,
+ int matches, int result)
+{
+ /* Find the type name. */
+ tree type_decl = TYPE_STUB_DECL (type);
+ tree t = type_decl;
+ const char *name = 0;
+ if (TREE_CODE (t) == TYPE_DECL)
+ t = DECL_NAME (t);
+ if (t)
+ name = IDENTIFIER_POINTER (t);
+
+ fprintf (stderr, " struct %d %s %s %s %s %d %p %s\n",
+ criterion,
+ DECL_IN_SYSTEM_HEADER (type_decl) ? "sys" : "usr",
+ matches ? "bas" : "hdr",
+ generic ? "gen" : "ord",
+ usage == DINFO_USAGE_DFN ? ";" :
+ usage == DINFO_USAGE_DIR_USE ? "." : "*",
+ result,
+ (void*) type_decl, name);
+ return result;
+}
+#define DUMP_GSTRUCT(type, usage, criterion, generic, matches, result) \
+ dump_struct_debug (type, usage, criterion, generic, matches, result)
+
+#else
+
+#define DUMP_GSTRUCT(type, usage, criterion, generic, matches, result) \
+ (result)
+
+#endif
+
+static bool
+should_emit_struct_debug (tree type, enum debug_info_usage usage)
+{
+ enum debug_struct_file criterion;
+ tree type_decl;
+ bool generic = lang_hooks.types.generic_p (type);
+
+ if (generic)
+ criterion = debug_struct_generic[usage];
+ else
+ criterion = debug_struct_ordinary[usage];
+
+ if (criterion == DINFO_STRUCT_FILE_NONE)
+ return DUMP_GSTRUCT (type, usage, criterion, generic, false, false);
+ if (criterion == DINFO_STRUCT_FILE_ANY)
+ return DUMP_GSTRUCT (type, usage, criterion, generic, false, true);
+
+ type_decl = TYPE_STUB_DECL (type);
+
+ if (criterion == DINFO_STRUCT_FILE_SYS && DECL_IN_SYSTEM_HEADER (type_decl))
+ return DUMP_GSTRUCT (type, usage, criterion, generic, false, true);
+
+ if (matches_main_base (DECL_SOURCE_FILE (type_decl)))
+ return DUMP_GSTRUCT (type, usage, criterion, generic, true, true);
+ return DUMP_GSTRUCT (type, usage, criterion, generic, false, false);
+}
+\f
/* Hook used by __throw. */
rtx
static inline dw_cfi_ref
new_cfi (void)
{
- dw_cfi_ref cfi = GGC_NEW (dw_cfi_node);
+ dw_cfi_ref cfi = ggc_alloc_dw_cfi_node ();
cfi->dw_cfi_next = NULL;
cfi->dw_cfi_oprnd1.dw_cfi_reg_num = 0;
}
else
{
- ASM_GENERATE_INTERNAL_LABEL (label, "LCFI", dwarf2out_cfi_label_num++);
- ASM_OUTPUT_LABEL (asm_out_file, label);
+ int num = dwarf2out_cfi_label_num++;
+ ASM_GENERATE_INTERNAL_LABEL (label, "LCFI", num);
+ ASM_OUTPUT_DEBUG_LABEL (asm_out_file, "LCFI", num);
}
return label;
/* True if remember_state should be emitted before following CFI directive. */
static bool emit_cfa_remember;
+/* True if any CFI directives were emitted at the current insn. */
+static bool any_cfis_emitted;
+
/* Add CFI to the current fde at the PC value indicated by LABEL if specified,
or to the CIE if LABEL is NULL. */
output_cfi_directive (cfi);
list_head = &fde->dw_fde_cfi;
+ any_cfis_emitted = true;
}
/* ??? If this is a CFI for the CIE, we don't emit. This
assumes that the standard CIE contents that the assembler
}
list_head = &fde->dw_fde_cfi;
+ any_cfis_emitted = true;
}
add_cfi (list_head, cfi);
reg_save (label, DWARF_FRAME_RETURN_COLUMN, DWARF_FRAME_REGNUM (sreg), 0);
}
-#ifdef DWARF2_UNWIND_INFO
/* Record the initial position of the return address. RTL is
INCOMING_RETURN_ADDR_RTX. */
if (reg != DWARF_FRAME_RETURN_COLUMN)
reg_save (NULL, DWARF_FRAME_RETURN_COLUMN, reg, offset - cfa.offset);
}
-#endif
/* Given a SET, calculate the amount of stack adjustment it
contains. */
dwarf2out_stack_adjust (offset, label);
}
-#endif
-
/* We delay emitting a register save until either (a) we reach the end
of the prologue or (b) the register is clobbered. This clusters
register saves so that there are fewer pc advances. */
static GTY(()) struct reg_saved_in_data regs_saved_in_regs[4];
static GTY(()) size_t num_regs_saved_in_regs;
-#if defined (DWARF2_DEBUGGING_INFO) || defined (DWARF2_UNWIND_INFO)
static const char *last_reg_save_label;
/* Add an entry to QUEUED_REG_SAVES saying that REG is now saved at
if (q == NULL)
{
- q = GGC_NEW (struct queued_reg_save);
+ q = ggc_alloc_queued_reg_save ();
q->next = queued_reg_saves;
queued_reg_saves = q;
}
/* Output all the entries in QUEUED_REG_SAVES. */
-static void
-flush_queued_reg_saves (void)
+void
+dwarf2out_flush_queued_reg_saves (void)
{
struct queued_reg_save *q;
cfa.reg = REGNO (pat);
break;
+ case MEM:
+ cfa.indirect = 1;
+ pat = XEXP (pat, 0);
+ if (GET_CODE (pat) == PLUS)
+ {
+ cfa.base_offset = INTVAL (XEXP (pat, 1));
+ pat = XEXP (pat, 0);
+ }
+ cfa.reg = REGNO (pat);
+ break;
+
default:
/* Recurse and define an expression. */
gcc_unreachable ();
reg_save (label, sregno, dregno, 0);
}
+/* A subroutine of dwarf2out_frame_debug, process a REG_CFA_EXPRESSION note. */
+
+static void
+dwarf2out_frame_debug_cfa_expression (rtx set, const char *label)
+{
+ rtx src, dest, span;
+ dw_cfi_ref cfi = new_cfi ();
+
+ dest = SET_DEST (set);
+ src = SET_SRC (set);
+
+ gcc_assert (REG_P (src));
+ gcc_assert (MEM_P (dest));
+
+ span = targetm.dwarf_register_span (src);
+ gcc_assert (!span);
+
+ cfi->dw_cfi_opc = DW_CFA_expression;
+ cfi->dw_cfi_oprnd1.dw_cfi_reg_num = DWARF_FRAME_REGNUM (REGNO (src));
+ cfi->dw_cfi_oprnd2.dw_cfi_loc
+ = mem_loc_descriptor (XEXP (dest, 0), GET_MODE (dest),
+ VAR_INIT_STATUS_INITIALIZED);
+
+ /* ??? We'd like to use queue_reg_save, were the interface different,
+ and, as above, we could manage flushing for epilogues. */
+ add_fde_cfi (label, cfi);
+}
+
/* A subroutine of dwarf2out_frame_debug, process a REG_CFA_RESTORE note. */
static void
alignment. */
if (fde && XEXP (src, 0) == stack_pointer_rtx)
{
+ /* We interpret reg_save differently with stack_realign set.
+ Thus we must flush whatever we have queued first. */
+ dwarf2out_flush_queued_reg_saves ();
+
gcc_assert (cfa_store.reg == REGNO (XEXP (src, 0)));
fde->stack_realign = 1;
fde->stack_realignment = INTVAL (XEXP (src, 1));
regno = REGNO (XEXP (XEXP (dest, 0), 0));
- if (cfa_store.reg == (unsigned) regno)
+ if (cfa.reg == (unsigned) regno)
+ offset -= cfa.offset;
+ else if (cfa_store.reg == (unsigned) regno)
offset -= cfa_store.offset;
else
{
{
int regno = REGNO (XEXP (dest, 0));
- if (cfa_store.reg == (unsigned) regno)
+ if (cfa.reg == (unsigned) regno)
+ offset = -cfa.offset;
+ else if (cfa_store.reg == (unsigned) regno)
offset = -cfa_store.offset;
else
{
size_t i;
/* Flush any queued register saves. */
- flush_queued_reg_saves ();
+ dwarf2out_flush_queued_reg_saves ();
/* Set up state for generating call frame debug info. */
lookup_cfa (&cfa);
}
if (!NONJUMP_INSN_P (insn) || clobbers_queued_reg_save (insn))
- flush_queued_reg_saves ();
+ dwarf2out_flush_queued_reg_saves ();
if (!RTX_FRAME_RELATED_P (insn))
{
}
label = dwarf2out_cfi_label (false);
+ any_cfis_emitted = false;
for (note = REG_NOTES (insn); note; note = XEXP (note, 1))
switch (REG_NOTE_KIND (note))
handled_one = true;
break;
+ case REG_CFA_EXPRESSION:
+ n = XEXP (note, 0);
+ if (n == NULL)
+ n = single_set (insn);
+ dwarf2out_frame_debug_cfa_expression (n, label);
+ handled_one = true;
+ break;
+
case REG_CFA_RESTORE:
n = XEXP (note, 0);
if (n == NULL)
break;
}
if (handled_one)
- return;
+ {
+ if (any_cfis_emitted)
+ dwarf2out_flush_queued_reg_saves ();
+ return;
+ }
insn = PATTERN (insn);
found:
dwarf2out_frame_debug_expr (insn, label);
+
+ /* Check again. A parallel can save and update the same register.
+ We could probably check just once, here, but this is safer than
+ removing the check above. */
+ if (any_cfis_emitted || clobbers_queued_reg_save (insn))
+ dwarf2out_flush_queued_reg_saves ();
}
/* Determine if we need to save and restore CFI information around this
NOTE_INSN_CFA_RESTORE_STATE at the appropriate place in the stream. */
void
-dwarf2out_begin_epilogue (rtx insn)
+dwarf2out_cfi_begin_epilogue (rtx insn)
{
bool saw_frp = false;
rtx i;
cfa_remember.in_use = 1;
}
-/* A "subroutine" of dwarf2out_begin_epilogue. Emit the restore required. */
+/* A "subroutine" of dwarf2out_cfi_begin_epilogue. Emit the restore
+ required. */
void
dwarf2out_frame_debug_restore_state (void)
cfa_remember.in_use = 0;
}
-#endif
-
/* Describe for the GTY machinery what parts of dw_cfi_oprnd1 are used. */
static enum dw_cfi_oprnd_type dw_cfi_oprnd1_desc
(enum dwarf_call_frame_info cfi);
}
}
-#if defined (DWARF2_DEBUGGING_INFO) || defined (DWARF2_UNWIND_INFO)
-
/* Switch [BACK] to eh_frame_section. If we don't have an eh_frame_section,
switch to the data section instead, and write out a synthetic start label
for collect2 the first time around. */
flags = SECTION_WRITE;
eh_frame_section = get_section (EH_FRAME_SECTION_NAME, flags, NULL);
}
-#endif
+#endif /* EH_FRAME_SECTION_NAME */
if (eh_frame_section)
switch_to_section (eh_frame_section);
char l1[20], l2[20];
dw_cfi_ref cfi;
- targetm.asm_out.unwind_label (asm_out_file, fde->decl, for_eh,
- /* empty */ 0);
+ targetm.asm_out.emit_unwind_label (asm_out_file, fde->decl, for_eh,
+ /* empty */ 0);
targetm.asm_out.internal_label (asm_out_file, FDE_LABEL,
for_eh + j);
ASM_GENERATE_INTERNAL_LABEL (l1, FDE_AFTER_SIZE_LABEL, for_eh + j);
else if (fde_needed_for_eh_p (&fde_table[i]))
any_eh_needed = true;
else if (TARGET_USES_WEAK_UNWIND_INFO)
- targetm.asm_out.unwind_label (asm_out_file, fde_table[i].decl, 1, 1);
+ targetm.asm_out.emit_unwind_label (asm_out_file, fde_table[i].decl,
+ 1, 1);
if (!any_eh_needed)
return;
char * dup_label;
dw_fde_ref fde;
section *fnsec;
+ bool do_frame;
current_function_func_begin_label = NULL;
-#ifdef TARGET_UNWIND_INFO
- /* ??? current_function_func_begin_label is also used by except.c
- for call-site information. We must emit this label if it might
- be used. */
- if ((! flag_exceptions || USING_SJLJ_EXCEPTIONS)
- && ! dwarf2out_do_frame ())
- return;
-#else
- if (! dwarf2out_do_frame ())
+ do_frame = dwarf2out_do_frame ();
+
+ /* ??? current_function_func_begin_label is also used by except.c for
+ call-site information. We must emit this label if it might be used. */
+ if (!do_frame
+ && (!flag_exceptions
+ || targetm.except_unwind_info (&global_options) != UI_TARGET))
return;
-#endif
fnsec = function_section (current_function_decl);
switch_to_section (fnsec);
dup_label = xstrdup (label);
current_function_func_begin_label = dup_label;
-#ifdef TARGET_UNWIND_INFO
/* We can elide the fde allocation if we're not emitting debug info. */
- if (! dwarf2out_do_frame ())
+ if (!do_frame)
return;
-#endif
/* Expand the fde table if necessary. */
if (fde_table_in_use == fde_table_allocated)
fde->dw_fde_switched_sections = 0;
fde->dw_fde_switched_cold_to_hot = 0;
fde->dw_fde_end = NULL;
+ fde->dw_fde_vms_end_prologue = NULL;
+ fde->dw_fde_vms_begin_epilogue = NULL;
fde->dw_fde_cfi = NULL;
fde->dw_fde_switch_cfi = NULL;
fde->funcdef_number = current_function_funcdef_no;
}
}
+/* Output a marker (i.e. a label) for the end of the generated code
+ for a function prologue. This gets called *after* the prologue code has
+ been generated. */
+
+void
+dwarf2out_vms_end_prologue (unsigned int line ATTRIBUTE_UNUSED,
+ const char *file ATTRIBUTE_UNUSED)
+{
+ dw_fde_ref fde;
+ char label[MAX_ARTIFICIAL_LABEL_BYTES];
+
+ /* Output a label to mark the endpoint of the code generated for this
+ function. */
+ ASM_GENERATE_INTERNAL_LABEL (label, PROLOGUE_END_LABEL,
+ current_function_funcdef_no);
+ ASM_OUTPUT_DEBUG_LABEL (asm_out_file, PROLOGUE_END_LABEL,
+ current_function_funcdef_no);
+ fde = &fde_table[fde_table_in_use - 1];
+ fde->dw_fde_vms_end_prologue = xstrdup (label);
+}
+
+/* Output a marker (i.e. a label) for the beginning of the generated code
+ for a function epilogue. This gets called *before* the prologue code has
+ been generated. */
+
+void
+dwarf2out_vms_begin_epilogue (unsigned int line ATTRIBUTE_UNUSED,
+ const char *file ATTRIBUTE_UNUSED)
+{
+ dw_fde_ref fde;
+ char label[MAX_ARTIFICIAL_LABEL_BYTES];
+
+ fde = &fde_table[fde_table_in_use - 1];
+ if (fde->dw_fde_vms_begin_epilogue)
+ return;
+
+ /* Output a label to mark the endpoint of the code generated for this
+ function. */
+ ASM_GENERATE_INTERNAL_LABEL (label, EPILOGUE_BEGIN_LABEL,
+ current_function_funcdef_no);
+ ASM_OUTPUT_DEBUG_LABEL (asm_out_file, EPILOGUE_BEGIN_LABEL,
+ current_function_funcdef_no);
+ fde->dw_fde_vms_begin_epilogue = xstrdup (label);
+}
+
/* Output a marker (i.e. a label) for the absolute end of the generated code
for a function definition. This gets called *after* the epilogue code has
been generated. */
dw_fde_ref fde;
char label[MAX_ARTIFICIAL_LABEL_BYTES];
-#ifdef DWARF2_DEBUGGING_INFO
last_var_location_insn = NULL_RTX;
-#endif
if (dwarf2out_do_cfi_asm ())
fprintf (asm_out_file, "\t.cfi_endproc\n");
dwarf2out_frame_init (void)
{
/* Allocate the initial hunk of the fde_table. */
- fde_table = GGC_CNEWVEC (dw_fde_node, FDE_TABLE_INCREMENT);
+ fde_table = ggc_alloc_cleared_vec_dw_fde_node (FDE_TABLE_INCREMENT);
fde_table_allocated = FDE_TABLE_INCREMENT;
fde_table_in_use = 0;
/* On entry, the Canonical Frame Address is at SP. */
dwarf2out_def_cfa (NULL, STACK_POINTER_REGNUM, INCOMING_FRAME_SP_OFFSET);
-#ifdef DWARF2_UNWIND_INFO
- if (DWARF2_UNWIND_INFO || DWARF2_FRAME_INFO)
+ if (targetm.debug_unwind_info () == UI_DWARF2
+ || targetm.except_unwind_info (&global_options) == UI_DWARF2)
initial_return_save (INCOMING_RETURN_ADDR_RTX);
-#endif
}
void
dwarf2out_frame_finish (void)
{
/* Output call frame information. */
- if (DWARF2_FRAME_INFO)
+ if (targetm.debug_unwind_info () == UI_DWARF2)
output_call_frame_info (0);
-#ifndef TARGET_UNWIND_INFO
/* Output another copy for the unwinder. */
- if (! USING_SJLJ_EXCEPTIONS && (flag_unwind_tables || flag_exceptions))
+ if ((flag_unwind_tables || flag_exceptions)
+ && targetm.except_unwind_info (&global_options) == UI_DWARF2)
output_call_frame_info (1);
-#endif
}
/* Note that the current function section is being used for code. */
fde->dw_fde_switch_cfi = cfi;
}
}
-#endif
\f
/* And now, the subset of the debugging information support code necessary
for emitting location expressions. */
dw_val_class_str,
dw_val_class_macptr,
dw_val_class_file,
- dw_val_class_data8
+ dw_val_class_data8,
+ dw_val_class_decl_ref,
+ dw_val_class_vms_delta
};
/* Describe a floating point constant value, or a vector constant value. */
unsigned char GTY ((tag ("dw_val_class_flag"))) val_flag;
struct dwarf_file_data * GTY ((tag ("dw_val_class_file"))) val_file;
unsigned char GTY ((tag ("dw_val_class_data8"))) val_data8[8];
+ tree GTY ((tag ("dw_val_class_decl_ref"))) val_decl_ref;
+ struct dw_val_vms_delta_union
+ {
+ char * lbl1;
+ char * lbl2;
+ } GTY ((tag ("dw_val_class_vms_delta"))) val_vms_delta;
}
GTY ((desc ("%1.val_class"))) v;
}
Only on head of list */
const char *section; /* Section this loclist is relative to */
dw_loc_descr_ref expr;
+ hashval_t hash;
+ bool emitted;
} dw_loc_list_node;
-#if defined (DWARF2_DEBUGGING_INFO) || defined (DWARF2_UNWIND_INFO)
-
static dw_loc_descr_ref int_loc_descriptor (HOST_WIDE_INT);
/* Convert a DWARF stack opcode into its string name. */
return "DW_OP_GNU_uninit";
case DW_OP_GNU_encoded_addr:
return "DW_OP_GNU_encoded_addr";
+ case DW_OP_GNU_implicit_pointer:
+ return "DW_OP_GNU_implicit_pointer";
default:
return "OP_<unknown>";
new_loc_descr (enum dwarf_location_atom op, unsigned HOST_WIDE_INT oprnd1,
unsigned HOST_WIDE_INT oprnd2)
{
- dw_loc_descr_ref descr = GGC_CNEW (dw_loc_descr_node);
+ dw_loc_descr_ref descr = ggc_alloc_cleared_dw_loc_descr_node ();
descr->dw_loc_opc = op;
descr->dw_loc_oprnd1.val_class = dw_val_class_unsigned_const;
}
}
-#ifdef DWARF2_DEBUGGING_INFO
/* Add a constant OFFSET to a location list. */
static void
for (d = list_head; d != NULL; d = d->dw_loc_next)
loc_descr_plus_const (&d->expr, offset);
}
-#endif
+
+#define DWARF_REF_SIZE \
+ (dwarf_version == 2 ? DWARF2_ADDR_SIZE : DWARF_OFFSET_SIZE)
/* Return the size of a location descriptor. */
size += 4;
break;
case DW_OP_call_ref:
- size += DWARF2_ADDR_SIZE;
+ size += DWARF_REF_SIZE;
break;
case DW_OP_implicit_value:
size += size_of_uleb128 (loc->dw_loc_oprnd1.v.val_unsigned)
+ loc->dw_loc_oprnd1.v.val_unsigned;
break;
+ case DW_OP_GNU_implicit_pointer:
+ size += DWARF_REF_SIZE + size_of_sleb128 (loc->dw_loc_oprnd2.v.val_int);
+ break;
default:
break;
}
return size;
}
-#ifdef DWARF2_DEBUGGING_INFO
static HOST_WIDE_INT extract_int (const unsigned char *, unsigned);
-#endif
+static void get_ref_die_offset_label (char *, dw_die_ref);
/* Output location description stack opcode's operands (if any). */
dw2_asm_output_data (2, val1->v.val_int, NULL);
break;
case DW_OP_const4u:
+ if (loc->dtprel)
+ {
+ gcc_assert (targetm.asm_out.output_dwarf_dtprel);
+ targetm.asm_out.output_dwarf_dtprel (asm_out_file, 4,
+ val1->v.val_addr);
+ fputc ('\n', asm_out_file);
+ break;
+ }
+ /* FALLTHRU */
case DW_OP_const4s:
dw2_asm_output_data (4, val1->v.val_int, NULL);
break;
case DW_OP_const8u:
+ if (loc->dtprel)
+ {
+ gcc_assert (targetm.asm_out.output_dwarf_dtprel);
+ targetm.asm_out.output_dwarf_dtprel (asm_out_file, 8,
+ val1->v.val_addr);
+ fputc ('\n', asm_out_file);
+ break;
+ }
+ /* FALLTHRU */
case DW_OP_const8s:
gcc_assert (HOST_BITS_PER_WIDE_INT >= 64);
dw2_asm_output_data (8, val1->v.val_int, NULL);
}
break;
+ case DW_OP_GNU_implicit_pointer:
+ {
+ char label[MAX_ARTIFICIAL_LABEL_BYTES
+ + HOST_BITS_PER_WIDE_INT / 2 + 2];
+ gcc_assert (val1->val_class == dw_val_class_die_ref);
+ get_ref_die_offset_label (label, val1->v.val_die_ref.die);
+ dw2_asm_output_offset (DWARF_REF_SIZE, label, debug_info_section, NULL);
+ dw2_asm_output_data_sleb128 (val2->v.val_int, NULL);
+ }
+ break;
+
default:
/* Other codes have no operands. */
break;
dw2_asm_output_data_sleb128_raw (val2->v.val_int);
break;
+ case DW_OP_GNU_implicit_pointer:
+ gcc_unreachable ();
+ break;
+
default:
/* Other codes have no operands. */
break;
}
}
}
-#endif /* .debug_frame support */
\f
/* And now, the support for symbolic debugging information. */
-#ifdef DWARF2_DEBUGGING_INFO
/* .debug_str support. */
static int output_indirect_string (void **, void *);
dwarf2out_ignore_block,
dwarf2out_source_line,
dwarf2out_begin_prologue,
- debug_nothing_int_charstar, /* end_prologue */
+#if VMS_DEBUGGING_INFO
+ dwarf2out_vms_end_prologue,
+ dwarf2out_vms_begin_epilogue,
+#else
+ debug_nothing_int_charstar,
+ debug_nothing_int_charstar,
+#endif
dwarf2out_end_epilogue,
dwarf2out_begin_function,
debug_nothing_int, /* end_function */
dwarf2out_copy_call_info,
dwarf2out_virtual_call,
dwarf2out_set_name,
- 1 /* start_end_main_source_file */
+ 1, /* start_end_main_source_file */
+ TYPE_SYMTAB_IS_DIE /* tree_type_symtab_field */
};
-#endif
\f
/* NOTE: In the comments in this file, many references are made to
"Debugging Information Entries". This term is abbreviated as `DIE'
die_sib. die_child points to the node *before* the "first" child node. */
typedef struct GTY((chain_circular ("%h.die_sib"))) die_struct {
- enum dwarf_tag die_tag;
union die_symbol_or_type_node
{
char * GTY ((tag ("0"))) die_symbol;
/* Die is used and must not be pruned as unused. */
int die_perennial_p;
unsigned int decl_id;
+ enum dwarf_tag die_tag;
}
die_node;
int num;
};
+/* A structure to hold a macinfo entry. */
+
+typedef struct GTY(()) macinfo_struct {
+ unsigned HOST_WIDE_INT code;
+ unsigned HOST_WIDE_INT lineno;
+ const char *info;
+}
+macinfo_entry;
+
+DEF_VEC_O(macinfo_entry);
+DEF_VEC_ALLOC_O(macinfo_entry, gc);
+
struct GTY(()) dw_ranges_by_label_struct {
const char *begin;
const char *end;
}
limbo_die_node;
-typedef struct GTY(()) skeleton_chain_struct
+typedef struct skeleton_chain_struct
{
dw_die_ref old_die;
dw_die_ref new_die;
#define DWARF_LINE_DEFAULT_MAX_OPS_PER_INSN 1
#endif
-#ifdef DWARF2_DEBUGGING_INFO
/* This location is used by calc_die_sizes() to keep track
the offset of each DIE within the .debug_info section. */
static unsigned long next_die_offset;
-#endif
/* Record the root of the DIE's built for the current compilation unit. */
-static GTY(()) dw_die_ref comp_unit_die;
+static GTY(()) dw_die_ref single_comp_unit_die;
/* A list of type DIEs that have been separated into comdat sections. */
static GTY(()) comdat_type_node *comdat_type_list;
line_info_table. */
#define LINE_INFO_TABLE_INCREMENT 1024
+/* A flag to tell pubnames/types export if there is an info section to
+ refer to. */
+static bool info_section_emitted;
+
/* A pointer to the base of a table that contains a list of publicly
accessible names. */
static GTY (()) VEC (pubname_entry, gc) * pubname_table;
accessible types. */
static GTY (()) VEC (pubname_entry, gc) * pubtype_table;
+/* A pointer to the base of a table that contains a list of macro
+ defines/undefines (and file start/end markers). */
+static GTY (()) VEC (macinfo_entry, gc) * macinfo_table;
+
/* Array of dies for which we should generate .debug_arange info. */
static GTY((length ("arange_table_allocated"))) dw_die_ref *arange_table;
static GTY ((param_is (struct vcall_insn))) htab_t vcall_insn_table;
-#ifdef DWARF2_DEBUGGING_INFO
/* Record whether the function being analyzed contains inlined functions. */
static int current_function_has_inlines;
-#endif
-#if 0 && defined (MIPS_DEBUGGING_INFO)
-static int comp_unit_has_inlines;
-#endif
/* The last file entry emitted by maybe_emit_file(). */
static GTY(()) struct dwarf_file_data * last_emitted_file;
static GTY(()) VEC(die_arg_entry,gc) *tmpl_value_parm_die_table;
-#ifdef DWARF2_DEBUGGING_INFO
-
/* Offset from the "steady-state frame pointer" to the frame base,
within the current function. */
static HOST_WIDE_INT frame_pointer_fb_offset;
static void add_child_die (dw_die_ref, dw_die_ref);
static dw_die_ref new_die (enum dwarf_tag, dw_die_ref, tree);
static dw_die_ref lookup_type_die (tree);
+static dw_die_ref lookup_type_die_strip_naming_typedef (tree);
static void equate_type_number_to_die (tree, dw_die_ref);
static hashval_t decl_die_table_hash (const void *);
static int decl_die_table_eq (const void *, const void *);
enum var_init_status);
static int is_based_loc (const_rtx);
static int resolve_one_addr (rtx *, void *);
-static dw_loc_descr_ref mem_loc_descriptor (rtx, enum machine_mode mode,
- enum var_init_status);
static dw_loc_descr_ref concat_loc_descriptor (rtx, rtx,
enum var_init_status);
static dw_loc_descr_ref loc_descriptor (rtx, enum machine_mode mode,
static void gen_block_die (tree, dw_die_ref, int);
static void decls_for_scope (tree, dw_die_ref, int);
static int is_redundant_typedef (const_tree);
+static bool is_naming_typedef_decl (const_tree);
static inline dw_die_ref get_context_die (tree);
static void gen_namespace_die (tree, dw_die_ref);
-static void gen_decl_die (tree, tree, dw_die_ref);
+static dw_die_ref gen_decl_die (tree, tree, dw_die_ref);
static dw_die_ref force_decl_die (tree);
static dw_die_ref force_type_die (tree);
static dw_die_ref setup_namespace_context (tree, dw_die_ref);
static void retry_incomplete_types (void);
static void gen_type_die_for_member (tree, tree, dw_die_ref);
static void gen_generic_params_dies (tree);
+static void gen_tagged_type_die (tree, dw_die_ref, enum debug_info_usage);
+static void gen_type_die_with_usage (tree, dw_die_ref, enum debug_info_usage);
static void splice_child_die (dw_die_ref, dw_die_ref);
static int file_info_cmp (const void *, const void *);
static dw_loc_list_ref new_loc_list (dw_loc_descr_ref, const char *,
static void prune_unused_types_prune (dw_die_ref);
static void prune_unused_types (void);
static int maybe_emit_file (struct dwarf_file_data *fd);
+static inline const char *AT_vms_delta1 (dw_attr_ref);
+static inline const char *AT_vms_delta2 (dw_attr_ref);
+static inline void add_AT_vms_delta (dw_die_ref, enum dwarf_attribute,
+ const char *, const char *);
static void append_entry_to_tmpl_value_parm_die_table (dw_die_ref, tree);
static void gen_remaining_tmpl_value_param_die_attribute (void);
#define DEBUG_MACINFO_SECTION_LABEL "Ldebug_macinfo"
#endif
-/* Mangled name attribute to use. This used to be a vendor extension
- until DWARF 4 standardized it. */
-#define AT_linkage_name \
- (dwarf_version >= 4 ? DW_AT_linkage_name : DW_AT_MIPS_linkage_name)
-
/* Definitions of defaults for formats and names of various special
(artificial) labels which may be generated within this file (when the -g
#endif
\f
+/* Return the root of the DIE's built for the current compilation unit. */
+static dw_die_ref
+comp_unit_die (void)
+{
+ if (!single_comp_unit_die)
+ single_comp_unit_die = gen_compile_unit_die (NULL);
+ return single_comp_unit_die;
+}
+
/* We allow a language front-end to designate a function that is to be
called to "demangle" any name before it is put into a DIE. */
|| code == QUAL_UNION_TYPE || code == ENUMERAL_TYPE);
}
+/* Set label to debug_info_section_label + die_offset of a DIE reference. */
+
+static void
+get_ref_die_offset_label (char *label, dw_die_ref ref)
+{
+ sprintf (label, "%s+%ld", debug_info_section_label, ref->die_offset);
+}
+
/* Convert a DIE tag into its string name. */
static const char *
return "DW_AT_call_file";
case DW_AT_call_line:
return "DW_AT_call_line";
+ case DW_AT_object_pointer:
+ return "DW_AT_object_pointer";
case DW_AT_signature:
return "DW_AT_signature";
return "DW_AT_MIPS_tail_loop_begin";
case DW_AT_MIPS_epilog_begin:
return "DW_AT_MIPS_epilog_begin";
+#if VMS_DEBUGGING_INFO
+ case DW_AT_HP_prologue:
+ return "DW_AT_HP_prologue";
+#else
case DW_AT_MIPS_loop_unroll_factor:
return "DW_AT_MIPS_loop_unroll_factor";
+#endif
case DW_AT_MIPS_software_pipeline_depth:
return "DW_AT_MIPS_software_pipeline_depth";
case DW_AT_MIPS_linkage_name:
return "DW_AT_MIPS_linkage_name";
+#if VMS_DEBUGGING_INFO
+ case DW_AT_HP_epilogue:
+ return "DW_AT_HP_epilogue";
+#else
case DW_AT_MIPS_stride:
return "DW_AT_MIPS_stride";
+#endif
case DW_AT_MIPS_abstract_name:
return "DW_AT_MIPS_abstract_name";
case DW_AT_MIPS_clone_origin:
htab_hash_string (str), INSERT);
if (*slot == NULL)
{
- node = (struct indirect_string_node *)
- ggc_alloc_cleared (sizeof (struct indirect_string_node));
+ node = ggc_alloc_cleared_indirect_string_node ();
node->str = ggc_strdup (str);
*slot = node;
}
{
dw_attr_node attr;
+#ifdef ENABLE_CHECKING
+ gcc_assert (targ_die != NULL);
+#else
+ /* With LTO we can end up trying to reference something we didn't create
+ a DIE for. Avoid crashing later on a NULL referenced DIE. */
+ if (targ_die == NULL)
+ return;
+#endif
+
attr.dw_attr = attr_kind;
attr.dw_attr_val.val_class = dw_val_class_die_ref;
attr.dw_attr_val.v.val_die_ref.die = targ_die;
return a->dw_attr_val.v.val_file;
}
+/* Add a vms delta attribute value to a DIE. */
+
+static inline void
+add_AT_vms_delta (dw_die_ref die, enum dwarf_attribute attr_kind,
+ const char *lbl1, const char *lbl2)
+{
+ dw_attr_node attr;
+
+ attr.dw_attr = attr_kind;
+ attr.dw_attr_val.val_class = dw_val_class_vms_delta;
+ attr.dw_attr_val.v.val_vms_delta.lbl1 = xstrdup (lbl1);
+ attr.dw_attr_val.v.val_vms_delta.lbl2 = xstrdup (lbl2);
+ add_dwarf_attr (die, &attr);
+}
+
/* Add a label identifier attribute value to a DIE. */
static inline void
add_dwarf_attr (die, &attr);
}
+/* Return the start label of a delta attribute. */
+
+static inline const char *
+AT_vms_delta1 (dw_attr_ref a)
+{
+ gcc_assert (a && (AT_class (a) == dw_val_class_vms_delta));
+ return a->dw_attr_val.v.val_vms_delta.lbl1;
+}
+
+/* Return the end label of a delta attribute. */
+
+static inline const char *
+AT_vms_delta2 (dw_attr_ref a)
+{
+ gcc_assert (a && (AT_class (a) == dw_val_class_vms_delta));
+ return a->dw_attr_val.v.val_vms_delta.lbl2;
+}
+
static inline const char *
AT_lbl (dw_attr_ref a)
{
if (! die)
return NULL;
- for (ix = 0; VEC_iterate (dw_attr_node, die->die_attr, ix, a); ix++)
+ FOR_EACH_VEC_ELT (dw_attr_node, die->die_attr, ix, a)
if (a->dw_attr == attr_kind)
return a;
else if (a->dw_attr == DW_AT_specification
static inline bool
is_cxx (void)
{
- unsigned int lang = get_AT_unsigned (comp_unit_die, DW_AT_language);
+ unsigned int lang = get_AT_unsigned (comp_unit_die (), DW_AT_language);
return lang == DW_LANG_C_plus_plus || lang == DW_LANG_ObjC_plus_plus;
}
static inline bool
is_fortran (void)
{
- unsigned int lang = get_AT_unsigned (comp_unit_die, DW_AT_language);
+ unsigned int lang = get_AT_unsigned (comp_unit_die (), DW_AT_language);
return (lang == DW_LANG_Fortran77
|| lang == DW_LANG_Fortran90
static inline bool
is_ada (void)
{
- unsigned int lang = get_AT_unsigned (comp_unit_die, DW_AT_language);
+ unsigned int lang = get_AT_unsigned (comp_unit_die (), DW_AT_language);
return lang == DW_LANG_Ada95 || lang == DW_LANG_Ada83;
}
if (! die)
return;
- for (ix = 0; VEC_iterate (dw_attr_node, die->die_attr, ix, a); ix++)
+ FOR_EACH_VEC_ELT (dw_attr_node, die->die_attr, ix, a)
if (a->dw_attr == attr_kind)
{
if (AT_class (a) == dw_val_class_str)
static inline dw_die_ref
new_die (enum dwarf_tag tag_value, dw_die_ref parent_die, tree t)
{
- dw_die_ref die = GGC_CNEW (die_node);
+ dw_die_ref die = ggc_alloc_cleared_die_node ();
die->die_tag = tag_value;
{
limbo_die_node *limbo_node;
- limbo_node = GGC_CNEW (limbo_die_node);
+ limbo_node = ggc_alloc_cleared_limbo_die_node ();
limbo_node->die = die;
limbo_node->created_for = t;
limbo_node->next = limbo_die_list;
return TYPE_SYMTAB_DIE (type);
}
+/* Like lookup_type_die, but if type is an anonymous type named by a
+ typedef[1], return the DIE of the anonymous type instead the one of
+ the naming typedef. This is because in gen_typedef_die, we did
+ equate the anonymous struct named by the typedef with the DIE of
+ the naming typedef. So by default, lookup_type_die on an anonymous
+ struct yields the DIE of the naming typedef.
+
+ [1]: Read the comment of is_naming_typedef_decl to learn about what
+ a naming typedef is. */
+
+static inline dw_die_ref
+lookup_type_die_strip_naming_typedef (tree type)
+{
+ dw_die_ref die = lookup_type_die (type);
+ if (TREE_CODE (type) == RECORD_TYPE
+ && die->die_tag == DW_TAG_typedef
+ && is_naming_typedef_decl (TYPE_NAME (type)))
+ die = get_AT_ref (die, DW_AT_type);
+ return die;
+}
+
/* Equate a DIE to a given type specifier. */
static inline void
slot = htab_find_slot_with_hash (decl_loc_table, decl, decl_id, INSERT);
if (*slot == NULL)
{
- temp = GGC_CNEW (var_loc_list);
+ temp = ggc_alloc_cleared_var_loc_list ();
temp->decl_id = decl_id;
*slot = temp;
}
memset (loc, '\0', sizeof (*loc));
}
else
- loc = GGC_CNEW (struct var_loc_node);
+ loc = ggc_alloc_cleared_var_loc_node ();
if (bitsize == -1 || piece_loc == NULL)
loc->loc = construct_piece_list (loc_note, bitpos, bitsize);
else
}
else
{
- loc = GGC_CNEW (struct var_loc_node);
+ loc = ggc_alloc_cleared_var_loc_node ();
temp->first = loc;
temp->last = loc;
loc->loc = construct_piece_list (loc_note, bitpos, bitsize);
unsigned ix;
print_spaces (outfile);
- fprintf (outfile, "DIE %4ld: %s\n",
- die->die_offset, dwarf_tag_name (die->die_tag));
+ fprintf (outfile, "DIE %4ld: %s (%p)\n",
+ die->die_offset, dwarf_tag_name (die->die_tag),
+ (void*) die);
print_spaces (outfile);
fprintf (outfile, " abbrev id: %lu", die->die_abbrev);
- fprintf (outfile, " offset: %ld\n", die->die_offset);
+ fprintf (outfile, " offset: %ld", die->die_offset);
+ fprintf (outfile, " mark: %d\n", die->die_mark);
+
if (dwarf_version >= 4 && die->die_id.die_type_node)
{
print_spaces (outfile);
fprintf (outfile, "\n");
}
- for (ix = 0; VEC_iterate (dw_attr_node, die->die_attr, ix, a); ix++)
+ FOR_EACH_VEC_ELT (dw_attr_node, die->die_attr, ix, a)
{
print_spaces (outfile);
fprintf (outfile, " %s: ", dwarf_attr_name (a->dw_attr));
AT_ref (a)->die_id.die_symbol);
else
fprintf (outfile, "die -> %ld", AT_ref (a)->die_offset);
+ fprintf (outfile, " (%p)", (void *) AT_ref (a));
}
else
fprintf (outfile, "die -> <null>");
break;
+ case dw_val_class_vms_delta:
+ fprintf (outfile, "delta: @slotcount(%s-%s)",
+ AT_vms_delta2 (a), AT_vms_delta1 (a));
+ break;
case dw_val_class_lbl_id:
case dw_val_class_lineptr:
case dw_val_class_macptr:
/* Print the information collected for a given DIE. */
-void
+DEBUG_FUNCTION void
debug_dwarf_die (dw_die_ref die)
{
print_die (die, stderr);
/* Print all DWARF information collected for the compilation unit.
This routine is a debugging aid only. */
-void
+DEBUG_FUNCTION void
debug_dwarf (void)
{
print_indent = 0;
- print_die (comp_unit_die, stderr);
+ print_die (comp_unit_die (), stderr);
if (! DWARF2_ASM_LINE_DEBUG_INFO)
print_dwarf_line_table (stderr);
}
break;
case dw_val_class_fde_ref:
+ case dw_val_class_vms_delta:
case dw_val_class_lbl_id:
case dw_val_class_lineptr:
case dw_val_class_macptr:
CHECKSUM (die->die_tag);
- for (ix = 0; VEC_iterate (dw_attr_node, die->die_attr, ix, a); ix++)
+ FOR_EACH_VEC_ELT (dw_attr_node, die->die_attr, ix, a)
attr_checksum (a, ctx, mark);
FOR_EACH_CHILD (die, c, die_checksum (c, ctx, mark));
dw_attr_ref a;
unsigned ix;
- for (ix = 0; VEC_iterate (dw_attr_node, die->die_attr, ix, a); ix++)
+ FOR_EACH_VEC_ELT (dw_attr_node, die->die_attr, ix, a)
{
switch (a->dw_attr)
{
return same_die_p (v1->v.val_die_ref.die, v2->v.val_die_ref.die, mark);
case dw_val_class_fde_ref:
+ case dw_val_class_vms_delta:
case dw_val_class_lbl_id:
case dw_val_class_lineptr:
case dw_val_class_macptr:
!= VEC_length (dw_attr_node, die2->die_attr))
return 0;
- for (ix = 0; VEC_iterate (dw_attr_node, die1->die_attr, ix, a1); ix++)
+ FOR_EACH_VEC_ELT (dw_attr_node, die1->die_attr, ix, a1)
if (!same_attr_p (a1, VEC_index (dw_attr_node, die2->die_attr, ix), mark))
return 0;
|| c->die_tag == DW_TAG_module);
}
+/* Returns true iff C is a compile-unit DIE. */
+
+static inline bool
+is_cu_die (dw_die_ref c)
+{
+ return c && c->die_tag == DW_TAG_compile_unit;
+}
+
static char *
gen_internal_sym (const char *prefix)
{
dw_attr_ref a;
unsigned ix;
- for (ix = 0; VEC_iterate (dw_attr_node, die->die_attr, ix, a); ix++)
+ FOR_EACH_VEC_ELT (dw_attr_node, die->die_attr, ix, a)
if (a->dw_attr == DW_AT_declaration)
return 1;
return 0;
}
-/* Return non-zero if this is a type DIE that should be moved to a
- COMDAT .debug_types section. */
+/* Return non-zero if this DIE is nested inside a subprogram. */
static int
-should_move_die_to_comdat (dw_die_ref die)
+is_nested_in_subprogram (dw_die_ref die)
{
- switch (die->die_tag)
- {
- case DW_TAG_class_type:
- case DW_TAG_structure_type:
+ dw_die_ref decl = get_AT_ref (die, DW_AT_specification);
+
+ if (decl == NULL)
+ decl = die;
+ return local_scope_p (decl);
+}
+
+/* Return non-zero if this is a type DIE that should be moved to a
+ COMDAT .debug_types section. */
+
+static int
+should_move_die_to_comdat (dw_die_ref die)
+{
+ switch (die->die_tag)
+ {
+ case DW_TAG_class_type:
+ case DW_TAG_structure_type:
case DW_TAG_enumeration_type:
case DW_TAG_union_type:
- /* Don't move declarations or inlined instances. */
- if (is_declaration_die (die) || get_AT (die, DW_AT_abstract_origin))
+ /* Don't move declarations, inlined instances, or types nested in a
+ subprogram. */
+ if (is_declaration_die (die)
+ || get_AT (die, DW_AT_abstract_origin)
+ || is_nested_in_subprogram (die))
return 0;
return 1;
case DW_TAG_array_type:
dw_attr_ref a;
unsigned ix;
- clone = GGC_CNEW (die_node);
+ clone = ggc_alloc_cleared_die_node ();
clone->die_tag = die->die_tag;
- for (ix = 0; VEC_iterate (dw_attr_node, die->die_attr, ix, a); ix++)
+ FOR_EACH_VEC_ELT (dw_attr_node, die->die_attr, ix, a)
add_dwarf_attr (clone, a);
return clone;
if (decl != NULL)
return clone_die (decl);
- clone = GGC_CNEW (die_node);
+ clone = ggc_alloc_cleared_die_node ();
clone->die_tag = die->die_tag;
- for (ix = 0; VEC_iterate (dw_attr_node, die->die_attr, ix, a); ix++)
+ FOR_EACH_VEC_ELT (dw_attr_node, die->die_attr, ix, a)
{
/* We don't want to copy over all attributes.
For example we don't want DW_AT_byte_size because otherwise we will no
remove_AT (die, DW_AT_specification);
- for (ix = 0; VEC_iterate (dw_attr_node, decl->die_attr, ix, a); ix++)
+ FOR_EACH_VEC_ELT (dw_attr_node, decl->die_attr, ix, a)
{
if (a->dw_attr != DW_AT_name
&& a->dw_attr != DW_AT_declaration
add it to the list of comdat types. */
unit = new_die (DW_TAG_type_unit, NULL, NULL);
add_AT_unsigned (unit, DW_AT_language,
- get_AT_unsigned (comp_unit_die, DW_AT_language));
- type_node = GGC_CNEW (comdat_type_node);
+ get_AT_unsigned (comp_unit_die (), DW_AT_language));
+ type_node = ggc_alloc_cleared_comdat_type_node ();
type_node->root_die = unit;
type_node->next = comdat_type_list;
comdat_type_list = type_node;
if (decl_table != NULL)
{
- /* Make sure the copy is marked as part of the type unit. */
- copy->die_mark = 1;
/* Record the pointer to the copy. */
entry->copy = copy;
}
dw_attr_ref a;
unsigned ix;
- for (ix = 0; VEC_iterate (dw_attr_node, die->die_attr, ix, a); ix++)
+ FOR_EACH_VEC_ELT (dw_attr_node, die->die_attr, ix, a)
{
if (AT_class (a) == dw_val_class_die_ref)
{
installed in a previously-added context, it won't
get visited otherwise. */
if (parent != unit)
- copy_decls_walk (unit, parent, decl_table);
+ {
+ /* Find the highest point of the newly-added tree,
+ mark each node along the way, and walk from there. */
+ parent->die_mark = 1;
+ while (parent->die_parent
+ && parent->die_parent->die_mark == 0)
+ {
+ parent = parent->die_parent;
+ parent->die_mark = 1;
+ }
+ copy_decls_walk (unit, parent, decl_table);
+ }
}
}
}
dw_attr_ref a;
unsigned ix;
- for (ix = 0; VEC_iterate (dw_attr_node, die->die_attr, ix, a); ix++)
+ FOR_EACH_VEC_ELT (dw_attr_node, die->die_attr, ix, a)
if (AT_class (a) == dw_val_class_loc_list)
output_loc_list (AT_loc_list (a));
/* Scan the DIE references, and mark as external any that refer to
DIEs from other CUs (i.e. those which are not marked). */
- for (ix = 0; VEC_iterate (dw_attr_node, die->die_attr, ix, a); ix++)
+ FOR_EACH_VEC_ELT (dw_attr_node, die->die_attr, ix, a)
if (AT_class (a) == dw_val_class_die_ref
&& AT_ref (a)->die_mark == 0)
{
!= VEC_length (dw_attr_node, die->die_attr))
continue;
- for (ix = 0; VEC_iterate (dw_attr_node, die->die_attr, ix, die_a); ix++)
+ FOR_EACH_VEC_ELT (dw_attr_node, die->die_attr, ix, die_a)
{
abbrev_a = VEC_index (dw_attr_node, abbrev->die_attr, ix);
if ((abbrev_a->dw_attr != die_a->dw_attr)
unsigned ix;
size += size_of_uleb128 (die->die_abbrev);
- for (ix = 0; VEC_iterate (dw_attr_node, die->die_attr, ix, a); ix++)
+ FOR_EACH_VEC_ELT (dw_attr_node, die->die_attr, ix, a)
{
switch (AT_class (a))
{
case dw_val_class_data8:
size += 8;
break;
+ case dw_val_class_vms_delta:
+ size += DWARF_OFFSET_SIZE;
+ break;
default:
gcc_unreachable ();
}
FOR_EACH_CHILD (die, c, unmark_all_dies (c));
- for (ix = 0; VEC_iterate (dw_attr_node, die->die_attr, ix, a); ix++)
+ FOR_EACH_VEC_ELT (dw_attr_node, die->die_attr, ix, a)
if (AT_class (a) == dw_val_class_die_ref)
unmark_all_dies (AT_ref (a));
}
pubname_ref p;
size = DWARF_PUBNAMES_HEADER_SIZE;
- for (i = 0; VEC_iterate (pubname_entry, names, i, p); i++)
+ FOR_EACH_VEC_ELT (pubname_entry, names, i, p)
if (names != pubtype_table
|| p->die->die_offset != 0
|| !flag_eliminate_unused_debug_types)
if (dwarf_version >= 4)
return DW_FORM_sec_offset;
/* FALLTHRU */
+ case dw_val_class_vms_delta:
case dw_val_class_offset:
switch (DWARF_OFFSET_SIZE)
{
new_loc_list (dw_loc_descr_ref expr, const char *begin, const char *end,
const char *section)
{
- dw_loc_list_ref retlist = GGC_CNEW (dw_loc_list_node);
+ dw_loc_list_ref retlist = ggc_alloc_cleared_dw_loc_list_node ();
retlist->begin = begin;
retlist->end = end;
{
dw_loc_list_ref curr = list_head;
+ if (list_head->emitted)
+ return;
+ list_head->emitted = true;
+
ASM_OUTPUT_LABEL (asm_out_file, list_head->ll_symbol);
/* Walk the location list, and output each range + expression. */
(unsigned long)die->die_offset,
dwarf_tag_name (die->die_tag));
- for (ix = 0; VEC_iterate (dw_attr_node, die->die_attr, ix, a); ix++)
+ FOR_EACH_VEC_ELT (dw_attr_node, die->die_attr, ix, a)
{
const char *name = dwarf_attr_name (a->dw_attr);
}
break;
+ case dw_val_class_vms_delta:
+ dw2_asm_output_vms_delta (DWARF_OFFSET_SIZE,
+ AT_vms_delta2 (a), AT_vms_delta1 (a),
+ "%s", name);
+ break;
+
case dw_val_class_lbl_id:
dw2_asm_output_addr (DWARF2_ADDR_SIZE, AT_lbl (a), "%s", name);
break;
switch_to_section (get_section (secname, SECTION_DEBUG, NULL));
}
else
- switch_to_section (debug_info_section);
+ {
+ switch_to_section (debug_info_section);
+ ASM_OUTPUT_LABEL (asm_out_file, debug_info_section_label);
+ info_section_emitted = true;
+ }
/* Output debugging information. */
output_compilation_unit_header ();
static const char *
dwarf2_name (tree decl, int scope)
{
+ if (DECL_NAMELESS (decl))
+ return NULL;
return lang_hooks.dwarf_name (decl, scope ? 1 : 0);
}
static void
add_pubname_string (const char *str, dw_die_ref die)
{
- pubname_entry e;
+ if (targetm.want_debug_pub_sections)
+ {
+ pubname_entry e;
- e.die = die;
- e.name = xstrdup (str);
- VEC_safe_push (pubname_entry, gc, pubname_table, &e);
+ e.die = die;
+ e.name = xstrdup (str);
+ VEC_safe_push (pubname_entry, gc, pubname_table, &e);
+ }
}
static void
add_pubname (tree decl, dw_die_ref die)
{
- if (TREE_PUBLIC (decl))
+ if (targetm.want_debug_pub_sections && TREE_PUBLIC (decl))
{
const char *name = dwarf2_name (decl, 1);
if (name)
{
pubname_entry e;
+ if (!targetm.want_debug_pub_sections)
+ return;
+
e.name = NULL;
if ((TREE_PUBLIC (decl)
- || die->die_parent == comp_unit_die)
+ || is_cu_die (die->die_parent))
&& (die->die_tag == DW_TAG_typedef || COMPLETE_TYPE_P (decl)))
{
e.die = die;
dw2_asm_output_data (DWARF_OFFSET_SIZE, next_die_offset,
"Compilation Unit Length");
- for (i = 0; VEC_iterate (pubname_entry, names, i, pub); i++)
+ FOR_EACH_VEC_ELT (pubname_entry, names, i, pub)
{
/* We shouldn't see pubnames for DIEs outside of the main CU. */
if (names == pubname_table)
/* File length in bytes. */
dw2_asm_output_data_uleb128 (0, NULL);
-#endif
+#endif /* VMS_DEBUGGING_INFO */
}
dw2_asm_output_data (1, 0, "End file name table");
size = 2 + DWARF_OFFSET_SIZE + 1;
/* Each entry: code label + DIE offset. */
- for (i = 0; VEC_iterate (dcall_entry, dcall_table, i, p); i++)
+ FOR_EACH_VEC_ELT (dcall_entry, dcall_table, i, p)
{
gcc_assert (p->targ_die != NULL);
/* Insert a "from" entry when the point-of-call DIE offset changes. */
"Offset of Compilation Unit Info");
dw2_asm_output_data (1, DWARF2_ADDR_SIZE, "Pointer Size (in bytes)");
- for (i = 0; VEC_iterate (dcall_entry, dcall_table, i, p); i++)
+ FOR_EACH_VEC_ELT (dcall_entry, dcall_table, i, p)
{
/* Insert a "from" entry when the point-of-call DIE offset changes. */
if (p->poc_decl != last_poc_decl)
size = 2 + 1;
/* Each entry: code label + vtable slot index. */
- for (i = 0; VEC_iterate (vcall_entry, vcall_table, i, p); i++)
+ FOR_EACH_VEC_ELT (vcall_entry, vcall_table, i, p)
size += DWARF_OFFSET_SIZE + size_of_uleb128 (p->vtable_slot);
return size;
dw2_asm_output_data (2, 4, "Version number");
dw2_asm_output_data (1, DWARF2_ADDR_SIZE, "Pointer Size (in bytes)");
- for (i = 0; VEC_iterate (vcall_entry, vcall_table, i, p); i++)
+ FOR_EACH_VEC_ELT (vcall_entry, vcall_table, i, p)
{
ASM_GENERATE_INTERNAL_LABEL (poc_label, "LPOC", p->poc_label_num);
dw2_asm_output_addr (DWARF_OFFSET_SIZE, poc_label, "Point of call");
switch (TREE_CODE (type))
{
case INTEGER_TYPE:
+ if ((dwarf_version >= 4 || !dwarf_strict)
+ && TYPE_NAME (type)
+ && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
+ && DECL_IS_BUILTIN (TYPE_NAME (type))
+ && DECL_NAME (TYPE_NAME (type)))
+ {
+ const char *name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
+ if (strcmp (name, "char16_t") == 0
+ || strcmp (name, "char32_t") == 0)
+ {
+ encoding = DW_ATE_UTF;
+ break;
+ }
+ }
if (TYPE_STRING_FLAG (type))
{
if (TYPE_UNSIGNED (type))
gcc_unreachable ();
}
- base_type_result = new_die (DW_TAG_base_type, comp_unit_die, type);
+ base_type_result = new_die (DW_TAG_base_type, comp_unit_die (), type);
add_AT_unsigned (base_type_result, DW_AT_byte_size,
int_size_in_bytes (type));
case METHOD_TYPE:
case POINTER_TYPE:
case REFERENCE_TYPE:
+ case NULLPTR_TYPE:
case OFFSET_TYPE:
case LANG_TYPE:
case VECTOR_TYPE:
return TYPE_ALIGN (type);
}
+/* Similarly, but return a double_int instead of UHWI. */
+
+static inline double_int
+double_int_type_size_in_bits (const_tree type)
+{
+ if (TREE_CODE (type) == ERROR_MARK)
+ return uhwi_to_double_int (BITS_PER_WORD);
+ else if (TYPE_SIZE (type) == NULL_TREE)
+ return double_int_zero;
+ else if (TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST)
+ return tree_to_double_int (TYPE_SIZE (type));
+ else
+ return uhwi_to_double_int (TYPE_ALIGN (type));
+}
+
/* Given a pointer to a tree node for a subrange type, return a pointer
to a DIE that describes the given type. */
const HOST_WIDE_INT size_in_bytes = int_size_in_bytes (type);
if (context_die == NULL)
- context_die = comp_unit_die;
+ context_die = comp_unit_die ();
subrange_die = new_die (DW_TAG_subrange_type, context_die, type);
&& TYPE_NAME (qualified_type)
&& TREE_CODE (TYPE_NAME (qualified_type)) == TYPE_DECL)
{
-#ifdef ENABLE_CHECKING
- gcc_assert (TREE_CODE (TREE_TYPE (TYPE_NAME (qualified_type)))
- == INTEGER_TYPE
- && TYPE_PRECISION (TREE_TYPE (TYPE_NAME (qualified_type)))
- == TYPE_PRECISION (qualified_type)
- && TYPE_UNSIGNED (TREE_TYPE (TYPE_NAME (qualified_type)))
- == TYPE_UNSIGNED (qualified_type));
-#endif
- qualified_type = TREE_TYPE (TYPE_NAME (qualified_type));
+ tree t = TREE_TYPE (TYPE_NAME (qualified_type));
+
+ gcc_checking_assert (TREE_CODE (t) == INTEGER_TYPE
+ && TYPE_PRECISION (t)
+ == TYPE_PRECISION (qualified_type)
+ && TYPE_UNSIGNED (t)
+ == TYPE_UNSIGNED (qualified_type));
+ qualified_type = t;
}
/* If we do, then we can just use its DIE, if it exists. */
/* Else cv-qualified version of named type; fall through. */
}
- if (is_const_type)
+ if (is_const_type
+ /* If both is_const_type and is_volatile_type, prefer the path
+ which leads to a qualified type. */
+ && (!is_volatile_type
+ || get_qualified_type (type, TYPE_QUAL_CONST) == NULL_TREE
+ || get_qualified_type (type, TYPE_QUAL_VOLATILE) != NULL_TREE))
{
- mod_type_die = new_die (DW_TAG_const_type, comp_unit_die, type);
+ mod_type_die = new_die (DW_TAG_const_type, comp_unit_die (), type);
sub_die = modified_type_die (type, 0, is_volatile_type, context_die);
}
else if (is_volatile_type)
{
- mod_type_die = new_die (DW_TAG_volatile_type, comp_unit_die, type);
- sub_die = modified_type_die (type, 0, 0, context_die);
+ mod_type_die = new_die (DW_TAG_volatile_type, comp_unit_die (), type);
+ sub_die = modified_type_die (type, is_const_type, 0, context_die);
}
else if (code == POINTER_TYPE)
{
- mod_type_die = new_die (DW_TAG_pointer_type, comp_unit_die, type);
+ mod_type_die = new_die (DW_TAG_pointer_type, comp_unit_die (), type);
add_AT_unsigned (mod_type_die, DW_AT_byte_size,
simple_type_size_in_bits (type) / BITS_PER_UNIT);
item_type = TREE_TYPE (type);
else if (code == REFERENCE_TYPE)
{
if (TYPE_REF_IS_RVALUE (type) && dwarf_version >= 4)
- mod_type_die = new_die (DW_TAG_rvalue_reference_type, comp_unit_die,
+ mod_type_die = new_die (DW_TAG_rvalue_reference_type, comp_unit_die (),
type);
else
- mod_type_die = new_die (DW_TAG_reference_type, comp_unit_die, type);
+ mod_type_die = new_die (DW_TAG_reference_type, comp_unit_die (), type);
add_AT_unsigned (mod_type_die, DW_AT_byte_size,
simple_type_size_in_bits (type) / BITS_PER_UNIT);
item_type = TREE_TYPE (type);
if (REGNO (rtl) >= FIRST_PSEUDO_REGISTER)
return 0;
+ /* We only use "frame base" when we're sure we're talking about the
+ post-prologue local stack frame. We do this by *not* running
+ register elimination until this point, and recognizing the special
+ argument pointer and soft frame pointer rtx's.
+ Use DW_OP_fbreg offset DW_OP_stack_value in this case. */
+ if ((rtl == arg_pointer_rtx || rtl == frame_pointer_rtx)
+ && eliminate_regs (rtl, VOIDmode, NULL_RTX) != rtl)
+ {
+ dw_loc_descr_ref result = NULL;
+
+ if (dwarf_version >= 4 || !dwarf_strict)
+ {
+ result = mem_loc_descriptor (rtl, VOIDmode, initialized);
+ if (result)
+ add_loc_descr (&result,
+ new_loc_descr (DW_OP_stack_value, 0, 0));
+ }
+ return result;
+ }
+
regs = targetm.dwarf_register_span (rtl);
if (hard_regno_nregs[REGNO (rtl)][GET_MODE (rtl)] > 1 || regs)
return loc_result;
}
-#endif /* DWARF2_DEBUGGING_INFO */
-
-#if defined (DWARF2_DEBUGGING_INFO) || defined (DWARF2_UNWIND_INFO)
-
/* Return a location descriptor that designates a constant. */
static dw_loc_descr_ref
return new_loc_descr (op, i, 0);
}
-#endif
-#ifdef DWARF2_DEBUGGING_INFO
/* Return loc description representing "address" of integer value.
This can appear only as toplevel expression. */
/* If delegitimize_address couldn't do anything with the UNSPEC, assume
we can't express it in the debug info. */
#ifdef ENABLE_CHECKING
- inform (current_function_decl
- ? DECL_SOURCE_LOCATION (current_function_decl)
- : UNKNOWN_LOCATION,
- "non-delegitimized UNSPEC %d found in variable location",
- XINT (rtl, 1));
+ /* Don't complain about TLS UNSPECs, those are just too hard to
+ delegitimize. */
+ if (XVECLEN (rtl, 0) != 1
+ || GET_CODE (XVECEXP (rtl, 0, 0)) != SYMBOL_REF
+ || SYMBOL_REF_DECL (XVECEXP (rtl, 0, 0)) == NULL
+ || TREE_CODE (SYMBOL_REF_DECL (XVECEXP (rtl, 0, 0))) != VAR_DECL
+ || !DECL_THREAD_LOCAL_P (SYMBOL_REF_DECL (XVECEXP (rtl, 0, 0))))
+ inform (current_function_decl
+ ? DECL_SOURCE_LOCATION (current_function_decl)
+ : UNKNOWN_LOCATION,
+ "non-delegitimized UNSPEC %d found in variable location",
+ XINT (rtl, 1));
#endif
expansion_failed (NULL_TREE, rtl,
"UNSPEC hasn't been delegitimized.\n");
if (!targetm.have_tls || !targetm.asm_out.output_dwarf_dtprel)
break;
- temp = new_loc_descr (DW_OP_addr, 0, 0);
+ /* We used to emit DW_OP_addr here, but that's wrong, since
+ DW_OP_addr should be relocated by the debug info consumer,
+ while DW_OP_GNU_push_tls_address operand should not. */
+ temp = new_loc_descr (DWARF2_ADDR_SIZE == 4
+ ? DW_OP_const4u : DW_OP_const8u, 0, 0);
temp->dw_loc_oprnd1.val_class = dw_val_class_addr;
temp->dw_loc_oprnd1.v.val_addr = rtl;
temp->dtprel = true;
case CONCAT:
case CONCATN:
case VAR_LOCATION:
+ case DEBUG_IMPLICIT_PTR:
expansion_failed (NULL_TREE, rtl,
"CONCAT/CONCATN/VAR_LOCATION is handled only by loc_descriptor");
return 0;
}
break;
- case COMPARE:
case IF_THEN_ELSE:
+ {
+ dw_loc_descr_ref op2, bra_node, drop_node;
+ op0 = mem_loc_descriptor (XEXP (rtl, 0), mode,
+ VAR_INIT_STATUS_INITIALIZED);
+ op1 = mem_loc_descriptor (XEXP (rtl, 1), mode,
+ VAR_INIT_STATUS_INITIALIZED);
+ op2 = mem_loc_descriptor (XEXP (rtl, 2), mode,
+ VAR_INIT_STATUS_INITIALIZED);
+ if (op0 == NULL || op1 == NULL || op2 == NULL)
+ break;
+
+ mem_loc_result = op1;
+ add_loc_descr (&mem_loc_result, op2);
+ add_loc_descr (&mem_loc_result, op0);
+ bra_node = new_loc_descr (DW_OP_bra, 0, 0);
+ add_loc_descr (&mem_loc_result, bra_node);
+ add_loc_descr (&mem_loc_result, new_loc_descr (DW_OP_swap, 0, 0));
+ drop_node = new_loc_descr (DW_OP_drop, 0, 0);
+ add_loc_descr (&mem_loc_result, drop_node);
+ bra_node->dw_loc_oprnd1.val_class = dw_val_class_loc;
+ bra_node->dw_loc_oprnd1.v.val_loc = drop_node;
+ }
+ break;
+
+ case COMPARE:
case ROTATE:
case ROTATERT:
case TRUNCATE:
return cc_loc_result;
}
+/* Helper function for loc_descriptor. Return DW_OP_GNU_implicit_pointer
+ for DEBUG_IMPLICIT_PTR RTL. */
+
+static dw_loc_descr_ref
+implicit_ptr_descriptor (rtx rtl, HOST_WIDE_INT offset)
+{
+ dw_loc_descr_ref ret;
+ dw_die_ref ref;
+
+ if (dwarf_strict)
+ return NULL;
+ gcc_assert (TREE_CODE (DEBUG_IMPLICIT_PTR_DECL (rtl)) == VAR_DECL
+ || TREE_CODE (DEBUG_IMPLICIT_PTR_DECL (rtl)) == PARM_DECL
+ || TREE_CODE (DEBUG_IMPLICIT_PTR_DECL (rtl)) == RESULT_DECL);
+ ref = lookup_decl_die (DEBUG_IMPLICIT_PTR_DECL (rtl));
+ ret = new_loc_descr (DW_OP_GNU_implicit_pointer, 0, offset);
+ ret->dw_loc_oprnd2.val_class = dw_val_class_const;
+ if (ref)
+ {
+ ret->dw_loc_oprnd1.val_class = dw_val_class_die_ref;
+ ret->dw_loc_oprnd1.v.val_die_ref.die = ref;
+ ret->dw_loc_oprnd1.v.val_die_ref.external = 0;
+ }
+ else
+ {
+ ret->dw_loc_oprnd1.val_class = dw_val_class_decl_ref;
+ ret->dw_loc_oprnd1.v.val_decl_ref = DEBUG_IMPLICIT_PTR_DECL (rtl);
+ }
+ return ret;
+}
+
/* Output a proper Dwarf location descriptor for a variable or parameter
which is either allocated in a register or in a memory location. For a
register, we just generate an OP_REG and the register number. For a
loc_result = reg_loc_descriptor (rtl, initialized);
break;
- case SIGN_EXTEND:
- case ZERO_EXTEND:
- loc_result = loc_descriptor (XEXP (rtl, 0), mode, initialized);
- break;
-
case MEM:
loc_result = mem_loc_descriptor (XEXP (rtl, 0), GET_MODE (rtl),
initialized);
if (SCALAR_FLOAT_MODE_P (mode))
{
unsigned int length = GET_MODE_SIZE (mode);
- unsigned char *array = GGC_NEWVEC (unsigned char, length);
+ unsigned char *array
+ = (unsigned char*) ggc_alloc_atomic (length);
insert_float (rtl, array);
loc_result->dw_loc_oprnd2.val_class = dw_val_class_vec;
{
unsigned int elt_size = GET_MODE_UNIT_SIZE (GET_MODE (rtl));
unsigned int length = CONST_VECTOR_NUNITS (rtl);
- unsigned char *array = GGC_NEWVEC (unsigned char, length * elt_size);
+ unsigned char *array = (unsigned char *)
+ ggc_alloc_atomic (length * elt_size);
unsigned int i;
unsigned char *p;
}
break;
+ case DEBUG_IMPLICIT_PTR:
+ loc_result = implicit_ptr_descriptor (rtl, 0);
+ break;
+
+ case PLUS:
+ if (GET_CODE (XEXP (rtl, 0)) == DEBUG_IMPLICIT_PTR
+ && CONST_INT_P (XEXP (rtl, 1)))
+ {
+ loc_result
+ = implicit_ptr_descriptor (XEXP (rtl, 0), INTVAL (XEXP (rtl, 1)));
+ break;
+ }
+ /* FALLTHRU */
default:
if (GET_MODE_CLASS (mode) == MODE_INT && GET_MODE (rtl) == mode
&& GET_MODE_SIZE (GET_MODE (rtl)) <= DWARF2_ADDR_SIZE
list = list->dw_loc_next;
while (list)
{
- copy = GGC_CNEW (dw_loc_descr_node);
+ copy = ggc_alloc_dw_loc_descr_node ();
memcpy (copy, ref, sizeof (dw_loc_descr_node));
add_loc_descr (&list->expr, copy);
while (copy->dw_loc_next)
{
- dw_loc_descr_ref new_copy = GGC_CNEW (dw_loc_descr_node);
+ dw_loc_descr_ref new_copy = ggc_alloc_dw_loc_descr_node ();
memcpy (new_copy, copy->dw_loc_next, sizeof (dw_loc_descr_node));
copy->dw_loc_next = new_copy;
copy = new_copy;
/* The way DW_OP_GNU_push_tls_address is specified, we
can only look up addresses of objects in the current
- module. */
+ module. We used DW_OP_addr as first op, but that's
+ wrong, because DW_OP_addr is relocated by the debug
+ info consumer, while DW_OP_GNU_push_tls_address
+ operand shouldn't be. */
if (DECL_EXTERNAL (loc) && !targetm.binds_local_p (loc))
return 0;
- first_op = DW_OP_addr;
+ first_op = DWARF2_ADDR_SIZE == 4 ? DW_OP_const4u : DW_OP_const8u;
dtprel = true;
second_op = DW_OP_GNU_push_tls_address;
}
if (!targetm.emutls.debug_form_tls_address
|| !(dwarf_version >= 3 || !dwarf_strict))
return 0;
- loc = emutls_decl (loc);
+ /* We stuffed the control variable into the DECL_VALUE_EXPR
+ to signal (via DECL_HAS_VALUE_EXPR_P) that the decl should
+ no longer appear in gimple code. We used the control
+ variable in specific so that we could pick it up here. */
+ loc = DECL_VALUE_EXPR (loc);
first_op = DW_OP_addr;
second_op = DW_OP_form_tls_address;
}
}
break;
+ case MEM_REF:
+ /* ??? FIXME. */
+ if (!integer_zerop (TREE_OPERAND (loc, 1)))
+ return 0;
+ /* Fallthru. */
case INDIRECT_REF:
- case ALIGN_INDIRECT_REF:
- case MISALIGNED_INDIRECT_REF:
list_ret = loc_list_from_tree (TREE_OPERAND (loc, 0), 0);
have_address = 1;
break;
/* Return the result of rounding T up to ALIGN. */
-static inline HOST_WIDE_INT
-round_up_to_align (HOST_WIDE_INT t, unsigned int align)
+static inline double_int
+round_up_to_align (double_int t, unsigned int align)
{
- /* We must be careful if T is negative because HOST_WIDE_INT can be
- either "above" or "below" unsigned int as per the C promotion
- rules, depending on the host, thus making the signedness of the
- direct multiplication and division unpredictable. */
- unsigned HOST_WIDE_INT u = (unsigned HOST_WIDE_INT) t;
-
- u += align - 1;
- u /= align;
- u *= align;
-
- return (HOST_WIDE_INT) u;
+ double_int alignd = uhwi_to_double_int (align);
+ t = double_int_add (t, alignd);
+ t = double_int_add (t, double_int_minus_one);
+ t = double_int_div (t, alignd, true, TRUNC_DIV_EXPR);
+ t = double_int_mul (t, alignd);
+ return t;
}
/* Given a pointer to a FIELD_DECL, compute and return the byte offset of the
static HOST_WIDE_INT
field_byte_offset (const_tree decl)
{
- HOST_WIDE_INT object_offset_in_bits;
- HOST_WIDE_INT bitpos_int;
+ double_int object_offset_in_bits;
+ double_int object_offset_in_bytes;
+ double_int bitpos_int;
if (TREE_CODE (decl) == ERROR_MARK)
return 0;
/* We cannot yet cope with fields whose positions are variable, so
for now, when we see such things, we simply return 0. Someday, we may
be able to handle such cases, but it will be damn difficult. */
- if (! host_integerp (bit_position (decl), 0))
+ if (TREE_CODE (bit_position (decl)) != INTEGER_CST)
return 0;
- bitpos_int = int_bit_position (decl);
+ bitpos_int = tree_to_double_int (bit_position (decl));
#ifdef PCC_BITFIELD_TYPE_MATTERS
if (PCC_BITFIELD_TYPE_MATTERS)
{
tree type;
tree field_size_tree;
- HOST_WIDE_INT deepest_bitpos;
- unsigned HOST_WIDE_INT field_size_in_bits;
+ double_int deepest_bitpos;
+ double_int field_size_in_bits;
unsigned int type_align_in_bits;
unsigned int decl_align_in_bits;
- unsigned HOST_WIDE_INT type_size_in_bits;
+ double_int type_size_in_bits;
type = field_type (decl);
- type_size_in_bits = simple_type_size_in_bits (type);
+ type_size_in_bits = double_int_type_size_in_bits (type);
type_align_in_bits = simple_type_align_in_bits (type);
field_size_tree = DECL_SIZE (decl);
field_size_tree = bitsize_zero_node;
/* If the size of the field is not constant, use the type size. */
- if (host_integerp (field_size_tree, 1))
- field_size_in_bits = tree_low_cst (field_size_tree, 1);
+ if (TREE_CODE (field_size_tree) == INTEGER_CST)
+ field_size_in_bits = tree_to_double_int (field_size_tree);
else
- field_size_in_bits = type_size_in_bits;
+ field_size_in_bits = type_size_in_bits;
decl_align_in_bits = simple_decl_align_in_bits (decl);
/* The GCC front-end doesn't make any attempt to keep track of the
- starting bit offset (relative to the start of the containing
- structure type) of the hypothetical "containing object" for a
- bit-field. Thus, when computing the byte offset value for the
- start of the "containing object" of a bit-field, we must deduce
- this information on our own. This can be rather tricky to do in
- some cases. For example, handling the following structure type
- definition when compiling for an i386/i486 target (which only
- aligns long long's to 32-bit boundaries) can be very tricky:
+ starting bit offset (relative to the start of the containing
+ structure type) of the hypothetical "containing object" for a
+ bit-field. Thus, when computing the byte offset value for the
+ start of the "containing object" of a bit-field, we must deduce
+ this information on our own. This can be rather tricky to do in
+ some cases. For example, handling the following structure type
+ definition when compiling for an i386/i486 target (which only
+ aligns long long's to 32-bit boundaries) can be very tricky:
struct S { int field1; long long field2:31; };
- Fortunately, there is a simple rule-of-thumb which can be used
- in such cases. When compiling for an i386/i486, GCC will
- allocate 8 bytes for the structure shown above. It decides to
- do this based upon one simple rule for bit-field allocation.
- GCC allocates each "containing object" for each bit-field at
- the first (i.e. lowest addressed) legitimate alignment boundary
- (based upon the required minimum alignment for the declared
- type of the field) which it can possibly use, subject to the
- condition that there is still enough available space remaining
- in the containing object (when allocated at the selected point)
- to fully accommodate all of the bits of the bit-field itself.
-
- This simple rule makes it obvious why GCC allocates 8 bytes for
- each object of the structure type shown above. When looking
- for a place to allocate the "containing object" for `field2',
- the compiler simply tries to allocate a 64-bit "containing
- object" at each successive 32-bit boundary (starting at zero)
- until it finds a place to allocate that 64- bit field such that
- at least 31 contiguous (and previously unallocated) bits remain
- within that selected 64 bit field. (As it turns out, for the
- example above, the compiler finds it is OK to allocate the
- "containing object" 64-bit field at bit-offset zero within the
- structure type.)
-
- Here we attempt to work backwards from the limited set of facts
- we're given, and we try to deduce from those facts, where GCC
- must have believed that the containing object started (within
- the structure type). The value we deduce is then used (by the
- callers of this routine) to generate DW_AT_location and
- DW_AT_bit_offset attributes for fields (both bit-fields and, in
- the case of DW_AT_location, regular fields as well). */
+ Fortunately, there is a simple rule-of-thumb which can be used
+ in such cases. When compiling for an i386/i486, GCC will
+ allocate 8 bytes for the structure shown above. It decides to
+ do this based upon one simple rule for bit-field allocation.
+ GCC allocates each "containing object" for each bit-field at
+ the first (i.e. lowest addressed) legitimate alignment boundary
+ (based upon the required minimum alignment for the declared
+ type of the field) which it can possibly use, subject to the
+ condition that there is still enough available space remaining
+ in the containing object (when allocated at the selected point)
+ to fully accommodate all of the bits of the bit-field itself.
+
+ This simple rule makes it obvious why GCC allocates 8 bytes for
+ each object of the structure type shown above. When looking
+ for a place to allocate the "containing object" for `field2',
+ the compiler simply tries to allocate a 64-bit "containing
+ object" at each successive 32-bit boundary (starting at zero)
+ until it finds a place to allocate that 64- bit field such that
+ at least 31 contiguous (and previously unallocated) bits remain
+ within that selected 64 bit field. (As it turns out, for the
+ example above, the compiler finds it is OK to allocate the
+ "containing object" 64-bit field at bit-offset zero within the
+ structure type.)
+
+ Here we attempt to work backwards from the limited set of facts
+ we're given, and we try to deduce from those facts, where GCC
+ must have believed that the containing object started (within
+ the structure type). The value we deduce is then used (by the
+ callers of this routine) to generate DW_AT_location and
+ DW_AT_bit_offset attributes for fields (both bit-fields and, in
+ the case of DW_AT_location, regular fields as well). */
/* Figure out the bit-distance from the start of the structure to
- the "deepest" bit of the bit-field. */
- deepest_bitpos = bitpos_int + field_size_in_bits;
+ the "deepest" bit of the bit-field. */
+ deepest_bitpos = double_int_add (bitpos_int, field_size_in_bits);
/* This is the tricky part. Use some fancy footwork to deduce
- where the lowest addressed bit of the containing object must
- be. */
- object_offset_in_bits = deepest_bitpos - type_size_in_bits;
+ where the lowest addressed bit of the containing object must
+ be. */
+ object_offset_in_bits
+ = double_int_sub (deepest_bitpos, type_size_in_bits);
/* Round up to type_align by default. This works best for
- bitfields. */
+ bitfields. */
object_offset_in_bits
- = round_up_to_align (object_offset_in_bits, type_align_in_bits);
+ = round_up_to_align (object_offset_in_bits, type_align_in_bits);
- if (object_offset_in_bits > bitpos_int)
- {
- object_offset_in_bits = deepest_bitpos - type_size_in_bits;
+ if (double_int_ucmp (object_offset_in_bits, bitpos_int) > 0)
+ {
+ object_offset_in_bits
+ = double_int_sub (deepest_bitpos, type_size_in_bits);
- /* Round up to decl_align instead. */
- object_offset_in_bits
- = round_up_to_align (object_offset_in_bits, decl_align_in_bits);
- }
+ /* Round up to decl_align instead. */
+ object_offset_in_bits
+ = round_up_to_align (object_offset_in_bits, decl_align_in_bits);
+ }
}
else
-#endif
+#endif /* PCC_BITFIELD_TYPE_MATTERS */
object_offset_in_bits = bitpos_int;
- return object_offset_in_bits / BITS_PER_UNIT;
+ object_offset_in_bytes
+ = double_int_div (object_offset_in_bits,
+ uhwi_to_double_int (BITS_PER_UNIT), true,
+ TRUNC_DIV_EXPR);
+ return double_int_to_shwi (object_offset_in_bytes);
}
\f
/* The following routines define various Dwarf attributes and any data
add_AT_loc_list (die, attr_kind, descr);
}
+/* Add DW_AT_accessibility attribute to DIE if needed. */
+
+static void
+add_accessibility_attribute (dw_die_ref die, tree decl)
+{
+ /* In DWARF3+ the default is DW_ACCESS_private only in DW_TAG_class_type
+ children, otherwise the default is DW_ACCESS_public. In DWARF2
+ the default has always been DW_ACCESS_public. */
+ if (TREE_PROTECTED (decl))
+ add_AT_unsigned (die, DW_AT_accessibility, DW_ACCESS_protected);
+ else if (TREE_PRIVATE (decl))
+ {
+ if (dwarf_version == 2
+ || die->die_parent == NULL
+ || die->die_parent->die_tag != DW_TAG_class_type)
+ add_AT_unsigned (die, DW_AT_accessibility, DW_ACCESS_private);
+ }
+ else if (dwarf_version > 2
+ && die->die_parent
+ && die->die_parent->die_tag == DW_TAG_class_type)
+ add_AT_unsigned (die, DW_AT_accessibility, DW_ACCESS_public);
+}
+
/* Attach the specialized form of location attribute used for data members of
struct and union types. In the special case of a FIELD_DECL node which
represents a bit-field, the "offset" part of this special location
if (dwarf_version > 2)
{
/* Don't need to output a location expression, just the constant. */
- add_AT_int (die, DW_AT_data_member_location, offset);
+ if (offset < 0)
+ add_AT_int (die, DW_AT_data_member_location, offset);
+ else
+ add_AT_unsigned (die, DW_AT_data_member_location, offset);
return;
}
else
if (SCALAR_FLOAT_MODE_P (mode))
{
unsigned int length = GET_MODE_SIZE (mode);
- unsigned char *array = GGC_NEWVEC (unsigned char, length);
+ unsigned char *array = (unsigned char *) ggc_alloc_atomic (length);
insert_float (rtl, array);
add_AT_vec (die, DW_AT_const_value, length / 4, 4, array);
enum machine_mode mode = GET_MODE (rtl);
unsigned int elt_size = GET_MODE_UNIT_SIZE (mode);
unsigned int length = CONST_VECTOR_NUNITS (rtl);
- unsigned char *array = GGC_NEWVEC (unsigned char, length * elt_size);
+ unsigned char *array = (unsigned char *) ggc_alloc_atomic
+ (length * elt_size);
unsigned int i;
unsigned char *p;
return *tp;
else if (TREE_CODE (*tp) == VAR_DECL)
{
- struct varpool_node *node = varpool_node (*tp);
- if (!node->needed)
+ struct varpool_node *node = varpool_get_node (*tp);
+ if (!node || !node->needed)
return *tp;
}
else if (TREE_CODE (*tp) == FUNCTION_DECL
;
/* Vectors only work if their mode is supported by the target.
FIXME: generic vectors ought to work too. */
- else if (TREE_CODE (type) == VECTOR_TYPE && TYPE_MODE (type) == BLKmode)
+ else if (TREE_CODE (type) == VECTOR_TYPE
+ && !VECTOR_MODE_P (TYPE_MODE (type)))
;
/* If the initializer is something that we know will expand into an
immediate RTL constant, expand it now. We must be careful not to
&& (!REG_P (XEXP (rtl, 0))
|| REGNO (XEXP (rtl, 0)) == HARD_FRAME_POINTER_REGNUM
|| REGNO (XEXP (rtl, 0)) == STACK_POINTER_REGNUM
-#if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
+#if !HARD_FRAME_POINTER_IS_ARG_POINTER
|| REGNO (XEXP (rtl, 0)) == ARG_POINTER_REGNUM
#endif
)
min_index = tree_low_cst (TYPE_MIN_VALUE (TYPE_DOMAIN (type)), 0);
memset (array, '\0', size);
- for (cnt = 0;
- VEC_iterate (constructor_elt, CONSTRUCTOR_ELTS (init), cnt, ce);
- cnt++)
+ FOR_EACH_VEC_ELT (constructor_elt, CONSTRUCTOR_ELTS (init), cnt, ce)
{
tree val = ce->value;
tree index = ce->index;
if (TREE_CODE (type) == RECORD_TYPE)
field = TYPE_FIELDS (type);
- for (cnt = 0;
- VEC_iterate (constructor_elt, CONSTRUCTOR_ELTS (init), cnt, ce);
- cnt++, field = field ? TREE_CHAIN (field) : 0)
+ FOR_EACH_VEC_ELT (constructor_elt, CONSTRUCTOR_ELTS (init), cnt, ce)
{
tree val = ce->value;
int pos, fieldsize;
HOST_WIDE_INT size = int_size_in_bytes (TREE_TYPE (init));
if (size > 0 && (int) size == size)
{
- unsigned char *array = GGC_CNEWVEC (unsigned char, size);
+ unsigned char *array = (unsigned char *)
+ ggc_alloc_cleared_atomic (size);
if (native_encode_initializer (init, array, size))
{
int wdlen;
wdlen = strlen (wd);
- wd1 = GGC_NEWVEC (char, wdlen + 2);
+ wd1 = (char *) ggc_alloc_atomic (wdlen + 2);
strcpy (wd1, wd);
wd1 [wdlen] = DIR_SEPARATOR;
wd1 [wdlen + 1] = 0;
static int
lower_bound_default (void)
{
- switch (get_AT_unsigned (comp_unit_die, DW_AT_language))
+ switch (get_AT_unsigned (comp_unit_die (), DW_AT_language))
{
case DW_LANG_C:
case DW_LANG_C89:
break;
if (current_function_decl == 0)
- ctx = comp_unit_die;
+ ctx = comp_unit_die ();
else
ctx = lookup_decl_die (current_function_decl);
static inline void
add_prototyped_attribute (dw_die_ref die, tree func_type)
{
- if (get_AT_unsigned (comp_unit_die, DW_AT_language) == DW_LANG_C89
+ if (get_AT_unsigned (comp_unit_die (), DW_AT_language) == DW_LANG_C89
&& TYPE_ARG_TYPES (func_type) != NULL)
add_AT_flag (die, DW_AT_prototyped, 1);
}
}
}
\f
+/* Add a DW_AT_linkage_name or DW_AT_MIPS_linkage_name attribute for the
+ given decl. This used to be a vendor extension until after DWARF 4
+ standardized it. */
+
+static void
+add_linkage_attr (dw_die_ref die, tree decl)
+{
+ const char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
+
+ /* Mimic what assemble_name_raw does with a leading '*'. */
+ if (name[0] == '*')
+ name = &name[1];
+
+ if (dwarf_version >= 4)
+ add_AT_string (die, DW_AT_linkage_name, name);
+ else
+ add_AT_string (die, DW_AT_MIPS_linkage_name, name);
+}
+
/* Add source coordinate attributes for the given decl. */
static void
add_AT_unsigned (die, DW_AT_decl_line, s.line);
}
+/* Add DW_AT_{,MIPS_}linkage_name attribute for the given decl. */
+
+static void
+add_linkage_name (dw_die_ref die, tree decl)
+{
+ if ((TREE_CODE (decl) == FUNCTION_DECL || TREE_CODE (decl) == VAR_DECL)
+ && TREE_PUBLIC (decl)
+ && !DECL_ABSTRACT (decl)
+ && !(TREE_CODE (decl) == VAR_DECL && DECL_REGISTER (decl))
+ && die->die_tag != DW_TAG_member)
+ {
+ /* Defer until we have an assembler name set. */
+ if (!DECL_ASSEMBLER_NAME_SET_P (decl))
+ {
+ limbo_die_node *asm_name;
+
+ asm_name = ggc_alloc_cleared_limbo_die_node ();
+ asm_name->die = die;
+ asm_name->created_for = decl;
+ asm_name->next = deferred_asm_name;
+ deferred_asm_name = asm_name;
+ }
+ else if (DECL_ASSEMBLER_NAME (decl) != DECL_NAME (decl))
+ add_linkage_attr (die, decl);
+ }
+}
+
/* Add a DW_AT_name attribute and source coordinate attribute for the
given decl, but only if it actually has a name. */
if (! DECL_ARTIFICIAL (decl))
add_src_coords_attributes (die, decl);
- if ((TREE_CODE (decl) == FUNCTION_DECL || TREE_CODE (decl) == VAR_DECL)
- && TREE_PUBLIC (decl)
- && !DECL_ABSTRACT (decl)
- && !(TREE_CODE (decl) == VAR_DECL && DECL_REGISTER (decl)))
- {
- /* Defer until we have an assembler name set. */
- if (!DECL_ASSEMBLER_NAME_SET_P (decl))
- {
- limbo_die_node *asm_name;
-
- asm_name = GGC_CNEW (limbo_die_node);
- asm_name->die = die;
- asm_name->created_for = decl;
- asm_name->next = deferred_asm_name;
- deferred_asm_name = asm_name;
- }
- else if (DECL_ASSEMBLER_NAME (decl) != DECL_NAME (decl))
- add_AT_string (die, AT_linkage_name,
- IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
- }
+ add_linkage_name (die, decl);
}
#ifdef VMS_DEBUGGING_INFO
XEXP (DECL_RTL (decl), 0));
VEC_safe_push (rtx, gc, used_rtx_array, XEXP (DECL_RTL (decl), 0));
}
-#endif
+#endif /* VMS_DEBUGGING_INFO */
+}
+
+#ifdef VMS_DEBUGGING_INFO
+/* Output the debug main pointer die for VMS */
+
+void
+dwarf2out_vms_debug_main_pointer (void)
+{
+ char label[MAX_ARTIFICIAL_LABEL_BYTES];
+ dw_die_ref die;
+
+ /* Allocate the VMS debug main subprogram die. */
+ die = ggc_alloc_cleared_die_node ();
+ die->die_tag = DW_TAG_subprogram;
+ add_name_attribute (die, VMS_DEBUG_MAIN_POINTER);
+ ASM_GENERATE_INTERNAL_LABEL (label, PROLOGUE_END_LABEL,
+ current_function_funcdef_no);
+ add_AT_lbl_id (die, DW_AT_entry_pc, label);
+
+ /* Make it the first child of comp_unit_die (). */
+ die->die_parent = comp_unit_die ();
+ if (comp_unit_die ()->die_child)
+ {
+ die->die_sib = comp_unit_die ()->die_child->die_sib;
+ comp_unit_die ()->die_child->die_sib = die;
+ }
+ else
+ {
+ die->die_sib = die;
+ comp_unit_die ()->die_child = die;
+ }
}
+#endif /* VMS_DEBUGGING_INFO */
/* Push a new declaration scope. */
if (containing_scope && TREE_CODE (containing_scope) == FUNCTION_TYPE)
containing_scope = NULL_TREE;
- if (containing_scope == NULL_TREE)
- scope_die = comp_unit_die;
+ if (SCOPE_FILE_SCOPE_P (containing_scope))
+ scope_die = comp_unit_die ();
else if (TYPE_P (containing_scope))
{
/* For types, we can just look up the appropriate DIE. But
{
gcc_assert (debug_info_level <= DINFO_LEVEL_TERSE
|| TREE_ASM_WRITTEN (containing_scope));
+ /*We are not in the middle of emitting the type
+ CONTAINING_SCOPE. Let's see if it's emitted already. */
+ scope_die = lookup_type_die (containing_scope);
/* If none of the current dies are suitable, we get file scope. */
- scope_die = comp_unit_die;
+ if (scope_die == NULL)
+ scope_die = comp_unit_die ();
}
else
- scope_die = lookup_type_die (containing_scope);
+ scope_die = lookup_type_die_strip_naming_typedef (containing_scope);
}
else
scope_die = context_die;
value = ((enum dwarf_calling_convention)
targetm.dwarf_calling_convention (TREE_TYPE (decl)));
- /* DWARF doesn't provide a way to identify a program's source-level
- entry point. DW_AT_calling_convention attributes are only meant
- to describe functions' calling conventions. However, lacking a
- better way to signal the Fortran main program, we use this for the
- time being, following existing custom. */
if (is_fortran ()
&& !strcmp (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)), "MAIN__"))
- value = DW_CC_program;
+ {
+ /* DWARF 2 doesn't provide a way to identify a program's source-level
+ entry point. DW_AT_calling_convention attributes are only meant
+ to describe functions' calling conventions. However, lacking a
+ better way to signal the Fortran main program, we used this for
+ a long time, following existing custom. Now, DWARF 4 has
+ DW_AT_main_subprogram, which we add below, but some tools still
+ rely on the old way, which we thus keep. */
+ value = DW_CC_program;
+
+ if (dwarf_version >= 4 || !dwarf_strict)
+ add_AT_flag (subr_die, DW_AT_main_subprogram, 1);
+ }
/* Only add the attribute if the backend requests it, and
is not DW_CC_normal. */
tree t = 0;
/* Find the IDENTIFIER_NODE for the type name. */
- if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
+ if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE
+ && !TYPE_NAMELESS (type))
t = TYPE_NAME (type);
/* The g++ front end makes the TYPE_NAME of *each* tagged type point to
DECL_NAME isn't set. The default hook for decl_printable_name
doesn't like that, and in this context it's correct to return
0, instead of "<anonymous>" or the like. */
- if (DECL_NAME (TYPE_NAME (type)))
+ if (DECL_NAME (TYPE_NAME (type))
+ && !DECL_NAMELESS (TYPE_NAME (type)))
name = lang_hooks.dwarf_name (TYPE_NAME (type), 2);
}
equate_type_number_to_die (type, array_die);
if (TREE_CODE (type) == VECTOR_TYPE)
- {
- /* The frontend feeds us a representation for the vector as a struct
- containing an array. Pull out the array type. */
- type = TREE_TYPE (TYPE_FIELDS (TYPE_DEBUG_REPRESENTATION_TYPE (type)));
- add_AT_flag (array_die, DW_AT_GNU_vector, 1);
- }
+ add_AT_flag (array_die, DW_AT_GNU_vector, 1);
/* For Fortran multidimensional arrays use DW_ORD_col_major ordering. */
if (is_fortran ()
#ifdef MIPS_DEBUGGING_INFO
/* The SGI compilers handle arrays of unknown bound by setting
AT_declaration and not emitting any subrange DIEs. */
- if (! TYPE_DOMAIN (type))
+ if (TREE_CODE (type) == ARRAY_TYPE
+ && ! TYPE_DOMAIN (type))
add_AT_flag (array_die, DW_AT_declaration, 1);
else
#endif
+ if (TREE_CODE (type) == VECTOR_TYPE)
+ {
+ /* For VECTOR_TYPEs we use an array die with appropriate bounds. */
+ dw_die_ref subrange_die = new_die (DW_TAG_subrange_type, array_die, NULL);
+ add_bound_info (subrange_die, DW_AT_lower_bound, size_zero_node);
+ add_bound_info (subrange_die, DW_AT_upper_bound,
+ size_int (TYPE_VECTOR_SUBPARTS (type) - 1));
+ }
+ else
add_subscript_info (array_die, type, collapse_nested_arrays);
/* Add representation of the type of the elements of this array type and
for (i = VEC_length (tree, incomplete_types) - 1; i >= 0; i--)
if (should_emit_struct_debug (VEC_index (tree, incomplete_types, i),
DINFO_USAGE_DIR_USE))
- gen_type_die (VEC_index (tree, incomplete_types, i), comp_unit_die);
+ gen_type_die (VEC_index (tree, incomplete_types, i), comp_unit_die ());
}
/* Determine what tag to use for a record type. */
scope_die_for (type, context_die), type);
equate_type_number_to_die (type, type_die);
add_name_attribute (type_die, type_tag (type));
- if ((dwarf_version >= 4 || !dwarf_strict)
- && ENUM_IS_SCOPED (type))
- add_AT_flag (type_die, DW_AT_enum_class, 1);
+ if (dwarf_version >= 4 || !dwarf_strict)
+ {
+ if (ENUM_IS_SCOPED (type))
+ add_AT_flag (type_die, DW_AT_enum_class, 1);
+ if (ENUM_IS_OPAQUE (type))
+ add_AT_flag (type_die, DW_AT_declaration, 1);
+ }
}
else if (! TYPE_SIZE (type))
return type_die;
TREE_ASM_WRITTEN (type) = 1;
add_byte_size_attribute (type_die, type);
if (TYPE_STUB_DECL (type) != NULL_TREE)
- add_src_coords_attributes (type_die, TYPE_STUB_DECL (type));
+ {
+ add_src_coords_attributes (type_die, TYPE_STUB_DECL (type));
+ add_accessibility_attribute (type_die, TYPE_STUB_DECL (type));
+ }
/* If the first reference to this type was as the return type of an
inline function, then it may not have a parent. Fix this now. */
parm_pack_die = new_die (DW_TAG_GNU_formal_parameter_pack, subr_die, parm_pack);
add_src_coords_attributes (parm_pack_die, parm_pack);
- for (arg = pack_arg; arg; arg = TREE_CHAIN (arg))
+ for (arg = pack_arg; arg; arg = DECL_CHAIN (arg))
{
if (! lang_hooks.decls.function_parm_expanded_from_pack_p (arg,
parm_pack))
parm_die = gen_formal_parameter_die (formal_type, NULL,
true /* Emit name attribute. */,
context_die);
- if ((TREE_CODE (function_or_method_type) == METHOD_TYPE
- && link == first_parm_type)
- || (arg && DECL_ARTIFICIAL (arg)))
+ if (TREE_CODE (function_or_method_type) == METHOD_TYPE
+ && link == first_parm_type)
+ {
+ add_AT_flag (parm_die, DW_AT_artificial, 1);
+ if (dwarf_version >= 3 || !dwarf_strict)
+ add_AT_die_ref (context_die, DW_AT_object_pointer, parm_die);
+ }
+ else if (arg && DECL_ARTIFICIAL (arg))
add_AT_flag (parm_die, DW_AT_artificial, 1);
link = TREE_CHAIN (link);
if (arg)
- arg = TREE_CHAIN (arg);
+ arg = DECL_CHAIN (arg);
}
/* If this function type has an ellipsis, add a
gcc_assert (!decl_ultimate_origin (member));
push_decl_scope (type);
- type_die = lookup_type_die (type);
+ type_die = lookup_type_die_strip_naming_typedef (type);
if (TREE_CODE (member) == FUNCTION_DECL)
gen_subprogram_die (member, type_die);
else if (TREE_CODE (member) == FIELD_DECL)
context = decl_class_context (decl);
if (context)
gen_type_die_for_member
- (context, decl, decl_function_context (decl) ? NULL : comp_unit_die);
+ (context, decl, decl_function_context (decl) ? NULL : comp_unit_die ());
}
/* Pretend we've just finished compiling this function. */
{
/* Ask cgraph if the global variable really is to be emitted.
If yes, then we'll keep the DIE of ENTRY->TYPE. */
- struct varpool_node *node = varpool_node (entry->var_decl);
- if (node->needed)
+ struct varpool_node *node = varpool_get_node (entry->var_decl);
+ if (node && node->needed)
{
die->die_perennial_p = 1;
/* Keep the parent DIEs as well. */
instances of inlines, since the spec requires the out-of-line copy
to have the same parent. For local class methods, this doesn't
apply; we just use the old DIE. */
- if ((old_die->die_parent == comp_unit_die || context_die == NULL)
+ if ((is_cu_die (old_die->die_parent) || context_die == NULL)
&& (DECL_ARTIFICIAL (decl)
|| (get_AT_file (old_die, DW_AT_decl_file) == file_index
&& (get_AT_unsigned (old_die, DW_AT_decl_line)
cases die that forced declaration die (e.g. TAG_imported_module)
is one of the children that we do not want to remove. */
remove_AT (subr_die, DW_AT_declaration);
+ remove_AT (subr_die, DW_AT_object_pointer);
remove_child_TAG (subr_die, DW_TAG_formal_parameter);
}
else
if (DECL_ARTIFICIAL (decl))
add_AT_flag (subr_die, DW_AT_artificial, 1);
- if (TREE_PROTECTED (decl))
- add_AT_unsigned (subr_die, DW_AT_accessibility, DW_ACCESS_protected);
- else if (TREE_PRIVATE (decl))
- add_AT_unsigned (subr_die, DW_AT_accessibility, DW_ACCESS_private);
+ add_accessibility_attribute (subr_die, decl);
}
if (declaration)
current_function_funcdef_no);
add_AT_lbl_id (subr_die, DW_AT_high_pc, label_id);
+#if VMS_DEBUGGING_INFO
+ /* HP OpenVMS Industry Standard 64: DWARF Extensions
+ Section 2.3 Prologue and Epilogue Attributes:
+ When a breakpoint is set on entry to a function, it is generally
+ desirable for execution to be suspended, not on the very first
+ instruction of the function, but rather at a point after the
+ function's frame has been set up, after any language defined local
+ declaration processing has been completed, and before execution of
+ the first statement of the function begins. Debuggers generally
+ cannot properly determine where this point is. Similarly for a
+ breakpoint set on exit from a function. The prologue and epilogue
+ attributes allow a compiler to communicate the location(s) to use. */
+
+ {
+ dw_fde_ref fde = &fde_table[current_funcdef_fde];
+
+ if (fde->dw_fde_vms_end_prologue)
+ add_AT_vms_delta (subr_die, DW_AT_HP_prologue,
+ fde->dw_fde_begin, fde->dw_fde_vms_end_prologue);
+
+ if (fde->dw_fde_vms_begin_epilogue)
+ add_AT_vms_delta (subr_die, DW_AT_HP_epilogue,
+ fde->dw_fde_begin, fde->dw_fde_vms_begin_epilogue);
+ }
+#endif
+
add_pubname (decl, subr_die);
add_arange (decl, subr_die);
}
&parm);
else if (parm)
{
- gen_decl_die (parm, NULL, subr_die);
- parm = TREE_CHAIN (parm);
+ dw_die_ref parm_die = gen_decl_die (parm, NULL, subr_die);
+
+ if (parm == DECL_ARGUMENTS (decl)
+ && TREE_CODE (TREE_TYPE (decl)) == METHOD_TYPE
+ && parm_die
+ && (dwarf_version >= 3 || !dwarf_strict))
+ add_AT_die_ref (subr_die, DW_AT_object_pointer, parm_die);
+
+ parm = DECL_CHAIN (parm);
}
if (generic_decl_parm)
- generic_decl_parm = TREE_CHAIN (generic_decl_parm);
+ generic_decl_parm = DECL_CHAIN (generic_decl_parm);
}
/* Decide whether we need an unspecified_parameters DIE at the end.
if (fn_arg_types != NULL)
{
/* This is the prototyped case, check for.... */
- if (TREE_VALUE (tree_last (fn_arg_types)) != void_type_node)
+ if (stdarg_p (TREE_TYPE (decl)))
gen_unspecified_parameters_die (decl, subr_die);
}
else if (DECL_INITIAL (decl) == NULL_TREE)
current_function_has_inlines = 0;
decls_for_scope (outer_scope, subr_die, 0);
-
-#if 0 && defined (MIPS_DEBUGGING_INFO)
- if (current_function_has_inlines)
- {
- add_AT_flag (subr_die, DW_AT_MIPS_has_inlines, 1);
- if (! comp_unit_has_inlines)
- {
- add_AT_flag (comp_unit_die, DW_AT_MIPS_has_inlines, 1);
- comp_unit_has_inlines = 1;
- }
- }
-#endif
}
/* Add the calling convention attribute if requested. */
add_calling_convention_attribute (subr_die, decl);
if (get_AT_unsigned (old_die, DW_AT_decl_line) != (unsigned) s.line)
add_AT_unsigned (var_die, DW_AT_decl_line, s.line);
+
+ if (old_die->die_tag == DW_TAG_member)
+ add_linkage_name (var_die, decl);
}
}
else
if (DECL_ARTIFICIAL (decl))
add_AT_flag (var_die, DW_AT_artificial, 1);
- if (TREE_PROTECTED (decl))
- add_AT_unsigned (var_die, DW_AT_accessibility, DW_ACCESS_protected);
- else if (TREE_PRIVATE (decl))
- add_AT_unsigned (var_die, DW_AT_accessibility, DW_ACCESS_private);
+ add_accessibility_attribute (var_die, decl);
}
if (declaration)
add_AT_flag (var_die, DW_AT_declaration, 1);
- if (decl && (DECL_ABSTRACT (decl) || declaration))
+ if (decl && (DECL_ABSTRACT (decl) || declaration || old_die == NULL))
equate_decl_number_to_die (decl, var_die);
if (! declaration
if (DECL_ARTIFICIAL (decl))
add_AT_flag (decl_die, DW_AT_artificial, 1);
- if (TREE_PROTECTED (decl))
- add_AT_unsigned (decl_die, DW_AT_accessibility, DW_ACCESS_protected);
- else if (TREE_PRIVATE (decl))
- add_AT_unsigned (decl_die, DW_AT_accessibility, DW_ACCESS_private);
+ add_accessibility_attribute (decl_die, decl);
/* Equate decl number to die, so that we can look up this decl later on. */
equate_decl_number_to_die (decl, decl_die);
add_AT_string (die, DW_AT_producer, producer);
+ /* If our producer is LTO try to figure out a common language to use
+ from the global list of translation units. */
+ if (strcmp (language_string, "GNU GIMPLE") == 0)
+ {
+ unsigned i;
+ tree t;
+ const char *common_lang = NULL;
+
+ FOR_EACH_VEC_ELT (tree, all_translation_units, i, t)
+ {
+ if (!TRANSLATION_UNIT_LANGUAGE (t))
+ continue;
+ if (!common_lang)
+ common_lang = TRANSLATION_UNIT_LANGUAGE (t);
+ else if (strcmp (common_lang, TRANSLATION_UNIT_LANGUAGE (t)) == 0)
+ ;
+ else if (strncmp (common_lang, "GNU C", 5) == 0
+ && strncmp (TRANSLATION_UNIT_LANGUAGE (t), "GNU C", 5) == 0)
+ /* Mixing C and C++ is ok, use C++ in that case. */
+ common_lang = "GNU C++";
+ else
+ {
+ /* Fall back to C. */
+ common_lang = NULL;
+ break;
+ }
+ }
+
+ if (common_lang)
+ language_string = common_lang;
+ }
+
language = DW_LANG_C89;
if (strcmp (language_string, "GNU C++") == 0)
language = DW_LANG_C_plus_plus;
if (BINFO_VIRTUAL_P (binfo))
add_AT_unsigned (die, DW_AT_virtuality, DW_VIRTUALITY_virtual);
+ /* In DWARF3+ the default is DW_ACCESS_private only in DW_TAG_class_type
+ children, otherwise the default is DW_ACCESS_public. In DWARF2
+ the default has always been DW_ACCESS_private. */
if (access == access_public_node)
- add_AT_unsigned (die, DW_AT_accessibility, DW_ACCESS_public);
+ {
+ if (dwarf_version == 2
+ || context_die->die_tag == DW_TAG_class_type)
+ add_AT_unsigned (die, DW_AT_accessibility, DW_ACCESS_public);
+ }
else if (access == access_protected_node)
add_AT_unsigned (die, DW_AT_accessibility, DW_ACCESS_protected);
+ else if (dwarf_version > 2
+ && context_die->die_tag != DW_TAG_class_type)
+ add_AT_unsigned (die, DW_AT_accessibility, DW_ACCESS_private);
}
/* Generate a DIE for a class member. */
}
/* Now output info about the data members and type members. */
- for (member = TYPE_FIELDS (type); member; member = TREE_CHAIN (member))
+ for (member = TYPE_FIELDS (type); member; member = DECL_CHAIN (member))
{
/* If we thought we were generating minimal debug info for TYPE
and then changed our minds, some of the member declarations
}
/* Now output info about the function members (if any). */
- for (member = TYPE_METHODS (type); member; member = TREE_CHAIN (member))
+ for (member = TYPE_METHODS (type); member; member = DECL_CHAIN (member))
{
/* Don't include clones in the member list. */
if (DECL_ABSTRACT_ORIGIN (member))
scope_die = scope_die_for (type, context_die);
- if (! type_die || (nested && scope_die == comp_unit_die))
+ if (! type_die || (nested && is_cu_die (scope_die)))
/* First occurrence of type or toplevel definition of nested class. */
{
dw_die_ref old_die = type_die;
TREE_ASM_WRITTEN (type) = 1;
add_byte_size_attribute (type_die, type);
if (TYPE_STUB_DECL (type) != NULL_TREE)
- add_src_coords_attributes (type_die, TYPE_STUB_DECL (type));
+ {
+ add_src_coords_attributes (type_die, TYPE_STUB_DECL (type));
+ add_accessibility_attribute (type_die, TYPE_STUB_DECL (type));
+ }
/* If the first reference to this type was as the return type of an
inline function, then it may not have a parent. Fix this now. */
equate_type_number_to_die (TREE_TYPE (decl), type_die);
}
else
- type = TREE_TYPE (decl);
+ {
+ type = TREE_TYPE (decl);
+
+ if (is_naming_typedef_decl (TYPE_NAME (type)))
+ {
+ /* Here, we are in the case of decl being a typedef naming
+ an anonymous type, e.g:
+ typedef struct {...} foo;
+ In that case TREE_TYPE (decl) is not a typedef variant
+ type and TYPE_NAME of the anonymous type is set to the
+ TYPE_DECL of the typedef. This construct is emitted by
+ the C++ FE.
+
+ TYPE is the anonymous struct named by the typedef
+ DECL. As we need the DW_AT_type attribute of the
+ DW_TAG_typedef to point to the DIE of TYPE, let's
+ generate that DIE right away. add_type_attribute
+ called below will then pick (via lookup_type_die) that
+ anonymous struct DIE. */
+ if (!TREE_ASM_WRITTEN (type))
+ gen_tagged_type_die (type, context_die, DINFO_USAGE_DIR_USE);
+ }
+ }
add_type_attribute (type_die, type, TREE_READONLY (decl),
TREE_THIS_VOLATILE (decl), context_die);
+
+ if (is_naming_typedef_decl (decl))
+ /* We want that all subsequent calls to lookup_type_die with
+ TYPE in argument yield the DW_TAG_typedef we have just
+ created. */
+ equate_type_number_to_die (type, type_die);
+
+ add_accessibility_attribute (type_die, decl);
}
if (DECL_ABSTRACT (decl))
add_pubtype (decl, type_die);
}
-/* Generate a type description DIE. */
+/* Generate a DIE for a struct, class, enum or union type. */
static void
-gen_type_die_with_usage (tree type, dw_die_ref context_die,
- enum debug_info_usage usage)
+gen_tagged_type_die (tree type,
+ dw_die_ref context_die,
+ enum debug_info_usage usage)
{
int need_pop;
- struct array_descr_info info;
- if (type == NULL_TREE || type == error_mark_node)
+ if (type == NULL_TREE
+ || !is_tagged_type (type))
return;
- /* If TYPE is a typedef type variant, let's generate debug info
- for the parent typedef which TYPE is a type of. */
- if (TYPE_NAME (type) && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
- && DECL_ORIGINAL_TYPE (TYPE_NAME (type)))
+ /* If this is a nested type whose containing class hasn't been written
+ out yet, writing it out will cover this one, too. This does not apply
+ to instantiations of member class templates; they need to be added to
+ the containing class as they are generated. FIXME: This hurts the
+ idea of combining type decls from multiple TUs, since we can't predict
+ what set of template instantiations we'll get. */
+ if (TYPE_CONTEXT (type)
+ && AGGREGATE_TYPE_P (TYPE_CONTEXT (type))
+ && ! TREE_ASM_WRITTEN (TYPE_CONTEXT (type)))
{
+ gen_type_die_with_usage (TYPE_CONTEXT (type), context_die, usage);
+
if (TREE_ASM_WRITTEN (type))
return;
- /* Prevent broken recursion; we can't hand off to the same type. */
- gcc_assert (DECL_ORIGINAL_TYPE (TYPE_NAME (type)) != type);
+ /* If that failed, attach ourselves to the stub. */
+ push_decl_scope (TYPE_CONTEXT (type));
+ context_die = lookup_type_die (TYPE_CONTEXT (type));
+ need_pop = 1;
+ }
+ else if (TYPE_CONTEXT (type) != NULL_TREE
+ && (TREE_CODE (TYPE_CONTEXT (type)) == FUNCTION_DECL))
+ {
+ /* If this type is local to a function that hasn't been written
+ out yet, use a NULL context for now; it will be fixed up in
+ decls_for_scope. */
+ context_die = lookup_decl_die (TYPE_CONTEXT (type));
+ /* A declaration DIE doesn't count; nested types need to go in the
+ specification. */
+ if (context_die && is_declaration_die (context_die))
+ context_die = NULL;
+ need_pop = 0;
+ }
+ else
+ {
+ context_die = declare_in_namespace (type, context_die);
+ need_pop = 0;
+ }
- /* Use the DIE of the containing namespace as the parent DIE of
- the type description DIE we want to generate. */
- if (DECL_CONTEXT (TYPE_NAME (type))
+ if (TREE_CODE (type) == ENUMERAL_TYPE)
+ {
+ /* This might have been written out by the call to
+ declare_in_namespace. */
+ if (!TREE_ASM_WRITTEN (type))
+ gen_enumeration_type_die (type, context_die);
+ }
+ else
+ gen_struct_or_union_type_die (type, context_die, usage);
+
+ if (need_pop)
+ pop_decl_scope ();
+
+ /* Don't set TREE_ASM_WRITTEN on an incomplete struct; we want to fix
+ it up if it is ever completed. gen_*_type_die will set it for us
+ when appropriate. */
+}
+
+/* Generate a type description DIE. */
+
+static void
+gen_type_die_with_usage (tree type, dw_die_ref context_die,
+ enum debug_info_usage usage)
+{
+ struct array_descr_info info;
+
+ if (type == NULL_TREE || type == error_mark_node)
+ return;
+
+ /* If TYPE is a typedef type variant, let's generate debug info
+ for the parent typedef which TYPE is a type of. */
+ if (typedef_variant_p (type))
+ {
+ if (TREE_ASM_WRITTEN (type))
+ return;
+
+ /* Prevent broken recursion; we can't hand off to the same type. */
+ gcc_assert (DECL_ORIGINAL_TYPE (TYPE_NAME (type)) != type);
+
+ /* Use the DIE of the containing namespace as the parent DIE of
+ the type description DIE we want to generate. */
+ if (DECL_CONTEXT (TYPE_NAME (type))
&& TREE_CODE (DECL_CONTEXT (TYPE_NAME (type))) == NAMESPACE_DECL)
context_die = get_context_die (DECL_CONTEXT (TYPE_NAME (type)));
TREE_ASM_WRITTEN (type) = 1;
+
+ gen_decl_die (TYPE_NAME (type), NULL, context_die);
+ return;
+ }
+
+ /* If type is an anonymous tagged type named by a typedef, let's
+ generate debug info for the typedef. */
+ if (is_naming_typedef_decl (TYPE_NAME (type)))
+ {
+ /* Use the DIE of the containing namespace as the parent DIE of
+ the type description DIE we want to generate. */
+ if (DECL_CONTEXT (TYPE_NAME (type))
+ && TREE_CODE (DECL_CONTEXT (TYPE_NAME (type))) == NAMESPACE_DECL)
+ context_die = get_context_die (DECL_CONTEXT (TYPE_NAME (type)));
+
gen_decl_die (TYPE_NAME (type), NULL, context_die);
return;
}
case RECORD_TYPE:
case UNION_TYPE:
case QUAL_UNION_TYPE:
- /* If this is a nested type whose containing class hasn't been written
- out yet, writing it out will cover this one, too. This does not apply
- to instantiations of member class templates; they need to be added to
- the containing class as they are generated. FIXME: This hurts the
- idea of combining type decls from multiple TUs, since we can't predict
- what set of template instantiations we'll get. */
- if (TYPE_CONTEXT (type)
- && AGGREGATE_TYPE_P (TYPE_CONTEXT (type))
- && ! TREE_ASM_WRITTEN (TYPE_CONTEXT (type)))
- {
- gen_type_die_with_usage (TYPE_CONTEXT (type), context_die, usage);
-
- if (TREE_ASM_WRITTEN (type))
- return;
-
- /* If that failed, attach ourselves to the stub. */
- push_decl_scope (TYPE_CONTEXT (type));
- context_die = lookup_type_die (TYPE_CONTEXT (type));
- need_pop = 1;
- }
- else if (TYPE_CONTEXT (type) != NULL_TREE
- && (TREE_CODE (TYPE_CONTEXT (type)) == FUNCTION_DECL))
- {
- /* If this type is local to a function that hasn't been written
- out yet, use a NULL context for now; it will be fixed up in
- decls_for_scope. */
- context_die = lookup_decl_die (TYPE_CONTEXT (type));
- need_pop = 0;
- }
- else
- {
- context_die = declare_in_namespace (type, context_die);
- need_pop = 0;
- }
-
- if (TREE_CODE (type) == ENUMERAL_TYPE)
- {
- /* This might have been written out by the call to
- declare_in_namespace. */
- if (!TREE_ASM_WRITTEN (type))
- gen_enumeration_type_die (type, context_die);
- }
- else
- gen_struct_or_union_type_die (type, context_die, usage);
-
- if (need_pop)
- pop_decl_scope ();
-
- /* Don't set TREE_ASM_WRITTEN on an incomplete struct; we want to fix
- it up if it is ever completed. gen_*_type_die will set it for us
- when appropriate. */
+ gen_tagged_type_die (type, context_die, usage);
return;
case VOID_TYPE:
/* No DIEs needed for fundamental types. */
break;
+ case NULLPTR_TYPE:
case LANG_TYPE:
/* Just use DW_TAG_unspecified_type. */
{
tree name = TYPE_NAME (type);
if (TREE_CODE (name) == TYPE_DECL)
name = DECL_NAME (name);
- type_die = new_die (DW_TAG_unspecified_type, comp_unit_die, type);
+ type_die = new_die (DW_TAG_unspecified_type, comp_unit_die (), type);
add_name_attribute (type_die, IDENTIFIER_POINTER (name));
equate_type_number_to_die (type, type_die);
}
declared directly within this block but not within any nested
sub-blocks. Also, nested function and tag DIEs have been
generated with a parent of NULL; fix that up now. */
- for (decl = BLOCK_VARS (stmt); decl != NULL; decl = TREE_CHAIN (decl))
+ for (decl = BLOCK_VARS (stmt); decl != NULL; decl = DECL_CHAIN (decl))
process_scope_var (stmt, decl, NULL_TREE, context_die);
for (i = 0; i < BLOCK_NUM_NONLOCALIZED_VARS (stmt); i++)
process_scope_var (stmt, NULL, BLOCK_NONLOCALIZED_VAR (stmt, i),
return 0;
}
+/* Return TRUE if TYPE is a typedef that names a type for linkage
+ purposes. This kind of typedefs is produced by the C++ FE for
+ constructs like:
+
+ typedef struct {...} foo;
+
+ In that case, there is no typedef variant type produced for foo.
+ Rather, the TREE_TYPE of the TYPE_DECL of foo is the anonymous
+ struct type. */
+
+static bool
+is_naming_typedef_decl (const_tree decl)
+{
+ if (decl == NULL_TREE
+ || TREE_CODE (decl) != TYPE_DECL
+ || !is_tagged_type (TREE_TYPE (decl))
+ || DECL_IS_BUILTIN (decl)
+ || is_redundant_typedef (decl)
+ /* It looks like Ada produces TYPE_DECLs that are very similar
+ to C++ naming typedefs but that have different
+ semantics. Let's be specific to c++ for now. */
+ || !is_cxx ())
+ return FALSE;
+
+ return (DECL_ORIGINAL_TYPE (decl) == NULL_TREE
+ && TYPE_NAME (TREE_TYPE (decl)) == decl
+ && (TYPE_STUB_DECL (TREE_TYPE (decl))
+ != TYPE_NAME (TREE_TYPE (decl))));
+}
+
/* Returns the DIE for a context. */
static inline dw_die_ref
else
return force_decl_die (context);
}
- return comp_unit_die;
+ return comp_unit_die ();
}
/* Returns the DIE for decl. A DIE will always be returned. */
dwarf2out_decl (decl);
else
/* DWARF2 has neither DW_TAG_module, nor DW_TAG_namespace. */
- decl_die = comp_unit_die;
+ decl_die = comp_unit_die ();
+ break;
+
+ case TRANSLATION_UNIT_DECL:
+ decl_die = comp_unit_die ();
break;
default:
if (DECL_ABSTRACT_ORIGIN (decl) == NULL)
{
/* Output a real namespace or module. */
- context_die = setup_namespace_context (decl, comp_unit_die);
+ context_die = setup_namespace_context (decl, comp_unit_die ());
namespace_die = new_die (is_fortran ()
? DW_TAG_module : DW_TAG_namespace,
context_die, decl);
dw_die_ref origin_die
= force_decl_die (DECL_ABSTRACT_ORIGIN (decl));
- if (DECL_CONTEXT (decl) == NULL_TREE
+ if (DECL_FILE_SCOPE_P (decl)
|| TREE_CODE (DECL_CONTEXT (decl)) == NAMESPACE_DECL)
- context_die = setup_namespace_context (decl, comp_unit_die);
+ context_die = setup_namespace_context (decl, comp_unit_die ());
/* Now create the namespace alias DIE. */
namespace_die = new_die (DW_TAG_imported_declaration, context_die, decl);
add_name_and_src_coords_attributes (namespace_die, decl);
}
}
-/* Generate Dwarf debug information for a decl described by DECL. */
+/* Generate Dwarf debug information for a decl described by DECL.
+ The return value is currently only meaningful for PARM_DECLs,
+ for all other decls it returns NULL. */
-static void
+static dw_die_ref
gen_decl_die (tree decl, tree origin, dw_die_ref context_die)
{
tree decl_or_origin = decl ? decl : origin;
tree class_origin = NULL, ultimate_origin;
if (DECL_P (decl_or_origin) && DECL_IGNORED_P (decl_or_origin))
- return;
+ return NULL;
switch (TREE_CODE (decl_or_origin))
{
break;
case CONST_DECL:
- if (!is_fortran ())
+ if (!is_fortran () && !is_ada ())
{
/* The individual enumerators of an enum type get output when we output
the Dwarf representation of the relevant enum type itself. */
/* Don't output any DIEs to represent mere function declarations,
unless they are class members or explicit block externs. */
if (DECL_INITIAL (decl_or_origin) == NULL_TREE
- && DECL_CONTEXT (decl_or_origin) == NULL_TREE
+ && DECL_FILE_SCOPE_P (decl_or_origin)
&& (current_function_decl == NULL_TREE
|| DECL_ARTIFICIAL (decl_or_origin)))
break;
else if (debug_info_level > DINFO_LEVEL_TERSE)
{
/* Before we describe the FUNCTION_DECL itself, make sure that we
- have described its return type. */
+ have its containing type. */
+ if (!origin)
+ origin = decl_class_context (decl);
+ if (origin != NULL_TREE)
+ gen_type_die (origin, context_die);
+
+ /* And its return type. */
gen_type_die (TREE_TYPE (TREE_TYPE (decl)), context_die);
/* And its virtual context. */
if (DECL_VINDEX (decl) != NULL_TREE)
gen_type_die (DECL_CONTEXT (decl), context_die);
- /* And its containing type. */
- if (!origin)
- origin = decl_class_context (decl);
+ /* Make sure we have a member DIE for decl. */
if (origin != NULL_TREE)
gen_type_die_for_member (origin, decl, context_die);
gen_type_die (TREE_TYPE (TREE_TYPE (decl_or_origin)), context_die);
else
gen_type_die (TREE_TYPE (decl_or_origin), context_die);
- gen_formal_parameter_die (decl, origin,
- true /* Emit name attribute. */,
- context_die);
- break;
+ return gen_formal_parameter_die (decl, origin,
+ true /* Emit name attribute. */,
+ context_die);
case NAMESPACE_DECL:
case IMPORTED_DECL:
gcc_assert ((int)TREE_CODE (decl) > NUM_TREE_CODES);
break;
}
+
+ return NULL;
}
\f
/* Output debug information for global decl DECL. Called from toplev.c after
void
dwarf2out_decl (tree decl)
{
- dw_die_ref context_die = comp_unit_die;
+ dw_die_ref context_die = comp_unit_die ();
switch (TREE_CODE (decl))
{
case CONST_DECL:
if (debug_info_level <= DINFO_LEVEL_TERSE)
return;
- if (!is_fortran ())
+ if (!is_fortran () && !is_ada ())
return;
if (TREE_STATIC (decl) && decl_function_context (decl))
context_die = lookup_decl_die (DECL_CONTEXT (decl));
/* Don't bother trying to generate any DIEs to represent any of the
normal built-in types for the language we are compiling. */
if (DECL_IS_BUILTIN (decl))
- {
- /* OK, we need to generate one for `bool' so GDB knows what type
- comparisons have. */
- if (is_cxx ()
- && TREE_CODE (TREE_TYPE (decl)) == BOOLEAN_TYPE
- && ! DECL_IGNORED_P (decl))
- modified_type_die (TREE_TYPE (decl), 0, 0, NULL);
-
- return;
- }
+ return;
/* If we are in terse mode, don't generate any DIEs for types. */
if (debug_info_level <= DINFO_LEVEL_TERSE)
tree decl;
unsigned int i;
- for (decl = BLOCK_VARS (block); decl; decl = TREE_CHAIN (decl))
+ for (decl = BLOCK_VARS (block); decl; decl = DECL_CHAIN (decl))
if (TREE_CODE (decl) == FUNCTION_DECL
|| (TREE_CODE (decl) == TYPE_DECL && TYPE_DECL_IS_STUB (decl)))
return 0;
if (*slot)
return (struct dwarf_file_data *) *slot;
- created = GGC_NEW (struct dwarf_file_data);
+ created = ggc_alloc_dwarf_file_data ();
created->filename = file_name;
created->emitted_number = 0;
*slot = created;
unsigned i;
die_arg_entry *e;
- for (i = 0;
- VEC_iterate (die_arg_entry, tmpl_value_parm_die_table, i, e);
- i++)
+ FOR_EACH_VEC_ELT (die_arg_entry, tmpl_value_parm_die_table, i, e)
tree_add_const_value_attribute (e->die, e->arg);
}
}
static void
store_vcall_insn (unsigned int vtable_slot, int insn_uid)
{
- struct vcall_insn *item = GGC_NEW (struct vcall_insn);
+ struct vcall_insn *item = ggc_alloc_vcall_insn ();
struct vcall_insn **slot;
gcc_assert (item);
next_real = next_real_insn (loc_note);
/* If there are no instructions which would be affected by this note,
don't do anything. */
- if (next_real == NULL_RTX)
+ if (next_real == NULL_RTX && !NOTE_DURING_CALL_P (loc_note))
return;
/* If there were any real insns between note we processed last time
{
if (function_section (fun) != text_section)
have_multiple_function_sections = true;
+ else if (flag_reorder_blocks_and_partition && !cold_text_section)
+ {
+ gcc_assert (current_function_decl == fun);
+ cold_text_section = unlikely_text_section ();
+ switch_to_section (cold_text_section);
+ ASM_OUTPUT_LABEL (asm_out_file, cold_text_section_label);
+ switch_to_section (current_function_section ());
+ }
dwarf2out_note_section_used ();
}
/* Record the beginning of the file for break_out_includes. */
dw_die_ref bincl_die;
- bincl_die = new_die (DW_TAG_GNU_BINCL, comp_unit_die, NULL);
+ bincl_die = new_die (DW_TAG_GNU_BINCL, comp_unit_die (), NULL);
add_AT_string (bincl_die, DW_AT_name, remap_debug_filename (filename));
}
if (debug_info_level >= DINFO_LEVEL_VERBOSE)
{
- int file_num = maybe_emit_file (lookup_filename (filename));
-
- switch_to_section (debug_macinfo_section);
- dw2_asm_output_data (1, DW_MACINFO_start_file, "Start new file");
- dw2_asm_output_data_uleb128 (lineno, "Included from line number %d",
- lineno);
-
- dw2_asm_output_data_uleb128 (file_num, "file %s", filename);
+ macinfo_entry e;
+ e.code = DW_MACINFO_start_file;
+ e.lineno = lineno;
+ e.info = xstrdup (filename);
+ VEC_safe_push (macinfo_entry, gc, macinfo_table, &e);
}
}
{
if (flag_eliminate_dwarf2_dups && dwarf_version < 4)
/* Record the end of the file for break_out_includes. */
- new_die (DW_TAG_GNU_EINCL, comp_unit_die, NULL);
+ new_die (DW_TAG_GNU_EINCL, comp_unit_die (), NULL);
if (debug_info_level >= DINFO_LEVEL_VERBOSE)
{
- switch_to_section (debug_macinfo_section);
- dw2_asm_output_data (1, DW_MACINFO_end_file, "End file");
+ macinfo_entry e;
+ e.code = DW_MACINFO_end_file;
+ e.lineno = lineno;
+ e.info = NULL;
+ VEC_safe_push (macinfo_entry, gc, macinfo_table, &e);
}
}
{
if (debug_info_level >= DINFO_LEVEL_VERBOSE)
{
- switch_to_section (debug_macinfo_section);
- dw2_asm_output_data (1, DW_MACINFO_define, "Define macro");
- dw2_asm_output_data_uleb128 (lineno, "At line number %d", lineno);
- dw2_asm_output_nstring (buffer, -1, "The macro");
+ macinfo_entry e;
+ e.code = DW_MACINFO_define;
+ e.lineno = lineno;
+ e.info = xstrdup (buffer);;
+ VEC_safe_push (macinfo_entry, gc, macinfo_table, &e);
}
}
{
if (debug_info_level >= DINFO_LEVEL_VERBOSE)
{
- switch_to_section (debug_macinfo_section);
- dw2_asm_output_data (1, DW_MACINFO_undef, "Undefine macro");
- dw2_asm_output_data_uleb128 (lineno, "At line number %d", lineno);
- dw2_asm_output_nstring (buffer, -1, "The macro");
+ macinfo_entry e;
+ e.code = DW_MACINFO_undef;
+ e.lineno = lineno;
+ e.info = xstrdup (buffer);;
+ VEC_safe_push (macinfo_entry, gc, macinfo_table, &e);
+ }
+}
+
+static void
+output_macinfo (void)
+{
+ unsigned i;
+ unsigned long length = VEC_length (macinfo_entry, macinfo_table);
+ macinfo_entry *ref;
+
+ if (! length)
+ return;
+
+ for (i = 0; VEC_iterate (macinfo_entry, macinfo_table, i, ref); i++)
+ {
+ switch (ref->code)
+ {
+ case DW_MACINFO_start_file:
+ {
+ int file_num = maybe_emit_file (lookup_filename (ref->info));
+ dw2_asm_output_data (1, DW_MACINFO_start_file, "Start new file");
+ dw2_asm_output_data_uleb128
+ (ref->lineno, "Included from line number %lu",
+ (unsigned long)ref->lineno);
+ dw2_asm_output_data_uleb128 (file_num, "file %s", ref->info);
+ }
+ break;
+ case DW_MACINFO_end_file:
+ dw2_asm_output_data (1, DW_MACINFO_end_file, "End file");
+ break;
+ case DW_MACINFO_define:
+ dw2_asm_output_data (1, DW_MACINFO_define, "Define macro");
+ dw2_asm_output_data_uleb128 (ref->lineno, "At line number %lu",
+ (unsigned long)ref->lineno);
+ dw2_asm_output_nstring (ref->info, -1, "The macro");
+ break;
+ case DW_MACINFO_undef:
+ dw2_asm_output_data (1, DW_MACINFO_undef, "Undefine macro");
+ dw2_asm_output_data_uleb128 (ref->lineno, "At line number %lu",
+ (unsigned long)ref->lineno);
+ dw2_asm_output_nstring (ref->info, -1, "The macro");
+ break;
+ default:
+ fprintf (asm_out_file, "%s unrecognized macinfo code %lu\n",
+ ASM_COMMENT_START, (unsigned long)ref->code);
+ break;
+ }
}
}
decl_scope_table = VEC_alloc (tree, gc, 256);
/* Allocate the initial hunk of the abbrev_die_table. */
- abbrev_die_table = GGC_CNEWVEC (dw_die_ref, ABBREV_DIE_TABLE_INCREMENT);
+ abbrev_die_table = ggc_alloc_cleared_vec_dw_die_ref
+ (ABBREV_DIE_TABLE_INCREMENT);
abbrev_die_table_allocated = ABBREV_DIE_TABLE_INCREMENT;
/* Zero-th entry is allocated, but unused. */
abbrev_die_table_in_use = 1;
/* Allocate the initial hunk of the line_info_table. */
- line_info_table = GGC_CNEWVEC (dw_line_info_entry, LINE_INFO_TABLE_INCREMENT);
+ line_info_table = ggc_alloc_cleared_vec_dw_line_info_entry
+ (LINE_INFO_TABLE_INCREMENT);
line_info_table_allocated = LINE_INFO_TABLE_INCREMENT;
/* Zero-th entry is allocated, but unused. */
vcall_insn_table = htab_create_ggc (10, vcall_insn_table_hash,
vcall_insn_table_eq, NULL);
- /* Generate the initial DIE for the .debug section. Note that the (string)
- value given in the DW_AT_name attribute of the DW_TAG_compile_unit DIE
- will (typically) be a relative pathname and that this pathname should be
- taken as being relative to the directory from which the compiler was
- invoked when the given (base) source file was compiled. We will fill
- in this value in dwarf2out_finish. */
- comp_unit_die = gen_compile_unit_die (NULL);
-
incomplete_types = VEC_alloc (tree, gc, 64);
used_rtx_array = VEC_alloc (rtx, gc, 32);
DEBUG_LINE_SECTION_LABEL, 0);
ASM_GENERATE_INTERNAL_LABEL (ranges_section_label,
DEBUG_RANGES_SECTION_LABEL, 0);
- switch_to_section (debug_abbrev_section);
- ASM_OUTPUT_LABEL (asm_out_file, abbrev_section_label);
- switch_to_section (debug_info_section);
- ASM_OUTPUT_LABEL (asm_out_file, debug_info_section_label);
- switch_to_section (debug_line_section);
- ASM_OUTPUT_LABEL (asm_out_file, debug_line_section_label);
+ ASM_GENERATE_INTERNAL_LABEL (macinfo_section_label,
+ DEBUG_MACINFO_SECTION_LABEL, 0);
if (debug_info_level >= DINFO_LEVEL_VERBOSE)
- {
- switch_to_section (debug_macinfo_section);
- ASM_GENERATE_INTERNAL_LABEL (macinfo_section_label,
- DEBUG_MACINFO_SECTION_LABEL, 0);
- ASM_OUTPUT_LABEL (asm_out_file, macinfo_section_label);
- }
+ macinfo_table = VEC_alloc (macinfo_entry, gc, 64);
switch_to_section (text_section);
ASM_OUTPUT_LABEL (asm_out_file, text_section_label);
- if (flag_reorder_blocks_and_partition)
- {
- cold_text_section = unlikely_text_section ();
- switch_to_section (cold_text_section);
- ASM_OUTPUT_LABEL (asm_out_file, cold_text_section_label);
- }
-
}
/* Called before cgraph_optimize starts outputtting functions, variables
static void
dwarf2out_assembly_start (void)
{
- if (HAVE_GAS_CFI_SECTIONS_DIRECTIVE && dwarf2out_do_cfi_asm ())
- {
-#ifndef TARGET_UNWIND_INFO
- if (USING_SJLJ_EXCEPTIONS || (!flag_unwind_tables && !flag_exceptions))
-#endif
- fprintf (asm_out_file, "\t.cfi_sections\t.debug_frame\n");
- }
+ if (HAVE_GAS_CFI_SECTIONS_DIRECTIVE
+ && dwarf2out_do_cfi_asm ()
+ && (!(flag_unwind_tables || flag_exceptions)
+ || targetm.except_unwind_info (&global_options) != UI_DWARF2))
+ fprintf (asm_out_file, "\t.cfi_sections\t.debug_frame\n");
}
/* A helper function for dwarf2out_finish called through
dw_attr_ref a;
unsigned ix;
- for (ix = 0; VEC_iterate (dw_attr_node, die->die_attr, ix, a); ix++)
+ FOR_EACH_VEC_ELT (dw_attr_node, die->die_attr, ix, a)
{
if (a->dw_attr_val.val_class == dw_val_class_die_ref)
{
dw_attr_ref a;
unsigned ix;
- for (ix = 0; VEC_iterate (dw_attr_node, die->die_attr, ix, a); ix++)
+ FOR_EACH_VEC_ELT (dw_attr_node, die->die_attr, ix, a)
if (AT_class (a) == dw_val_class_str)
{
struct indirect_string_node *s = a->dw_attr_val.v.val_str;
#if ENABLE_ASSERT_CHECKING
/* All the marks should already be clear. */
- verify_marks_clear (comp_unit_die);
+ verify_marks_clear (comp_unit_die ());
for (node = limbo_die_list; node; node = node->next)
verify_marks_clear (node->die);
for (ctnode = comdat_type_list; ctnode; ctnode = ctnode->next)
premark_types_used_by_global_vars ();
/* Set the mark on nodes that are actually used. */
- prune_unused_types_walk (comp_unit_die);
+ prune_unused_types_walk (comp_unit_die ());
for (node = limbo_die_list; node; node = node->next)
prune_unused_types_walk (node->die);
for (ctnode = comdat_type_list; ctnode; ctnode = ctnode->next)
/* Also set the mark on nodes referenced from the
pubname_table or arange_table. */
- for (i = 0; VEC_iterate (pubname_entry, pubname_table, i, pub); i++)
+ FOR_EACH_VEC_ELT (pubname_entry, pubname_table, i, pub)
prune_unused_types_mark (pub->die, 1);
for (i = 0; i < arange_table_in_use; i++)
prune_unused_types_mark (arange_table[i], 1);
/* Mark nodes referenced from the direct call table. */
- for (i = 0; VEC_iterate (dcall_entry, dcall_table, i, dcall); i++)
+ FOR_EACH_VEC_ELT (dcall_entry, dcall_table, i, dcall)
prune_unused_types_mark (dcall->targ_die, 1);
/* Get rid of nodes that aren't marked; and update the string counts. */
htab_traverse (debug_str_hash, prune_indirect_string, NULL);
else if (debug_str_hash)
htab_empty (debug_str_hash);
- prune_unused_types_prune (comp_unit_die);
+ prune_unused_types_prune (comp_unit_die ());
for (node = limbo_die_list; node; node = node->next)
prune_unused_types_prune (node->die);
for (ctnode = comdat_type_list; ctnode; ctnode = ctnode->next)
prune_unused_types_prune (ctnode->root_die);
/* Leave the marks clear. */
- prune_unmark_dies (comp_unit_die);
+ prune_unmark_dies (comp_unit_die ());
for (node = limbo_die_list; node; node = node->next)
prune_unmark_dies (node->die);
for (ctnode = comdat_type_list; ctnode; ctnode = ctnode->next)
unsigned ix = VEC_length (dw_attr_node, die->die_attr);
dw_attr_node linkage = *VEC_index (dw_attr_node, die->die_attr, ix - 1);
- gcc_assert (linkage.dw_attr == AT_linkage_name);
+ gcc_assert (linkage.dw_attr == DW_AT_linkage_name
+ || linkage.dw_attr == DW_AT_MIPS_linkage_name);
while (--ix > 0)
{
resolve_addr_in_expr (dw_loc_descr_ref loc)
{
for (; loc; loc = loc->dw_loc_next)
- if ((loc->dw_loc_opc == DW_OP_addr
+ if (((loc->dw_loc_opc == DW_OP_addr || loc->dtprel)
&& resolve_one_addr (&loc->dw_loc_oprnd1.v.val_addr, NULL))
|| (loc->dw_loc_opc == DW_OP_implicit_value
&& loc->dw_loc_oprnd2.val_class == dw_val_class_addr
&& resolve_one_addr (&loc->dw_loc_oprnd2.v.val_addr, NULL)))
return false;
+ else if (loc->dw_loc_opc == DW_OP_GNU_implicit_pointer
+ && loc->dw_loc_oprnd1.val_class == dw_val_class_decl_ref)
+ {
+ dw_die_ref ref
+ = lookup_decl_die (loc->dw_loc_oprnd1.v.val_decl_ref);
+ if (ref == NULL)
+ return false;
+ loc->dw_loc_oprnd1.val_class = dw_val_class_die_ref;
+ loc->dw_loc_oprnd1.v.val_die_ref.die = ref;
+ loc->dw_loc_oprnd1.v.val_die_ref.external = 0;
+ }
return true;
}
dw_loc_list_ref *curr;
unsigned ix;
- for (ix = 0; VEC_iterate (dw_attr_node, die->die_attr, ix, a); ix++)
+ FOR_EACH_VEC_ELT (dw_attr_node, die->die_attr, ix, a)
switch (AT_class (a))
{
case dw_val_class_loc_list:
FOR_EACH_CHILD (die, c, resolve_addr (c));
}
+\f
+/* Helper routines for optimize_location_lists.
+ This pass tries to share identical local lists in .debug_loc
+ section. */
+
+/* Iteratively hash operands of LOC opcode. */
+
+static inline hashval_t
+hash_loc_operands (dw_loc_descr_ref loc, hashval_t hash)
+{
+ dw_val_ref val1 = &loc->dw_loc_oprnd1;
+ dw_val_ref val2 = &loc->dw_loc_oprnd2;
+
+ switch (loc->dw_loc_opc)
+ {
+ case DW_OP_const4u:
+ case DW_OP_const8u:
+ if (loc->dtprel)
+ goto hash_addr;
+ /* FALLTHRU */
+ case DW_OP_const1u:
+ case DW_OP_const1s:
+ case DW_OP_const2u:
+ case DW_OP_const2s:
+ case DW_OP_const4s:
+ case DW_OP_const8s:
+ case DW_OP_constu:
+ case DW_OP_consts:
+ case DW_OP_pick:
+ case DW_OP_plus_uconst:
+ case DW_OP_breg0:
+ case DW_OP_breg1:
+ case DW_OP_breg2:
+ case DW_OP_breg3:
+ case DW_OP_breg4:
+ case DW_OP_breg5:
+ case DW_OP_breg6:
+ case DW_OP_breg7:
+ case DW_OP_breg8:
+ case DW_OP_breg9:
+ case DW_OP_breg10:
+ case DW_OP_breg11:
+ case DW_OP_breg12:
+ case DW_OP_breg13:
+ case DW_OP_breg14:
+ case DW_OP_breg15:
+ case DW_OP_breg16:
+ case DW_OP_breg17:
+ case DW_OP_breg18:
+ case DW_OP_breg19:
+ case DW_OP_breg20:
+ case DW_OP_breg21:
+ case DW_OP_breg22:
+ case DW_OP_breg23:
+ case DW_OP_breg24:
+ case DW_OP_breg25:
+ case DW_OP_breg26:
+ case DW_OP_breg27:
+ case DW_OP_breg28:
+ case DW_OP_breg29:
+ case DW_OP_breg30:
+ case DW_OP_breg31:
+ case DW_OP_regx:
+ case DW_OP_fbreg:
+ case DW_OP_piece:
+ case DW_OP_deref_size:
+ case DW_OP_xderef_size:
+ hash = iterative_hash_object (val1->v.val_int, hash);
+ break;
+ case DW_OP_skip:
+ case DW_OP_bra:
+ {
+ int offset;
+ gcc_assert (val1->val_class == dw_val_class_loc);
+ offset = val1->v.val_loc->dw_loc_addr - (loc->dw_loc_addr + 3);
+ hash = iterative_hash_object (offset, hash);
+ }
+ break;
+ case DW_OP_implicit_value:
+ hash = iterative_hash_object (val1->v.val_unsigned, hash);
+ switch (val2->val_class)
+ {
+ case dw_val_class_const:
+ hash = iterative_hash_object (val2->v.val_int, hash);
+ break;
+ case dw_val_class_vec:
+ {
+ unsigned int elt_size = val2->v.val_vec.elt_size;
+ unsigned int len = val2->v.val_vec.length;
+
+ hash = iterative_hash_object (elt_size, hash);
+ hash = iterative_hash_object (len, hash);
+ hash = iterative_hash (val2->v.val_vec.array,
+ len * elt_size, hash);
+ }
+ break;
+ case dw_val_class_const_double:
+ hash = iterative_hash_object (val2->v.val_double.low, hash);
+ hash = iterative_hash_object (val2->v.val_double.high, hash);
+ break;
+ case dw_val_class_addr:
+ hash = iterative_hash_rtx (val2->v.val_addr, hash);
+ break;
+ default:
+ gcc_unreachable ();
+ }
+ break;
+ case DW_OP_bregx:
+ case DW_OP_bit_piece:
+ hash = iterative_hash_object (val1->v.val_int, hash);
+ hash = iterative_hash_object (val2->v.val_int, hash);
+ break;
+ case DW_OP_addr:
+ hash_addr:
+ if (loc->dtprel)
+ {
+ unsigned char dtprel = 0xd1;
+ hash = iterative_hash_object (dtprel, hash);
+ }
+ hash = iterative_hash_rtx (val1->v.val_addr, hash);
+ break;
+ case DW_OP_GNU_implicit_pointer:
+ hash = iterative_hash_object (val2->v.val_int, hash);
+ break;
+
+ default:
+ /* Other codes have no operands. */
+ break;
+ }
+ return hash;
+}
+
+/* Iteratively hash the whole DWARF location expression LOC. */
+
+static inline hashval_t
+hash_locs (dw_loc_descr_ref loc, hashval_t hash)
+{
+ dw_loc_descr_ref l;
+ bool sizes_computed = false;
+ /* Compute sizes, so that DW_OP_skip/DW_OP_bra can be checksummed. */
+ size_of_locs (loc);
+
+ for (l = loc; l != NULL; l = l->dw_loc_next)
+ {
+ enum dwarf_location_atom opc = l->dw_loc_opc;
+ hash = iterative_hash_object (opc, hash);
+ if ((opc == DW_OP_skip || opc == DW_OP_bra) && !sizes_computed)
+ {
+ size_of_locs (loc);
+ sizes_computed = true;
+ }
+ hash = hash_loc_operands (l, hash);
+ }
+ return hash;
+}
+
+/* Compute hash of the whole location list LIST_HEAD. */
+
+static inline void
+hash_loc_list (dw_loc_list_ref list_head)
+{
+ dw_loc_list_ref curr = list_head;
+ hashval_t hash = 0;
+
+ for (curr = list_head; curr != NULL; curr = curr->dw_loc_next)
+ {
+ hash = iterative_hash (curr->begin, strlen (curr->begin) + 1, hash);
+ hash = iterative_hash (curr->end, strlen (curr->end) + 1, hash);
+ if (curr->section)
+ hash = iterative_hash (curr->section, strlen (curr->section) + 1,
+ hash);
+ hash = hash_locs (curr->expr, hash);
+ }
+ list_head->hash = hash;
+}
+
+/* Return true if X and Y opcodes have the same operands. */
+
+static inline bool
+compare_loc_operands (dw_loc_descr_ref x, dw_loc_descr_ref y)
+{
+ dw_val_ref valx1 = &x->dw_loc_oprnd1;
+ dw_val_ref valx2 = &x->dw_loc_oprnd2;
+ dw_val_ref valy1 = &y->dw_loc_oprnd1;
+ dw_val_ref valy2 = &y->dw_loc_oprnd2;
+
+ switch (x->dw_loc_opc)
+ {
+ case DW_OP_const4u:
+ case DW_OP_const8u:
+ if (x->dtprel)
+ goto hash_addr;
+ /* FALLTHRU */
+ case DW_OP_const1u:
+ case DW_OP_const1s:
+ case DW_OP_const2u:
+ case DW_OP_const2s:
+ case DW_OP_const4s:
+ case DW_OP_const8s:
+ case DW_OP_constu:
+ case DW_OP_consts:
+ case DW_OP_pick:
+ case DW_OP_plus_uconst:
+ case DW_OP_breg0:
+ case DW_OP_breg1:
+ case DW_OP_breg2:
+ case DW_OP_breg3:
+ case DW_OP_breg4:
+ case DW_OP_breg5:
+ case DW_OP_breg6:
+ case DW_OP_breg7:
+ case DW_OP_breg8:
+ case DW_OP_breg9:
+ case DW_OP_breg10:
+ case DW_OP_breg11:
+ case DW_OP_breg12:
+ case DW_OP_breg13:
+ case DW_OP_breg14:
+ case DW_OP_breg15:
+ case DW_OP_breg16:
+ case DW_OP_breg17:
+ case DW_OP_breg18:
+ case DW_OP_breg19:
+ case DW_OP_breg20:
+ case DW_OP_breg21:
+ case DW_OP_breg22:
+ case DW_OP_breg23:
+ case DW_OP_breg24:
+ case DW_OP_breg25:
+ case DW_OP_breg26:
+ case DW_OP_breg27:
+ case DW_OP_breg28:
+ case DW_OP_breg29:
+ case DW_OP_breg30:
+ case DW_OP_breg31:
+ case DW_OP_regx:
+ case DW_OP_fbreg:
+ case DW_OP_piece:
+ case DW_OP_deref_size:
+ case DW_OP_xderef_size:
+ return valx1->v.val_int == valy1->v.val_int;
+ case DW_OP_skip:
+ case DW_OP_bra:
+ gcc_assert (valx1->val_class == dw_val_class_loc
+ && valy1->val_class == dw_val_class_loc
+ && x->dw_loc_addr == y->dw_loc_addr);
+ return valx1->v.val_loc->dw_loc_addr == valy1->v.val_loc->dw_loc_addr;
+ case DW_OP_implicit_value:
+ if (valx1->v.val_unsigned != valy1->v.val_unsigned
+ || valx2->val_class != valy2->val_class)
+ return false;
+ switch (valx2->val_class)
+ {
+ case dw_val_class_const:
+ return valx2->v.val_int == valy2->v.val_int;
+ case dw_val_class_vec:
+ return valx2->v.val_vec.elt_size == valy2->v.val_vec.elt_size
+ && valx2->v.val_vec.length == valy2->v.val_vec.length
+ && memcmp (valx2->v.val_vec.array, valy2->v.val_vec.array,
+ valx2->v.val_vec.elt_size
+ * valx2->v.val_vec.length) == 0;
+ case dw_val_class_const_double:
+ return valx2->v.val_double.low == valy2->v.val_double.low
+ && valx2->v.val_double.high == valy2->v.val_double.high;
+ case dw_val_class_addr:
+ return rtx_equal_p (valx2->v.val_addr, valy2->v.val_addr);
+ default:
+ gcc_unreachable ();
+ }
+ case DW_OP_bregx:
+ case DW_OP_bit_piece:
+ return valx1->v.val_int == valy1->v.val_int
+ && valx2->v.val_int == valy2->v.val_int;
+ case DW_OP_addr:
+ hash_addr:
+ return rtx_equal_p (valx1->v.val_addr, valx2->v.val_addr);
+ case DW_OP_GNU_implicit_pointer:
+ return valx1->val_class == dw_val_class_die_ref
+ && valx1->val_class == valy1->val_class
+ && valx1->v.val_die_ref.die == valy1->v.val_die_ref.die
+ && valx2->v.val_int == valy2->v.val_int;
+ default:
+ /* Other codes have no operands. */
+ return true;
+ }
+}
+
+/* Return true if DWARF location expressions X and Y are the same. */
+
+static inline bool
+compare_locs (dw_loc_descr_ref x, dw_loc_descr_ref y)
+{
+ for (; x != NULL && y != NULL; x = x->dw_loc_next, y = y->dw_loc_next)
+ if (x->dw_loc_opc != y->dw_loc_opc
+ || x->dtprel != y->dtprel
+ || !compare_loc_operands (x, y))
+ break;
+ return x == NULL && y == NULL;
+}
+
+/* Return precomputed hash of location list X. */
+
+static hashval_t
+loc_list_hash (const void *x)
+{
+ return ((const struct dw_loc_list_struct *) x)->hash;
+}
+
+/* Return 1 if location lists X and Y are the same. */
+
+static int
+loc_list_eq (const void *x, const void *y)
+{
+ const struct dw_loc_list_struct *a = (const struct dw_loc_list_struct *) x;
+ const struct dw_loc_list_struct *b = (const struct dw_loc_list_struct *) y;
+ if (a == b)
+ return 1;
+ if (a->hash != b->hash)
+ return 0;
+ for (; a != NULL && b != NULL; a = a->dw_loc_next, b = b->dw_loc_next)
+ if (strcmp (a->begin, b->begin) != 0
+ || strcmp (a->end, b->end) != 0
+ || (a->section == NULL) != (b->section == NULL)
+ || (a->section && strcmp (a->section, b->section) != 0)
+ || !compare_locs (a->expr, b->expr))
+ break;
+ return a == NULL && b == NULL;
+}
+
+/* Recursively optimize location lists referenced from DIE
+ children and share them whenever possible. */
+
+static void
+optimize_location_lists_1 (dw_die_ref die, htab_t htab)
+{
+ dw_die_ref c;
+ dw_attr_ref a;
+ unsigned ix;
+ void **slot;
+
+ FOR_EACH_VEC_ELT (dw_attr_node, die->die_attr, ix, a)
+ if (AT_class (a) == dw_val_class_loc_list)
+ {
+ dw_loc_list_ref list = AT_loc_list (a);
+ /* TODO: perform some optimizations here, before hashing
+ it and storing into the hash table. */
+ hash_loc_list (list);
+ slot = htab_find_slot_with_hash (htab, list, list->hash,
+ INSERT);
+ if (*slot == NULL)
+ *slot = (void *) list;
+ else
+ a->dw_attr_val.v.val_loc_list = (dw_loc_list_ref) *slot;
+ }
+
+ FOR_EACH_CHILD (die, c, optimize_location_lists_1 (c, htab));
+}
+
+/* Optimize location lists referenced from DIE
+ children and share them whenever possible. */
+
+static void
+optimize_location_lists (dw_die_ref die)
+{
+ htab_t htab = htab_create (500, loc_list_hash, loc_list_eq, NULL);
+ optimize_location_lists_1 (die, htab);
+ htab_delete (htab);
+}
+\f
/* Output stuff that dwarf requires at the end of every file,
and generate the DWARF-2 debugging info. */
limbo_die_node *node, *next_node;
comdat_type_node *ctnode;
htab_t comdat_type_table;
- dw_die_ref die = 0;
unsigned int i;
gen_remaining_tmpl_value_param_die_attribute ();
/* Add the name for the main input file now. We delayed this from
dwarf2out_init to avoid complications with PCH. */
- add_name_attribute (comp_unit_die, remap_debug_filename (filename));
+ add_name_attribute (comp_unit_die (), remap_debug_filename (filename));
if (!IS_ABSOLUTE_PATH (filename))
- add_comp_dir_attribute (comp_unit_die);
- else if (get_AT (comp_unit_die, DW_AT_comp_dir) == NULL)
+ add_comp_dir_attribute (comp_unit_die ());
+ else if (get_AT (comp_unit_die (), DW_AT_comp_dir) == NULL)
{
bool p = false;
htab_traverse (file_table, file_table_relative_p, &p);
if (p)
- add_comp_dir_attribute (comp_unit_die);
+ add_comp_dir_attribute (comp_unit_die ());
}
for (i = 0; i < VEC_length (deferred_locations, deferred_locations_list); i++)
instance. */
for (node = limbo_die_list; node; node = next_node)
{
+ dw_die_ref die = node->die;
next_node = node->next;
- die = node->die;
if (die->die_parent == NULL)
{
if (origin)
add_child_die (origin->die_parent, die);
- else if (die == comp_unit_die)
+ else if (is_cu_die (die))
;
else if (seen_error ())
/* It's OK to be confused by errors in the input. */
- add_child_die (comp_unit_die, die);
+ add_child_die (comp_unit_die (), die);
else
{
/* In certain situations, the lexical block containing a
if (origin)
add_child_die (origin, die);
else
- add_child_die (comp_unit_die, die);
+ add_child_die (comp_unit_die (), die);
}
}
}
limbo_die_list = NULL;
- resolve_addr (comp_unit_die);
+ resolve_addr (comp_unit_die ());
for (node = deferred_asm_name; node; node = node->next)
{
tree decl = node->created_for;
if (DECL_ASSEMBLER_NAME (decl) != DECL_NAME (decl))
{
- add_AT_string (node->die, AT_linkage_name,
- IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
+ add_linkage_attr (node->die, decl);
move_linkage_attr (node->die);
}
}
/* Generate separate CUs for each of the include files we've seen.
They will go into limbo_die_list. */
if (flag_eliminate_dwarf2_dups && dwarf_version < 4)
- break_out_includes (comp_unit_die);
+ break_out_includes (comp_unit_die ());
/* Generate separate COMDAT sections for type DIEs. */
if (dwarf_version >= 4)
{
- break_out_comdat_types (comp_unit_die);
+ break_out_comdat_types (comp_unit_die ());
/* Each new type_unit DIE was added to the limbo die list when created.
Since these have all been added to comdat_type_list, clear the
references to the main compile unit). */
for (ctnode = comdat_type_list; ctnode != NULL; ctnode = ctnode->next)
copy_decls_for_unworthy_types (ctnode->root_die);
- copy_decls_for_unworthy_types (comp_unit_die);
+ copy_decls_for_unworthy_types (comp_unit_die ());
/* In the process of copying declarations from one unit to another,
we may have left some declarations behind that are no longer
/* Traverse the DIE's and add add sibling attributes to those DIE's
that have children. */
- add_sibling_attributes (comp_unit_die);
+ add_sibling_attributes (comp_unit_die ());
for (node = limbo_die_list; node; node = node->next)
add_sibling_attributes (node->die);
for (ctnode = comdat_type_list; ctnode != NULL; ctnode = ctnode->next)
/* Output a terminator label for the .text section. */
switch_to_section (text_section);
targetm.asm_out.internal_label (asm_out_file, TEXT_END_LABEL, 0);
- if (flag_reorder_blocks_and_partition)
+ if (cold_text_section)
{
- switch_to_section (unlikely_text_section ());
+ switch_to_section (cold_text_section);
targetm.asm_out.internal_label (asm_out_file, COLD_END_LABEL, 0);
}
if (!have_multiple_function_sections
|| !(dwarf_version >= 3 || !dwarf_strict))
{
- add_AT_lbl_id (comp_unit_die, DW_AT_low_pc, text_section_label);
- add_AT_lbl_id (comp_unit_die, DW_AT_high_pc, text_end_label);
+ add_AT_lbl_id (comp_unit_die (), DW_AT_low_pc, text_section_label);
+ add_AT_lbl_id (comp_unit_die (), DW_AT_high_pc, text_end_label);
}
else
absolute. Historically, we've emitted the unexpected
DW_AT_entry_pc instead of DW_AT_low_pc for this purpose.
Emit both to give time for other tools to adapt. */
- add_AT_addr (comp_unit_die, DW_AT_low_pc, const0_rtx);
- add_AT_addr (comp_unit_die, DW_AT_entry_pc, const0_rtx);
+ add_AT_addr (comp_unit_die (), DW_AT_low_pc, const0_rtx);
+ add_AT_addr (comp_unit_die (), DW_AT_entry_pc, const0_rtx);
if (text_section_used)
- add_ranges_by_labels (comp_unit_die, text_section_label,
+ add_ranges_by_labels (comp_unit_die (), text_section_label,
text_end_label, &range_list_added);
if (flag_reorder_blocks_and_partition && cold_text_section_used)
- add_ranges_by_labels (comp_unit_die, cold_text_section_label,
+ add_ranges_by_labels (comp_unit_die (), cold_text_section_label,
cold_end_label, &range_list_added);
for (fde_idx = 0; fde_idx < fde_table_in_use; fde_idx++)
if (fde->dw_fde_switched_sections)
{
if (!fde->in_std_section)
- add_ranges_by_labels (comp_unit_die,
+ add_ranges_by_labels (comp_unit_die (),
fde->dw_fde_hot_section_label,
fde->dw_fde_hot_section_end_label,
&range_list_added);
if (!fde->cold_in_std_section)
- add_ranges_by_labels (comp_unit_die,
+ add_ranges_by_labels (comp_unit_die (),
fde->dw_fde_unlikely_section_label,
fde->dw_fde_unlikely_section_end_label,
&range_list_added);
}
else if (!fde->in_std_section)
- add_ranges_by_labels (comp_unit_die, fde->dw_fde_begin,
+ add_ranges_by_labels (comp_unit_die (), fde->dw_fde_begin,
fde->dw_fde_end, &range_list_added);
}
add_ranges (NULL);
}
- /* Output location list section if necessary. */
- if (have_location_lists)
- {
- /* Output the location lists info. */
- switch_to_section (debug_loc_section);
- ASM_GENERATE_INTERNAL_LABEL (loc_section_label,
- DEBUG_LOC_SECTION_LABEL, 0);
- ASM_OUTPUT_LABEL (asm_out_file, loc_section_label);
- output_location_lists (die);
- }
-
if (debug_info_level >= DINFO_LEVEL_NORMAL)
- add_AT_lineptr (comp_unit_die, DW_AT_stmt_list,
+ add_AT_lineptr (comp_unit_die (), DW_AT_stmt_list,
debug_line_section_label);
if (debug_info_level >= DINFO_LEVEL_VERBOSE)
- add_AT_macptr (comp_unit_die, DW_AT_macro_info, macinfo_section_label);
+ add_AT_macptr (comp_unit_die (), DW_AT_macro_info, macinfo_section_label);
+
+ if (have_location_lists)
+ optimize_location_lists (comp_unit_die ());
/* Output all of the compilation units. We put the main one last so that
the offsets are available to output_pubnames. */
htab_delete (comdat_type_table);
/* Output the main compilation unit if non-empty or if .debug_macinfo
- has been emitted. */
- output_comp_unit (comp_unit_die, debug_info_level >= DINFO_LEVEL_VERBOSE);
+ will be emitted. */
+ output_comp_unit (comp_unit_die (), debug_info_level >= DINFO_LEVEL_VERBOSE);
/* Output the abbreviation table. */
switch_to_section (debug_abbrev_section);
+ ASM_OUTPUT_LABEL (asm_out_file, abbrev_section_label);
output_abbrev_section ();
+ /* Output location list section if necessary. */
+ if (have_location_lists)
+ {
+ /* Output the location lists info. */
+ switch_to_section (debug_loc_section);
+ ASM_GENERATE_INTERNAL_LABEL (loc_section_label,
+ DEBUG_LOC_SECTION_LABEL, 0);
+ ASM_OUTPUT_LABEL (asm_out_file, loc_section_label);
+ output_location_lists (comp_unit_die ());
+ }
+
/* Output public names table if necessary. */
if (!VEC_empty (pubname_entry, pubname_table))
{
+ gcc_assert (info_section_emitted);
switch_to_section (debug_pubnames_section);
output_pubnames (pubname_table);
}
simply won't look for the section. */
if (!VEC_empty (pubname_entry, pubtype_table))
{
- switch_to_section (debug_pubtypes_section);
- output_pubnames (pubtype_table);
+ bool empty = false;
+
+ if (flag_eliminate_unused_debug_types)
+ {
+ /* The pubtypes table might be emptied by pruning unused items. */
+ unsigned i;
+ pubname_ref p;
+ empty = true;
+ FOR_EACH_VEC_ELT (pubname_entry, pubtype_table, i, p)
+ if (p->die->die_offset != 0)
+ {
+ empty = false;
+ break;
+ }
+ }
+ if (!empty)
+ {
+ gcc_assert (info_section_emitted);
+ switch_to_section (debug_pubtypes_section);
+ output_pubnames (pubtype_table);
+ }
}
/* Output direct and virtual call tables if necessary. */
.debug_info section. IRIX 6.5 `nm' will then complain when
examining the file. This is done late so that any filenames
used by the debug_info section are marked as 'used'. */
+ switch_to_section (debug_line_section);
+ ASM_OUTPUT_LABEL (asm_out_file, debug_line_section_label);
if (! DWARF2_ASM_LINE_DEBUG_INFO)
- {
- switch_to_section (debug_line_section);
- output_line_info ();
- }
+ output_line_info ();
/* Have to end the macro section. */
if (debug_info_level >= DINFO_LEVEL_VERBOSE)
{
switch_to_section (debug_macinfo_section);
+ ASM_OUTPUT_LABEL (asm_out_file, macinfo_section_label);
+ if (!VEC_empty (macinfo_entry, macinfo_table))
+ output_macinfo ();
dw2_asm_output_data (1, 0, "End compilation unit");
}
if (debug_str_hash)
htab_traverse (debug_str_hash, output_indirect_string, NULL);
}
-#else
-
-/* This should never be used, but its address is needed for comparisons. */
-const struct gcc_debug_hooks dwarf2_debug_hooks =
-{
- 0, /* init */
- 0, /* finish */
- 0, /* assembly_start */
- 0, /* define */
- 0, /* undef */
- 0, /* start_source_file */
- 0, /* end_source_file */
- 0, /* begin_block */
- 0, /* end_block */
- 0, /* ignore_block */
- 0, /* source_line */
- 0, /* begin_prologue */
- 0, /* end_prologue */
- 0, /* end_epilogue */
- 0, /* begin_function */
- 0, /* end_function */
- 0, /* function_decl */
- 0, /* global_decl */
- 0, /* type_decl */
- 0, /* imported_module_or_decl */
- 0, /* deferred_inline_function */
- 0, /* outlining_inline_function */
- 0, /* label */
- 0, /* handle_pch */
- 0, /* var_location */
- 0, /* switch_text_section */
- 0, /* direct_call */
- 0, /* virtual_call_token */
- 0, /* copy_call_info */
- 0, /* virtual_call */
- 0, /* set_name */
- 0 /* start_end_main_source_file */
-};
-
-#endif /* DWARF2_DEBUGGING_INFO */
#include "gt-dwarf2out.h"