From: Jan Vrany <jan.vrany@labware.com>
To: gdb-patches@sourceware.org
Cc: Jan Vrany <jan.vrany@labware.com>
Subject: [PATCH v2 01/13] gdb: reimplement readnow_functions::search
Date: Mon, 24 Nov 2025 19:55:23 +0000 [thread overview]
Message-ID: <20251124195535.2116845-2-jan.vrany@labware.com> (raw)
In-Reply-To: <20251124195535.2116845-1-jan.vrany@labware.com>
This commit reimplements readnow_functions::search without using DWARF
data structures. This will allow readnow_functions to be used in other
cases, for example in JIT reader.
I was bit surprised to realize that original code did not use lookup_name
to match symbols at all, and this calling listener with more CUs than
needed. I did try to use it as described in the comment but run into
issues (test failures) when completing symbols so I decided not to.
With this change, running all tests with -readnow shown no regressions
(on my Debian, x86_64 machine).
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33554
---
gdb/dwarf2/read.c | 49 +++++++++++++++++++++++++++++++----------------
1 file changed, 32 insertions(+), 17 deletions(-)
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index b34c3463774..561e2dc2add 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -1546,26 +1546,41 @@ struct readnow_functions : public dwarf2_base_index_functions
domain_search_flags domain,
search_symtabs_lang_matcher lang_matcher) override
{
- dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
- auto_bool_vector cus_to_skip;
- dw_search_file_matcher (per_objfile, cus_to_skip, file_matcher);
+ /* This invariant is documented in quick-functions.h. */
+ gdb_assert (lookup_name != nullptr || symbol_matcher == nullptr);
- for (const auto &per_cu : per_objfile->per_bfd->all_units)
+ for (compunit_symtab &cu : objfile->compunits ())
{
- QUIT;
-
- /* Skip various types of unit that should not be searched
- directly: partial units and dummy units. */
- if (/* Note that we request the non-strict unit type here. If
- there was an error while reading, like in
- dw-form-strx-out-of-bounds.exp, then the unit type may
- not be set. */
- per_cu->unit_type (false) == DW_UT_partial
- || per_cu->unit_type (false) == 0
- || per_objfile->get_symtab (per_cu.get ()) == nullptr)
+ if (lang_matcher != nullptr && !lang_matcher (cu.language ()))
continue;
- if (!dw2_search_one (per_cu.get (), per_objfile, cus_to_skip,
- file_matcher, listener, lang_matcher))
+
+ if (file_matcher != nullptr)
+ {
+ bool matched = false;
+ for (auto st : cu.filetabs ())
+ {
+ if (file_matcher (st->filename (), false))
+ {
+ matched = true;
+ break;
+ }
+ if ((basenames_may_differ
+ || file_matcher (lbasename (st->filename ()), true))
+ && file_matcher (symtab_to_fullname (st), false))
+ {
+ matched = true;
+ break;
+ }
+ }
+ if (!matched)
+ continue;
+ }
+
+ /* Here we simply call the listener (if any) without bothering to
+ consult lookup_name and symbol_matcher (if any). This should be
+ okay since i) all symtabs are already expanded and ii) listeners
+ iterate over matching symbols themselves. */
+ if (listener != nullptr && !listener (&cu))
return false;
}
return true;
--
2.51.0
next prev parent reply other threads:[~2025-11-24 19:58 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-24 19:55 [PATCH v2 00/13] reimplement readnow_functions Jan Vrany
2025-11-24 19:55 ` Jan Vrany [this message]
2025-12-02 17:25 ` [PATCH v2 01/13] gdb: reimplement readnow_functions::search Tom Tromey
2025-11-24 19:55 ` [PATCH v2 02/13] gdb: implement readnow_functions::has_symbols Jan Vrany
2025-11-24 19:55 ` [PATCH v2 03/13] gdb: implement readnow_functions::has_unexpanded_symtabs Jan Vrany
2025-11-24 19:55 ` [PATCH v2 04/13] gdb: implement readnow_functions::find_last_source_symtab Jan Vrany
2025-11-24 19:55 ` [PATCH v2 05/13] gdb: implement readnow_functions::forget_cached_source_info Jan Vrany
2025-11-24 19:55 ` [PATCH v2 06/13] gdb: implement readnow_functions::lookup_global_symbol_language Jan Vrany
2025-11-24 19:55 ` [PATCH v2 07/13] gdb: implement readnow_functions::print_stats Jan Vrany
2025-11-24 19:55 ` [PATCH v2 08/13] gdb: implement readnow_functions::expand_all_symtabs Jan Vrany
2025-11-24 19:55 ` [PATCH v2 09/13] gdb: implement readnow_functions::find_pc_sect_compunit_symtab Jan Vrany
2025-11-24 19:55 ` [PATCH v2 10/13] gdb: implement readnow_functions::map_symbol_filenames Jan Vrany
2025-11-24 19:55 ` [PATCH v2 11/13] gdb: make readnow_functions to inherit from quick_symbol_functions Jan Vrany
2025-11-24 19:55 ` [PATCH v2 12/13] gdb/testsuite: fix few tests after change in readnow_functions Jan Vrany
2025-12-02 17:26 ` Tom Tromey
2025-11-24 19:55 ` [PATCH v2 13/13] gdb: update message in symbol_file_add_with_addrs after changes " Jan Vrany
2025-12-02 17:29 ` Tom Tromey
2025-12-02 18:48 ` Jan Vraný
2025-12-02 18:57 ` Tom Tromey
2025-12-02 19:03 ` Tom Tromey
2025-12-03 17:46 ` Jan Vraný
2025-12-02 13:39 ` [PATCH v2 00/13] reimplement readnow_functions Jan Vraný
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251124195535.2116845-2-jan.vrany@labware.com \
--to=jan.vrany@labware.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox