[binutils-gdb] Have iterate_over_one_compunit_symtab search included symtabs
Tom Tromey
tromey@sourceware.org
Tue Apr 7 19:28:21 GMT 2026
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=49042895f01ef96f63300f6d4f6e5ddf62ac84a8
commit 49042895f01ef96f63300f6d4f6e5ddf62ac84a8
Author: Tom Tromey <tom@tromey.com>
Date: Sat Jan 24 14:56:10 2026 -0700
Have iterate_over_one_compunit_symtab search included symtabs
A latent bug in the search-via-psyms series was that it neglected to
update iterate_over_one_compunit_symtab to search included symtabs.
I think lookups that needed this search used to work by accident -- an
included CU would be expanded but not searched, but a search of all
compunits() would then find it.
This patch corrects the oversight. I'm not sure if this bug is
readily visible without the next patch.
Acked-By: Tom de Vries <tdevries@suse.de>
Approved-By: Simon Marchi <simark@simark.ca>
Diff:
---
gdb/symfile-debug.c | 23 ++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c
index 6562dcad433..2c9deba20ae 100644
--- a/gdb/symfile-debug.c
+++ b/gdb/symfile-debug.c
@@ -171,17 +171,12 @@ objfile::forget_cached_source_info ()
the specified compunit symtab is also searched. */
static bool
-iterate_over_one_compunit_symtab (const char *name,
+iterate_over_one_compunit_symtab (const char *base_name,
+ const char *name,
const char *real_path,
compunit_symtab *cust,
gdb::function_view<bool (symtab *)> callback)
{
- const char *base_name = lbasename (name);
-
- /* Skip included compunits. */
- if (cust->user != nullptr)
- return false;
-
for (symtab *s : cust->filetabs ())
{
if (compare_filenames_for_search (s->filename (), name))
@@ -224,6 +219,11 @@ iterate_over_one_compunit_symtab (const char *name,
}
}
+ for (compunit_symtab *iter : cust->includes)
+ if (iterate_over_one_compunit_symtab (base_name, name, real_path,
+ iter, callback))
+ return true;
+
return false;
}
@@ -257,10 +257,15 @@ objfile::map_symtabs_matching_filename
auto listener = [&] (compunit_symtab *symtab)
{
+ /* Skip included compunits, as they are searched by
+ iterate_over_one_compunit_symtab. */
+ if (symtab->user != nullptr)
+ return true;
+
/* CALLBACK returns false to keep going and true to continue, so
we have to invert the result here, for search. */
- return !iterate_over_one_compunit_symtab (name, real_path, symtab,
- callback);
+ return !iterate_over_one_compunit_symtab (name_basename, name, real_path,
+ symtab, callback);
};
for (const auto &iter : qf)
More information about the Gdb-cvs
mailing list