diff options
author | mrs <mrs@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-11-04 21:29:11 +0000 |
---|---|---|
committer | mrs <mrs@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-11-04 21:29:11 +0000 |
commit | aeb682a27a580c32813c316b911b59b851f6f34e (patch) | |
tree | caef14d95e41d87b155a732aa16f18f483eea729 /gcc/dwarf2out.c | |
parent | 8945e16bd0dc520c80b423cc0802c89ce551ff08 (diff) | |
parent | 8dd9f7ce09ba28909b069f5baa405ea4cc7b5c42 (diff) | |
download | gcc-aeb682a27a580c32813c316b911b59b851f6f34e.tar.gz |
Merge in trunk.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/wide-int@204366 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/dwarf2out.c')
-rw-r--r-- | gcc/dwarf2out.c | 148 |
1 files changed, 121 insertions, 27 deletions
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 54fc6f7320d..07cb28e8d3c 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -93,6 +93,7 @@ along with GCC; see the file COPYING3. If not see #include "dumpfile.h" #include "opts.h" #include "tree-dfa.h" +#include "gdb/gdb-index.h" static void dwarf2out_source_line (unsigned int, const char *, int, bool); static rtx last_var_location_insn; @@ -3369,10 +3370,14 @@ new_addr_loc_descr (rtx addr, enum dtprel_bool dtprel) #define DEBUG_DWO_LOC_SECTION ".debug_loc.dwo" #endif #ifndef DEBUG_PUBNAMES_SECTION -#define DEBUG_PUBNAMES_SECTION ".debug_pubnames" +#define DEBUG_PUBNAMES_SECTION \ + ((debug_generate_pub_sections == 2) \ + ? ".debug_gnu_pubnames" : ".debug_pubnames") #endif #ifndef DEBUG_PUBTYPES_SECTION -#define DEBUG_PUBTYPES_SECTION ".debug_pubtypes" +#define DEBUG_PUBTYPES_SECTION \ + ((debug_generate_pub_sections == 2) \ + ? ".debug_gnu_pubtypes" : ".debug_pubtypes") #endif #define DEBUG_NORM_STR_OFFSETS_SECTION ".debug_str_offsets" #define DEBUG_DWO_STR_OFFSETS_SECTION ".debug_str_offsets.dwo" @@ -4630,6 +4635,16 @@ is_cxx (void) return lang == DW_LANG_C_plus_plus || lang == DW_LANG_ObjC_plus_plus; } +/* Return TRUE if the language is Java. */ + +static inline bool +is_java (void) +{ + unsigned int lang = get_AT_unsigned (comp_unit_die (), DW_AT_language); + + return lang == DW_LANG_Java; +} + /* Return TRUE if the language is Fortran. */ static inline bool @@ -8052,6 +8067,12 @@ unmark_all_dies (dw_die_ref die) static bool include_pubname_in_output (vec<pubname_entry, va_gc> *table, pubname_entry *p) { + /* By limiting gnu pubnames to definitions only, gold can generate a + gdb index without entries for declarations, which don't include + enough information to be useful. */ + if (debug_generate_pub_sections == 2 && is_declaration_die (p->die)) + return false; + if (table == pubname_table) { /* Enumerator names are part of the pubname table, but the @@ -8081,11 +8102,12 @@ size_of_pubnames (vec<pubname_entry, va_gc> *names) unsigned long size; unsigned i; pubname_ref p; + int space_for_flags = (debug_generate_pub_sections == 2) ? 1 : 0; size = DWARF_PUBNAMES_HEADER_SIZE; FOR_EACH_VEC_ELT (*names, i, p) if (include_pubname_in_output (names, p)) - size += strlen (p->name) + DWARF_OFFSET_SIZE + 1; + size += strlen (p->name) + DWARF_OFFSET_SIZE + 1 + space_for_flags; size += DWARF_OFFSET_SIZE; return size; @@ -9278,6 +9300,76 @@ add_pubtype (tree decl, dw_die_ref die) } } +/* Output a single entry in the pubnames table. */ + +static void +output_pubname (dw_offset die_offset, pubname_entry *entry) +{ + dw_die_ref die = entry->die; + int is_static = get_AT_flag (die, DW_AT_external) ? 0 : 1; + + dw2_asm_output_data (DWARF_OFFSET_SIZE, die_offset, "DIE offset"); + + if (debug_generate_pub_sections == 2) + { + /* This logic follows gdb's method for determining the value of the flag + byte. */ + uint32_t flags = GDB_INDEX_SYMBOL_KIND_NONE; + switch (die->die_tag) + { + case DW_TAG_typedef: + case DW_TAG_base_type: + case DW_TAG_subrange_type: + GDB_INDEX_SYMBOL_KIND_SET_VALUE(flags, GDB_INDEX_SYMBOL_KIND_TYPE); + GDB_INDEX_SYMBOL_STATIC_SET_VALUE(flags, 1); + break; + case DW_TAG_enumerator: + GDB_INDEX_SYMBOL_KIND_SET_VALUE(flags, + GDB_INDEX_SYMBOL_KIND_VARIABLE); + if (!is_cxx () && !is_java ()) + GDB_INDEX_SYMBOL_STATIC_SET_VALUE(flags, 1); + break; + case DW_TAG_subprogram: + GDB_INDEX_SYMBOL_KIND_SET_VALUE(flags, + GDB_INDEX_SYMBOL_KIND_FUNCTION); + if (!is_ada ()) + GDB_INDEX_SYMBOL_STATIC_SET_VALUE(flags, is_static); + break; + case DW_TAG_constant: + GDB_INDEX_SYMBOL_KIND_SET_VALUE(flags, + GDB_INDEX_SYMBOL_KIND_VARIABLE); + GDB_INDEX_SYMBOL_STATIC_SET_VALUE(flags, is_static); + break; + case DW_TAG_variable: + GDB_INDEX_SYMBOL_KIND_SET_VALUE(flags, + GDB_INDEX_SYMBOL_KIND_VARIABLE); + GDB_INDEX_SYMBOL_STATIC_SET_VALUE(flags, is_static); + break; + case DW_TAG_namespace: + case DW_TAG_imported_declaration: + GDB_INDEX_SYMBOL_KIND_SET_VALUE(flags, GDB_INDEX_SYMBOL_KIND_TYPE); + break; + case DW_TAG_class_type: + case DW_TAG_interface_type: + case DW_TAG_structure_type: + case DW_TAG_union_type: + case DW_TAG_enumeration_type: + GDB_INDEX_SYMBOL_KIND_SET_VALUE(flags, GDB_INDEX_SYMBOL_KIND_TYPE); + if (!is_cxx () && !is_java ()) + GDB_INDEX_SYMBOL_STATIC_SET_VALUE(flags, 1); + break; + default: + /* An unusual tag. Leave the flag-byte empty. */ + break; + } + dw2_asm_output_data (1, flags >> GDB_INDEX_CU_BITSIZE, + "GDB-index flags"); + } + + dw2_asm_output_nstring (entry->name, -1, "external name"); +} + + /* Output the public names table used to speed up access to externally visible names; or the public types table used to find type definitions. */ @@ -9288,23 +9380,14 @@ output_pubnames (vec<pubname_entry, va_gc> *names) unsigned long pubnames_length = size_of_pubnames (names); pubname_ref pub; - if (!want_pubnames () || !info_section_emitted) - return; - if (names == pubname_table) - switch_to_section (debug_pubnames_section); - else - switch_to_section (debug_pubtypes_section); if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4) dw2_asm_output_data (4, 0xffffffff, "Initial length escape value indicating 64-bit DWARF extension"); - if (names == pubname_table) - dw2_asm_output_data (DWARF_OFFSET_SIZE, pubnames_length, - "Length of Public Names Info"); - else - dw2_asm_output_data (DWARF_OFFSET_SIZE, pubnames_length, - "Length of Public Type Names Info"); - /* Version number for pubnames/pubtypes is still 2, even in DWARF3. */ + dw2_asm_output_data (DWARF_OFFSET_SIZE, pubnames_length, "Pub Info Length"); + + /* Version number for pubnames/pubtypes is independent of dwarf version. */ dw2_asm_output_data (2, 2, "DWARF Version"); + if (dwarf_split_debug_info) dw2_asm_output_offset (DWARF_OFFSET_SIZE, debug_skeleton_info_section_label, debug_skeleton_info_section, @@ -9340,15 +9423,31 @@ output_pubnames (vec<pubname_entry, va_gc> *names) : 0); } - dw2_asm_output_data (DWARF_OFFSET_SIZE, die_offset, "DIE offset"); - - dw2_asm_output_nstring (pub->name, -1, "external name"); + output_pubname (die_offset, pub); } } dw2_asm_output_data (DWARF_OFFSET_SIZE, 0, NULL); } +/* Output public names and types tables if necessary. */ + +static void +output_pubtables (void) +{ + if (!want_pubnames () || !info_section_emitted) + return; + + switch_to_section (debug_pubnames_section); + output_pubnames (pubname_table); + /* ??? Only defined by DWARF3, but emitted by Darwin for DWARF2. + It shouldn't hurt to emit it always, since pure DWARF2 consumers + simply won't look for the section. */ + switch_to_section (debug_pubtypes_section); + output_pubnames (pubtype_table); +} + + /* Output the information that goes into the .debug_aranges table. Namely, define the beginning and ending address range of the text section generated for this compilation unit. */ @@ -15211,7 +15310,7 @@ reference_to_unused (tree * tp, int * walk_subtrees, else if (TREE_CODE (*tp) == VAR_DECL) { struct varpool_node *node = varpool_get_node (*tp); - if (!node || !node->symbol.definition) + if (!node || !node->definition) return *tp; } else if (TREE_CODE (*tp) == FUNCTION_DECL @@ -17884,7 +17983,7 @@ premark_types_used_by_global_vars_helper (void **slot, /* 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_get_node (entry->var_decl); - if (node && node->symbol.definition) + if (node && node->definition) { die->die_perennial_p = 1; /* Keep the parent DIEs as well. */ @@ -24264,12 +24363,7 @@ dwarf2out_finish (const char *filename) output_location_lists (comp_unit_die ()); } - /* Output public names and types tables if necessary. */ - output_pubnames (pubname_table); - /* ??? Only defined by DWARF3, but emitted by Darwin for DWARF2. - It shouldn't hurt to emit it always, since pure DWARF2 consumers - simply won't look for the section. */ - output_pubnames (pubtype_table); + output_pubtables (); /* Output the address range information if a CU (.debug_info section) was emitted. We output an empty table even if we had no functions |