From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 51629 invoked by alias); 25 Dec 2016 16:57:38 -0000 Mailing-List: contact archer-commits-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: Received: (qmail 51611 invoked by uid 9674); 25 Dec 2016 16:57:37 -0000 Date: Sun, 25 Dec 2016 16:57:00 -0000 Message-ID: <20161225165737.51580.qmail@sourceware.org> From: jkratoch@sourceware.org To: archer-commits@sourceware.org Subject: [SCM] users/jkratoch/dwarf5gcc-indexcxx-debugnames: Merge branch 'dwarf5gcc-indexcxx' into dwarf5gcc-indexcxx-debugnames X-Git-Refname: refs/heads/users/jkratoch/dwarf5gcc-indexcxx-debugnames X-Git-Reftype: branch X-Git-Oldrev: 008befe725efec8e18eedc4200cfbe765affbc0e X-Git-Newrev: 844ada9b6a5230911df26ebb692839b15c462823 X-SW-Source: 2016-q4/txt/msg00050.txt.bz2 List-Id: The branch, users/jkratoch/dwarf5gcc-indexcxx-debugnames has been updated via 844ada9b6a5230911df26ebb692839b15c462823 (commit) via 8f9fb12f5b33de7c6219500254ed37b901ab01e6 (commit) via fe67053b845cfe05d3063707c6896262e2084926 (commit) via 5ac952da2deb837686c10a52c179501294594b30 (commit) from 008befe725efec8e18eedc4200cfbe765affbc0e (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit 844ada9b6a5230911df26ebb692839b15c462823 Merge: fe67053 8f9fb12 Author: Jan Kratochvil Date: Sun Dec 25 17:55:53 2016 +0100 Merge branch 'dwarf5gcc-indexcxx' into dwarf5gcc-indexcxx-debugnames commit fe67053b845cfe05d3063707c6896262e2084926 Author: Jan Kratochvil Date: Sun Dec 25 17:47:06 2016 +0100 . commit 5ac952da2deb837686c10a52c179501294594b30 Author: Jan Kratochvil Date: Sun Dec 25 17:20:13 2016 +0100 . ----------------------------------------------------------------------- Summary of changes: gdb/contrib/gdb-add-index.sh | 16 ++++++++-- gdb/dwarf2read.c | 63 ++++++++++++++++++++++++++++-------------- include/dwarf2.h | 5 ++- 3 files changed, 59 insertions(+), 25 deletions(-) First 500 lines of diff: diff --git a/gdb/contrib/gdb-add-index.sh b/gdb/contrib/gdb-add-index.sh index cca7153..725aa65 100755 --- a/gdb/contrib/gdb-add-index.sh +++ b/gdb/contrib/gdb-add-index.sh @@ -38,10 +38,12 @@ fi dir="${file%/*}" test "$dir" = "$file" && dir="." index="${file}.gdb-index" +debugstr="${file}.debug_str" +debugstrmerge="${file}.debug_str.merge" -rm -f $index +rm -f $index $debugstr $debugstrmerge # Ensure intermediate index file is removed when we exit. -trap "rm -f $index" 0 +trap "rm -f $index $debugstr $debugstrmerge" 0 $GDB --batch -nx -iex 'set auto-load no' \ -ex "file $file" -ex "save gdb-index $dir" || { @@ -58,8 +60,16 @@ $GDB --batch -nx -iex 'set auto-load no' \ status=0 if test -f "$index"; then + # Older GDBs did not create: ${file}.debug_str + test ! -f "$debugstr" && touch "$debugstr" + $OBJCOPY --dump-section .debug_str="$debugstrmerge" "$file" /dev/null + cat "$debugstr" >>"$debugstrmerge" + $OBJCOPY --add-section .gdb_index="$index" \ - --set-section-flags .gdb_index=readonly "$file" "$file" + --set-section-flags .gdb_index=readonly \ + --update-section .debug_str="$debugstrmerge" \ + "$file" "$file" + status=$? else echo "$myname: No index was created for $file" 1>&2 diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 1608339..f3cf417 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -23193,6 +23193,15 @@ public: } }; +namespace std { + template struct hash> { + size_t operator() (const pair &key) const { + return std::hash() (key.first) + ^std::hash() (key.second); + } + }; +} + class DebugNamesNameTable { private: @@ -23201,8 +23210,9 @@ private: public: const char *name; int tag, cu_index; - Name(const char *name_, int tag_, int cu_index_) - :name(name_),tag(tag_),cu_index(cu_index_) + bool is_static; + Name(const char *name_, int tag_, int cu_index_, bool is_static_) + :name(name_), tag(tag_), cu_index(cu_index_), is_static (is_static_) {} }; std::unordered_multimap hash_to_name; @@ -23264,7 +23274,8 @@ private: DwarfTmpl dwarf32; DwarfTmpl dwarf64; OffsetVec &name_table_string_offs, &name_table_entry_offs; - std::unordered_set tags_used; + std::unordered_map, int> tag_isstatic_to_idx; + int idx_next = 1; DataBuf abbrev_table, entry_pool; DebugStrLookup debugstrlookup; static uint32_t @@ -23320,7 +23331,7 @@ public: { } void - insert (const partial_symbol *psym, int cu_index) + insert (const partial_symbol *psym, int cu_index, bool is_static) { const int tag (psymbol_tag (psym)); if (!tag) @@ -23328,7 +23339,8 @@ public: const char *name (SYMBOL_SEARCH_NAME (psym)); const uint32_t hash (djb_hash (reinterpret_cast (name))); - hash_to_name.emplace (hash, Name (name, psymbol_tag (psym), cu_index)); + hash_to_name.emplace (hash, Name (name, psymbol_tag (psym), cu_index, + is_static)); } void build () @@ -23350,24 +23362,29 @@ public: hash_table.push_back (hash); name_table_string_offs.push_back (debugstrlookup.lookup (name.name)); name_table_entry_offs.push_back (entry_pool.size ()); + int &idx(tag_isstatic_to_idx[std::make_pair (name.tag, name.is_static)]); + if (!idx) { + idx = idx_next++; + // DW_TAG_* numerical value is used also as the value of the index tag. + abbrev_table.add_unsigned_leb128 (idx); + abbrev_table.add_unsigned_leb128 (name.tag); + abbrev_table.add_unsigned_leb128 (DW_IDX_compile_unit); + abbrev_table.add_unsigned_leb128 (DW_FORM_udata); + abbrev_table.add_unsigned_leb128 (name.is_static + ? DW_IDX_GNU_static + : DW_IDX_GNU_external); + abbrev_table.add_unsigned_leb128 (DW_FORM_flag_present); + // Terminate attributes list. + abbrev_table.add_unsigned_leb128 (0); + abbrev_table.add_unsigned_leb128 (0); + } // DW_TAG_* numerical value is used also as the value of the index tag. - entry_pool.add_unsigned_leb128 (name.tag); + entry_pool.add_unsigned_leb128 (idx); entry_pool.add_unsigned_leb128 (name.cu_index); + // Terminate the list of CUs. entry_pool.add_unsigned_leb128 (0); - tags_used.insert (name.tag); } gdb_assert (hash_table.size () == hash_to_name.size ()); - for (const auto tag:tags_used) - { - // DW_TAG_* numerical value is used also as the value of the index tag. - abbrev_table.add_unsigned_leb128 (tag); - abbrev_table.add_unsigned_leb128 (tag); - abbrev_table.add_unsigned_leb128 (DW_IDX_compile_unit); - abbrev_table.add_unsigned_leb128 (DW_FORM_udata); - // Terminate attributes list. - abbrev_table.add_unsigned_leb128 (0); - abbrev_table.add_unsigned_leb128 (0); - } // Terminate tags list. abbrev_table.add_unsigned_leb128 (0); } @@ -23410,7 +23427,7 @@ private: /* Only add a given psymbol once. */ if (psyms_seen.insert (psym).second) - insert (psym, cu_index); + insert (psym, cu_index, is_static); } } public: @@ -23638,8 +23655,9 @@ write_debug_names (struct objfile *objfile, FILE *out_file, FILE *out_file_str) per_cu.offset.sect_off); } + const gdb_byte augmentation[] = { 'G', 'D', 'B', 0 }; const offset_type bytes_of_header ((dwarf5_is_dwarf64 ? 12 : 4) - + 2 + 2 + 7 * 4); + + 2 + 2 + 7 * 4 + sizeof (augmentation)); size_t expected_bytes (0); expected_bytes += bytes_of_header; expected_bytes += cu_list.size (); @@ -23697,7 +23715,10 @@ write_debug_names (struct objfile *objfile, FILE *out_file, FILE *out_file_str) /* augmentation_string_size - The size in bytes of the augmentation string. This value is rounded up to a multiple of 4. */ - store_unsigned_integer (header.add_size (4), 4, dwarf5_byte_order, 0); + static_assert (sizeof (augmentation) % 4 == 0); + store_unsigned_integer (header.add_size (4), 4, dwarf5_byte_order, + sizeof (augmentation)); + header.add_data (augmentation); gdb_assert (header.size () == bytes_of_header); diff --git a/include/dwarf2.h b/include/dwarf2.h index ca8ff3b..8490fa0 100644 --- a/include/dwarf2.h +++ b/include/dwarf2.h @@ -429,7 +429,10 @@ enum dwarf_name_index_attribute DW_IDX_parent = 4, DW_IDX_type_hash = 5, DW_IDX_lo_user = 0x2000, - DW_IDX_hi_user = 0x3fff + DW_IDX_hi_user = 0x3fff, + + DW_IDX_GNU_static = 0x2000, + DW_IDX_GNU_external = 0x2001 }; /* Range list entry kinds in .debug_rnglists* section. */ hooks/post-receive -- Repository for Project Archer.