aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2021-04-17 09:35:04 -0600
committerTom Tromey <tom@tromey.com>2021-04-17 09:35:06 -0600
commit7089bd886ec78d623c3188cac48c039bc5eaf3b6 (patch)
tree30a968c0059567e8b15a36a2f9459883aebd6a95 /gdb
parent536a40f3a8d2c18aae18a9137b838ff2accdfc08 (diff)
downloadfsf-binutils-gdb-7089bd886ec78d623c3188cac48c039bc5eaf3b6.zip
fsf-binutils-gdb-7089bd886ec78d623c3188cac48c039bc5eaf3b6.tar.gz
fsf-binutils-gdb-7089bd886ec78d623c3188cac48c039bc5eaf3b6.tar.bz2
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 <tom@tromey.com> * symfile-debug.c (objfile::expand_symtabs_for_function): Rewrite. * quick-symbol.h (struct quick_symbol_functions) <expand_symtabs_for_function>: Remove. * psymtab.c (psymbol_functions::expand_symtabs_for_function): Remove. * psympriv.h (struct psymbol_functions) <expand_symtabs_for_function>: Remove. * objfiles.h (struct objfile) <expand_symtabs_for_function>: Update comment. * dwarf2/read.c (struct dwarf2_gdb_index) <expand_symtabs_for_function>: Remove. (struct dwarf2_debug_names_index) <expand_symtabs_for_function>: 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.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog22
-rw-r--r--gdb/dwarf2/read.c148
-rw-r--r--gdb/objfiles.h3
-rw-r--r--gdb/psympriv.h3
-rw-r--r--gdb/psymtab.c23
-rw-r--r--gdb/quick-symbol.h5
-rw-r--r--gdb/symfile-debug.c13
7 files changed, 41 insertions, 176 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 78e7795..88e8790 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,27 @@
2021-04-17 Tom Tromey <tom@tromey.com>
+ * symfile-debug.c (objfile::expand_symtabs_for_function):
+ Rewrite.
+ * quick-symbol.h (struct quick_symbol_functions)
+ <expand_symtabs_for_function>: Remove.
+ * psymtab.c (psymbol_functions::expand_symtabs_for_function):
+ Remove.
+ * psympriv.h (struct psymbol_functions)
+ <expand_symtabs_for_function>: Remove.
+ * objfiles.h (struct objfile) <expand_symtabs_for_function>:
+ Update comment.
+ * dwarf2/read.c (struct dwarf2_gdb_index)
+ <expand_symtabs_for_function>: Remove.
+ (struct dwarf2_debug_names_index) <expand_symtabs_for_function>:
+ 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 <tom@tromey.com>
+
* symfile-debug.c (objfile::map_symtabs_matching_filename):
Rewrite.
* quick-symbol.h (struct quick_symbol_functions)
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 763e416..007b70e 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<char> 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_enum> block_index,
- domain_enum domain)
+dw2_symtab_iter_init (struct dw2_symtab_iterator *iter,
+ dwarf2_per_objfile *per_objfile,
+ gdb::optional<block_enum> 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_enum> 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_enum> 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. */
@@ -3605,22 +3506,6 @@ dwarf2_gdb_index::dump (struct objfile *objfile)
}
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)
{
dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
@@ -5661,29 +5546,6 @@ dwarf2_debug_names_index::dump (struct objfile *objfile)
}
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,
const lookup_name_info &name, domain_enum domain,
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index cff1d8a..64cfca4 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 3c17447..4bd6dec 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 be523a7..8afeeb3 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 63aba60..1aa02e9 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 cc31fc0..deabea4 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