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 ------------ 3 files changed, 290 deletions(-) (limited to 'gdb/dwarf2') 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, -- cgit v1.1