[binutils-gdb] Have iterate_over_one_compunit_symtab search included symtabs
Tom Tromey via Gdb-cvs <[email protected]>
| Newsgroups | gmane.comp.gdb.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=49042895f01ef96f63300f6d4f6e5ddf62ac84a8 commit 49042895f01ef96f63300f6d4f6e5ddf62ac84a8 Author: Tom Tromey <[email protected]> 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 <[email protected]> Approved-By: Simon Marchi <[email protected]> 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)