From patchwork Wed Jul 31 20:14:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 33882 Received: (qmail 121620 invoked by alias); 31 Jul 2019 20:22:37 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 121610 invoked by uid 89); 31 Jul 2019 20:22:37 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=6127 X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 31 Jul 2019 20:22:35 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 1433C116FBC; Wed, 31 Jul 2019 16:14:16 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id I7nVVZwoeWoR; Wed, 31 Jul 2019 16:14:16 -0400 (EDT) Received: from murgatroyd.Home (97-122-178-82.hlrn.qwest.net [97.122.178.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPSA id B3B9F116BDB; Wed, 31 Jul 2019 16:14:15 -0400 (EDT) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 4/8] Change map_matching_symbols to take a lookup_name_info Date: Wed, 31 Jul 2019 14:14:07 -0600 Message-Id: <20190731201411.8044-5-tromey@adacore.com> In-Reply-To: <20190731201411.8044-1-tromey@adacore.com> References: <20190731201411.8044-1-tromey@adacore.com> MIME-Version: 1.0 This patch further simplified the map_matching_symbols callback, by having it take a lookup_name_info rather than a plain string. gdb/ChangeLog 2019-07-31 Tom Tromey * ada-lang.c (add_nonlocal_symbols): Combine calls to map_matching_symbols. Update. * dwarf2read.c (dw2_map_matching_symbols): Update. * psymtab.c (match_partial_symbol): Change type; update. (psym_map_matching_symbols): Likewise. * symfile-debug.c (debug_qf_map_matching_symbols): Change type; update. * symfile.h (struct quick_symbol_functions) : Change "name" to be a lookup_name_info. Remove "match". --- gdb/ChangeLog | 13 +++++++++++++ gdb/ada-lang.c | 20 +++++++------------- gdb/dwarf2read.c | 3 +-- gdb/psymtab.c | 27 +++++++-------------------- gdb/symfile-debug.c | 9 +++------ gdb/symfile.h | 4 ++-- 6 files changed, 33 insertions(+), 43 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 8294101c06e..73045c272e7 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -5551,16 +5551,10 @@ add_nonlocal_symbols (struct obstack *obstackp, { data.objfile = objfile; - if (is_wild_match) - objfile->sf->qf->map_matching_symbols (objfile, lookup_name.name ().c_str (), - domain, global, callback, - symbol_name_match_type::WILD, - NULL); - else - objfile->sf->qf->map_matching_symbols (objfile, lookup_name.name ().c_str (), - domain, global, callback, - symbol_name_match_type::FULL, - compare_names); + objfile->sf->qf->map_matching_symbols (objfile, lookup_name, + domain, global, callback, + (is_wild_match + ? NULL : compare_names)); for (compunit_symtab *cu : objfile->compunits ()) { @@ -5576,14 +5570,14 @@ add_nonlocal_symbols (struct obstack *obstackp, if (num_defns_collected (obstackp) == 0 && global && !is_wild_match) { const char *name = ada_lookup_name (lookup_name); - std::string name1 = std::string ("<_ada_") + name + '>'; + lookup_name_info name1 (std::string ("<_ada_") + name + '>', + symbol_name_match_type::FULL); for (objfile *objfile : current_program_space->objfiles ()) { data.objfile = objfile; - objfile->sf->qf->map_matching_symbols (objfile, name1.c_str (), + objfile->sf->qf->map_matching_symbols (objfile, name1, domain, global, callback, - symbol_name_match_type::FULL, compare_names); } } diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index e86fdaa7bc8..2c55f8d7cd9 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -4183,10 +4183,9 @@ dw2_expand_symtabs_with_fullname (struct objfile *objfile, static void dw2_map_matching_symbols (struct objfile *objfile, - const char * name, domain_enum domain, + const lookup_name_info &name, domain_enum domain, int global, gdb::function_view callback, - symbol_name_match_type match, symbol_compare_ftype *ordered_compare) { /* Currently unimplemented; used for Ada. The function can be called if the diff --git a/gdb/psymtab.c b/gdb/psymtab.c index daaa608d5d1..f730b9d08e1 100644 --- a/gdb/psymtab.c +++ b/gdb/psymtab.c @@ -37,13 +37,6 @@ #include #include -static struct partial_symbol *match_partial_symbol (struct objfile *, - struct partial_symtab *, - int, - const char *, domain_enum, - symbol_name_match_type, - symbol_compare_ftype *); - static struct partial_symbol *lookup_partial_symbol (struct objfile *, struct partial_symtab *, const char *, int, @@ -545,8 +538,7 @@ psymbol_name_matches (partial_symbol *psym, static struct partial_symbol * match_partial_symbol (struct objfile *objfile, struct partial_symtab *pst, int global, - const char *name, domain_enum domain, - symbol_name_match_type match_type, + const lookup_name_info &name, domain_enum domain, symbol_compare_ftype *ordered_compare) { struct partial_symbol **start, **psym; @@ -557,8 +549,6 @@ match_partial_symbol (struct objfile *objfile, if (length == 0) return NULL; - lookup_name_info lookup_name (name, match_type); - start = (global ? &objfile->partial_symtabs->global_psymbols[pst->globals_offset] : &objfile->partial_symtabs->static_psymbols[pst->statics_offset]); @@ -583,7 +573,7 @@ match_partial_symbol (struct objfile *objfile, enum language lang = (*center)->ginfo.language; const char *lang_ln - = lookup_name.language_lookup_name (lang).c_str (); + = name.language_lookup_name (lang).c_str (); if (ordered_compare (symbol_search_name (&(*center)->ginfo), lang_ln) >= 0) @@ -594,7 +584,7 @@ match_partial_symbol (struct objfile *objfile, gdb_assert (top == bottom); while (top <= real_top - && psymbol_name_matches (*top, lookup_name)) + && psymbol_name_matches (*top, name)) { if (symbol_matches_domain ((*top)->ginfo.language, (*top)->domain, domain)) @@ -612,7 +602,7 @@ match_partial_symbol (struct objfile *objfile, { if (symbol_matches_domain ((*psym)->ginfo.language, (*psym)->domain, domain) - && psymbol_name_matches (*psym, lookup_name)) + && psymbol_name_matches (*psym, name)) return *psym; } } @@ -1168,21 +1158,18 @@ psymtab_to_fullname (struct partial_symtab *ps) static void psym_map_matching_symbols (struct objfile *objfile, - const char *name, domain_enum domain, + const lookup_name_info &name, domain_enum domain, int global, gdb::function_view callback, - symbol_name_match_type match, symbol_compare_ftype *ordered_compare) { const int block_kind = global ? GLOBAL_BLOCK : STATIC_BLOCK; - lookup_name_info lookup_name (name, match); - for (partial_symtab *ps : require_partial_symbols (objfile, 1)) { QUIT; if (ps->readin - || match_partial_symbol (objfile, ps, global, name, domain, match, + || match_partial_symbol (objfile, ps, global, name, domain, ordered_compare)) { struct compunit_symtab *cust = psymtab_to_symtab (objfile, ps); @@ -1191,7 +1178,7 @@ psym_map_matching_symbols if (cust == NULL) continue; block = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust), block_kind); - if (!iterate_over_symbols_terminated (block, lookup_name, + if (!iterate_over_symbols_terminated (block, name, domain, callback)) return; } diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c index 17bc5e8b977..b059be3552a 100644 --- a/gdb/symfile-debug.c +++ b/gdb/symfile-debug.c @@ -230,26 +230,23 @@ debug_qf_expand_symtabs_with_fullname (struct objfile *objfile, static void debug_qf_map_matching_symbols (struct objfile *objfile, - const char *name, domain_enum domain, + const lookup_name_info &name, domain_enum domain, int global, gdb::function_view callback, - symbol_name_match_type match, symbol_compare_ftype *ordered_compare) { const struct debug_sym_fns_data *debug_data = symfile_debug_objfile_data_key.get (objfile); fprintf_filtered (gdb_stdlog, - "qf->map_matching_symbols (%s, \"%s\", %s, %d, %s, %s)\n", - objfile_debug_name (objfile), name, + "qf->map_matching_symbols (%s, %s, %d, %s)\n", + objfile_debug_name (objfile), domain_name (domain), global, - plongest ((LONGEST) match), host_address_to_string (ordered_compare)); debug_data->real_sf->qf->map_matching_symbols (objfile, name, domain, global, callback, - match, ordered_compare); } diff --git a/gdb/symfile.h b/gdb/symfile.h index 9121d883ee0..98fb377806b 100644 --- a/gdb/symfile.h +++ b/gdb/symfile.h @@ -226,10 +226,10 @@ struct quick_symbol_functions void (*map_matching_symbols) (struct objfile *, - const char *name, domain_enum domain, + const lookup_name_info &lookup_name, + domain_enum domain, int global, gdb::function_view callback, - symbol_name_match_type match, symbol_compare_ftype *ordered_compare); /* Expand all symbol tables in OBJFILE matching some criteria.