From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id 5F087385840C; Tue, 12 Apr 2022 15:41:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5F087385840C Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom Tromey To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Adapt .debug_names writer to new DWARF scanner X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: 6dd7aa909b6f98202ebe995518613e565e11e1a5 X-Git-Newrev: 600f5f702728f66ced24f8497c75c58ff442aeb6 Message-Id: <20220412154142.5F087385840C@sourceware.org> Date: Tue, 12 Apr 2022 15:41:42 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Apr 2022 15:41:42 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D600f5f702728= f66ced24f8497c75c58ff442aeb6 commit 600f5f702728f66ced24f8497c75c58ff442aeb6 Author: Tom Tromey Date: Sat May 29 15:12:44 2021 -0600 Adapt .debug_names writer to new DWARF scanner =20 This updates the .debug_names writer to work with the new DWARF scanner. Diff: --- gdb/dwarf2/index-write.c | 52 ++++++++++++++++++++++++++++++++++++++------= ---- 1 file changed, 42 insertions(+), 10 deletions(-) diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c index 4d9a9a18c95..8efe370acaf 100644 --- a/gdb/dwarf2/index-write.c +++ b/gdb/dwarf2/index-write.c @@ -664,15 +664,10 @@ public: enum class unit_kind { cu, tu }; =20 /* Insert one symbol. */ - void insert (const partial_symbol *psym, int cu_index, bool is_static, - unit_kind kind) + void insert (int dwarf_tag, const char *name, int cu_index, bool is_stat= ic, + unit_kind kind, enum language lang) { - const int dwarf_tag =3D psymbol_tag (psym); - if (dwarf_tag =3D=3D 0) - return; - const char *name =3D psym->ginfo.search_name (); - - if (psym->ginfo.language () =3D=3D language_ada) + if (lang =3D=3D language_ada) { /* We want to ensure that the Ada main function's name appears verbatim in the index. However, this name will be of the @@ -715,6 +710,28 @@ public: value_set.emplace (symbol_value (dwarf_tag, cu_index, is_static, kind)= ); } =20 + void insert (const partial_symbol *psym, int cu_index, bool is_static, + unit_kind kind) + { + const int dwarf_tag =3D psymbol_tag (psym); + if (dwarf_tag =3D=3D 0) + return; + const char *name =3D psym->ginfo.search_name (); + + insert (dwarf_tag, name, cu_index, is_static, kind, + psym->ginfo.language ()); + } + + void insert (const cooked_index_entry *entry) + { + const auto it =3D m_cu_index_htab.find (entry->per_cu); + gdb_assert (it !=3D m_cu_index_htab.cend ()); + const char *name =3D entry->full_name (&m_string_obstack); + insert (entry->tag, name, it->second, (entry->flags & IS_STATIC) !=3D = 0, + entry->per_cu->is_debug_types ? unit_kind::tu : unit_kind::cu, + entry->per_cu->lang); + } + /* Build all the tables. All symbols must be already inserted. This function does not call file_write, caller has to do it afterwards. */ @@ -897,6 +914,11 @@ public: m_debugstrlookup.file_write (file_str); } =20 + void add_cu (dwarf2_per_cu_data *per_cu, offset_type index) + { + m_cu_index_htab.emplace (per_cu, index); + } + private: =20 /* Storage for symbol names mapping them to their .debug_str section @@ -1211,6 +1233,8 @@ private: =20 /* Temporary storage for Ada names. */ auto_obstack m_string_obstack; + + cu_index_map m_cu_index_htab; }; =20 /* Return iff any of the needed offsets does not fit into 32-bit @@ -1491,17 +1515,20 @@ write_debug_names (dwarf2_per_objfile *per_objfile, int types_counter =3D 0; for (int i =3D 0; i < per_objfile->per_bfd->all_comp_units.size (); ++i) { - const dwarf2_per_cu_data *per_cu + dwarf2_per_cu_data *per_cu =3D per_objfile->per_bfd->all_comp_units[i].get (); - partial_symtab *psymtab =3D per_cu->v.psymtab; =20 int &this_counter =3D per_cu->is_debug_types ? types_counter : count= er; data_buf &this_list =3D per_cu->is_debug_types ? types_cu_list : cu_= list; + partial_symtab *psymtab =3D (per_objfile->per_bfd->using_index + ? nullptr + : per_cu->v.psymtab); =20 if (psymtab !=3D nullptr && psymtab->user =3D=3D nullptr) nametable.recursively_write_psymbols (objfile, psymtab, psyms_seen, this_counter); =20 + nametable.add_cu (per_cu, this_counter); this_list.append_uint (nametable.dwarf5_offset_size (), dwarf5_byte_order, to_underlying (per_cu->sect_off)); @@ -1513,6 +1540,11 @@ write_debug_names (dwarf2_per_objfile *per_objfile, - per_objfile->per_bfd->tu_stats.nr_tus)); gdb_assert (types_counter =3D=3D per_objfile->per_bfd->tu_stats.nr_tus); =20 + if (per_objfile->per_bfd->using_index) + for (const cooked_index_entry *entry + : per_objfile->per_bfd->cooked_index_table->all_entries ()) + nametable.insert (entry); + nametable.build (); =20 /* No addr_vec - DWARF-5 uses .debug_aranges generated by GCC. */