From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 117678 invoked by alias); 24 Dec 2016 23:44:28 -0000 Mailing-List: contact archer-commits-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: Received: (qmail 117654 invoked by uid 9674); 24 Dec 2016 23:44:27 -0000 Date: Sat, 24 Dec 2016 23:44:00 -0000 Message-ID: <20161224234426.117624.qmail@sourceware.org> From: jkratoch@sourceware.org To: archer-commits@sourceware.org Subject: [SCM] users/jkratoch/dwarf5gcc-indexcxx-debugnames: . X-Git-Refname: refs/heads/users/jkratoch/dwarf5gcc-indexcxx-debugnames X-Git-Reftype: branch X-Git-Oldrev: b4a7a7a9e2667da102466acab515189a993074ad X-Git-Newrev: 008befe725efec8e18eedc4200cfbe765affbc0e X-SW-Source: 2016-q4/txt/msg00048.txt.bz2 List-Id: The branch, users/jkratoch/dwarf5gcc-indexcxx-debugnames has been updated via 008befe725efec8e18eedc4200cfbe765affbc0e (commit) via db14cf485d74e9888d88cca68a47c48d031ccfe6 (commit) via 98ed76513a7ab004c13386689be1d7f32d9fc868 (commit) via 5532b1e372a5738788d0898c8d73bb5c8728c9ec (commit) from b4a7a7a9e2667da102466acab515189a993074ad (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit 008befe725efec8e18eedc4200cfbe765affbc0e Author: Jan Kratochvil Date: Sun Dec 25 00:42:45 2016 +0100 . commit db14cf485d74e9888d88cca68a47c48d031ccfe6 Author: Jan Kratochvil Date: Sun Dec 25 00:34:52 2016 +0100 . commit 98ed76513a7ab004c13386689be1d7f32d9fc868 Author: Jan Kratochvil Date: Sun Dec 25 00:26:26 2016 +0100 . commit 5532b1e372a5738788d0898c8d73bb5c8728c9ec Author: Jan Kratochvil Date: Sat Dec 24 22:36:07 2016 +0100 . ----------------------------------------------------------------------- Summary of changes: gdb/dwarf2read.c | 69 ++++++++++++++++++++++++++++++++++------------------- 1 files changed, 44 insertions(+), 25 deletions(-) First 500 lines of diff: diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 6ffeb18..1608339 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -76,6 +76,7 @@ #include #include #include +#include typedef struct symbol *symbolp; DEF_VEC_P (symbolp); @@ -2058,6 +2059,7 @@ attr_value_as_address (struct attribute *attr) /* The suffix for an index file. */ #define INDEX_SUFFIX ".gdb-index" +#define DEBUG_STR_SUFFIX ".debug_str" /* Try to locate the sections we need for DWARF 2 debugging information and return true if we have enough to do something. @@ -22606,7 +22608,7 @@ file_write (FILE *file, const void *data, size_t size) template static void file_write (FILE *file, const std::vector &vec) { - file_write (file, vec.data (), vec.size()); + file_write (file, vec.data (), vec.size() * sizeof (vec[0])); } class DataBuf @@ -23151,6 +23153,7 @@ class DebugStrLookup private: std::unordered_map str_table; bfd *const abfd; + DataBuf str_add_buf; public: DebugStrLookup ():abfd (dwarf2_per_objfile->objfile->obfd) { @@ -23173,18 +23176,20 @@ public: } } size_t - lookup (const char *s) const + lookup (const char *s) { const auto it (str_table.find (CstrView (s))); - if (it == str_table.end ()) - { - // FIXME - /*error*/warning (_("Cannot find string \"%s\" in " - ".debug_str section [in module %s]"), - s, bfd_get_filename (abfd)); - return 0; - } - return it->second; + if (it != str_table.end ()) + return it->second; + const size_t offset (dwarf2_per_objfile->str.size + str_add_buf.size ()); + str_table.emplace (CstrView (s), offset); + str_add_buf.add_cstr0 (s); + return offset; + } + void + file_write (FILE *file) const + { + str_add_buf.file_write (file); } }; @@ -23216,21 +23221,25 @@ private: private: std::vector vec; public: - virtual void reserve (size_t nelem) override + virtual void + reserve (size_t nelem) override { vec.reserve (nelem); } - virtual void push_back (size_t elem) override + virtual void + push_back (size_t elem) override { vec.push_back (elem); // Check for overflow. gdb_assert (vec.back () == elem); } - virtual size_t bytes () const override + virtual size_t + bytes () const override { return vec.size () * sizeof (vec[0]); } - virtual void file_write (FILE *file) const override + virtual void + file_write (FILE *file) const override { ::file_write (file, vec); } @@ -23257,12 +23266,14 @@ private: OffsetVec &name_table_string_offs, &name_table_entry_offs; std::unordered_set tags_used; DataBuf abbrev_table, entry_pool; + DebugStrLookup debugstrlookup; static uint32_t djb_hash (const unsigned char *str) { uint32_t hash (5381); while (int c = *str++) - hash = hash * 33 + c; + // FIXME: std::bad_cast - std::tolower (c, std::locale::classic ()) + hash = hash * 33 + tolower (c); return hash; } static int @@ -23324,11 +23335,10 @@ public: { gdb_assert (bucket_table.empty ()); bucket_table.resize - (std::pow (2, std::ceil (std::log2 (hash_to_name.size ())))); + (std::pow (2, std::ceil (std::log2 (hash_to_name.size () * 4 / 3)))); hash_table.reserve (hash_to_name.size ()); name_table_string_offs.reserve (hash_to_name.size ()); name_table_entry_offs.reserve (hash_to_name.size ()); - DebugStrLookup debugstrlookup; for (const auto &it:hash_to_name) { const uint32_t hash (it.first); @@ -23346,6 +23356,7 @@ public: 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. @@ -23359,8 +23370,6 @@ public: } // Terminate tags list. abbrev_table.add_unsigned_leb128 (0); - gdb_assert (hash_table.size () == hash_to_name.size ()); - } uint32_t bucket_count () const @@ -23440,7 +23449,7 @@ public: return expected_bytes; } void - file_write (FILE *file) const + file_write (FILE *file, FILE *file_str) const { gdb_assert (!bucket_table.empty ()); ::file_write (file, bucket_table); @@ -23449,6 +23458,7 @@ public: name_table_entry_offs.file_write (file); abbrev_table.file_write (file); entry_pool.file_write (file); + debugstrlookup.file_write (file_str); } }; @@ -23474,7 +23484,7 @@ check_dwarf64_offsets () } static size_t -write_gdbindex (struct objfile *objfile, FILE *out_file) +write_gdbindex (struct objfile *objfile, FILE *out_file, FILE *out_file_str) { mapped_symtab symtab; DataBuf cu_list; @@ -23581,7 +23591,7 @@ write_gdbindex (struct objfile *objfile, FILE *out_file) } static size_t -write_debug_names (struct objfile *objfile, FILE *out_file) +write_debug_names (struct objfile *objfile, FILE *out_file, FILE *out_file_str) { const bool dwarf5_is_dwarf64 (check_dwarf64_offsets ()); const int dwarf5_offset_size (dwarf5_is_dwarf64 ? 8 : 4); @@ -23694,7 +23704,7 @@ write_debug_names (struct objfile *objfile, FILE *out_file) header.file_write (out_file); cu_list.file_write (out_file); types_cu_list.file_write (out_file); - nametable.file_write (out_file); + nametable.file_write (out_file, out_file_str); return expected_bytes; } @@ -23719,15 +23729,21 @@ write_psymtabs_to_index (struct objfile *objfile, const char *dir, bool is_dwarf std::string filename (std::string (dir) + SLASH_STRING + lbasename (objfile_name (objfile)) + INDEX_SUFFIX); + std::string filename_str (std::string (dir) + SLASH_STRING + + lbasename (objfile_name (objfile)) + + DEBUG_STR_SUFFIX); FILE *out_file (gdb_fopen_cloexec (filename.c_str (), "wb")); if (!out_file) error (_("Can't open `%s' for writing"), filename.c_str ()); + FILE *out_file_str (gdb_fopen_cloexec (filename_str.c_str (), "wb")); + if (!out_file_str) + error (_("Can't open `%s' for writing"), filename_str.c_str ()); try { const size_t total_len ((is_dwarf5 ? write_debug_names : write_gdbindex) - (objfile, out_file)); + (objfile, out_file, out_file_str)); const auto out_file_size (ftell (out_file)); if (out_file_size == -1) error (_("Can't get `%s' size"), filename.c_str ()); @@ -23737,9 +23753,12 @@ write_psymtabs_to_index (struct objfile *objfile, const char *dir, bool is_dwarf { fclose (out_file); unlink (filename.c_str ()); + fclose (out_file_str); + unlink (filename_str.c_str ()); throw; } fclose (out_file); + fclose (out_file_str); } /* Implementation of the `save gdb-index' command. hooks/post-receive -- Repository for Project Archer.