From 2bb9e05637f5a08e6da30450482f5a413b7f6972 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Fri, 10 Nov 2023 14:21:41 -0700 Subject: Remove quick_symbol_functions::expand_matching_symbols The only caller of quick_symbol_functions::expand_matching_symbols was removed, so now this method and all implementations of it can be removed. --- gdb/dwarf2/read-debug-names.c | 46 ---------- gdb/dwarf2/read-gdb-index.c | 190 ------------------------------------------ gdb/dwarf2/read.c | 54 ------------ gdb/objfiles.h | 6 -- gdb/psymtab.c | 104 ----------------------- gdb/psymtab.h | 7 -- gdb/quick-symbol.h | 27 ------ gdb/symfile-debug.c | 18 ---- 8 files changed, 452 deletions(-) (limited to 'gdb') diff --git a/gdb/dwarf2/read-debug-names.c b/gdb/dwarf2/read-debug-names.c index 67e2bf2..59c49da 100644 --- a/gdb/dwarf2/read-debug-names.c +++ b/gdb/dwarf2/read-debug-names.c @@ -84,13 +84,6 @@ struct dwarf2_debug_names_index : 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, @@ -941,45 +934,6 @@ dwarf2_debug_names_index::dump (struct objfile *objfile) gdb_printf (".debug_names: exists\n"); } -void -dwarf2_debug_names_index::expand_matching_symbols - (struct objfile *objfile, - const lookup_name_info &name, domain_enum domain, - int global, - symbol_compare_ftype *ordered_compare) -{ - dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile); - - mapped_debug_names &map - = *(gdb::checked_static_cast - (per_objfile->per_bfd->index_table.get ())); - const block_search_flags block_flags - = global ? SEARCH_GLOBAL_BLOCK : SEARCH_STATIC_BLOCK; - - const char *match_name = name.ada ().lookup_name ().c_str (); - auto matcher = [&] (const char *symname) - { - if (ordered_compare == nullptr) - return true; - return ordered_compare (symname, match_name) == 0; - }; - - dw2_expand_symtabs_matching_symbol (map, name, matcher, - [&] (offset_type namei) - { - /* The name was matched, now expand corresponding CUs that were - marked. */ - dw2_debug_names_iterator iter (map, block_flags, domain, namei, - per_objfile); - - struct dwarf2_per_cu_data *per_cu; - while ((per_cu = iter.next ()) != NULL) - dw2_expand_symtabs_matching_one (per_cu, per_objfile, nullptr, - nullptr); - return true; - }, per_objfile); -} - bool dwarf2_debug_names_index::expand_symtabs_matching (struct objfile *objfile, diff --git a/gdb/dwarf2/read-gdb-index.c b/gdb/dwarf2/read-gdb-index.c index da180fa..4ca4454 100644 --- a/gdb/dwarf2/read-gdb-index.c +++ b/gdb/dwarf2/read-gdb-index.c @@ -139,13 +139,6 @@ struct dwarf2_gdb_index : public dwarf2_base_index_functions gdb.dwarf2/gdb-index.exp testcase. */ 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, @@ -173,189 +166,6 @@ dwarf2_gdb_index::dump (struct objfile *objfile) gdb_printf ("\n"); } -/* Struct used to manage iterating over all CUs looking for a symbol. */ - -struct dw2_symtab_iterator -{ - /* The dwarf2_per_objfile owning the CUs we are iterating on. */ - dwarf2_per_objfile *per_objfile; - /* If set, only look for symbols that match that block. Valid values are - GLOBAL_BLOCK and STATIC_BLOCK. */ - std::optional block_index; - /* The kind of symbol we're looking for. */ - domain_enum domain; - /* The list of CUs from the index entry of the symbol, - or NULL if not found. */ - offset_view vec; - /* The next element in VEC to look at. */ - int next; - /* The number of elements in VEC, or zero if there is no match. */ - int length; - /* Have we seen a global version of the symbol? - If so we can ignore all further global instances. - This is to work around gold/15646, inefficient gold-generated - indices. */ - int global_seen; -}; - -/* Initialize the index symtab iterator ITER, offset_type NAMEI variant. */ - -static void -dw2_symtab_iter_init (struct dw2_symtab_iterator *iter, - dwarf2_per_objfile *per_objfile, - std::optional block_index, - domain_enum domain, offset_type namei, - mapped_gdb_index &index) -{ - iter->per_objfile = per_objfile; - iter->block_index = block_index; - iter->domain = domain; - iter->next = 0; - iter->global_seen = 0; - iter->vec = {}; - iter->length = 0; - - gdb_assert (!index.symbol_name_slot_invalid (namei)); - offset_type vec_idx = index.symbol_vec_index (namei); - - iter->vec = offset_view (index.constant_pool.slice (vec_idx)); - iter->length = iter->vec[0]; -} - -/* Return the next matching CU or NULL if there are no more. */ - -static struct dwarf2_per_cu_data * -dw2_symtab_iter_next (struct dw2_symtab_iterator *iter, - mapped_gdb_index &index) -{ - dwarf2_per_objfile *per_objfile = iter->per_objfile; - - for ( ; iter->next < iter->length; ++iter->next) - { - offset_type cu_index_and_attrs = iter->vec[iter->next + 1]; - offset_type cu_index = GDB_INDEX_CU_VALUE (cu_index_and_attrs); - gdb_index_symbol_kind symbol_kind = - GDB_INDEX_SYMBOL_KIND_VALUE (cu_index_and_attrs); - /* Only check the symbol attributes if they're present. - Indices prior to version 7 don't record them, - and indices >= 7 may elide them for certain symbols - (gold does this). */ - int attrs_valid = (index.version >= 7 - && symbol_kind != GDB_INDEX_SYMBOL_KIND_NONE); - - /* Don't crash on bad data. */ - if (cu_index >= per_objfile->per_bfd->all_units.size ()) - { - complaint (_(".gdb_index entry has bad CU index" - " [in module %s]"), objfile_name (per_objfile->objfile)); - continue; - } - - dwarf2_per_cu_data *per_cu = per_objfile->per_bfd->get_cu (cu_index); - - /* Skip if already read in. */ - if (per_objfile->symtab_set_p (per_cu)) - continue; - - /* Check static vs global. */ - if (attrs_valid) - { - bool is_static = GDB_INDEX_SYMBOL_STATIC_VALUE (cu_index_and_attrs); - - if (iter->block_index.has_value ()) - { - bool want_static = *iter->block_index == STATIC_BLOCK; - - if (is_static != want_static) - continue; - } - - /* Work around gold/15646. */ - if (!is_static - && symbol_kind == GDB_INDEX_SYMBOL_KIND_TYPE) - { - if (iter->global_seen) - continue; - - iter->global_seen = 1; - } - } - - /* Only check the symbol's kind if it has one. */ - if (attrs_valid) - { - switch (iter->domain) - { - case VAR_DOMAIN: - if (symbol_kind != GDB_INDEX_SYMBOL_KIND_VARIABLE - && symbol_kind != GDB_INDEX_SYMBOL_KIND_FUNCTION - /* Some types are also in VAR_DOMAIN. */ - && symbol_kind != GDB_INDEX_SYMBOL_KIND_TYPE) - continue; - break; - case STRUCT_DOMAIN: - if (symbol_kind != GDB_INDEX_SYMBOL_KIND_TYPE) - continue; - break; - case LABEL_DOMAIN: - if (symbol_kind != GDB_INDEX_SYMBOL_KIND_OTHER) - continue; - break; - case MODULE_DOMAIN: - if (symbol_kind != GDB_INDEX_SYMBOL_KIND_OTHER) - continue; - break; - default: - break; - } - } - - ++iter->next; - return per_cu; - } - - return NULL; -} - -void -dwarf2_gdb_index::expand_matching_symbols - (struct objfile *objfile, - const lookup_name_info &name, domain_enum domain, - int global, - symbol_compare_ftype *ordered_compare) -{ - /* Used for Ada. */ - dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile); - - const block_enum block_kind = global ? GLOBAL_BLOCK : STATIC_BLOCK; - - mapped_gdb_index &index - = *(gdb::checked_static_cast - (per_objfile->per_bfd->index_table.get ())); - - const char *match_name = name.ada ().lookup_name ().c_str (); - auto matcher = [&] (const char *symname) - { - if (ordered_compare == nullptr) - return true; - return ordered_compare (symname, match_name) == 0; - }; - - 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, - index); - while ((per_cu = dw2_symtab_iter_next (&iter, index)) != NULL) - dw2_expand_symtabs_matching_one (per_cu, per_objfile, nullptr, - nullptr); - return true; - }, per_objfile); -} - /* Helper for dw2_expand_matching symtabs. Called on each symbol matched, to expand corresponding CUs that were marked. IDX is the index of the symbol name that matched. */ diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index dd25e34..37cabe5 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -1628,15 +1628,6 @@ struct readnow_functions : public dwarf2_base_index_functions { } - 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, @@ -16514,13 +16505,6 @@ struct cooked_index_functions : public dwarf2_base_index_functions index->dump (objfile->arch ()); } - 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, @@ -16617,44 +16601,6 @@ cooked_index_functions::find_compunit_symtab_by_address return dw2_instantiate_symtab (per_cu, per_objfile, false); } -void -cooked_index_functions::expand_matching_symbols - (struct objfile *objfile, - const lookup_name_info &lookup_name, - domain_enum domain, - int global, - symbol_compare_ftype *ordered_compare) -{ - dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile); - cooked_index *table - = (gdb::checked_static_cast - (per_objfile->per_bfd->index_table.get ())); - if (table == nullptr) - return; - - const block_search_flags search_flags = (global - ? SEARCH_GLOBAL_BLOCK - : SEARCH_STATIC_BLOCK); - const language_defn *lang = language_def (language_ada); - symbol_name_matcher_ftype *name_match - = lang->get_symbol_name_matcher (lookup_name); - - for (const cooked_index_entry *entry : table->all_entries ()) - { - QUIT; - - if (entry->parent_entry != nullptr) - continue; - - if (!entry->matches (search_flags) - || !entry->matches (domain)) - continue; - - if (name_match (entry->canonical, lookup_name, nullptr)) - dw2_instantiate_symtab (entry->per_cu, per_objfile, false); - } -} - bool cooked_index_functions::expand_symtabs_matching (struct objfile *objfile, diff --git a/gdb/objfiles.h b/gdb/objfiles.h index ec9d354..0cad596 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -585,12 +585,6 @@ public: void expand_symtabs_with_fullname (const char *fullname); /* See quick_symbol_functions. */ - void expand_matching_symbols - (const lookup_name_info &name, domain_enum domain, - int global, - symbol_compare_ftype *ordered_compare); - - /* See quick_symbol_functions. */ bool expand_symtabs_matching (gdb::function_view file_matcher, const lookup_name_info *lookup_name, diff --git a/gdb/psymtab.c b/gdb/psymtab.c index d4cd581..ca1bcf1 100644 --- a/gdb/psymtab.c +++ b/gdb/psymtab.c @@ -318,90 +318,6 @@ psymbol_name_matches (partial_symbol *psym, return name_match (psym->ginfo.search_name (), lookup_name, NULL); } -/* Look in PST for a symbol in DOMAIN whose name matches NAME. Search - the global block of PST if GLOBAL, and otherwise the static block. - MATCH is the comparison operation that returns true iff MATCH (s, - NAME), where s is a SYMBOL_SEARCH_NAME. If ORDERED_COMPARE is - non-null, the symbols in the block are assumed to be ordered - according to it (allowing binary search). It must be compatible - with MATCH. Returns the symbol, if found, and otherwise NULL. */ - -static struct partial_symbol * -match_partial_symbol (struct objfile *objfile, - struct partial_symtab *pst, int global, - const lookup_name_info &name, domain_enum domain, - symbol_compare_ftype *ordered_compare) -{ - struct partial_symbol **start, **psym; - struct partial_symbol **top, **real_top, **bottom, **center; - int length = (global - ? pst->global_psymbols.size () - : pst->static_psymbols.size ()); - int do_linear_search = 1; - - if (length == 0) - return NULL; - - start = (global ? - &pst->global_psymbols[0] : - &pst->static_psymbols[0]); - - if (global && ordered_compare) /* Can use a binary search. */ - { - do_linear_search = 0; - - /* Binary search. This search is guaranteed to end with center - pointing at the earliest partial symbol whose name might be - correct. At that point *all* partial symbols with an - appropriate name will be checked against the correct - domain. */ - - bottom = start; - top = start + length - 1; - real_top = top; - while (top > bottom) - { - center = bottom + (top - bottom) / 2; - gdb_assert (center < top); - - enum language lang = (*center)->ginfo.language (); - const char *lang_ln = name.language_lookup_name (lang); - - if (ordered_compare ((*center)->ginfo.search_name (), - lang_ln) >= 0) - top = center; - else - bottom = center + 1; - } - gdb_assert (top == bottom); - - while (top <= real_top - && psymbol_name_matches (*top, name)) - { - if (symbol_matches_domain ((*top)->ginfo.language (), - (*top)->domain, domain)) - return *top; - top++; - } - } - - /* Can't use a binary search or else we found during the binary search that - we should also do a linear search. */ - - if (do_linear_search) - { - for (psym = start; psym < start + length; psym++) - { - if (symbol_matches_domain ((*psym)->ginfo.language (), - (*psym)->domain, domain) - && psymbol_name_matches (*psym, name)) - return *psym; - } - } - - return NULL; -} - /* Look, in partial_symtab PST, for symbol whose natural name is LOOKUP_NAME. Check the global symbols if GLOBAL, the static symbols if not. */ @@ -877,26 +793,6 @@ psymtab_to_fullname (struct partial_symtab *ps) return ps->fullname; } -/* Psymtab version of expand_matching_symbols. See its definition in - the definition of quick_symbol_functions in symfile.h. */ - -void -psymbol_functions::expand_matching_symbols - (struct objfile *objfile, - const lookup_name_info &name, domain_enum domain, - int global, - symbol_compare_ftype *ordered_compare) -{ - for (partial_symtab *ps : partial_symbols (objfile)) - { - QUIT; - if (!ps->readin_p (objfile) - && match_partial_symbol (objfile, ps, global, name, domain, - ordered_compare)) - psymtab_to_symtab (objfile, ps); - } -} - /* A helper for psym_expand_symtabs_matching that handles searching included psymtabs. This returns true if a symbol is found, and false otherwise. It also updates the 'searched_flag' on the diff --git a/gdb/psymtab.h b/gdb/psymtab.h index 005a63c..54ad78b 100644 --- a/gdb/psymtab.h +++ b/gdb/psymtab.h @@ -626,13 +626,6 @@ struct psymbol_functions : public quick_symbol_functions void expand_all_symtabs (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, diff --git a/gdb/quick-symbol.h b/gdb/quick-symbol.h index a7fea2c..e48eeed 100644 --- a/gdb/quick-symbol.h +++ b/gdb/quick-symbol.h @@ -30,11 +30,6 @@ enum block_search_flag_values DEF_ENUM_FLAGS_TYPE (enum block_search_flag_values, block_search_flags); -/* Comparison function for symbol look ups. */ - -typedef int (symbol_compare_ftype) (const char *string1, - const char *string2); - /* Callback for quick_symbol_functions->map_symbol_filenames. */ typedef void (symbol_filename_ftype) (const char *filename, @@ -125,28 +120,6 @@ struct quick_symbol_functions /* Read all symbol tables associated with OBJFILE. */ virtual void expand_all_symtabs (struct objfile *objfile) = 0; - /* Find global or static symbols in all tables that are in DOMAIN - and for which MATCH (symbol name, NAME) == 0, reading in partial - symbol tables as needed. Look through global symbols if GLOBAL - and otherwise static symbols. - - MATCH must be weaker than strcmp_iw_ordered in the sense that - strcmp_iw_ordered(x,y) == 0 --> MATCH(x,y) == 0. ORDERED_COMPARE, - if non-null, must be an ordering relation compatible with - strcmp_iw_ordered in the sense that - strcmp_iw_ordered(x,y) == 0 --> ORDERED_COMPARE(x,y) == 0 - and - strcmp_iw_ordered(x,y) <= 0 --> ORDERED_COMPARE(x,y) <= 0 - (allowing strcmp_iw_ordered(x,y) < 0 while ORDERED_COMPARE(x, y) == 0). - */ - - virtual void expand_matching_symbols - (struct objfile *, - const lookup_name_info &lookup_name, - domain_enum domain, - int global, - symbol_compare_ftype *ordered_compare) = 0; - /* Expand all symbol tables in OBJFILE matching some criteria. FILE_MATCHER is called for each file in OBJFILE. The file name diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c index 85c4371..d31ff33 100644 --- a/gdb/symfile-debug.c +++ b/gdb/symfile-debug.c @@ -388,24 +388,6 @@ objfile::expand_symtabs_with_fullname (const char *fullname) ALL_DOMAIN); } -void -objfile::expand_matching_symbols - (const lookup_name_info &name, domain_enum domain, - int global, - symbol_compare_ftype *ordered_compare) -{ - if (debug_symfile) - gdb_printf (gdb_stdlog, - "qf->expand_matching_symbols (%s, %s, %d, %s)\n", - objfile_debug_name (this), - domain_name (domain), global, - host_address_to_string (ordered_compare)); - - for (const auto &iter : qf_require_partial_symbols ()) - iter->expand_matching_symbols (this, name, domain, global, - ordered_compare); -} - bool objfile::expand_symtabs_matching (gdb::function_view file_matcher, -- cgit v1.1