From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id 4B99D3856DC1; Wed, 20 Apr 2022 15:12:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4B99D3856DC1 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] Introduce readnow_functions X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: dfaa040b440084dd73ebd359326752d5f44fc02c X-Git-Newrev: 045a7baed2e8039fc734b43f4f35393c76e59e55 Message-Id: <20220420151212.4B99D3856DC1@sourceware.org> Date: Wed, 20 Apr 2022 15:12:12 +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: Wed, 20 Apr 2022 15:12:12 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D045a7baed2e8= 039fc734b43f4f35393c76e59e55 commit 045a7baed2e8039fc734b43f4f35393c76e59e55 Author: Tom Tromey Date: Mon Mar 29 20:14:30 2021 -0600 Introduce readnow_functions =20 This introduces readnow_functions, a new subclass of dwarf2_base_index_functions, and changes the DWARF reader to use it. This lets us drop the "index is NULL" hack from the gdb index code. Diff: --- gdb/dwarf2/read.c | 109 ++++++++++++++++++++++++++++----------------------= ---- 1 file changed, 56 insertions(+), 53 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 165bea9c5a8..83651f21d31 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -1841,6 +1841,40 @@ struct dwarf2_base_index_functions : public quick_sy= mbol_functions bool need_fullname) override; }; =20 +/* With OBJF_READNOW, the DWARF reader expands all CUs immediately. + It's handy in this case to have an empty implementation of the + quick symbol functions, to avoid special cases in the rest of the + code. */ + +struct readnow_functions : public dwarf2_base_index_functions +{ + void dump (struct objfile *objfile) override + { + } + + void expand_matching_symbols + (struct objfile *, + const lookup_name_info &lookup_name, + domain_enum domain, + int global, + symbol_compare_ftype *ordered_compare) override + { + } + + bool expand_symtabs_matching + (struct objfile *objfile, + gdb::function_view file_matcher, + const lookup_name_info *lookup_name, + gdb::function_view symbol_matche= r, + gdb::function_view expansion_notify, + block_search_flags search_flags, + domain_enum domain, + enum search_domain kind) override + { + return true; + } +}; + struct dwarf2_gdb_index : public dwarf2_base_index_functions { void dump (struct objfile *objfile) override; @@ -1885,12 +1919,6 @@ struct dwarf2_debug_names_index : public dwarf2_base= _index_functions enum search_domain kind) override; }; =20 -static quick_symbol_functions_up -make_dwarf_gdb_index () -{ - return quick_symbol_functions_up (new dwarf2_gdb_index); -} - quick_symbol_functions_up mapped_index::make_quick_functions () const { @@ -2910,9 +2938,6 @@ dw2_symtab_iter_init (struct dw2_symtab_iterator *ite= r, iter->length =3D 0; =20 mapped_index *index =3D per_objfile->per_bfd->index_table.get (); - /* index is NULL if OBJF_READNOW. */ - if (index =3D=3D NULL) - return; =20 gdb_assert (!index->symbol_name_slot_invalid (namei)); offset_type vec_idx =3D index->symbol_vec_index (namei); @@ -3048,14 +3073,8 @@ dwarf2_gdb_index::dump (struct objfile *objfile) { dwarf2_per_objfile *per_objfile =3D get_dwarf2_per_objfile (objfile); =20 - gdb_printf (".gdb_index:"); - if (per_objfile->per_bfd->index_table !=3D NULL) - { - gdb_printf (" version %d\n", - per_objfile->per_bfd->index_table->version); - } - else - gdb_printf (" faked for \"readnow\"\n"); + gdb_printf (".gdb_index: version %d\n", + per_objfile->per_bfd->index_table->version); gdb_printf ("\n"); } =20 @@ -3105,37 +3124,28 @@ dwarf2_gdb_index::expand_matching_symbols =20 const block_enum block_kind =3D global ? GLOBAL_BLOCK : STATIC_BLOCK; =20 - if (per_objfile->per_bfd->index_table !=3D nullptr) - { - mapped_index &index =3D *per_objfile->per_bfd->index_table; + mapped_index &index =3D *per_objfile->per_bfd->index_table; =20 - const char *match_name =3D name.ada ().lookup_name ().c_str (); - auto matcher =3D [&] (const char *symname) - { - if (ordered_compare =3D=3D nullptr) - return true; - return ordered_compare (symname, match_name) =3D=3D 0; - }; + const char *match_name =3D name.ada ().lookup_name ().c_str (); + auto matcher =3D [&] (const char *symname) + { + if (ordered_compare =3D=3D nullptr) + return true; + return ordered_compare (symname, match_name) =3D=3D 0; + }; =20 - dw2_expand_symtabs_matching_symbol (index, name, matcher, - [&] (offset_type namei) - { - struct dw2_symtab_iterator iter; - struct dwarf2_per_cu_data *per_cu; - - dw2_symtab_iter_init (&iter, per_objfile, block_kind, domain, - namei); - while ((per_cu =3D dw2_symtab_iter_next (&iter)) !=3D NULL) - dw2_expand_symtabs_matching_one (per_cu, per_objfile, nullptr, - nullptr); - return true; - }, per_objfile); - } - else + dw2_expand_symtabs_matching_symbol (index, name, matcher, + [&] (offset_type namei) { - /* We have -readnow: no .gdb_index, but no partial symtabs either. = So, - proceed assuming all symtabs have been read in. */ - } + struct dw2_symtab_iterator iter; + struct dwarf2_per_cu_data *per_cu; + + dw2_symtab_iter_init (&iter, per_objfile, block_kind, domain, namei); + while ((per_cu =3D dw2_symtab_iter_next (&iter)) !=3D NULL) + dw2_expand_symtabs_matching_one (per_cu, per_objfile, nullptr, + nullptr); + return true; + }, per_objfile); } =20 /* Starting from a search name, return the string that finds the upper @@ -4151,10 +4161,6 @@ dwarf2_gdb_index::expand_symtabs_matching { dwarf2_per_objfile *per_objfile =3D get_dwarf2_per_objfile (objfile); =20 - /* index_table is NULL if OBJF_READNOW. */ - if (!per_objfile->per_bfd->index_table) - return true; - dw_expand_symtabs_matching_file_matcher (per_objfile, file_matcher); =20 /* This invariant is documented in quick-functions.h. */ @@ -5269,10 +5275,7 @@ dwarf2_initialize_objfile (struct objfile *objfile) per_bfd->quick_file_names_table =3D create_quick_file_names_table (per_bfd->all_comp_units.size ()); =20 - /* Arrange for gdb to see the "quick" functions. However, these - functions will be no-ops because we will have expanded all - symtabs. */ - objfile->qf.push_front (make_dwarf_gdb_index ()); + objfile->qf.emplace_front (new readnow_functions); return; }