/* Pointers to various DWARF2 sections. */
static GTY(()) section *debug_info_section;
+static GTY(()) section *debug_skeleton_info_section;
static GTY(()) section *debug_abbrev_section;
+static GTY(()) section *debug_skeleton_abbrev_section;
static GTY(()) section *debug_aranges_section;
+static GTY(()) section *debug_addr_section;
static GTY(()) section *debug_macinfo_section;
static GTY(()) section *debug_line_section;
+static GTY(()) section *debug_skeleton_line_section;
static GTY(()) section *debug_loc_section;
static GTY(()) section *debug_pubnames_section;
static GTY(()) section *debug_pubtypes_section;
static GTY(()) section *debug_str_section;
+static GTY(()) section *debug_str_offsets_section;
static GTY(()) section *debug_ranges_section;
static GTY(()) section *debug_frame_section;
/* A vector for a table that contains frame description
information for each routine. */
+#define NOT_INDEXED (-1U)
+#define NO_INDEX_ASSIGNED (-2U)
+
static GTY(()) VEC(dw_fde_ref, gc) *fde_vec;
struct GTY(()) indirect_string_node {
unsigned int refcount;
enum dwarf_form form;
char *label;
+ unsigned int index;
};
static GTY ((param_is (struct indirect_string_node))) htab_t debug_str_hash;
DEF_VEC_P(dw_die_ref);
DEF_VEC_ALLOC_P(dw_die_ref,heap);
+/* Describe an entry into the .debug_addr section. */
+
+enum ate_kind {
+ ate_kind_rtx,
+ ate_kind_rtx_dtprel,
+ ate_kind_label
+};
+
+typedef struct GTY(()) addr_table_entry_struct {
+ enum ate_kind kind;
+ unsigned int refcount;
+ unsigned int index;
+ union addr_table_entry_struct_union
+ {
+ rtx GTY ((tag ("0"))) rtl;
+ char * GTY ((tag ("1"))) label;
+ }
+ GTY ((desc ("%1.kind"))) addr;
+}
+addr_table_entry;
+
/* Location lists are ranges + location descriptions for that range,
so you can track variables that are in different places over
their entire life. */
typedef struct GTY(()) dw_loc_list_struct {
dw_loc_list_ref dw_loc_next;
- const char *begin; /* Label for begin address of range */
- const char *end; /* Label for end address of range */
+ const char *begin; /* Label and addr_entry for start of range */
+ addr_table_entry *begin_entry;
+ const char *end; /* Label for end of range */
char *ll_symbol; /* Label for beginning of location list.
Only on head of list */
const char *section; /* Section this loclist is relative to */
descr->dw_loc_opc = op;
descr->dw_loc_oprnd1.val_class = dw_val_class_unsigned_const;
+ descr->dw_loc_oprnd1.val_entry = NULL;
descr->dw_loc_oprnd1.v.val_unsigned = oprnd1;
descr->dw_loc_oprnd2.val_class = dw_val_class_unsigned_const;
+ descr->dw_loc_oprnd2.val_entry = NULL;
descr->dw_loc_oprnd2.v.val_unsigned = oprnd2;
return descr;
case DW_OP_addr:
size += DWARF2_ADDR_SIZE;
break;
+ case DW_OP_GNU_addr_index:
+ case DW_OP_GNU_const_index:
+ gcc_assert (loc->dw_loc_oprnd1.val_entry->index != NO_INDEX_ASSIGNED);
+ size += size_of_uleb128 (loc->dw_loc_oprnd1.val_entry->index);
+ break;
case DW_OP_const1u:
case DW_OP_const1s:
size += 1;
}
break;
+ case DW_OP_GNU_addr_index:
+ case DW_OP_GNU_const_index:
+ gcc_assert (loc->dw_loc_oprnd1.val_entry->index != NO_INDEX_ASSIGNED);
+ dw2_asm_output_data_uleb128 (loc->dw_loc_oprnd1.val_entry->index,
+ "(index into .debug_addr)");
+ break;
+
case DW_OP_GNU_implicit_pointer:
{
char label[MAX_ARTIFICIAL_LABEL_BYTES
switch (loc->dw_loc_opc)
{
case DW_OP_addr:
+ case DW_OP_GNU_addr_index:
+ case DW_OP_GNU_const_index:
case DW_OP_implicit_value:
/* We cannot output addresses in .cfi_escape, only bytes. */
gcc_unreachable ();
{
head = new_reg_loc_descr (cfa->reg, cfa->base_offset);
head->dw_loc_oprnd1.val_class = dw_val_class_const;
+ head->dw_loc_oprnd1.val_entry = NULL;
tmp = new_loc_descr (DW_OP_deref, 0, 0);
add_loc_descr (&head, tmp);
if (offset != 0)
static tree decl_class_context (tree);
static void add_dwarf_attr (dw_die_ref, dw_attr_ref);
static inline enum dw_val_class AT_class (dw_attr_ref);
+static inline unsigned int AT_index (dw_attr_ref);
static void add_AT_flag (dw_die_ref, enum dwarf_attribute, unsigned);
static inline unsigned AT_flag (dw_attr_ref);
static void add_AT_int (dw_die_ref, enum dwarf_attribute, HOST_WIDE_INT);
static void add_AT_loc_list (dw_die_ref, enum dwarf_attribute,
dw_loc_list_ref);
static inline dw_loc_list_ref AT_loc_list (dw_attr_ref);
-static void add_AT_addr (dw_die_ref, enum dwarf_attribute, rtx);
+static addr_table_entry *add_addr_table_entry (void *, enum ate_kind);
+static void remove_addr_table_entry (addr_table_entry *);
+static void add_AT_addr (dw_die_ref, enum dwarf_attribute, rtx, bool);
static inline rtx AT_addr (dw_attr_ref);
static void add_AT_lbl_id (dw_die_ref, enum dwarf_attribute, const char *);
static void add_AT_lineptr (dw_die_ref, enum dwarf_attribute, const char *);
static void add_AT_offset (dw_die_ref, enum dwarf_attribute,
unsigned HOST_WIDE_INT);
static void add_AT_range_list (dw_die_ref, enum dwarf_attribute,
- unsigned long);
+ unsigned long, bool);
static inline const char *AT_lbl (dw_attr_ref);
static dw_attr_ref get_AT (dw_die_ref, enum dwarf_attribute);
static const char *get_AT_low_pc (dw_die_ref);
static enum dwarf_form value_format (dw_attr_ref);
static void output_value_format (dw_attr_ref);
static void output_abbrev_section (void);
+static void output_die_abbrevs (unsigned long, dw_die_ref);
static void output_die_symbol (dw_die_ref);
static void output_die (dw_die_ref);
static void output_compilation_unit_header (void);
static unsigned int add_ranges_num (int);
static unsigned int add_ranges (const_tree);
static void add_ranges_by_labels (dw_die_ref, const char *, const char *,
- bool *);
+ bool *, bool);
static void output_ranges (void);
static dw_line_info_table *new_line_info_table (void);
-static void output_line_info (void);
+static void output_line_info (bool);
static void output_file_names (void);
static dw_die_ref base_type_die (tree);
static int is_base_type (tree);
static void schedule_generic_params_dies_gen (tree t);
static void gen_scheduled_generic_parms_dies (void);
+/* enum for tracking thread-local variables whose address is really an offset
+ relative to the TLS pointer, which will need link-time relocation, but will
+ not need relocation by the DWARF consumer. */
+
+enum dtprel_bool
+{
+ dtprel_false = 0,
+ dtprel_true = 1
+};
+
+/* Return the operator to use for an address of a variable. For dtprel_true, we
+ use DW_OP_const*. For regular variables, which need both link-time
+ relocation and consumer-level relocation (e.g., to account for shared objects
+ loaded at a random address), we use DW_OP_addr*. */
+
+static inline enum dwarf_location_atom
+dw_addr_op (enum dtprel_bool dtprel)
+{
+ if (dtprel == dtprel_true)
+ return (dwarf_split_debug_info ? DW_OP_GNU_const_index
+ : (DWARF2_ADDR_SIZE == 4 ? DW_OP_const4u : DW_OP_const8u));
+ else
+ return dwarf_split_debug_info ? DW_OP_GNU_addr_index : DW_OP_addr;
+}
+
+/* Return a pointer to a newly allocated address location description. If
+ dwarf_split_debug_info is true, then record the address with the appropriate
+ relocation. */
+static inline dw_loc_descr_ref
+new_addr_loc_descr (rtx addr, enum dtprel_bool dtprel)
+{
+ dw_loc_descr_ref ref = new_loc_descr (dw_addr_op (dtprel), 0, 0);
+
+ ref->dw_loc_oprnd1.val_class = dw_val_class_addr;
+ ref->dw_loc_oprnd1.v.val_addr = addr;
+ ref->dtprel = dtprel;
+ if (dwarf_split_debug_info)
+ ref->dw_loc_oprnd1.val_entry
+ = add_addr_table_entry (addr,
+ dtprel ? ate_kind_rtx_dtprel : ate_kind_rtx);
+ else
+ ref->dw_loc_oprnd1.val_entry = NULL;
+
+ return ref;
+}
+
/* Section names used to hold DWARF debugging information. */
+
#ifndef DEBUG_INFO_SECTION
#define DEBUG_INFO_SECTION ".debug_info"
#endif
+#ifndef DEBUG_DWO_INFO_SECTION
+#define DEBUG_DWO_INFO_SECTION ".debug_info.dwo"
+#endif
#ifndef DEBUG_ABBREV_SECTION
#define DEBUG_ABBREV_SECTION ".debug_abbrev"
#endif
+#ifndef DEBUG_DWO_ABBREV_SECTION
+#define DEBUG_DWO_ABBREV_SECTION ".debug_abbrev.dwo"
+#endif
#ifndef DEBUG_ARANGES_SECTION
#define DEBUG_ARANGES_SECTION ".debug_aranges"
#endif
+#ifndef DEBUG_ADDR_SECTION
+#define DEBUG_ADDR_SECTION ".debug_addr"
+#endif
+#ifndef DEBUG_NORM_MACINFO_SECTION
+#define DEBUG_NORM_MACINFO_SECTION ".debug_macinfo"
+#endif
+#ifndef DEBUG_DWO_MACINFO_SECTION
+#define DEBUG_DWO_MACINFO_SECTION ".debug_macinfo.dwo"
+#endif
#ifndef DEBUG_MACINFO_SECTION
-#define DEBUG_MACINFO_SECTION ".debug_macinfo"
+#define DEBUG_MACINFO_SECTION \
+ (!dwarf_split_debug_info \
+ ? (DEBUG_NORM_MACINFO_SECTION) : (DEBUG_DWO_MACINFO_SECTION))
+#endif
+#ifndef DEBUG_NORM_MACRO_SECTION
+#define DEBUG_NORM_MACRO_SECTION ".debug_macro"
+#endif
+#ifndef DEBUG_DWO_MACRO_SECTION
+#define DEBUG_DWO_MACRO_SECTION ".debug_macro.dwo"
#endif
#ifndef DEBUG_MACRO_SECTION
-#define DEBUG_MACRO_SECTION ".debug_macro"
+#define DEBUG_MACRO_SECTION \
+ (!dwarf_split_debug_info \
+ ? (DEBUG_NORM_MACRO_SECTION) : (DEBUG_DWO_MACRO_SECTION))
#endif
#ifndef DEBUG_LINE_SECTION
#define DEBUG_LINE_SECTION ".debug_line"
#endif
+#ifndef DEBUG_DWO_LINE_SECTION
+#define DEBUG_DWO_LINE_SECTION ".debug_line.dwo"
+#endif
#ifndef DEBUG_LOC_SECTION
#define DEBUG_LOC_SECTION ".debug_loc"
#endif
+#ifndef DEBUG_DWO_LOC_SECTION
+#define DEBUG_DWO_LOC_SECTION ".debug_loc.dwo"
+#endif
#ifndef DEBUG_PUBNAMES_SECTION
#define DEBUG_PUBNAMES_SECTION ".debug_pubnames"
#endif
#ifndef DEBUG_PUBTYPES_SECTION
#define DEBUG_PUBTYPES_SECTION ".debug_pubtypes"
#endif
+#define DEBUG_NORM_STR_OFFSETS_SECTION ".debug_str_offsets"
+#define DEBUG_DWO_STR_OFFSETS_SECTION ".debug_str_offsets.dwo"
+#ifndef DEBUG_STR_OFFSETS_SECTION
+#define DEBUG_STR_OFFSETS_SECTION \
+ (!dwarf_split_debug_info \
+ ? (DEBUG_NORM_STR_OFFSETS_SECTION) : (DEBUG_DWO_STR_OFFSETS_SECTION))
+#endif
+#define DEBUG_DWO_STR_SECTION ".debug_str.dwo"
+#define DEBUG_NORM_STR_SECTION ".debug_str"
#ifndef DEBUG_STR_SECTION
-#define DEBUG_STR_SECTION ".debug_str"
+#define DEBUG_STR_SECTION \
+ (!dwarf_split_debug_info ? (DEBUG_NORM_STR_SECTION) : (DEBUG_DWO_STR_SECTION))
#endif
#ifndef DEBUG_RANGES_SECTION
#define DEBUG_RANGES_SECTION ".debug_ranges"
#define TEXT_SECTION_NAME ".text"
#endif
+/* Section flags for .debug_macinfo/.debug_macro section. */
+#define DEBUG_MACRO_SECTION_FLAGS \
+ (dwarf_split_debug_info ? SECTION_DEBUG | SECTION_EXCLUDE : SECTION_DEBUG)
+
/* Section flags for .debug_str section. */
#define DEBUG_STR_SECTION_FLAGS \
- (HAVE_GAS_SHF_MERGE && flag_merge_debug_strings \
- ? SECTION_DEBUG | SECTION_MERGE | SECTION_STRINGS | 1 \
- : SECTION_DEBUG)
+ (dwarf_split_debug_info \
+ ? SECTION_DEBUG | SECTION_EXCLUDE \
+ : (HAVE_GAS_SHF_MERGE && flag_merge_debug_strings \
+ ? SECTION_DEBUG | SECTION_MERGE | SECTION_STRINGS | 1 \
+ : SECTION_DEBUG))
/* Labels we insert at beginning sections we can reference instead of
the section names themselves. */
#ifndef TEXT_SECTION_LABEL
-#define TEXT_SECTION_LABEL "Ltext"
+#define TEXT_SECTION_LABEL "Ltext"
#endif
#ifndef COLD_TEXT_SECTION_LABEL
-#define COLD_TEXT_SECTION_LABEL "Ltext_cold"
+#define COLD_TEXT_SECTION_LABEL "Ltext_cold"
#endif
#ifndef DEBUG_LINE_SECTION_LABEL
-#define DEBUG_LINE_SECTION_LABEL "Ldebug_line"
+#define DEBUG_LINE_SECTION_LABEL "Ldebug_line"
+#endif
+#ifndef DEBUG_SKELETON_LINE_SECTION_LABEL
+#define DEBUG_SKELETON_LINE_SECTION_LABEL "Lskeleton_debug_line"
#endif
#ifndef DEBUG_INFO_SECTION_LABEL
-#define DEBUG_INFO_SECTION_LABEL "Ldebug_info"
+#define DEBUG_INFO_SECTION_LABEL "Ldebug_info"
+#endif
+#ifndef DEBUG_SKELETON_INFO_SECTION_LABEL
+#define DEBUG_SKELETON_INFO_SECTION_LABEL "Lskeleton_debug_info"
#endif
#ifndef DEBUG_ABBREV_SECTION_LABEL
-#define DEBUG_ABBREV_SECTION_LABEL "Ldebug_abbrev"
+#define DEBUG_ABBREV_SECTION_LABEL "Ldebug_abbrev"
+#endif
+#ifndef DEBUG_SKELETON_ABBREV_SECTION_LABEL
+#define DEBUG_SKELETON_ABBREV_SECTION_LABEL "Lskeleton_debug_abbrev"
+#endif
+#ifndef DEBUG_ADDR_SECTION_LABEL
+#define DEBUG_ADDR_SECTION_LABEL "Ldebug_addr"
#endif
#ifndef DEBUG_LOC_SECTION_LABEL
-#define DEBUG_LOC_SECTION_LABEL "Ldebug_loc"
+#define DEBUG_LOC_SECTION_LABEL "Ldebug_loc"
#endif
#ifndef DEBUG_RANGES_SECTION_LABEL
-#define DEBUG_RANGES_SECTION_LABEL "Ldebug_ranges"
+#define DEBUG_RANGES_SECTION_LABEL "Ldebug_ranges"
#endif
#ifndef DEBUG_MACINFO_SECTION_LABEL
-#define DEBUG_MACINFO_SECTION_LABEL "Ldebug_macinfo"
+#define DEBUG_MACINFO_SECTION_LABEL "Ldebug_macinfo"
#endif
#ifndef DEBUG_MACRO_SECTION_LABEL
-#define DEBUG_MACRO_SECTION_LABEL "Ldebug_macro"
+#define DEBUG_MACRO_SECTION_LABEL "Ldebug_macro"
#endif
-
+#define SKELETON_COMP_DIE_ABBREV 1
+#define SKELETON_TYPE_DIE_ABBREV 2
/* Definitions of defaults for formats and names of various special
(artificial) labels which may be generated within this file (when the -g
static char cold_end_label[MAX_ARTIFICIAL_LABEL_BYTES];
static char abbrev_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
static char debug_info_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
+static char debug_skeleton_info_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
+static char debug_skeleton_abbrev_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
static char debug_line_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
+static char debug_addr_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
+static char debug_skeleton_line_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
static char macinfo_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
static char loc_section_label[MAX_ARTIFICIAL_LABEL_BYTES];
static char ranges_section_label[2 * MAX_ARTIFICIAL_LABEL_BYTES];
return a->dw_attr_val.val_class;
}
+/* Return the index for any attribute that will be referenced with a
+ DW_FORM_GNU_addr_index or DW_FORM_GNU_str_index. String indices
+ are stored in dw_attr_val.v.val_str for reference counting
+ pruning. */
+
+static inline unsigned int
+AT_index (dw_attr_ref a)
+{
+ if (AT_class (a) == dw_val_class_str)
+ return a->dw_attr_val.v.val_str->index;
+ else if (a->dw_attr_val.val_entry != NULL)
+ return a->dw_attr_val.val_entry->index;
+ return NOT_INDEXED;
+}
+
/* Add a flag value attribute to a DIE. */
static inline void
attr.dw_attr = attr_kind;
attr.dw_attr_val.val_class = dw_val_class_flag;
+ attr.dw_attr_val.val_entry = NULL;
attr.dw_attr_val.v.val_flag = flag;
add_dwarf_attr (die, &attr);
}
attr.dw_attr = attr_kind;
attr.dw_attr_val.val_class = dw_val_class_const;
+ attr.dw_attr_val.val_entry = NULL;
attr.dw_attr_val.v.val_int = int_val;
add_dwarf_attr (die, &attr);
}
attr.dw_attr = attr_kind;
attr.dw_attr_val.val_class = dw_val_class_unsigned_const;
+ attr.dw_attr_val.val_entry = NULL;
attr.dw_attr_val.v.val_unsigned = unsigned_val;
add_dwarf_attr (die, &attr);
}
attr.dw_attr = attr_kind;
attr.dw_attr_val.val_class = dw_val_class_const_double;
+ attr.dw_attr_val.val_entry = NULL;
attr.dw_attr_val.v.val_double.high = high;
attr.dw_attr_val.v.val_double.low = low;
add_dwarf_attr (die, &attr);
attr.dw_attr = attr_kind;
attr.dw_attr_val.val_class = dw_val_class_vec;
+ attr.dw_attr_val.val_entry = NULL;
attr.dw_attr_val.v.val_vec.length = length;
attr.dw_attr_val.v.val_vec.elt_size = elt_size;
attr.dw_attr_val.v.val_vec.array = array;
attr.dw_attr = attr_kind;
attr.dw_attr_val.val_class = dw_val_class_data8;
+ attr.dw_attr_val.val_entry = NULL;
memcpy (attr.dw_attr_val.v.val_data8, data8, 8);
add_dwarf_attr (die, &attr);
}
-/* Add DW_AT_low_pc and DW_AT_high_pc to a DIE. */
+/* Add DW_AT_low_pc and DW_AT_high_pc to a DIE. When using
+ dwarf_split_debug_info, address attributes in dies destined for the
+ final executable have force_direct set to avoid using indexed
+ references. */
+
static inline void
-add_AT_low_high_pc (dw_die_ref die, const char *lbl_low, const char *lbl_high)
+add_AT_low_high_pc (dw_die_ref die, const char *lbl_low, const char *lbl_high,
+ bool force_direct)
{
dw_attr_node attr;
+ char * lbl_id;
+ lbl_id = xstrdup (lbl_low);
attr.dw_attr = DW_AT_low_pc;
attr.dw_attr_val.val_class = dw_val_class_lbl_id;
- attr.dw_attr_val.v.val_lbl_id = xstrdup (lbl_low);
+ attr.dw_attr_val.v.val_lbl_id = lbl_id;
+ if (dwarf_split_debug_info && !force_direct)
+ attr.dw_attr_val.val_entry
+ = add_addr_table_entry (lbl_id, ate_kind_label);
+ else
+ attr.dw_attr_val.val_entry = NULL;
add_dwarf_attr (die, &attr);
attr.dw_attr = DW_AT_high_pc;
attr.dw_attr_val.val_class = dw_val_class_lbl_id;
else
attr.dw_attr_val.val_class = dw_val_class_high_pc;
- attr.dw_attr_val.v.val_lbl_id = xstrdup (lbl_high);
+ lbl_id = xstrdup (lbl_high);
+ attr.dw_attr_val.v.val_lbl_id = lbl_id;
+ if (attr.dw_attr_val.val_class == dw_val_class_lbl_id
+ && dwarf_split_debug_info && !force_direct)
+ attr.dw_attr_val.val_entry
+ = add_addr_table_entry (lbl_id, ate_kind_label);
+ else
+ attr.dw_attr_val.val_entry = NULL;
add_dwarf_attr (die, &attr);
}
attr.dw_attr = attr_kind;
attr.dw_attr_val.val_class = dw_val_class_str;
+ attr.dw_attr_val.val_entry = NULL;
attr.dw_attr_val.v.val_str = node;
add_dwarf_attr (die, &attr);
}
return a->dw_attr_val.v.val_str->str;
}
+/* Call this function directly to bypass AT_string_form's logic to put
+ the string inline in the die. */
+
+static void
+set_indirect_string (struct indirect_string_node *node)
+{
+ char label[32];
+ /* Already indirect is a no op. */
+ if (node->form == DW_FORM_strp || node->form == DW_FORM_GNU_str_index)
+ {
+ gcc_assert (node->label);
+ return;
+ }
+ ASM_GENERATE_INTERNAL_LABEL (label, "LASF", dw2_string_counter);
+ ++dw2_string_counter;
+ node->label = xstrdup (label);
+
+ if (!dwarf_split_debug_info)
+ {
+ node->form = DW_FORM_strp;
+ node->index = NOT_INDEXED;
+ }
+ else
+ {
+ node->form = DW_FORM_GNU_str_index;
+ node->index = NO_INDEX_ASSIGNED;
+ }
+}
+
/* Find out whether a string should be output inline in DIE
or out-of-line in .debug_str section. */
static enum dwarf_form
-AT_string_form (dw_attr_ref a)
+find_string_form (struct indirect_string_node *node)
{
- struct indirect_string_node *node;
unsigned int len;
- char label[32];
- gcc_assert (a && AT_class (a) == dw_val_class_str);
-
- node = a->dw_attr_val.v.val_str;
if (node->form)
return node->form;
&& (len - DWARF_OFFSET_SIZE) * node->refcount <= len))
return node->form = DW_FORM_string;
- ASM_GENERATE_INTERNAL_LABEL (label, "LASF", dw2_string_counter);
- ++dw2_string_counter;
- node->label = xstrdup (label);
+ set_indirect_string (node);
+
+ return node->form;
+}
- return node->form = DW_FORM_strp;
+/* Find out whether the string referenced from the attribute should be
+ output inline in DIE or out-of-line in .debug_str section. */
+
+static enum dwarf_form
+AT_string_form (dw_attr_ref a)
+{
+ gcc_assert (a && AT_class (a) == dw_val_class_str);
+ return find_string_form (a->dw_attr_val.v.val_str);
}
/* Add a DIE reference attribute value to a DIE. */
attr.dw_attr = attr_kind;
attr.dw_attr_val.val_class = dw_val_class_die_ref;
+ attr.dw_attr_val.val_entry = NULL;
attr.dw_attr_val.v.val_die_ref.die = targ_die;
attr.dw_attr_val.v.val_die_ref.external = 0;
add_dwarf_attr (die, &attr);
attr.dw_attr = attr_kind;
attr.dw_attr_val.val_class = dw_val_class_fde_ref;
+ attr.dw_attr_val.val_entry = NULL;
attr.dw_attr_val.v.val_fde_index = targ_fde;
add_dwarf_attr (die, &attr);
}
attr.dw_attr = attr_kind;
attr.dw_attr_val.val_class = dw_val_class_loc;
+ attr.dw_attr_val.val_entry = NULL;
attr.dw_attr_val.v.val_loc = loc;
add_dwarf_attr (die, &attr);
}
attr.dw_attr = attr_kind;
attr.dw_attr_val.val_class = dw_val_class_loc_list;
+ attr.dw_attr_val.val_entry = NULL;
attr.dw_attr_val.v.val_loc_list = loc_list;
add_dwarf_attr (die, &attr);
have_location_lists = true;
return &a->dw_attr_val.v.val_loc_list;
}
-/* Add an address constant attribute value to a DIE. */
+/* Table of entries into the .debug_addr section. */
+
+static GTY ((param_is (addr_table_entry))) htab_t addr_index_table;
+
+/* Hash an address_table_entry. */
+
+static hashval_t
+addr_table_entry_do_hash (const void *x)
+{
+ const addr_table_entry *a = (const addr_table_entry *) x;
+ switch (a->kind)
+ {
+ case ate_kind_rtx:
+ return iterative_hash_rtx (a->addr.rtl, 0);
+ case ate_kind_rtx_dtprel:
+ return iterative_hash_rtx (a->addr.rtl, 1);
+ case ate_kind_label:
+ return htab_hash_string (a->addr.label);
+ default:
+ gcc_unreachable ();
+ }
+}
+
+/* Determine equality for two address_table_entries. */
+
+static int
+addr_table_entry_eq (const void *x1, const void *x2)
+{
+ const addr_table_entry *a1 = (const addr_table_entry *) x1;
+ const addr_table_entry *a2 = (const addr_table_entry *) x2;
+
+ if (a1->kind != a2->kind)
+ return 0;
+ switch (a1->kind)
+ {
+ case ate_kind_rtx:
+ case ate_kind_rtx_dtprel:
+ return rtx_equal_p (a1->addr.rtl, a2->addr.rtl);
+ case ate_kind_label:
+ return strcmp (a1->addr.label, a2->addr.label) == 0;
+ default:
+ gcc_unreachable ();
+ }
+}
+
+/* Initialize an addr_table_entry. */
+
+void
+init_addr_table_entry (addr_table_entry *e, enum ate_kind kind, void *addr)
+{
+ e->kind = kind;
+ switch (kind)
+ {
+ case ate_kind_rtx:
+ case ate_kind_rtx_dtprel:
+ e->addr.rtl = (rtx) addr;
+ break;
+ case ate_kind_label:
+ e->addr.label = (char *) addr;
+ break;
+ }
+ e->refcount = 0;
+ e->index = NO_INDEX_ASSIGNED;
+}
+
+/* Add attr to the address table entry to the table. Defer setting an
+ index until output time. */
+
+static addr_table_entry *
+add_addr_table_entry (void *addr, enum ate_kind kind)
+{
+ addr_table_entry *node;
+ addr_table_entry finder;
+ void **slot;
+
+ gcc_assert (dwarf_split_debug_info);
+ if (! addr_index_table)
+ addr_index_table = htab_create_ggc (10, addr_table_entry_do_hash,
+ addr_table_entry_eq, NULL);
+ init_addr_table_entry (&finder, kind, addr);
+ slot = htab_find_slot (addr_index_table, &finder, INSERT);
+
+ if (*slot == HTAB_EMPTY_ENTRY)
+ {
+ node = ggc_alloc_cleared_addr_table_entry ();
+ init_addr_table_entry (node, kind, addr);
+ *slot = node;
+ }
+ else
+ node = (addr_table_entry *) *slot;
+
+ node->refcount++;
+ return node;
+}
+
+/* Remove an entry from the addr table by decrementing its refcount.
+ Strictly, decrementing the refcount would be enough, but the
+ assertion that the entry is actually in the table has found
+ bugs. */
+
+static void
+remove_addr_table_entry (addr_table_entry *entry)
+{
+ addr_table_entry *node;
+
+ gcc_assert (dwarf_split_debug_info && addr_index_table);
+ node = (addr_table_entry *) htab_find (addr_index_table, entry);
+ /* After an index is assigned, the table is frozen. */
+ gcc_assert (node->refcount > 0 && node->index == NO_INDEX_ASSIGNED);
+ node->refcount--;
+}
+
+/* Given a location list, remove all addresses it refers to from the
+ address_table. */
+
+static void
+remove_loc_list_addr_table_entries (dw_loc_descr_ref descr)
+{
+ for (; descr; descr = descr->dw_loc_next)
+ if (descr->dw_loc_oprnd1.val_entry != NULL)
+ {
+ gcc_assert (descr->dw_loc_oprnd1.val_entry->index == NO_INDEX_ASSIGNED);
+ remove_addr_table_entry (descr->dw_loc_oprnd1.val_entry);
+ }
+}
+
+/* A helper function for dwarf2out_finish called through
+ htab_traverse. Assign an addr_table_entry its index. All entries
+ must be collected into the table when this function is called,
+ because the indexing code relies on htab_traverse to traverse nodes
+ in the same order for each run. */
+
+static int
+index_addr_table_entry (void **h, void *v)
+{
+ addr_table_entry *node = (addr_table_entry *) *h;
+ unsigned int *index = (unsigned int *) v;
+
+ gcc_assert(node->index == NO_INDEX_ASSIGNED);
+ node->index = *index;
+ *index += 1;
+
+ return 1;
+}
+
+/* Add an address constant attribute value to a DIE. When using
+ dwarf_split_debug_info, address attributes in dies destined for the
+ final executable should be direct references--setting the parameter
+ force_direct ensures this behavior. */
static inline void
-add_AT_addr (dw_die_ref die, enum dwarf_attribute attr_kind, rtx addr)
+add_AT_addr (dw_die_ref die, enum dwarf_attribute attr_kind, rtx addr,
+ bool force_direct)
{
dw_attr_node attr;
attr.dw_attr = attr_kind;
attr.dw_attr_val.val_class = dw_val_class_addr;
attr.dw_attr_val.v.val_addr = addr;
+ if (dwarf_split_debug_info && !force_direct)
+ attr.dw_attr_val.val_entry = add_addr_table_entry (addr, ate_kind_rtx);
+ else
+ attr.dw_attr_val.val_entry = NULL;
add_dwarf_attr (die, &attr);
}
attr.dw_attr = attr_kind;
attr.dw_attr_val.val_class = dw_val_class_file;
+ attr.dw_attr_val.val_entry = NULL;
attr.dw_attr_val.v.val_file = fd;
add_dwarf_attr (die, &attr);
}
attr.dw_attr = attr_kind;
attr.dw_attr_val.val_class = dw_val_class_vms_delta;
+ attr.dw_attr_val.val_entry = NULL;
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_AT_lbl_id (dw_die_ref die, enum dwarf_attribute attr_kind, const char *lbl_id)
+add_AT_lbl_id (dw_die_ref die, enum dwarf_attribute attr_kind,
+ const char *lbl_id)
{
dw_attr_node attr;
attr.dw_attr = attr_kind;
attr.dw_attr_val.val_class = dw_val_class_lbl_id;
+ attr.dw_attr_val.val_entry = NULL;
attr.dw_attr_val.v.val_lbl_id = xstrdup (lbl_id);
+ if (dwarf_split_debug_info)
+ attr.dw_attr_val.val_entry
+ = add_addr_table_entry (attr.dw_attr_val.v.val_lbl_id,
+ ate_kind_label);
add_dwarf_attr (die, &attr);
}
attr.dw_attr = attr_kind;
attr.dw_attr_val.val_class = dw_val_class_lineptr;
+ attr.dw_attr_val.val_entry = NULL;
attr.dw_attr_val.v.val_lbl_id = xstrdup (label);
add_dwarf_attr (die, &attr);
}
attr.dw_attr = attr_kind;
attr.dw_attr_val.val_class = dw_val_class_macptr;
+ attr.dw_attr_val.val_entry = NULL;
attr.dw_attr_val.v.val_lbl_id = xstrdup (label);
add_dwarf_attr (die, &attr);
}
attr.dw_attr = attr_kind;
attr.dw_attr_val.val_class = dw_val_class_offset;
+ attr.dw_attr_val.val_entry = NULL;
attr.dw_attr_val.v.val_offset = offset;
add_dwarf_attr (die, &attr);
}
-/* Add an range_list attribute value to a DIE. */
+/* Add a range_list attribute value to a DIE. When using
+ dwarf_split_debug_info, address attributes in dies destined for the
+ final executable should be direct references--setting the parameter
+ force_direct ensures this behavior. */
+
+#define UNRELOCATED_OFFSET ((addr_table_entry *) 1)
+#define RELOCATED_OFFSET (NULL)
static void
add_AT_range_list (dw_die_ref die, enum dwarf_attribute attr_kind,
- long unsigned int offset)
+ long unsigned int offset, bool force_direct)
{
dw_attr_node attr;
attr.dw_attr = attr_kind;
attr.dw_attr_val.val_class = dw_val_class_range_list;
+ /* For the range_list attribute, use val_entry to store whether the
+ offset should follow split-debug-info or normal semantics. This
+ value is read in output_range_list_offset. */
+ if (dwarf_split_debug_info && !force_direct)
+ attr.dw_attr_val.val_entry = UNRELOCATED_OFFSET;
+ else
+ attr.dw_attr_val.val_entry = RELOCATED_OFFSET;
attr.dw_attr_val.v.val_offset = offset;
add_dwarf_attr (die, &attr);
}
unsigned long size = 0;
dw_attr_ref a;
unsigned ix;
+ enum dwarf_form form;
size += size_of_uleb128 (die->die_abbrev);
FOR_EACH_VEC_ELT (dw_attr_node, die->die_attr, ix, a)
switch (AT_class (a))
{
case dw_val_class_addr:
- size += DWARF2_ADDR_SIZE;
+ if (dwarf_split_debug_info && AT_index (a) != NOT_INDEXED)
+ {
+ gcc_assert (AT_index (a) != NO_INDEX_ASSIGNED);
+ size += size_of_uleb128 (AT_index (a));
+ }
+ else
+ size += DWARF2_ADDR_SIZE;
break;
case dw_val_class_offset:
size += DWARF_OFFSET_SIZE;
}
break;
case dw_val_class_loc_list:
- size += DWARF_OFFSET_SIZE;
+ if (dwarf_split_debug_info && AT_index (a) != NOT_INDEXED)
+ {
+ gcc_assert (AT_index (a) != NO_INDEX_ASSIGNED);
+ size += size_of_uleb128 (AT_index (a));
+ }
+ else
+ size += DWARF_OFFSET_SIZE;
break;
case dw_val_class_range_list:
- size += DWARF_OFFSET_SIZE;
+ size += DWARF_OFFSET_SIZE;
break;
case dw_val_class_const:
size += size_of_sleb128 (AT_int (a));
size += DWARF_OFFSET_SIZE;
break;
case dw_val_class_lbl_id:
- size += DWARF2_ADDR_SIZE;
+ if (dwarf_split_debug_info && AT_index (a) != NOT_INDEXED)
+ {
+ gcc_assert (AT_index (a) != NO_INDEX_ASSIGNED);
+ size += size_of_uleb128 (AT_index (a));
+ }
+ else
+ size += DWARF2_ADDR_SIZE;
break;
case dw_val_class_lineptr:
case dw_val_class_macptr:
- size += DWARF_OFFSET_SIZE;
+ size += DWARF_OFFSET_SIZE;
break;
case dw_val_class_str:
- if (AT_string_form (a) == DW_FORM_strp)
+ form = AT_string_form (a);
+ if (form == DW_FORM_strp)
size += DWARF_OFFSET_SIZE;
+ else if (form == DW_FORM_GNU_str_index)
+ size += size_of_uleb128 (AT_index (a));
else
size += strlen (a->dw_attr_val.v.val_str->str) + 1;
break;
static enum dwarf_form
value_format (dw_attr_ref a)
{
- switch (a->dw_attr_val.val_class)
+ switch (AT_class (a))
{
case dw_val_class_addr:
/* Only very few attributes allow DW_FORM_addr. */
case DW_AT_high_pc:
case DW_AT_entry_pc:
case DW_AT_trampoline:
- return DW_FORM_addr;
+ return (AT_index (a) == NOT_INDEXED
+ ? DW_FORM_addr : DW_FORM_GNU_addr_index);
default:
break;
}
case dw_val_class_fde_ref:
return DW_FORM_data;
case dw_val_class_lbl_id:
- return DW_FORM_addr;
+ return (AT_index (a) == NOT_INDEXED
+ ? DW_FORM_addr : DW_FORM_GNU_addr_index);
case dw_val_class_lineptr:
case dw_val_class_macptr:
return dwarf_version >= 4 ? DW_FORM_sec_offset : DW_FORM_data;
dw2_asm_output_data_uleb128 (form, "(%s)", dwarf_form_name (form));
}
-/* Output the .debug_abbrev section which defines the DIE abbreviation
- table. */
+/* Given a die and id, produce the appropriate abbreviations. */
static void
-output_abbrev_section (void)
+output_die_abbrevs (unsigned long abbrev_id, dw_die_ref abbrev)
{
- unsigned long abbrev_id;
+ unsigned ix;
+ dw_attr_ref a_attr;
- for (abbrev_id = 1; abbrev_id < abbrev_die_table_in_use; ++abbrev_id)
+ dw2_asm_output_data_uleb128 (abbrev_id, "(abbrev code)");
+ dw2_asm_output_data_uleb128 (abbrev->die_tag, "(TAG: %s)",
+ dwarf_tag_name (abbrev->die_tag));
+
+ if (abbrev->die_child != NULL)
+ dw2_asm_output_data (1, DW_children_yes, "DW_children_yes");
+ else
+ dw2_asm_output_data (1, DW_children_no, "DW_children_no");
+
+ for (ix = 0; VEC_iterate (dw_attr_node, abbrev->die_attr, ix, a_attr);
+ ix++)
{
- dw_die_ref abbrev = abbrev_die_table[abbrev_id];
- unsigned ix;
- dw_attr_ref a_attr;
+ dw2_asm_output_data_uleb128 (a_attr->dw_attr, "(%s)",
+ dwarf_attr_name (a_attr->dw_attr));
+ output_value_format (a_attr);
+ }
- dw2_asm_output_data_uleb128 (abbrev_id, "(abbrev code)");
- dw2_asm_output_data_uleb128 (abbrev->die_tag, "(TAG: %s)",
- dwarf_tag_name (abbrev->die_tag));
+ dw2_asm_output_data (1, 0, NULL);
+ dw2_asm_output_data (1, 0, NULL);
+}
- if (abbrev->die_child != NULL)
- dw2_asm_output_data (1, DW_children_yes, "DW_children_yes");
- else
- dw2_asm_output_data (1, DW_children_no, "DW_children_no");
- for (ix = 0; VEC_iterate (dw_attr_node, abbrev->die_attr, ix, a_attr);
- ix++)
- {
- dw2_asm_output_data_uleb128 (a_attr->dw_attr, "(%s)",
- dwarf_attr_name (a_attr->dw_attr));
- output_value_format (a_attr);
- }
+/* Output the .debug_abbrev section which defines the DIE abbreviation
+ table. */
- dw2_asm_output_data (1, 0, NULL);
- dw2_asm_output_data (1, 0, NULL);
- }
+static void
+output_abbrev_section (void)
+{
+ unsigned long abbrev_id;
+
+ for (abbrev_id = 1; abbrev_id < abbrev_die_table_in_use; ++abbrev_id)
+ output_die_abbrevs (abbrev_id, abbrev_die_table[abbrev_id]);
/* Terminate the table. */
dw2_asm_output_data (1, 0, NULL);
dw_loc_list_ref retlist = ggc_alloc_cleared_dw_loc_list_node ();
retlist->begin = begin;
+ retlist->begin_entry = NULL;
retlist->end = end;
retlist->expr = expr;
retlist->section = section;
in a single range are unlikely very useful. */
if (size > 0xffff)
continue;
- if (!have_multiple_function_sections)
+ if (dwarf_split_debug_info)
+ {
+ dw2_asm_output_data (1, DW_LLE_GNU_start_length_entry,
+ "Location list start/length entry (%s)",
+ list_head->ll_symbol);
+ dw2_asm_output_data_uleb128 (curr->begin_entry->index,
+ "Location list range start index (%s)",
+ curr->begin);
+ /* The length field is 4 bytes. If we ever need to support
+ an 8-byte length, we can add a new DW_LLE code or fall back
+ to DW_LLE_GNU_start_end_entry. */
+ dw2_asm_output_delta (4, curr->end, curr->begin,
+ "Location list range length (%s)",
+ list_head->ll_symbol);
+ }
+ else if (!have_multiple_function_sections)
{
dw2_asm_output_delta (DWARF2_ADDR_SIZE, curr->begin, curr->section,
"Location list begin address (%s)",
output_loc_sequence (curr->expr, -1);
}
- dw2_asm_output_data (DWARF2_ADDR_SIZE, 0,
- "Location list terminator begin (%s)",
- list_head->ll_symbol);
- dw2_asm_output_data (DWARF2_ADDR_SIZE, 0,
- "Location list terminator end (%s)",
- list_head->ll_symbol);
+ if (dwarf_split_debug_info)
+ dw2_asm_output_data (1, DW_LLE_GNU_end_of_list_entry,
+ "Location list terminator (%s)",
+ list_head->ll_symbol);
+ else
+ {
+ dw2_asm_output_data (DWARF2_ADDR_SIZE, 0,
+ "Location list terminator begin (%s)",
+ list_head->ll_symbol);
+ dw2_asm_output_data (DWARF2_ADDR_SIZE, 0,
+ "Location list terminator end (%s)",
+ list_head->ll_symbol);
+ }
+}
+
+/* Output a range_list offset into the debug_range section. Emit a
+ relocated reference if val_entry is NULL, otherwise, emit an
+ indirect reference. */
+
+static void
+output_range_list_offset (dw_attr_ref a)
+{
+ const char *name = dwarf_attr_name (a->dw_attr);
+
+ if (a->dw_attr_val.val_entry == RELOCATED_OFFSET)
+ {
+ char *p = strchr (ranges_section_label, '\0');
+ sprintf (p, "+" HOST_WIDE_INT_PRINT_HEX, a->dw_attr_val.v.val_offset);
+ dw2_asm_output_offset (DWARF_OFFSET_SIZE, ranges_section_label,
+ debug_ranges_section, "%s", name);
+ *p = '\0';
+ }
+ else
+ dw2_asm_output_data (DWARF_OFFSET_SIZE, a->dw_attr_val.v.val_offset,
+ "%s (offset from %s)", name, ranges_section_label);
+}
+
+/* Output the offset into the debug_loc section. */
+
+static void
+output_loc_list_offset (dw_attr_ref a)
+{
+ char *sym = AT_loc_list (a)->ll_symbol;
+
+ gcc_assert (sym);
+ if (dwarf_split_debug_info)
+ dw2_asm_output_delta (DWARF_OFFSET_SIZE, sym, loc_section_label,
+ "%s", dwarf_attr_name (a->dw_attr));
+ else
+ dw2_asm_output_offset (DWARF_OFFSET_SIZE, sym, debug_loc_section,
+ "%s", dwarf_attr_name (a->dw_attr));
+}
+
+/* Output an attribute's index or value appropriately. */
+
+static void
+output_attr_index_or_value (dw_attr_ref a)
+{
+ const char *name = dwarf_attr_name (a->dw_attr);
+
+ if (dwarf_split_debug_info && AT_index (a) != NOT_INDEXED)
+ {
+ dw2_asm_output_data_uleb128 (AT_index (a), "%s", name);
+ return;
+ }
+ switch (AT_class (a))
+ {
+ case dw_val_class_addr:
+ dw2_asm_output_addr_rtx (DWARF2_ADDR_SIZE, AT_addr (a), "%s", name);
+ break;
+ case dw_val_class_high_pc:
+ case dw_val_class_lbl_id:
+ dw2_asm_output_addr (DWARF2_ADDR_SIZE, AT_lbl (a), "%s", name);
+ break;
+ case dw_val_class_loc_list:
+ output_loc_list_offset (a);
+ break;
+ default:
+ gcc_unreachable ();
+ }
}
/* Output a type signature. */
switch (AT_class (a))
{
case dw_val_class_addr:
- dw2_asm_output_addr_rtx (DWARF2_ADDR_SIZE, AT_addr (a), "%s", name);
+ output_attr_index_or_value (a);
break;
case dw_val_class_offset:
break;
case dw_val_class_range_list:
- {
- char *p = strchr (ranges_section_label, '\0');
-
- sprintf (p, "+" HOST_WIDE_INT_PRINT_HEX,
- a->dw_attr_val.v.val_offset);
- dw2_asm_output_offset (DWARF_OFFSET_SIZE, ranges_section_label,
- debug_ranges_section, "%s", name);
- *p = '\0';
- }
+ output_range_list_offset (a);
break;
case dw_val_class_loc:
}
dw2_asm_output_data (HOST_BITS_PER_WIDE_INT / HOST_BITS_PER_CHAR,
- first, name);
+ first, "%s", name);
dw2_asm_output_data (HOST_BITS_PER_WIDE_INT / HOST_BITS_PER_CHAR,
second, NULL);
}
break;
case dw_val_class_loc_list:
- {
- char *sym = AT_loc_list (a)->ll_symbol;
-
- gcc_assert (sym);
- dw2_asm_output_offset (DWARF_OFFSET_SIZE, sym, debug_loc_section,
- "%s", name);
- }
+ output_attr_index_or_value (a);
break;
case dw_val_class_die_ref:
break;
case dw_val_class_lbl_id:
- dw2_asm_output_addr (DWARF2_ADDR_SIZE, AT_lbl (a), "%s", name);
+ output_attr_index_or_value (a);
break;
case dw_val_class_lineptr:
break;
case dw_val_class_str:
- if (AT_string_form (a) == DW_FORM_strp)
- dw2_asm_output_offset (DWARF_OFFSET_SIZE,
- a->dw_attr_val.v.val_str->label,
- debug_str_section,
- "%s: \"%s\"", name, AT_string (a));
- else
+ if (a->dw_attr_val.v.val_str->form == DW_FORM_strp)
+ dw2_asm_output_offset (DWARF_OFFSET_SIZE,
+ a->dw_attr_val.v.val_str->label,
+ debug_str_section,
+ "%s: \"%s\"", name, AT_string (a));
+ else if (a->dw_attr_val.v.val_str->form == DW_FORM_GNU_str_index)
+ dw2_asm_output_data_uleb128 (AT_index (a),
+ "%s: \"%s\"", name, AT_string (a));
+ else
dw2_asm_output_nstring (AT_string (a), -1, "%s", name);
break;
add_AT_flag (die, DW_AT_GNU_pubnames, 1);
}
+/* Helper function to generate top-level dies for skeleton debug_info and
+ debug_types. */
+
+static void
+add_top_level_skeleton_die_attrs (dw_die_ref die)
+{
+ const char *dwo_file_name = concat (aux_base_name, ".dwo", NULL);
+ dw_attr_ref attr;
+
+ add_comp_dir_attribute (die);
+ add_AT_string (die, DW_AT_GNU_dwo_name, dwo_file_name);
+ /* The specification suggests that these attributes be inline to avoid
+ having a .debug_str section. We know that they exist in the die because
+ we just added them. */
+ attr = get_AT (die, DW_AT_GNU_dwo_name);
+ attr->dw_attr_val.v.val_str->form = DW_FORM_string;
+ attr = get_AT (die, DW_AT_comp_dir);
+ attr->dw_attr_val.v.val_str->form = DW_FORM_string;
+
+ add_AT_pubnames (die);
+ add_AT_lineptr (die, DW_AT_GNU_addr_base, debug_addr_section_label);
+}
+
+/* Return the single type-unit die for skeleton type units. */
+
+static dw_die_ref
+get_skeleton_type_unit (void)
+{
+ /* For dwarf_split_debug_sections with use_type info, all type units in the
+ skeleton sections have identical dies (but different headers). This
+ single die will be output many times. */
+
+ static dw_die_ref skeleton_type_unit = NULL;
+
+ if (skeleton_type_unit == NULL)
+ {
+ skeleton_type_unit = new_die (DW_TAG_type_unit, NULL, NULL);
+ add_top_level_skeleton_die_attrs (skeleton_type_unit);
+ skeleton_type_unit->die_abbrev = SKELETON_TYPE_DIE_ABBREV;
+ }
+ return skeleton_type_unit;
+}
+
+/* Output skeleton debug sections that point to the dwo file. */
+
+static void
+output_skeleton_debug_sections (dw_die_ref comp_unit)
+{
+ /* These attributes will be found in the full debug_info section. */
+ remove_AT (comp_unit, DW_AT_producer);
+ remove_AT (comp_unit, DW_AT_language);
+
+ /* Add attributes common to skeleton compile_units and type_units. */
+ add_top_level_skeleton_die_attrs (comp_unit);
+
+ switch_to_section (debug_skeleton_info_section);
+ ASM_OUTPUT_LABEL (asm_out_file, debug_skeleton_info_section_label);
+
+ /* Produce the skeleton compilation-unit header. This one differs enough from
+ a normal CU header that it's better not to call output_compilation_unit
+ header. */
+ if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4)
+ dw2_asm_output_data (4, 0xffffffff,
+ "Initial length escape value indicating 64-bit DWARF extension");
+
+ dw2_asm_output_data (DWARF_OFFSET_SIZE,
+ DWARF_COMPILE_UNIT_HEADER_SIZE
+ - DWARF_INITIAL_LENGTH_SIZE
+ + size_of_die (comp_unit),
+ "Length of Compilation Unit Info");
+ dw2_asm_output_data (2, dwarf_version, "DWARF version number");
+ dw2_asm_output_offset (DWARF_OFFSET_SIZE, debug_skeleton_abbrev_section_label,
+ debug_abbrev_section,
+ "Offset Into Abbrev. Section");
+ dw2_asm_output_data (1, DWARF2_ADDR_SIZE, "Pointer Size (in bytes)");
+
+ comp_unit->die_abbrev = SKELETON_COMP_DIE_ABBREV;
+ output_die (comp_unit);
+
+ /* Build the skeleton debug_abbrev section. */
+ switch_to_section (debug_skeleton_abbrev_section);
+ ASM_OUTPUT_LABEL (asm_out_file, debug_skeleton_abbrev_section_label);
+
+ output_die_abbrevs (SKELETON_COMP_DIE_ABBREV, comp_unit);
+ if (use_debug_types)
+ output_die_abbrevs (SKELETON_TYPE_DIE_ABBREV, get_skeleton_type_unit ());
+
+ dw2_asm_output_data (1, 0, "end of skeleton .debug_abbrev");
+}
+
/* Output a comdat type unit DIE and its children. */
static void
calc_die_sizes (node->root_die);
#if defined (OBJECT_FORMAT_ELF)
- secname = ".debug_types";
+ if (!dwarf_split_debug_info)
+ secname = ".debug_types";
+ else
+ secname = ".debug_types.dwo";
+
tmp = XALLOCAVEC (char, 4 + DWARF_TYPE_SIGNATURE_SIZE * 2);
sprintf (tmp, "wt.");
for (i = 0; i < DWARF_TYPE_SIGNATURE_SIZE; i++)
output_die (node->root_die);
unmark_dies (node->root_die);
+
+ if (dwarf_split_debug_info)
+ {
+ /* Produce the skeleton type-unit header. */
+ const char *secname = ".debug_types";
+
+ targetm.asm_out.named_section (secname,
+ SECTION_DEBUG | SECTION_LINKONCE,
+ comdat_key);
+ if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4)
+ dw2_asm_output_data (4, 0xffffffff,
+ "Initial length escape value indicating 64-bit DWARF extension");
+
+ dw2_asm_output_data (DWARF_OFFSET_SIZE,
+ DWARF_COMPILE_UNIT_HEADER_SIZE
+ - DWARF_INITIAL_LENGTH_SIZE
+ + size_of_die (get_skeleton_type_unit ())
+ + DWARF_TYPE_SIGNATURE_SIZE + DWARF_OFFSET_SIZE,
+ "Length of Type Unit Info");
+ dw2_asm_output_data (2, dwarf_version, "DWARF version number");
+ dw2_asm_output_offset (DWARF_OFFSET_SIZE,
+ debug_skeleton_abbrev_section_label,
+ debug_abbrev_section,
+ "Offset Into Abbrev. Section");
+ dw2_asm_output_data (1, DWARF2_ADDR_SIZE, "Pointer Size (in bytes)");
+ output_signature (node->signature, "Type Signature");
+ dw2_asm_output_data (DWARF_OFFSET_SIZE, 0, "Offset to Type DIE");
+
+ output_die (get_skeleton_type_unit ());
+ }
}
/* Return the DWARF2/3 pubname associated with a decl. */
class_member, it will either be inside the class already, or will have just
looked up the class to find the member. Either way, searching the class is
faster than searching the index. */
- if ((TREE_PUBLIC (decl) && !is_class_die (die->die_parent))
+ if ((TREE_PUBLIC (decl) && !class_scope_p (die->die_parent))
|| is_cu_die (die->die_parent) || is_namespace_die (die->die_parent))
{
const char *name = dwarf2_name (decl, 1);
"Length of Public Type Names Info");
/* Version number for pubnames/pubtypes is still 2, even in DWARF3. */
dw2_asm_output_data (2, 2, "DWARF Version");
- dw2_asm_output_offset (DWARF_OFFSET_SIZE, debug_info_section_label,
- debug_info_section,
- "Offset of Compilation Unit Info");
+ if (dwarf_split_debug_info)
+ dw2_asm_output_offset (DWARF_OFFSET_SIZE, debug_skeleton_info_section_label,
+ debug_skeleton_info_section,
+ "Offset of Compilation Unit Info");
+ else
+ dw2_asm_output_offset (DWARF_OFFSET_SIZE, debug_info_section_label,
+ debug_info_section,
+ "Offset of Compilation Unit Info");
dw2_asm_output_data (DWARF_OFFSET_SIZE, next_die_offset,
"Compilation Unit Length");
"Length of Address Ranges Info");
/* Version number for aranges is still 2, even in DWARF3. */
dw2_asm_output_data (2, 2, "DWARF Version");
- dw2_asm_output_offset (DWARF_OFFSET_SIZE, debug_info_section_label,
- debug_info_section,
- "Offset of Compilation Unit Info");
+ if (dwarf_split_debug_info)
+ dw2_asm_output_offset (DWARF_OFFSET_SIZE, debug_skeleton_info_section_label,
+ debug_skeleton_info_section,
+ "Offset of Compilation Unit Info");
+ else
+ dw2_asm_output_offset (DWARF_OFFSET_SIZE, debug_info_section_label,
+ debug_info_section,
+ "Offset of Compilation Unit Info");
dw2_asm_output_data (1, DWARF2_ADDR_SIZE, "Size of Address");
dw2_asm_output_data (1, 0, "Size of Segment Descriptor");
return add_ranges_num (block ? BLOCK_NUMBER (block) : 0);
}
-/* Add a new entry to .debug_ranges corresponding to a pair of
- labels. */
+/* Add a new entry to .debug_ranges corresponding to a pair of labels.
+ When using dwarf_split_debug_info, address attributes in dies destined
+ for the final executable should be direct references--setting the
+ parameter force_direct ensures this behavior. */
static void
add_ranges_by_labels (dw_die_ref die, const char *begin, const char *end,
- bool *added)
+ bool *added, bool force_direct)
{
unsigned int in_use = ranges_by_label_in_use;
unsigned int offset;
offset = add_ranges_num (-(int)in_use - 1);
if (!*added)
{
- add_AT_range_list (die, DW_AT_ranges, offset);
+ add_AT_range_list (die, DW_AT_ranges, offset, force_direct);
*added = true;
}
}
information goes into the .debug_line section. */
static void
-output_line_info (void)
+output_line_info (bool prologue_only)
{
char l1[20], l2[20], p1[20], p2[20];
int ver = dwarf_version;
/* Write out the information about the files we use. */
output_file_names ();
ASM_OUTPUT_LABEL (asm_out_file, p2);
+ if (prologue_only)
+ {
+ /* Output the marker for the end of the line number info. */
+ ASM_OUTPUT_LABEL (asm_out_file, l2);
+ return;
+ }
if (separate_line_info)
{
if (!targetm.have_tls || !targetm.asm_out.output_dwarf_dtprel)
break;
- /* 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;
+ temp = new_addr_loc_descr (rtl, dtprel_true);
mem_loc_result = new_loc_descr (DW_OP_GNU_push_tls_address, 0, 0);
add_loc_descr (&mem_loc_result, temp);
break;
symref:
- mem_loc_result = new_loc_descr (DW_OP_addr, 0, 0);
- mem_loc_result->dw_loc_oprnd1.val_class = dw_val_class_addr;
- mem_loc_result->dw_loc_oprnd1.v.val_addr = rtl;
+ mem_loc_result = new_addr_loc_descr (rtl, dtprel_false);
VEC_safe_push (rtx, gc, used_rtx_array, rtl);
break;
if (mode != VOIDmode && GET_MODE_SIZE (mode) == DWARF2_ADDR_SIZE
&& (dwarf_version >= 4 || !dwarf_strict))
{
- loc_result = new_loc_descr (DW_OP_addr, 0, 0);
- loc_result->dw_loc_oprnd1.val_class = dw_val_class_addr;
- loc_result->dw_loc_oprnd1.v.val_addr = rtl;
+ loc_result = new_addr_loc_descr (rtl, dtprel_false);
add_loc_descr (&loc_result, new_loc_descr (DW_OP_stack_value, 0, 0));
VEC_safe_push (rtx, gc, used_rtx_array, rtl);
}
if (DECL_THREAD_LOCAL_P (loc))
{
rtx rtl;
- enum dwarf_location_atom first_op;
- enum dwarf_location_atom second_op;
- bool dtprel = false;
+ enum dwarf_location_atom tls_op;
+ enum dtprel_bool dtprel = dtprel_false;
if (targetm.have_tls)
{
operand shouldn't be. */
if (DECL_EXTERNAL (loc) && !targetm.binds_local_p (loc))
return 0;
- first_op = DWARF2_ADDR_SIZE == 4 ? DW_OP_const4u : DW_OP_const8u;
- dtprel = true;
- second_op = DW_OP_GNU_push_tls_address;
+ dtprel = dtprel_true;
+ tls_op = DW_OP_GNU_push_tls_address;
}
else
{
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;
+ tls_op = DW_OP_form_tls_address;
}
rtl = rtl_for_decl_location (loc);
if (! CONSTANT_P (rtl))
return 0;
- ret = new_loc_descr (first_op, 0, 0);
- ret->dw_loc_oprnd1.val_class = dw_val_class_addr;
- ret->dw_loc_oprnd1.v.val_addr = rtl;
- ret->dtprel = dtprel;
-
- ret1 = new_loc_descr (second_op, 0, 0);
+ ret = new_addr_loc_descr (rtl, dtprel);
+ ret1 = new_loc_descr (tls_op, 0, 0);
add_loc_descr (&ret, ret1);
have_address = 1;
return 0;
}
else if (CONSTANT_P (rtl) && const_ok_for_output (rtl))
- {
- ret = new_loc_descr (DW_OP_addr, 0, 0);
- ret->dw_loc_oprnd1.val_class = dw_val_class_addr;
- ret->dw_loc_oprnd1.v.val_addr = rtl;
- }
+ ret = new_addr_loc_descr (rtl, dtprel_false);
else
{
enum machine_mode mode, mem_mode;
dw_loc_descr_ref loc_result;
resolve_one_addr (&rtl, NULL);
rtl_addr:
- loc_result = new_loc_descr (DW_OP_addr, 0, 0);
- loc_result->dw_loc_oprnd1.val_class = dw_val_class_addr;
- loc_result->dw_loc_oprnd1.v.val_addr = rtl;
+ loc_result = new_addr_loc_descr (rtl, dtprel_false);
add_loc_descr (&loc_result, new_loc_descr (DW_OP_stack_value, 0, 0));
add_AT_loc (die, DW_AT_location, loc_result);
VEC_safe_push (rtx, gc, used_rtx_array, rtl);
if (TREE_CODE (decl) == FUNCTION_DECL && TREE_ASM_WRITTEN (decl))
{
add_AT_addr (die, DW_AT_VMS_rtnbeg_pd_address,
- XEXP (DECL_RTL (decl), 0));
+ XEXP (DECL_RTL (decl), 0), false);
VEC_safe_push (rtx, gc, used_rtx_array, XEXP (DECL_RTL (decl), 0));
}
#endif /* VMS_DEBUGGING_INFO */
if (tdie)
add_AT_die_ref (die, DW_AT_abstract_origin, tdie);
else
- add_AT_addr (die, DW_AT_abstract_origin, ca_loc->symbol_ref);
+ add_AT_addr (die, DW_AT_abstract_origin, ca_loc->symbol_ref, false);
}
return die;
}
if (fde->dw_fde_begin)
{
/* We have already generated the labels. */
- add_AT_low_high_pc (subr_die, fde->dw_fde_begin, fde->dw_fde_end);
+ add_AT_low_high_pc (subr_die, fde->dw_fde_begin,
+ fde->dw_fde_end, false);
}
else
{
current_function_funcdef_no);
ASM_GENERATE_INTERNAL_LABEL (label_id_high, FUNC_END_LABEL,
current_function_funcdef_no);
- add_AT_low_high_pc (subr_die, label_id_low, label_id_high);
+ add_AT_low_high_pc (subr_die, label_id_low, label_id_high,
+ false);
}
#if VMS_DEBUGGING_INFO
alignment offset. */
bool range_list_added = false;
add_ranges_by_labels (subr_die, fde->dw_fde_begin,
- fde->dw_fde_end, &range_list_added);
+ fde->dw_fde_end, &range_list_added,
+ false);
add_ranges_by_labels (subr_die, fde->dw_fde_second_begin,
fde->dw_fde_second_end,
- &range_list_added);
+ &range_list_added, false);
if (range_list_added)
add_ranges (NULL);
}
/* Do the 'primary' section. */
add_AT_low_high_pc (subr_die, fde->dw_fde_begin,
- fde->dw_fde_end);
+ fde->dw_fde_end, false);
/* Build a minimal DIE for the secondary section. */
seg_die = new_die (DW_TAG_subprogram,
name = concat ("__second_sect_of_", name, NULL);
add_AT_low_high_pc (seg_die, fde->dw_fde_second_begin,
- fde->dw_fde_second_end);
+ fde->dw_fde_second_end, false);
add_name_attribute (seg_die, name);
if (want_pubnames ())
add_pubname_string (name, seg_die);
}
}
else
- add_AT_low_high_pc (subr_die, fde->dw_fde_begin, fde->dw_fde_end);
+ add_AT_low_high_pc (subr_die, fde->dw_fde_begin, fde->dw_fde_end,
+ false);
}
cfa_fb_offset = CFA_FRAME_BASE_OFFSET (decl);
{
/* Optimize the common case. */
if (single_element_loc_list_p (loc)
- && loc->expr->dw_loc_opc == DW_OP_addr
+ && loc->expr->dw_loc_opc == DW_OP_addr
&& loc->expr->dw_loc_next == NULL
&& GET_CODE (loc->expr->dw_loc_oprnd1.v.val_addr) == SYMBOL_REF)
{
gcc_assert (!INSN_DELETED_P (insn));
ASM_GENERATE_INTERNAL_LABEL (label, "L", CODE_LABEL_NUMBER (insn));
- add_AT_lbl_id (lbl_die, DW_AT_low_pc, label);
+ add_AT_lbl_id (lbl_die, DW_AT_low_pc, label);
}
else if (insn
&& NOTE_P (insn)
&& CODE_LABEL_NUMBER (insn) != -1)
{
ASM_GENERATE_INTERNAL_LABEL (label, "LDL", CODE_LABEL_NUMBER (insn));
- add_AT_lbl_id (lbl_die, DW_AT_low_pc, label);
+ add_AT_lbl_id (lbl_die, DW_AT_low_pc, label);
}
}
}
{
ASM_GENERATE_INTERNAL_LABEL (label, BLOCK_BEGIN_LABEL,
BLOCK_NUMBER (stmt));
- add_AT_lbl_id (die, DW_AT_entry_pc, label);
+ add_AT_lbl_id (die, DW_AT_entry_pc, label);
}
/* Optimize duplicate .debug_ranges lists or even tails of
++thiscnt;
gcc_assert (supercnt >= thiscnt);
add_AT_range_list (die, DW_AT_ranges,
- (off + supercnt - thiscnt)
- * 2 * DWARF2_ADDR_SIZE);
+ ((off + supercnt - thiscnt)
+ * 2 * DWARF2_ADDR_SIZE),
+ false);
return;
}
- add_AT_range_list (die, DW_AT_ranges, add_ranges (stmt));
+ add_AT_range_list (die, DW_AT_ranges, add_ranges (stmt), false);
chain = BLOCK_FRAGMENT_CHAIN (stmt);
do
BLOCK_NUMBER (stmt));
ASM_GENERATE_INTERNAL_LABEL (label_high, BLOCK_END_LABEL,
BLOCK_NUMBER (stmt));
- add_AT_low_high_pc (die, label, label_high);
+ add_AT_low_high_pc (die, label, label_high, false);
}
}
case DW_MACRO_GNU_define_indirect:
case DW_MACRO_GNU_undef_indirect:
node = find_AT_string (ref->info);
- if (node->form != DW_FORM_strp)
- {
- char label[32];
- ASM_GENERATE_INTERNAL_LABEL (label, "LASF", dw2_string_counter);
- ++dw2_string_counter;
- node->label = xstrdup (label);
- node->form = DW_FORM_strp;
- }
+ gcc_assert (node
+ && ((node->form == DW_FORM_strp)
+ || (node->form == DW_FORM_GNU_str_index)));
dw2_asm_output_data (1, ref->code,
ref->code == DW_MACRO_GNU_define_indirect
? "Define macro indirect"
: "Undefine macro indirect");
dw2_asm_output_data_uleb128 (ref->lineno, "At line number %lu",
(unsigned long) ref->lineno);
- dw2_asm_output_offset (DWARF_OFFSET_SIZE, node->label,
- debug_str_section, "The macro: \"%s\"",
- ref->info);
+ if (node->form == DW_FORM_strp)
+ dw2_asm_output_offset (DWARF_OFFSET_SIZE, node->label,
+ debug_str_section, "The macro: \"%s\"",
+ ref->info);
+ else
+ dw2_asm_output_data_uleb128 (node->index, "The macro: \"%s\"",
+ ref->info);
break;
case DW_MACRO_GNU_transparent_include:
dw2_asm_output_data (1, ref->code, "Transparent include");
return count;
}
+/* Save any strings needed by the macinfo table in the debug str
+ table. All strings must be collected into the table by the time
+ index_string is called. */
+
+static void
+save_macinfo_strings (void)
+{
+ unsigned len;
+ unsigned i;
+ macinfo_entry *ref;
+
+ for (i = 0; VEC_iterate (macinfo_entry, macinfo_table, i, ref); i++)
+ {
+ switch (ref->code)
+ {
+ /* Match the logic in output_macinfo_op to decide on
+ indirect strings. */
+ case DW_MACINFO_define:
+ case DW_MACINFO_undef:
+ len = strlen (ref->info) + 1;
+ if (!dwarf_strict
+ && len > DWARF_OFFSET_SIZE
+ && !DWARF2_INDIRECT_STRING_SUPPORT_MISSING_ON_TARGET
+ && (debug_str_section->common.flags & SECTION_MERGE) != 0)
+ set_indirect_string (find_AT_string (ref->info));
+ break;
+ case DW_MACRO_GNU_define_indirect:
+ case DW_MACRO_GNU_undef_indirect:
+ set_indirect_string (find_AT_string (ref->info));
+ break;
+ default:
+ break;
+ }
+ }
+}
+
/* Output macinfo section(s). */
static void
dw2_asm_output_data (1, 3, "Flags: 64-bit, lineptr present");
else
dw2_asm_output_data (1, 2, "Flags: 32-bit, lineptr present");
- dw2_asm_output_offset (DWARF_OFFSET_SIZE, debug_line_section_label,
- debug_line_section, NULL);
+ dw2_asm_output_offset (DWARF_OFFSET_SIZE,
+ (!dwarf_split_debug_info ? debug_line_section_label
+ : debug_skeleton_line_section_label),
+ debug_line_section, NULL);
}
/* In the first loop, it emits the primary .debug_macinfo section
used_rtx_array = VEC_alloc (rtx, gc, 32);
- debug_info_section = get_section (DEBUG_INFO_SECTION,
- SECTION_DEBUG, NULL);
- debug_abbrev_section = get_section (DEBUG_ABBREV_SECTION,
- SECTION_DEBUG, NULL);
+ if (!dwarf_split_debug_info)
+ {
+ debug_info_section = get_section (DEBUG_INFO_SECTION,
+ SECTION_DEBUG, NULL);
+ debug_abbrev_section = get_section (DEBUG_ABBREV_SECTION,
+ SECTION_DEBUG, NULL);
+ debug_loc_section = get_section (DEBUG_LOC_SECTION,
+ SECTION_DEBUG, NULL);
+ }
+ else
+ {
+ debug_info_section = get_section (DEBUG_DWO_INFO_SECTION,
+ SECTION_DEBUG | SECTION_EXCLUDE, NULL);
+ debug_abbrev_section = get_section (DEBUG_DWO_ABBREV_SECTION,
+ SECTION_DEBUG | SECTION_EXCLUDE,
+ NULL);
+ debug_addr_section = get_section (DEBUG_ADDR_SECTION,
+ SECTION_DEBUG, NULL);
+ debug_skeleton_info_section = get_section (DEBUG_INFO_SECTION,
+ SECTION_DEBUG, NULL);
+ debug_skeleton_abbrev_section = get_section (DEBUG_ABBREV_SECTION,
+ SECTION_DEBUG, NULL);
+ ASM_GENERATE_INTERNAL_LABEL (debug_skeleton_abbrev_section_label,
+ DEBUG_SKELETON_ABBREV_SECTION_LABEL, 0);
+
+ /* Somewhat confusing detail: The skeleton_[abbrev|info] sections stay in
+ the main .o, but the skeleton_line goes into the split off dwo. */
+ debug_skeleton_line_section
+ = get_section (DEBUG_DWO_LINE_SECTION,
+ SECTION_DEBUG | SECTION_EXCLUDE, NULL);
+ ASM_GENERATE_INTERNAL_LABEL (debug_skeleton_line_section_label,
+ DEBUG_SKELETON_LINE_SECTION_LABEL, 0);
+ debug_str_offsets_section = get_section (DEBUG_STR_OFFSETS_SECTION,
+ SECTION_DEBUG | SECTION_EXCLUDE,
+ NULL);
+ ASM_GENERATE_INTERNAL_LABEL (debug_skeleton_info_section_label,
+ DEBUG_SKELETON_INFO_SECTION_LABEL, 0);
+ debug_loc_section = get_section (DEBUG_DWO_LOC_SECTION,
+ SECTION_DEBUG | SECTION_EXCLUDE, NULL);
+ }
debug_aranges_section = get_section (DEBUG_ARANGES_SECTION,
SECTION_DEBUG, NULL);
debug_macinfo_section = get_section (dwarf_strict
? DEBUG_MACINFO_SECTION
: DEBUG_MACRO_SECTION,
- SECTION_DEBUG, NULL);
+ DEBUG_MACRO_SECTION_FLAGS, NULL);
debug_line_section = get_section (DEBUG_LINE_SECTION,
SECTION_DEBUG, NULL);
- debug_loc_section = get_section (DEBUG_LOC_SECTION,
- SECTION_DEBUG, NULL);
debug_pubnames_section = get_section (DEBUG_PUBNAMES_SECTION,
SECTION_DEBUG, NULL);
debug_pubtypes_section = get_section (DEBUG_PUBTYPES_SECTION,
DEBUG_LINE_SECTION_LABEL, 0);
ASM_GENERATE_INTERNAL_LABEL (ranges_section_label,
DEBUG_RANGES_SECTION_LABEL, 0);
+ ASM_GENERATE_INTERNAL_LABEL (debug_addr_section_label,
+ DEBUG_ADDR_SECTION_LABEL, 0);
ASM_GENERATE_INTERNAL_LABEL (macinfo_section_label,
dwarf_strict
? DEBUG_MACINFO_SECTION_LABEL
: DEBUG_MACRO_SECTION_LABEL, 0);
+ ASM_GENERATE_INTERNAL_LABEL (loc_section_label, DEBUG_LOC_SECTION_LABEL, 0);
if (debug_info_level >= DINFO_LEVEL_VERBOSE)
macinfo_table = VEC_alloc (macinfo_entry, gc, 64);
fprintf (asm_out_file, "\t.cfi_sections\t.debug_frame\n");
}
+/* A helper function for dwarf2out_finish called through
+ htab_traverse. Assign a string its index. All strings must be
+ collected into the table by the time index_string is called,
+ because the indexing code relies on htab_traverse to traverse nodes
+ in the same order for each run. */
+
+static int
+index_string (void **h, void *v)
+{
+ struct indirect_string_node *node = (struct indirect_string_node *) *h;
+ unsigned int *index = (unsigned int *) v;
+
+ find_string_form (node);
+ if (node->form == DW_FORM_GNU_str_index && node->refcount > 0)
+ {
+ gcc_assert(node->index == NO_INDEX_ASSIGNED);
+ node->index = *index;
+ *index += 1;
+ }
+ return 1;
+}
+
+/* A helper function for output_indirect_strings called through
+ htab_traverse. Output the offset to a string and update the
+ current offset. */
+
+static int
+output_index_string_offset (void **h, void *v)
+{
+ struct indirect_string_node *node = (struct indirect_string_node *) *h;
+ unsigned int *offset = (unsigned int *) v;
+
+ if (node->form == DW_FORM_GNU_str_index && node->refcount > 0)
+ {
+ /* Assert that this node has been assigned an index. */
+ gcc_assert (node->index != NO_INDEX_ASSIGNED
+ && node->index != NOT_INDEXED);
+ dw2_asm_output_data (DWARF_OFFSET_SIZE, *offset,
+ "indexed string 0x%x: %s", node->index, node->str);
+ *offset += strlen (node->str) + 1;
+ }
+ return 1;
+}
+
+/* A helper function for dwarf2out_finish called through
+ htab_traverse. Output the indexed string. */
+
+static int
+output_index_string (void **h, void *v)
+{
+ struct indirect_string_node *node = (struct indirect_string_node *) *h;
+ unsigned int *cur_idx = (unsigned int *) v;
+
+ if (node->form == DW_FORM_GNU_str_index && node->refcount > 0)
+ {
+ /* Assert that the strings are output in the same order as their
+ indexes were assigned. */
+ gcc_assert (*cur_idx == node->index);
+ ASM_OUTPUT_LABEL (asm_out_file, node->label);
+ assemble_string (node->str, strlen (node->str) + 1);
+ *cur_idx += 1;
+ }
+ return 1;
+}
+
/* A helper function for dwarf2out_finish called through
htab_traverse. Emit one queued .debug_str string. */
{
struct indirect_string_node *node = (struct indirect_string_node *) *h;
- if (node->form == DW_FORM_strp)
+ if (node->form == DW_FORM_strp && node->refcount > 0)
{
- switch_to_section (debug_str_section);
ASM_OUTPUT_LABEL (asm_out_file, node->label);
assemble_string (node->str, strlen (node->str) + 1);
}
return 1;
}
+/* Output the indexed string table. */
+
+static void
+output_indirect_strings (void)
+{
+ if (!dwarf_split_debug_info)
+ {
+ switch_to_section (debug_str_section);
+ htab_traverse (debug_str_hash, output_indirect_string, NULL);
+ }
+ else
+ {
+ unsigned int offset = 0;
+ unsigned int cur_idx = 0;
+
+ switch_to_section (debug_str_offsets_section);
+ htab_traverse_noresize (debug_str_hash,
+ output_index_string_offset,
+ &offset);
+ switch_to_section (debug_str_section);
+ htab_traverse_noresize (debug_str_hash,
+ output_index_string,
+ &cur_idx);
+ }
+}
+
+/* Callback for htab_traverse to assign an index to an entry in the
+ table, and to write that entry to the .debug_addr section. */
+
+static int
+output_addr_table_entry (void **slot, void *data)
+{
+ addr_table_entry *entry = (addr_table_entry *) *slot;
+ unsigned int *cur_index = (unsigned int *)data;
+
+ if (entry->refcount == 0)
+ {
+ gcc_assert (entry->index == NO_INDEX_ASSIGNED
+ || entry->index == NOT_INDEXED);
+ return 1;
+ }
+
+ gcc_assert (entry->index == *cur_index);
+ (*cur_index)++;
+
+ switch (entry->kind)
+ {
+ case ate_kind_rtx:
+ dw2_asm_output_addr_rtx (DWARF2_ADDR_SIZE, entry->addr.rtl,
+ "0x%x", entry->index);
+ break;
+ case ate_kind_rtx_dtprel:
+ gcc_assert (targetm.asm_out.output_dwarf_dtprel);
+ targetm.asm_out.output_dwarf_dtprel (asm_out_file,
+ DWARF2_ADDR_SIZE,
+ entry->addr.rtl);
+ fputc ('\n', asm_out_file);
+ break;
+ case ate_kind_label:
+ dw2_asm_output_addr (DWARF2_ADDR_SIZE, entry->addr.label,
+ "0x%x", entry->index);
+ break;
+ default:
+ gcc_unreachable ();
+ }
+ return 1;
+}
+
+/* Produce the .debug_addr section. */
+
+static void
+output_addr_table (void)
+{
+ unsigned int index = 0;
+ if (addr_index_table == NULL || htab_size (addr_index_table) == 0)
+ return;
+
+ switch_to_section (debug_addr_section);
+ htab_traverse_noresize (addr_index_table, output_addr_table_entry, &index);
+}
+
#if ENABLE_ASSERT_CHECKING
/* Verify that all marks are clear. */
if (resolve_one_addr (&loc->dw_loc_oprnd1.v.val_addr, NULL))
return false;
break;
+ case DW_OP_GNU_addr_index:
+ case DW_OP_GNU_const_index:
+ {
+ if ((loc->dw_loc_opc == DW_OP_GNU_addr_index
+ || (loc->dw_loc_opc == DW_OP_GNU_const_index && loc->dtprel))
+ && resolve_one_addr (&loc->dw_loc_oprnd1.val_entry->addr.rtl,
+ NULL))
+ return false;
+ }
+ break;
case DW_OP_const4u:
case DW_OP_const8u:
if (loc->dtprel
if (!resolve_addr_in_expr ((*curr)->expr))
{
dw_loc_list_ref next = (*curr)->dw_loc_next;
+ dw_loc_descr_ref l = (*curr)->expr;
+
if (next && (*curr)->ll_symbol)
{
gcc_assert (!next->ll_symbol);
next->ll_symbol = (*curr)->ll_symbol;
}
+ if (dwarf_split_debug_info)
+ remove_loc_list_addr_table_entries (l);
*curr = next;
}
else
else
{
loc->replaced = 1;
+ if (dwarf_split_debug_info)
+ remove_loc_list_addr_table_entries (loc->expr);
loc->dw_loc_next = *start;
}
}
|| l->dw_loc_next != NULL)
&& !resolve_addr_in_expr (l))
{
+ if (dwarf_split_debug_info)
+ remove_loc_list_addr_table_entries (l);
remove_AT (die, a->dw_attr);
ix--;
}
if (a->dw_attr == DW_AT_const_value
&& resolve_one_addr (&a->dw_attr_val.v.val_addr, NULL))
{
+ if (AT_index (a) != NOT_INDEXED)
+ remove_addr_table_entry (a->dw_attr_val.val_entry);
remove_AT (die, a->dw_attr);
ix--;
}
}
else
{
+ if (AT_index (a) != NOT_INDEXED)
+ remove_addr_table_entry (a->dw_attr_val.val_entry);
remove_AT (die, a->dw_attr);
ix--;
}
}
hash = iterative_hash_rtx (val1->v.val_addr, hash);
break;
+ case DW_OP_GNU_addr_index:
+ case DW_OP_GNU_const_index:
+ {
+ if (loc->dtprel)
+ {
+ unsigned char dtprel = 0xd1;
+ hash = iterative_hash_object (dtprel, hash);
+ }
+ hash = iterative_hash_rtx (val1->val_entry->addr.rtl, hash);
+ }
+ break;
case DW_OP_GNU_implicit_pointer:
hash = iterative_hash_object (val2->v.val_int, hash);
break;
return valx1->v.val_int == valy1->v.val_int;
case DW_OP_skip:
case DW_OP_bra:
+ /* If splitting debug info, the use of DW_OP_GNU_addr_index
+ can cause irrelevant differences in dw_loc_addr. */
gcc_assert (valx1->val_class == dw_val_class_loc
&& valy1->val_class == dw_val_class_loc
- && x->dw_loc_addr == y->dw_loc_addr);
+ && (dwarf_split_debug_info
+ || 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
case DW_OP_addr:
hash_addr:
return rtx_equal_p (valx1->v.val_addr, valy1->v.val_addr);
+ case DW_OP_GNU_addr_index:
+ case DW_OP_GNU_const_index:
+ {
+ rtx ax1 = valx1->val_entry->addr.rtl;
+ rtx ay1 = valy1->val_entry->addr.rtl;
+ return rtx_equal_p (ax1, ay1);
+ }
case DW_OP_GNU_implicit_pointer:
return valx1->val_class == dw_val_class_die_ref
&& valx1->val_class == valy1->val_class
if (*slot == NULL)
*slot = (void *) list;
else
- a->dw_attr_val.v.val_loc_list = (dw_loc_list_ref) *slot;
+ a->dw_attr_val.v.val_loc_list = (dw_loc_list_ref) *slot;
}
FOR_EACH_CHILD (die, c, optimize_location_lists_1 (c, htab));
}
+
+/* Recursively assign each location list a unique index into the debug_addr
+ section. */
+
+static void
+index_location_lists (dw_die_ref die)
+{
+ dw_die_ref c;
+ dw_attr_ref a;
+ unsigned ix;
+
+ 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);
+ dw_loc_list_ref curr;
+ for (curr = list; curr != NULL; curr = curr->dw_loc_next)
+ {
+ /* Don't index an entry that has already been indexed
+ or won't be output. */
+ if (curr->begin_entry != NULL
+ || (strcmp (curr->begin, curr->end) == 0 && !curr->force))
+ continue;
+
+ curr->begin_entry
+ = add_addr_table_entry (xstrdup (curr->begin),
+ ate_kind_label);
+ }
+ }
+
+ FOR_EACH_CHILD (die, c, index_location_lists (c));
+}
+
/* Optimize location lists referenced from DIE
children and share them whenever possible. */
comdat_type_node *ctnode;
htab_t comdat_type_table;
unsigned int i;
+ dw_die_ref main_comp_unit_die;
/* PCH might result in DW_AT_producer string being restored from the
header compilation, fix it up if needed. */
for (ctnode = comdat_type_list; ctnode != NULL; ctnode = ctnode->next)
add_sibling_attributes (ctnode->root_die);
+ /* When splitting DWARF info, we put some attributes in the
+ skeleton compile_unit DIE that remains in the .o, while
+ most attributes go in the DWO compile_unit_die. */
+ if (dwarf_split_debug_info)
+ main_comp_unit_die = gen_compile_unit_die (NULL);
+ else
+ main_comp_unit_die = comp_unit_die ();
+
/* 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);
{
/* Don't add if the CU has no associated code. */
if (text_section_used)
- add_AT_low_high_pc (comp_unit_die (), text_section_label,
- text_end_label);
+ add_AT_low_high_pc (main_comp_unit_die, text_section_label,
+ text_end_label, true);
}
else
{
bool range_list_added = false;
if (text_section_used)
- add_ranges_by_labels (comp_unit_die (), text_section_label,
- text_end_label, &range_list_added);
+ add_ranges_by_labels (main_comp_unit_die, text_section_label,
+ text_end_label, &range_list_added, true);
if (cold_text_section_used)
- add_ranges_by_labels (comp_unit_die (), cold_text_section_label,
- cold_end_label, &range_list_added);
+ add_ranges_by_labels (main_comp_unit_die, cold_text_section_label,
+ cold_end_label, &range_list_added, true);
FOR_EACH_VEC_ELT (dw_fde_ref, fde_vec, fde_idx, fde)
{
if (DECL_IGNORED_P (fde->decl))
continue;
if (!fde->in_std_section)
- add_ranges_by_labels (comp_unit_die (), fde->dw_fde_begin,
- fde->dw_fde_end, &range_list_added);
+ add_ranges_by_labels (main_comp_unit_die, fde->dw_fde_begin,
+ fde->dw_fde_end, &range_list_added,
+ true);
if (fde->dw_fde_second_begin && !fde->second_in_std_section)
- add_ranges_by_labels (comp_unit_die (), fde->dw_fde_second_begin,
- fde->dw_fde_second_end, &range_list_added);
+ add_ranges_by_labels (main_comp_unit_die, fde->dw_fde_second_begin,
+ fde->dw_fde_second_end, &range_list_added,
+ true);
}
if (range_list_added)
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 (main_comp_unit_die, DW_AT_low_pc, const0_rtx, true);
if (! dwarf_strict && dwarf_version < 4)
- add_AT_addr (comp_unit_die (), DW_AT_entry_pc, const0_rtx);
+ add_AT_addr (main_comp_unit_die, DW_AT_entry_pc, const0_rtx, true);
add_ranges (NULL);
}
}
if (debug_info_level >= DINFO_LEVEL_NORMAL)
- add_AT_lineptr (comp_unit_die (), DW_AT_stmt_list,
+ add_AT_lineptr (main_comp_unit_die, DW_AT_stmt_list,
debug_line_section_label);
if (have_macinfo)
dwarf_strict ? DW_AT_macro_info : DW_AT_GNU_macros,
macinfo_section_label);
+ if (dwarf_split_debug_info && addr_index_table != NULL)
+ {
+ /* optimize_location_lists calculates the size of the lists,
+ so index them first, and assign indices to the entries.
+ Although optimize_location_lists will remove entries from
+ the table, it only does so for duplicates, and therefore
+ only reduces ref_counts to 1. */
+ unsigned int index = 0;
+ index_location_lists (comp_unit_die ());
+ htab_traverse_noresize (addr_index_table,
+ index_addr_table_entry, &index);
+ }
if (have_location_lists)
optimize_location_lists (comp_unit_die ());
+ save_macinfo_strings ();
+ if (dwarf_split_debug_info)
+ {
+ unsigned int index = 0;
+ htab_traverse_noresize (debug_str_hash, index_string, &index);
+ }
+
/* Output all of the compilation units. We put the main one last so that
the offsets are available to output_pubnames. */
for (node = limbo_die_list; node; node = node->next)
attributes. */
if (debug_info_level >= DINFO_LEVEL_NORMAL)
add_AT_lineptr (ctnode->root_die, DW_AT_stmt_list,
- debug_line_section_label);
+ (!dwarf_split_debug_info
+ ? debug_line_section_label
+ : debug_skeleton_line_section_label));
output_comdat_type_unit (ctnode);
*slot = ctnode;
}
htab_delete (comdat_type_table);
- add_AT_pubnames (comp_unit_die ());
+ /* The AT_pubnames attribute needs to go in all skeleton dies, including
+ both the main_cu and all skeleton TUs. Making this call unconditional
+ would end up either adding a second copy of the AT_pubnames attribute, or
+ requiring a special case in add_top_level_skeleton_die_attrs. */
+ if (!dwarf_split_debug_info)
+ add_AT_pubnames (comp_unit_die ());
+
+ if (dwarf_split_debug_info)
+ {
+ int mark;
+ unsigned char checksum[16];
+ struct md5_ctx ctx;
+
+ /* Compute a checksum of the comp_unit to use as the dwo_id. */
+ md5_init_ctx (&ctx);
+ mark = 0;
+ die_checksum (comp_unit_die (), &ctx, &mark);
+ unmark_all_dies (comp_unit_die ());
+ md5_finish_ctx (&ctx, checksum);
+
+ /* Use the first 8 bytes of the checksum as the dwo_id,
+ and add it to both comp-unit DIEs. */
+ add_AT_data8 (main_comp_unit_die, DW_AT_GNU_dwo_id, checksum);
+ add_AT_data8 (comp_unit_die (), DW_AT_GNU_dwo_id, checksum);
+
+ /* Add the base offset of the ranges table to the skeleton
+ comp-unit DIE. */
+ if (ranges_table_in_use)
+ add_AT_lineptr (main_comp_unit_die, DW_AT_GNU_ranges_base,
+ ranges_section_label);
+
+ switch_to_section (debug_addr_section);
+ ASM_OUTPUT_LABEL (asm_out_file, debug_addr_section_label);
+ output_addr_table ();
+ }
/* Output the main compilation unit if non-empty or if .debug_macinfo
or .debug_macro will be emitted. */
output_comp_unit (comp_unit_die (), have_macinfo);
+ if (dwarf_split_debug_info && info_section_emitted)
+ output_skeleton_debug_sections (main_comp_unit_die);
+
/* Output the abbreviation table. */
if (abbrev_die_table_in_use != 1)
{
{
/* 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 ());
}
switch_to_section (debug_line_section);
ASM_OUTPUT_LABEL (asm_out_file, debug_line_section_label);
if (! DWARF2_ASM_LINE_DEBUG_INFO)
- output_line_info ();
+ output_line_info (false);
+
+ if (dwarf_split_debug_info && info_section_emitted)
+ {
+ switch_to_section (debug_skeleton_line_section);
+ ASM_OUTPUT_LABEL (asm_out_file, debug_skeleton_line_section_label);
+ output_line_info (true);
+ }
- /* If we emitted any DW_FORM_strp form attribute, output the string
- table too. */
+ /* If we emitted any indirect strings, output the string table too. */
if (debug_str_hash)
- htab_traverse (debug_str_hash, output_indirect_string, NULL);
+ output_indirect_strings ();
}
#include "gt-dwarf2out.h"