From 7089bd886ec78d623c3188cac48c039bc5eaf3b6 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Sat, 17 Apr 2021 09:35:04 -0600 Subject: [PATCH] Remove quick_symbol_functions::expand_symtabs_for_function This removes quick_symbol_functions::expand_symtabs_for_function, replacing it with a call to expand_symtabs_matching. As with the previous patches, the implementation is consolidated in the objfile method. gdb/ChangeLog 2021-04-17 Tom Tromey * symfile-debug.c (objfile::expand_symtabs_for_function): Rewrite. * quick-symbol.h (struct quick_symbol_functions) : Remove. * psymtab.c (psymbol_functions::expand_symtabs_for_function): Remove. * psympriv.h (struct psymbol_functions) : Remove. * objfiles.h (struct objfile) : Update comment. * dwarf2/read.c (struct dwarf2_gdb_index) : Remove. (struct dwarf2_debug_names_index) : Remove. (find_slot_in_mapped_hash): Remove. (dw2_symtab_iter_init_common): Merge with dw2_symtab_iter_init. (dw2_symtab_iter_init): Remove one overload. (dwarf2_gdb_index::expand_symtabs_for_function) (dwarf2_debug_names_index::expand_symtabs_for_function): Remove. --- gdb/ChangeLog | 22 +++++++ gdb/dwarf2/read.c | 148 ++------------------------------------------ gdb/objfiles.h | 3 +- gdb/psympriv.h | 3 - gdb/psymtab.c | 23 ------- gdb/quick-symbol.h | 5 -- gdb/symfile-debug.c | 13 +++- 7 files changed, 41 insertions(+), 176 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 78e7795853a..88e87905915 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,25 @@ +2021-04-17 Tom Tromey + + * symfile-debug.c (objfile::expand_symtabs_for_function): + Rewrite. + * quick-symbol.h (struct quick_symbol_functions) + : Remove. + * psymtab.c (psymbol_functions::expand_symtabs_for_function): + Remove. + * psympriv.h (struct psymbol_functions) + : Remove. + * objfiles.h (struct objfile) : + Update comment. + * dwarf2/read.c (struct dwarf2_gdb_index) + : Remove. + (struct dwarf2_debug_names_index) : + Remove. + (find_slot_in_mapped_hash): Remove. + (dw2_symtab_iter_init_common): Merge with dw2_symtab_iter_init. + (dw2_symtab_iter_init): Remove one overload. + (dwarf2_gdb_index::expand_symtabs_for_function) + (dwarf2_debug_names_index::expand_symtabs_for_function): Remove. + 2021-04-17 Tom Tromey * symfile-debug.c (objfile::map_symtabs_matching_filename): diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 763e41601dc..007b70ec32a 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -2263,9 +2263,6 @@ struct dwarf2_gdb_index : public dwarf2_base_index_functions { void dump (struct objfile *objfile) override; - void expand_symtabs_for_function (struct objfile *objfile, - const char *func_name) override; - void map_matching_symbols (struct objfile *, const lookup_name_info &lookup_name, @@ -2289,9 +2286,6 @@ struct dwarf2_debug_names_index : public dwarf2_base_index_functions { void dump (struct objfile *objfile) override; - void expand_symtabs_for_function (struct objfile *objfile, - const char *func_name) override; - void map_matching_symbols (struct objfile *, const lookup_name_info &lookup_name, @@ -2939,68 +2933,6 @@ create_addrmap_from_aranges (dwarf2_per_objfile *per_objfile, &per_bfd->obstack); } -/* Find a slot in the mapped index INDEX for the object named NAME. - If NAME is found, set *VEC_OUT to point to the CU vector in the - constant pool and return true. If NAME cannot be found, return - false. */ - -static bool -find_slot_in_mapped_hash (struct mapped_index *index, const char *name, - offset_type **vec_out) -{ - offset_type hash; - offset_type slot, step; - int (*cmp) (const char *, const char *); - - gdb::unique_xmalloc_ptr without_params; - if (current_language->la_language == language_cplus - || current_language->la_language == language_fortran - || current_language->la_language == language_d) - { - /* NAME is already canonical. Drop any qualifiers as .gdb_index does - not contain any. */ - - if (strchr (name, '(') != NULL) - { - without_params = cp_remove_params (name); - - if (without_params != NULL) - name = without_params.get (); - } - } - - /* Index version 4 did not support case insensitive searches. But the - indices for case insensitive languages are built in lowercase, therefore - simulate our NAME being searched is also lowercased. */ - hash = mapped_index_string_hash ((index->version == 4 - && case_sensitivity == case_sensitive_off - ? 5 : index->version), - name); - - slot = hash & (index->symbol_table.size () - 1); - step = ((hash * 17) & (index->symbol_table.size () - 1)) | 1; - cmp = (case_sensitivity == case_sensitive_on ? strcmp : strcasecmp); - - for (;;) - { - const char *str; - - const auto &bucket = index->symbol_table[slot]; - if (bucket.name == 0 && bucket.vec == 0) - return false; - - str = index->constant_pool + MAYBE_SWAP (bucket.name); - if (!cmp (name, str)) - { - *vec_out = (offset_type *) (index->constant_pool - + MAYBE_SWAP (bucket.vec)); - return true; - } - - slot = (slot + step) & (index->symbol_table.size () - 1); - } -} - /* A helper function that reads the .gdb_index from BUFFER and fills in MAP. FILENAME is the name of the file containing the data; it is used for error reporting. DEPRECATED_OK is true if it is @@ -3402,13 +3334,13 @@ struct dw2_symtab_iterator int global_seen; }; -/* Initialize the index symtab iterator ITER, common part. */ +/* Initialize the index symtab iterator ITER, offset_type NAMEI variant. */ static void -dw2_symtab_iter_init_common (struct dw2_symtab_iterator *iter, - dwarf2_per_objfile *per_objfile, - gdb::optional block_index, - domain_enum domain) +dw2_symtab_iter_init (struct dw2_symtab_iterator *iter, + dwarf2_per_objfile *per_objfile, + gdb::optional block_index, + domain_enum domain, offset_type namei) { iter->per_objfile = per_objfile; iter->block_index = block_index; @@ -3417,37 +3349,6 @@ dw2_symtab_iter_init_common (struct dw2_symtab_iterator *iter, iter->global_seen = 0; iter->vec = NULL; iter->length = 0; -} - -/* Initialize the index symtab iterator ITER, const char *NAME variant. */ - -static void -dw2_symtab_iter_init (struct dw2_symtab_iterator *iter, - dwarf2_per_objfile *per_objfile, - gdb::optional block_index, - domain_enum domain, - const char *name) -{ - dw2_symtab_iter_init_common (iter, per_objfile, block_index, domain); - - mapped_index *index = per_objfile->per_bfd->index_table.get (); - /* index is NULL if OBJF_READNOW. */ - if (index == NULL) - return; - - if (find_slot_in_mapped_hash (index, name, &iter->vec)) - iter->length = MAYBE_SWAP (*iter->vec); -} - -/* 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, - gdb::optional block_index, - domain_enum domain, offset_type namei) -{ - dw2_symtab_iter_init_common (iter, per_objfile, block_index, domain); mapped_index *index = per_objfile->per_bfd->index_table.get (); /* index is NULL if OBJF_READNOW. */ @@ -3604,22 +3505,6 @@ dwarf2_gdb_index::dump (struct objfile *objfile) printf_filtered ("\n"); } -void -dwarf2_gdb_index::expand_symtabs_for_function (struct objfile *objfile, - const char *func_name) -{ - dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile); - - struct dw2_symtab_iterator iter; - struct dwarf2_per_cu_data *per_cu; - - dw2_symtab_iter_init (&iter, per_objfile, {}, VAR_DOMAIN, func_name); - - while ((per_cu = dw2_symtab_iter_next (&iter)) != NULL) - dw2_instantiate_symtab (per_cu, per_objfile, false); - -} - void dwarf2_base_index_functions::expand_all_symtabs (struct objfile *objfile) { @@ -5660,29 +5545,6 @@ dwarf2_debug_names_index::dump (struct objfile *objfile) printf_filtered ("\n"); } -void -dwarf2_debug_names_index::expand_symtabs_for_function - (struct objfile *objfile, const char *func_name) -{ - dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile); - - /* per_objfile->per_bfd->debug_names_table is NULL if OBJF_READNOW. */ - if (per_objfile->per_bfd->debug_names_table) - { - const mapped_debug_names &map = *per_objfile->per_bfd->debug_names_table; - - dw2_debug_names_iterator iter (map, - (SEARCH_GLOBAL_BLOCK - | SEARCH_STATIC_BLOCK), - VAR_DOMAIN, func_name, - per_objfile); - - struct dwarf2_per_cu_data *per_cu; - while ((per_cu = iter.next ()) != NULL) - dw2_instantiate_symtab (per_cu, per_objfile, false); - } -} - void dwarf2_debug_names_index::map_matching_symbols (struct objfile *objfile, diff --git a/gdb/objfiles.h b/gdb/objfiles.h index cff1d8afbde..64cfca41f15 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -606,7 +606,8 @@ public: /* See quick_symbol_functions. */ void dump (); - /* See quick_symbol_functions. */ + /* Find all the symbols in OBJFILE named FUNC_NAME, and ensure that + the corresponding symbol tables are loaded. */ void expand_symtabs_for_function (const char *func_name); /* See quick_symbol_functions. */ diff --git a/gdb/psympriv.h b/gdb/psympriv.h index 3c174472d30..4bd6decfaa4 100644 --- a/gdb/psympriv.h +++ b/gdb/psympriv.h @@ -516,9 +516,6 @@ struct psymbol_functions : public quick_symbol_functions void dump (struct objfile *objfile) override; - void expand_symtabs_for_function (struct objfile *objfile, - const char *func_name) override; - void expand_all_symtabs (struct objfile *objfile) override; void expand_symtabs_with_fullname (struct objfile *objfile, diff --git a/gdb/psymtab.c b/gdb/psymtab.c index be523a7ded0..8afeeb39fb7 100644 --- a/gdb/psymtab.c +++ b/gdb/psymtab.c @@ -892,29 +892,6 @@ psymbol_functions::dump (struct objfile *objfile) } } -/* Psymtab version of expand_symtabs_for_function. See its definition in - the definition of quick_symbol_functions in symfile.h. */ - -void -psymbol_functions::expand_symtabs_for_function (struct objfile *objfile, - const char *func_name) -{ - lookup_name_info base_lookup (func_name, symbol_name_match_type::FULL); - lookup_name_info lookup_name = base_lookup.make_ignore_params (); - - for (partial_symtab *ps : require_partial_symbols (objfile)) - { - if (ps->readin_p (objfile)) - continue; - - if ((lookup_partial_symbol (objfile, ps, lookup_name, 1, VAR_DOMAIN) - != NULL) - || (lookup_partial_symbol (objfile, ps, lookup_name, 0, VAR_DOMAIN) - != NULL)) - psymtab_to_symtab (objfile, ps); - } -} - /* Psymtab version of expand_all_symtabs. See its definition in the definition of quick_symbol_functions in symfile.h. */ diff --git a/gdb/quick-symbol.h b/gdb/quick-symbol.h index 63aba60bb9a..1aa02e9ff4c 100644 --- a/gdb/quick-symbol.h +++ b/gdb/quick-symbol.h @@ -116,11 +116,6 @@ struct quick_symbol_functions gdb_stdout. This is used for "maint print objfiles". */ virtual void dump (struct objfile *objfile) = 0; - /* Find all the symbols in OBJFILE named FUNC_NAME, and ensure that - the corresponding symbol tables are loaded. */ - virtual void expand_symtabs_for_function (struct objfile *objfile, - const char *func_name) = 0; - /* Read all symbol tables associated with OBJFILE. */ virtual void expand_all_symtabs (struct objfile *objfile) = 0; diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c index cc31fc0b42c..deabea4737c 100644 --- a/gdb/symfile-debug.c +++ b/gdb/symfile-debug.c @@ -300,8 +300,19 @@ objfile::expand_symtabs_for_function (const char *func_name) "qf->expand_symtabs_for_function (%s, \"%s\")\n", objfile_debug_name (this), func_name); + lookup_name_info base_lookup (func_name, symbol_name_match_type::FULL); + lookup_name_info lookup_name = base_lookup.make_ignore_params (); + for (const auto &iter : qf) - iter->expand_symtabs_for_function (this, func_name); + iter->expand_symtabs_matching (this, + nullptr, + &lookup_name, + nullptr, + nullptr, + (SEARCH_GLOBAL_BLOCK + | SEARCH_STATIC_BLOCK), + VAR_DOMAIN, + ALL_DOMAIN); } void -- 2.30.2