* [PATCH v2 01/13] gdb: reimplement readnow_functions::search
2025-11-24 19:55 [PATCH v2 00/13] reimplement readnow_functions Jan Vrany
@ 2025-11-24 19:55 ` Jan Vrany
2025-12-02 17:25 ` Tom Tromey
2025-11-24 19:55 ` [PATCH v2 02/13] gdb: implement readnow_functions::has_symbols Jan Vrany
` (12 subsequent siblings)
13 siblings, 1 reply; 22+ messages in thread
From: Jan Vrany @ 2025-11-24 19:55 UTC (permalink / raw)
To: gdb-patches; +Cc: Jan Vrany
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
^ permalink raw reply [flat|nested] 22+ messages in thread* Re: [PATCH v2 01/13] gdb: reimplement readnow_functions::search
2025-11-24 19:55 ` [PATCH v2 01/13] gdb: reimplement readnow_functions::search Jan Vrany
@ 2025-12-02 17:25 ` Tom Tromey
0 siblings, 0 replies; 22+ messages in thread
From: Tom Tromey @ 2025-12-02 17:25 UTC (permalink / raw)
To: Jan Vrany; +Cc: gdb-patches
>>>>> "Jan" == Jan Vrany <jan.vrany@labware.com> writes:
Jan> This commit reimplements readnow_functions::search without using DWARF
Jan> data structures. This will allow readnow_functions to be used in other
Jan> cases, for example in JIT reader.
Jan> I was bit surprised to realize that original code did not use lookup_name
Jan> to match symbols at all, and this calling listener with more CUs than
Jan> needed. I did try to use it as described in the comment but run into
Jan> issues (test failures) when completing symbols so I decided not to.
Jan> With this change, running all tests with -readnow shown no regressions
Jan> (on my Debian, x86_64 machine).
Thanks, this is ok.
Approved-By: Tom Tromey <tom@tromey.com>
Tom
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH v2 02/13] gdb: implement readnow_functions::has_symbols
2025-11-24 19:55 [PATCH v2 00/13] reimplement readnow_functions Jan Vrany
2025-11-24 19:55 ` [PATCH v2 01/13] gdb: reimplement readnow_functions::search Jan Vrany
@ 2025-11-24 19:55 ` Jan Vrany
2025-11-24 19:55 ` [PATCH v2 03/13] gdb: implement readnow_functions::has_unexpanded_symtabs Jan Vrany
` (11 subsequent siblings)
13 siblings, 0 replies; 22+ messages in thread
From: Jan Vrany @ 2025-11-24 19:55 UTC (permalink / raw)
To: gdb-patches; +Cc: Jan Vrany, Tom Tromey
This commit implements readnow_functions::has_symbols
without using DWARF data structures. This will allow readnow_functions
to be used in other cases, for example in JIT reader.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33554
Approved-By: Tom Tromey <tom@tromey.com>
---
gdb/dwarf2/read.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 561e2dc2add..444c0c22b69 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -1533,6 +1533,11 @@ struct quick_file_names
struct readnow_functions : public dwarf2_base_index_functions
{
+ bool has_symbols (struct objfile *objfile) override
+ {
+ return true;
+ }
+
void dump (struct objfile *objfile) override
{
}
--
2.51.0
^ permalink raw reply [flat|nested] 22+ messages in thread* [PATCH v2 03/13] gdb: implement readnow_functions::has_unexpanded_symtabs
2025-11-24 19:55 [PATCH v2 00/13] reimplement readnow_functions Jan Vrany
2025-11-24 19:55 ` [PATCH v2 01/13] gdb: reimplement readnow_functions::search Jan Vrany
2025-11-24 19:55 ` [PATCH v2 02/13] gdb: implement readnow_functions::has_symbols Jan Vrany
@ 2025-11-24 19:55 ` Jan Vrany
2025-11-24 19:55 ` [PATCH v2 04/13] gdb: implement readnow_functions::find_last_source_symtab Jan Vrany
` (10 subsequent siblings)
13 siblings, 0 replies; 22+ messages in thread
From: Jan Vrany @ 2025-11-24 19:55 UTC (permalink / raw)
To: gdb-patches; +Cc: Jan Vrany, Tom Tromey
This commit implements readnow_functions::has_unexpanded_symtabs
without using DWARF data structures. This will allow readnow_functions
to be used in other cases, for example in JIT reader.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33554
Approved-By: Tom Tromey <tom@tromey.com>
---
gdb/dwarf2/read.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 444c0c22b69..bbe531c7ed3 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -1538,6 +1538,11 @@ struct readnow_functions : public dwarf2_base_index_functions
return true;
}
+ bool has_unexpanded_symtabs (struct objfile *objfile) override
+ {
+ return false;
+ }
+
void dump (struct objfile *objfile) override
{
}
--
2.51.0
^ permalink raw reply [flat|nested] 22+ messages in thread* [PATCH v2 04/13] gdb: implement readnow_functions::find_last_source_symtab
2025-11-24 19:55 [PATCH v2 00/13] reimplement readnow_functions Jan Vrany
` (2 preceding siblings ...)
2025-11-24 19:55 ` [PATCH v2 03/13] gdb: implement readnow_functions::has_unexpanded_symtabs Jan Vrany
@ 2025-11-24 19:55 ` Jan Vrany
2025-11-24 19:55 ` [PATCH v2 05/13] gdb: implement readnow_functions::forget_cached_source_info Jan Vrany
` (9 subsequent siblings)
13 siblings, 0 replies; 22+ messages in thread
From: Jan Vrany @ 2025-11-24 19:55 UTC (permalink / raw)
To: gdb-patches; +Cc: Jan Vrany, Tom Tromey
This commit implements readnow_functions::has_unexpanded_symtabs
without using DWARF data structures. This will allow readnow_functions
to be used in other cases, for example in JIT reader.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33554
Approved-By: Tom Tromey <tom@tromey.com>
---
gdb/dwarf2/read.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index bbe531c7ed3..e408f852dc0 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -1543,6 +1543,14 @@ struct readnow_functions : public dwarf2_base_index_functions
return false;
}
+ struct symtab *find_last_source_symtab (struct objfile *objfile) override
+ {
+ if (objfile->compunit_symtabs.empty ())
+ return nullptr;
+ else
+ return objfile->compunit_symtabs.back ().primary_filetab ();
+ }
+
void dump (struct objfile *objfile) override
{
}
--
2.51.0
^ permalink raw reply [flat|nested] 22+ messages in thread* [PATCH v2 05/13] gdb: implement readnow_functions::forget_cached_source_info
2025-11-24 19:55 [PATCH v2 00/13] reimplement readnow_functions Jan Vrany
` (3 preceding siblings ...)
2025-11-24 19:55 ` [PATCH v2 04/13] gdb: implement readnow_functions::find_last_source_symtab Jan Vrany
@ 2025-11-24 19:55 ` Jan Vrany
2025-11-24 19:55 ` [PATCH v2 06/13] gdb: implement readnow_functions::lookup_global_symbol_language Jan Vrany
` (8 subsequent siblings)
13 siblings, 0 replies; 22+ messages in thread
From: Jan Vrany @ 2025-11-24 19:55 UTC (permalink / raw)
To: gdb-patches; +Cc: Jan Vrany, Tom Tromey
This commit implements readnow_functions::forget_cached_source_info
without using DWARF data structures. This will allow readnow_functions
to be used in other cases, for example in JIT reader.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33554
Approved-By: Tom Tromey <tom@tromey.com>
---
gdb/dwarf2/read.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index e408f852dc0..172f491ab9c 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -1551,6 +1551,10 @@ struct readnow_functions : public dwarf2_base_index_functions
return objfile->compunit_symtabs.back ().primary_filetab ();
}
+ void forget_cached_source_info (struct objfile *objfile) override
+ {
+ }
+
void dump (struct objfile *objfile) override
{
}
--
2.51.0
^ permalink raw reply [flat|nested] 22+ messages in thread* [PATCH v2 06/13] gdb: implement readnow_functions::lookup_global_symbol_language
2025-11-24 19:55 [PATCH v2 00/13] reimplement readnow_functions Jan Vrany
` (4 preceding siblings ...)
2025-11-24 19:55 ` [PATCH v2 05/13] gdb: implement readnow_functions::forget_cached_source_info Jan Vrany
@ 2025-11-24 19:55 ` Jan Vrany
2025-11-24 19:55 ` [PATCH v2 07/13] gdb: implement readnow_functions::print_stats Jan Vrany
` (7 subsequent siblings)
13 siblings, 0 replies; 22+ messages in thread
From: Jan Vrany @ 2025-11-24 19:55 UTC (permalink / raw)
To: gdb-patches; +Cc: Jan Vrany, Tom Tromey
This commit implements readnow_functions::lookup_global_symbol_language
without using DWARF data structures. This will allow readnow_functions
to be used in other cases, for example in JIT reader.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33554
Approved-By: Tom Tromey <tom@tromey.com>
---
gdb/dwarf2/read.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 172f491ab9c..46ecbffd7fd 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -1555,6 +1555,15 @@ struct readnow_functions : public dwarf2_base_index_functions
{
}
+ enum language lookup_global_symbol_language (struct objfile *objfile,
+ const char *name,
+ domain_search_flags domain,
+ bool *symbol_found_p) override
+ {
+ *symbol_found_p = false;
+ return language_unknown;
+ }
+
void dump (struct objfile *objfile) override
{
}
--
2.51.0
^ permalink raw reply [flat|nested] 22+ messages in thread* [PATCH v2 07/13] gdb: implement readnow_functions::print_stats
2025-11-24 19:55 [PATCH v2 00/13] reimplement readnow_functions Jan Vrany
` (5 preceding siblings ...)
2025-11-24 19:55 ` [PATCH v2 06/13] gdb: implement readnow_functions::lookup_global_symbol_language Jan Vrany
@ 2025-11-24 19:55 ` Jan Vrany
2025-11-24 19:55 ` [PATCH v2 08/13] gdb: implement readnow_functions::expand_all_symtabs Jan Vrany
` (6 subsequent siblings)
13 siblings, 0 replies; 22+ messages in thread
From: Jan Vrany @ 2025-11-24 19:55 UTC (permalink / raw)
To: gdb-patches; +Cc: Jan Vrany, Tom Tromey
This commit implements readnow_functions::print_stats
without using DWARF data structures. This will allow readnow_functions
to be used in other cases, for example in JIT reader.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33554
Approved-By: Tom Tromey <tom@tromey.com>
---
gdb/dwarf2/read.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 46ecbffd7fd..471496bd4be 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -1564,6 +1564,10 @@ struct readnow_functions : public dwarf2_base_index_functions
return language_unknown;
}
+ void print_stats (struct objfile *objfile, bool print_bcache) override
+ {
+ }
+
void dump (struct objfile *objfile) override
{
}
--
2.51.0
^ permalink raw reply [flat|nested] 22+ messages in thread* [PATCH v2 08/13] gdb: implement readnow_functions::expand_all_symtabs
2025-11-24 19:55 [PATCH v2 00/13] reimplement readnow_functions Jan Vrany
` (6 preceding siblings ...)
2025-11-24 19:55 ` [PATCH v2 07/13] gdb: implement readnow_functions::print_stats Jan Vrany
@ 2025-11-24 19:55 ` Jan Vrany
2025-11-24 19:55 ` [PATCH v2 09/13] gdb: implement readnow_functions::find_pc_sect_compunit_symtab Jan Vrany
` (5 subsequent siblings)
13 siblings, 0 replies; 22+ messages in thread
From: Jan Vrany @ 2025-11-24 19:55 UTC (permalink / raw)
To: gdb-patches; +Cc: Jan Vrany, Tom Tromey
This commit implements readnow_functions::expand_all_symtabs as empty.
This will allow readnow_functions to be used in other cases, for example
in JIT reader.
Prior this code CUs were instantiated by calling objfile::expand_all_symtabs
(which in turn call dwarf2_base_index_functions::expand_all_symtabs)
from symbol_file_add_with_addrs right after the call to syms_from_objfile
(which in turn calls dwarf2_initialize_objfile).
Since now readnow_functions defines its own, empty expand_all_symtabs,
CUs are instantiated earlier in dwarf2_initialize_objfile. This seemed
like a good place because this function actually installs readnow_functions
into the objfile.
Testing on my machine with -readnow shown no regression.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33554
Approved-By: Tom Tromey <tom@tromey.com>
---
gdb/dwarf2/read.c | 35 ++++++++++++++++++++++++-----------
1 file changed, 24 insertions(+), 11 deletions(-)
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 471496bd4be..89e06923320 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -1572,6 +1572,10 @@ struct readnow_functions : public dwarf2_base_index_functions
{
}
+ void expand_all_symtabs (struct objfile *objfile) override
+ {
+ }
+
bool search (struct objfile *objfile,
search_symtabs_file_matcher file_matcher,
const lookup_name_info *lookup_name,
@@ -1748,6 +1752,24 @@ dw2_instantiate_symtab (dwarf2_per_cu *per_cu, dwarf2_per_objfile *per_objfile,
return per_objfile->get_symtab (per_cu);
}
+
+/* Ensure that the symbols for all CUs have been read in. DWARF2_PER_OBJFILE
+ is the per-objfile for which CUs are instantiated. */
+
+static void
+dw2_instantiate_all_symtabs (dwarf2_per_objfile *per_objfile)
+{
+ for (dwarf2_per_cu *per_cu : all_units_range (per_objfile->per_bfd))
+ {
+ /* We don't want to directly expand a partial CU, because if we
+ read it with the wrong language, then assertion failures can
+ be triggered later on. See PR symtab/23010. So, tell
+ dw2_instantiate_symtab to skip partial CUs -- any important
+ partial CU will be read via DW_TAG_imported_unit anyway. */
+ dw2_instantiate_symtab (per_cu, per_objfile, true);
+ }
+}
+
/* See read.h. */
dwarf2_per_cu_up
@@ -2051,17 +2073,7 @@ dwarf2_base_index_functions::print_stats (struct objfile *objfile,
void
dwarf2_base_index_functions::expand_all_symtabs (struct objfile *objfile)
{
- dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
-
- for (dwarf2_per_cu *per_cu : all_units_range (per_objfile->per_bfd))
- {
- /* We don't want to directly expand a partial CU, because if we
- read it with the wrong language, then assertion failures can
- be triggered later on. See PR symtab/23010. So, tell
- dw2_instantiate_symtab to skip partial CUs -- any important
- partial CU will be read via DW_TAG_imported_unit anyway. */
- dw2_instantiate_symtab (per_cu, per_objfile, true);
- }
+ dw2_instantiate_all_symtabs (get_dwarf2_per_objfile (objfile));
}
/* If FILE_MATCHER is NULL and if CUS_TO_SKIP does not include the
@@ -2441,6 +2453,7 @@ dwarf2_initialize_objfile (struct objfile *objfile,
dwarf_read_debug_printf ("readnow requested");
create_all_units (per_objfile);
+ dw2_instantiate_all_symtabs (per_objfile);
objfile->qf.emplace_front (new readnow_functions);
}
/* Was a GDB index already read when we processed an objfile sharing
--
2.51.0
^ permalink raw reply [flat|nested] 22+ messages in thread* [PATCH v2 09/13] gdb: implement readnow_functions::find_pc_sect_compunit_symtab
2025-11-24 19:55 [PATCH v2 00/13] reimplement readnow_functions Jan Vrany
` (7 preceding siblings ...)
2025-11-24 19:55 ` [PATCH v2 08/13] gdb: implement readnow_functions::expand_all_symtabs Jan Vrany
@ 2025-11-24 19:55 ` Jan Vrany
2025-11-24 19:55 ` [PATCH v2 10/13] gdb: implement readnow_functions::map_symbol_filenames Jan Vrany
` (4 subsequent siblings)
13 siblings, 0 replies; 22+ messages in thread
From: Jan Vrany @ 2025-11-24 19:55 UTC (permalink / raw)
To: gdb-patches; +Cc: Jan Vrany
This commit implements readnow_functions::find_pc_sect_compunit_symtab
without using DWARF data structures. This will allow readnow_functions
to be used in other cases, for example in JIT reader.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33554
---
gdb/dwarf2/read.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 89e06923320..0d57a2bd538 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -1625,6 +1625,16 @@ struct readnow_functions : public dwarf2_base_index_functions
return true;
}
+ struct compunit_symtab *find_pc_sect_compunit_symtab
+ (struct objfile *objfile, bound_minimal_symbol msymbol, CORE_ADDR pc,
+ struct obj_section *section, int warn_if_readin) override
+ {
+ /* Simply returning NULL here is okay since the (only) caller
+ find_compunit_symtab_for_pc_sect interates over existing CUs
+ anyway. */
+ return nullptr;
+ }
+
struct symbol *find_symbol_by_address (struct objfile *objfile,
CORE_ADDR address) override
{
--
2.51.0
^ permalink raw reply [flat|nested] 22+ messages in thread* [PATCH v2 10/13] gdb: implement readnow_functions::map_symbol_filenames
2025-11-24 19:55 [PATCH v2 00/13] reimplement readnow_functions Jan Vrany
` (8 preceding siblings ...)
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 ` Jan Vrany
2025-11-24 19:55 ` [PATCH v2 11/13] gdb: make readnow_functions to inherit from quick_symbol_functions Jan Vrany
` (3 subsequent siblings)
13 siblings, 0 replies; 22+ messages in thread
From: Jan Vrany @ 2025-11-24 19:55 UTC (permalink / raw)
To: gdb-patches; +Cc: Jan Vrany, Tom Tromey
This commit implements readnow_functions::map_symbol_filenames
without using DWARF data structures. This will allow readnow_functions
to be used in other cases, for example in JIT reader.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33554
Approved-By: Tom Tromey <tom@tromey.com>
---
gdb/dwarf2/read.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 0d57a2bd538..3516e3de556 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -1647,6 +1647,11 @@ struct readnow_functions : public dwarf2_base_index_functions
return nullptr;
}
+
+ void map_symbol_filenames (objfile *objfile, symbol_filename_listener fun,
+ bool need_fullname) override
+ {
+ }
};
/* See read.h. */
--
2.51.0
^ permalink raw reply [flat|nested] 22+ messages in thread* [PATCH v2 11/13] gdb: make readnow_functions to inherit from quick_symbol_functions
2025-11-24 19:55 [PATCH v2 00/13] reimplement readnow_functions Jan Vrany
` (9 preceding siblings ...)
2025-11-24 19:55 ` [PATCH v2 10/13] gdb: implement readnow_functions::map_symbol_filenames Jan Vrany
@ 2025-11-24 19:55 ` Jan Vrany
2025-11-24 19:55 ` [PATCH v2 12/13] gdb/testsuite: fix few tests after change in readnow_functions Jan Vrany
` (2 subsequent siblings)
13 siblings, 0 replies; 22+ messages in thread
From: Jan Vrany @ 2025-11-24 19:55 UTC (permalink / raw)
To: gdb-patches; +Cc: Jan Vrany, Tom Tromey
This commit makes readnow_functions to inherit directly from abstract
base class quick_symbol_functions since it does not use any of the
DWARF data structures. This will allow readnow_functions to be used in
other cases, for example in JIT reader.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33554
Approved-By: Tom Tromey <tom@tromey.com>
---
gdb/dwarf2/read.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 3516e3de556..7c1640a9d12 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -1531,7 +1531,7 @@ struct quick_file_names
quick symbol functions, to avoid special cases in the rest of the
code. */
-struct readnow_functions : public dwarf2_base_index_functions
+struct readnow_functions : public quick_symbol_functions
{
bool has_symbols (struct objfile *objfile) override
{
--
2.51.0
^ permalink raw reply [flat|nested] 22+ messages in thread* [PATCH v2 12/13] gdb/testsuite: fix few tests after change in readnow_functions
2025-11-24 19:55 [PATCH v2 00/13] reimplement readnow_functions Jan Vrany
` (10 preceding siblings ...)
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 ` 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 13:39 ` [PATCH v2 00/13] reimplement readnow_functions Jan Vraný
13 siblings, 1 reply; 22+ messages in thread
From: Jan Vrany @ 2025-11-24 19:55 UTC (permalink / raw)
To: gdb-patches; +Cc: Jan Vrany
When loading a file with -readnow, GDB prints message like:
Reading symbols from some_program...
Expanding full symbols from some_program...
Commit "gdb: implement readnow_functions::expand_all_symtabs" caused
slight in output when there are any "complaints" - since after this
change, CUs are instantiated before call to expand_all_symtabs and
therefore "complaits" are printed before "Expanding full symbols...",
breaking dw2-zero-range.exp, build-id-no-debug-warning.exp and
crc_mismatch.exp
This commit fixes the issue by allowing "complaint" occur either in
between "Reading ..." and "Expanding ..." messages (currently the case
of DWARF and -readnow) or after "Expanding ..." message (the case without
-readnow).
---
.../gdb.debuginfod/build-id-no-debug-warning.exp | 10 ++++++----
gdb/testsuite/gdb.debuginfod/crc_mismatch.exp | 10 ++++++----
gdb/testsuite/gdb.dwarf2/dw2-zero-range.exp | 10 ++++++++++
3 files changed, 22 insertions(+), 8 deletions(-)
diff --git a/gdb/testsuite/gdb.debuginfod/build-id-no-debug-warning.exp b/gdb/testsuite/gdb.debuginfod/build-id-no-debug-warning.exp
index 7a0cfda627c..e56538f721d 100644
--- a/gdb/testsuite/gdb.debuginfod/build-id-no-debug-warning.exp
+++ b/gdb/testsuite/gdb.debuginfod/build-id-no-debug-warning.exp
@@ -79,10 +79,11 @@ gdb_test_no_output "set debug-file-directory ${debug_file_directory}" \
# Now load the file into GDB, and look for the warning.
set debug_file_re [string_to_regexp $build_id_debug_file]
+set expanding_re "\r\nExpanding full symbols from $debug_file_re\\.\\.\\."
gdb_test "file ${build_id_debug_file}" \
[multi_line \
- "Reading symbols from $debug_file_re\\.\\.\\." \
- "warning: \"$debug_file_re\": separate debug info file has no debug info" \
+ "Reading symbols from $debug_file_re\\.\\.\\.($expanding_re)?" \
+ "warning: \"$debug_file_re\": separate debug info file has no debug info($expanding_re)?" \
"\\(No debugging symbols found in \[^\r\n\]+\\)"] \
"load test file, expect a warning"
@@ -97,11 +98,12 @@ with_test_prefix "check styling" {
# Now load the file into GDB, and look for the warning.
set debug_file_re [style [string_to_regexp $build_id_debug_file] file]
+ set expanding_re "\r\nExpanding full symbols from $debug_file_re\\.\\.\\."
gdb_test "file ${build_id_debug_file}" \
[multi_line \
- "Reading symbols from $debug_file_re\\.\\.\\." \
- "warning: \"$debug_file_re\": separate debug info file has no debug info" \
+ "Reading symbols from $debug_file_re\\.\\.\\.($expanding_re)?" \
+ "warning: \"$debug_file_re\": separate debug info file has no debug info($expanding_re)?" \
"\\(No debugging symbols found in \[^\r\n\]+\\)"] \
"load test file, expect a warning"
}
diff --git a/gdb/testsuite/gdb.debuginfod/crc_mismatch.exp b/gdb/testsuite/gdb.debuginfod/crc_mismatch.exp
index e44748f8205..2771d333d46 100644
--- a/gdb/testsuite/gdb.debuginfod/crc_mismatch.exp
+++ b/gdb/testsuite/gdb.debuginfod/crc_mismatch.exp
@@ -47,6 +47,8 @@ remote_exec build "mkdir $debugdir"
remote_exec build "mkdir -p [file dirname $debugfile]"
remote_exec build "mv -f [standard_output_file ${testfile}.debug] $debugfile"
+set expanding_re "\r\nExpanding full symbols from .+\\.\\.\\."
+
# Test CRC mismatch is reported.
if {[build_executable crc_mismatch.exp crc_mismatch-2 crc_mismatch-2.c debug] != -1
&& ![gdb_gnu_strip_debug [standard_output_file crc_mismatch-2]]} {
@@ -63,8 +65,8 @@ if {[build_executable crc_mismatch.exp crc_mismatch-2 crc_mismatch-2.c debug] !=
set escapedobjdirsubdir [string_to_regexp [standard_output_file {}]]
gdb_test "file [standard_output_file crc_mismatch-2]" \
[multi_line \
- "Reading symbols from ${escapedobjdirsubdir}/crc_mismatch-2\\.\\.\\." \
- "warning: the debug information found in \"${escapedobjdirsubdir}/crc_mismatch-2\\.debug\" does not match \"${escapedobjdirsubdir}/crc_mismatch-2\" \\(CRC mismatch\\)\\." \
+ "Reading symbols from ${escapedobjdirsubdir}/crc_mismatch-2\\.\\.\\.($expanding_re)?" \
+ "warning: the debug information found in \"${escapedobjdirsubdir}/crc_mismatch-2\\.debug\" does not match \"${escapedobjdirsubdir}/crc_mismatch-2\" \\(CRC mismatch\\)\\.($expanding_re)?" \
"\\(No debugging symbols found in .*\\)"] \
"CRC mismatch is reported"
@@ -79,8 +81,8 @@ if {[build_executable crc_mismatch.exp crc_mismatch-2 crc_mismatch-2.c debug] !=
gdb_test "file [standard_output_file crc_mismatch-2]" \
[multi_line \
- "Reading symbols from ${exe_file_re}\\.\\.\\." \
- "warning: the debug information found in \"${debug_file_re}\" does not match \"${exe_file_re}\" \\(CRC mismatch\\)\\." \
+ "Reading symbols from ${exe_file_re}\\.\\.\\.($expanding_re)?" \
+ "warning: the debug information found in \"${debug_file_re}\" does not match \"${exe_file_re}\" \\(CRC mismatch\\)\\.($expanding_re)?" \
"\\(No debugging symbols found in \[^\r\n\]+\\)"] \
"CRC mismatch is reported"
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-zero-range.exp b/gdb/testsuite/gdb.dwarf2/dw2-zero-range.exp
index d5faf6f74d0..79e48b24af1 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-zero-range.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-zero-range.exp
@@ -164,6 +164,16 @@ foreach_with_prefix ranges_sect {ranges rnglists} {
set complaint_re ".debug_${ranges_sect} entry has start address of zero"
set complaint_re \
"During symbol reading: $complaint_re \\\[in module \[^\r\n\]*\\\]"
+ # Complaints may be printed before or after message
+ #
+ # Expanding full symbols from ...
+ #
+ # or
+ #
+ # Expanded full symbols from ...
+ #
+ set complaint_re \
+ "${complaint_re}(\r\nExpanding full .*)?"
set readnow_p [readnow]
--
2.51.0
^ permalink raw reply [flat|nested] 22+ messages in thread* Re: [PATCH v2 12/13] gdb/testsuite: fix few tests after change in readnow_functions
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
0 siblings, 0 replies; 22+ messages in thread
From: Tom Tromey @ 2025-12-02 17:26 UTC (permalink / raw)
To: Jan Vrany; +Cc: gdb-patches
>>>>> "Jan" == Jan Vrany <jan.vrany@labware.com> writes:
Jan> When loading a file with -readnow, GDB prints message like:
Jan> Reading symbols from some_program...
Jan> Expanding full symbols from some_program...
Jan> Commit "gdb: implement readnow_functions::expand_all_symtabs" caused
Jan> slight in output when there are any "complaints" - since after this
Jan> change, CUs are instantiated before call to expand_all_symtabs and
Jan> therefore "complaits" are printed before "Expanding full symbols...",
Jan> breaking dw2-zero-range.exp, build-id-no-debug-warning.exp and
Jan> crc_mismatch.exp
If a previous patch causes a regression, then the test updates should be
included in that patch. The reason is that we generally try to make
patch series bisectable -- obviously this can't always be done perfectly
but it's still good when we know in advance that a patch causes a fail.
Tom
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH v2 13/13] gdb: update message in symbol_file_add_with_addrs after changes in readnow_functions
2025-11-24 19:55 [PATCH v2 00/13] reimplement readnow_functions Jan Vrany
` (11 preceding siblings ...)
2025-11-24 19:55 ` [PATCH v2 12/13] gdb/testsuite: fix few tests after change in readnow_functions Jan Vrany
@ 2025-11-24 19:55 ` Jan Vrany
2025-12-02 17:29 ` Tom Tromey
2025-12-02 13:39 ` [PATCH v2 00/13] reimplement readnow_functions Jan Vraný
13 siblings, 1 reply; 22+ messages in thread
From: Jan Vrany @ 2025-11-24 19:55 UTC (permalink / raw)
To: gdb-patches; +Cc: Jan Vrany
When loading a file with -readnow, GDB prints message like:
Reading symbols from some_program...
Expanding full symbols from some_program...
I assume the reason for the second message ("Expanding ...") is to let
the user know what's happening as symbol expansion may take time.
However after commit "gdb: implement readnow_functions::expand_all_symtabs"
no actual work is done in expand_all_symtabs (for objfiles with DWARF
info at least) so printing "Expanding full..." felt bit odd.
This commit therefore checks if there are any unexpanded CUs and if
so, prints "Expanding full..." message as before. If all CUs are already
expanded, say just "Expanded full...".
This commit also updates a number of tests to accommodate this change.
This is user-facing change.
---
gdb/symfile.c | 17 +++++++++++++----
gdb/testsuite/gdb.base/bfd-errors.exp | 2 +-
gdb/testsuite/gdb.base/cached-source-file.exp | 2 +-
gdb/testsuite/gdb.base/code_elim.exp | 10 +++++-----
gdb/testsuite/gdb.base/relocate.exp | 12 ++++++------
gdb/testsuite/gdb.base/style.exp | 2 +-
gdb/testsuite/gdb.base/sym-file.exp | 4 ++--
gdb/testsuite/gdb.cp/cp-relocate.exp | 2 +-
.../build-id-no-debug-warning.exp | 6 +++---
gdb/testsuite/gdb.debuginfod/crc_mismatch.exp | 4 ++--
gdb/testsuite/gdb.dwarf2/dw2-missing-cu-tag.exp | 2 +-
.../gdb.dwarf2/dw2-objfile-overlap.exp | 2 +-
.../gdb.dwarf2/dw2-using-debug-str.exp | 2 +-
gdb/testsuite/gdb.dwarf2/dw2-zero-range.exp | 2 +-
gdb/testsuite/gdb.dwarf2/per-bfd-sharing.exp | 2 +-
gdb/testsuite/gdb.multi/remove-inferiors.exp | 2 +-
gdb/testsuite/gdb.server/target-exec-file.exp | 4 ++--
gdb/testsuite/gdb.threads/detach-step-over.exp | 2 +-
gdb/testsuite/lib/gdb.exp | 2 +-
19 files changed, 45 insertions(+), 36 deletions(-)
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 11388772ff5..f0f44bca8c5 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -1088,11 +1088,20 @@ symbol_file_add_with_addrs (const gdb_bfd_ref_ptr &abfd, const char *name,
if ((flags & OBJF_READNOW))
{
- if (should_print)
- gdb_printf (_("Expanding full symbols from %ps...\n"),
- styled_string (file_name_style.style (), name));
+ if (objfile->has_unexpanded_symtabs ())
+ {
+ if (should_print)
+ gdb_printf (_ ("Expanding full symbols from %ps...\n"),
+ styled_string (file_name_style.style (), name));
- objfile->expand_all_symtabs ();
+ objfile->expand_all_symtabs ();
+ }
+ else
+ {
+ if (should_print)
+ gdb_printf (_ ("Expanded full symbols from %ps.\n"),
+ styled_string (file_name_style.style (), name));
+ }
}
/* Note that we only print a message if we have no symbols and have
diff --git a/gdb/testsuite/gdb.base/bfd-errors.exp b/gdb/testsuite/gdb.base/bfd-errors.exp
index 2e3847820e9..a920b799ea9 100644
--- a/gdb/testsuite/gdb.base/bfd-errors.exp
+++ b/gdb/testsuite/gdb.base/bfd-errors.exp
@@ -161,7 +161,7 @@ gdb_test_multiple "add-symbol-file -readnow $binfile_lib" \
incr bfd_error_count($expect_out(1,string))
exp_continue
}
- -re "Expanding full symbols from.*$gdb_prompt $" {
+ -re "Expand(ing|ed) full symbols from.*$gdb_prompt $" {
pass $gdb_test_name
}
}
diff --git a/gdb/testsuite/gdb.base/cached-source-file.exp b/gdb/testsuite/gdb.base/cached-source-file.exp
index 73d9359be9f..7637d35a832 100644
--- a/gdb/testsuite/gdb.base/cached-source-file.exp
+++ b/gdb/testsuite/gdb.base/cached-source-file.exp
@@ -93,7 +93,7 @@ set binregex [string_to_regexp $binfile]
set re \
[multi_line \
"\\`$binregex\\' has changed; re-reading symbols\\.(" \
- "Expanding full symbols from $binfile\\.\\.\\.)?" \
+ "Expand(ing|ed) full symbols from $binfile\\.(\\.\\.)?)?" \
"Starting program: ${binregex}.*"]
gdb_test "run" $re "rerun program" $q y
diff --git a/gdb/testsuite/gdb.base/code_elim.exp b/gdb/testsuite/gdb.base/code_elim.exp
index 0270bc92c84..375cf1d276d 100644
--- a/gdb/testsuite/gdb.base/code_elim.exp
+++ b/gdb/testsuite/gdb.base/code_elim.exp
@@ -80,7 +80,7 @@ gdb_exit
gdb_start
gdb_test "symbol-file ${binfile1}" \
- "Reading symbols from .*${testfile1}\\.\\.\\.(|\r\nUsing host libthread_db library .*libthread_db.so.*\\.)" \
+ "Reading symbols from .*${testfile1}\\.(\\.\\.)?(|\r\nUsing host libthread_db library .*libthread_db.so.*\\.)" \
"symbol-file ${testfile1}"
with_test_prefix "single psymtabs" {
@@ -113,13 +113,13 @@ gdb_start
with_test_prefix "order1" {
gdb_test "add-symbol-file ${binfile1} 0x100000 -s .bss 0x120000" \
- "Reading symbols from .*${testfile1}\\.\\.\\." \
+ "Reading symbols from .*${testfile1}\\.(\\.\\.)?" \
"add-symbol-file ${testfile1} 0x100000" \
"add symbol table from file \".*${testfile1}\" at.*\\(y or n\\) " \
"y"
gdb_test "add-symbol-file ${binfile2} 0x200000 -s .data 0x210000 -s .bss 0x220000" \
- "Reading symbols from .*${testfile2}\\.\\.\\." \
+ "Reading symbols from .*${testfile2}\\.(\\.\\.)?" \
"add-symbol-file ${testfile2} 0x200000" \
"add symbol table from file \".*${testfile2}\" at.*\\(y or n\\) " \
"y"
@@ -137,13 +137,13 @@ gdb_start
with_test_prefix "order2" {
gdb_test "add-symbol-file ${binfile2} 0x200000 -s .data 0x210000 -s .bss 0x220000" \
- "Reading symbols from .*${testfile2}\\.\\.\\." \
+ "Reading symbols from .*${testfile2}\\.(\\.\\.)?" \
"add-symbol-file ${testfile2} 0x200000" \
"add symbol table from file \".*${testfile2}\" at.*\\(y or n\\) " \
"y"
gdb_test "add-symbol-file ${binfile1} 0x100000 -s .bss 0x120000" \
- "Reading symbols from .*${testfile1}\\.\\.\\." \
+ "Reading symbols from .*${testfile1}\\.(\\.\\.)?" \
"add-symbol-file ${testfile1} 0x100000" \
"add symbol table from file \".*${testfile1}\" at.*\\(y or n\\) " \
"y"
diff --git a/gdb/testsuite/gdb.base/relocate.exp b/gdb/testsuite/gdb.base/relocate.exp
index db42885374c..93cca28eae3 100644
--- a/gdb/testsuite/gdb.base/relocate.exp
+++ b/gdb/testsuite/gdb.base/relocate.exp
@@ -114,11 +114,11 @@ gdb_test_multiple "add-symbol-file -s -section-name 0x200 $binfile 0x100" $test
# Since we're here, might as well test the 'symbol-file' command and
# if its arguments can also be passed at any position.
gdb_test "symbol-file -readnow $binfile" \
- "Reading symbols from ${binfile}\.\.\.\r\nExpanding full symbols from ${binfile}\.\.\." \
+ "Reading symbols from ${binfile}\.\.\.\r\nExpand(ing|ed) full symbols from ${binfile}\.(\.\.)?" \
"symbol-file with -readnow first"
clean_restart
gdb_test "symbol-file $binfile -readnow" \
- "Reading symbols from ${binfile}\.\.\.\r\nExpanding full symbols from ${binfile}\.\.\." \
+ "Reading symbols from ${binfile}\.\.\.\r\nExpand(ing|ed) full symbols from ${binfile}\.(\.\.)?" \
"symbol-file with -readnow second"
gdb_test "symbol-file -readnow" \
"no symbol file name was specified" \
@@ -128,7 +128,7 @@ gdb_test "symbol-file -- -non-existent-file" \
"symbol-file with -- disables option processing"
clean_restart
gdb_test "symbol-file -readnow -- $binfile" \
- "Reading symbols from ${binfile}\.\.\.\r\nExpanding full symbols from ${binfile}\.\.\." \
+ "Reading symbols from ${binfile}\.\.\.\r\nExpand(ing|ed) full symbols from ${binfile}\.(\.\.)?" \
"symbol-file with -- and -readnow"
gdb_test "symbol-file -- $binfile -readnow" \
"Unrecognized argument \"-readnow\"" \
@@ -144,8 +144,9 @@ gdb_test "add-symbol-file ${binfile} 0 -s .whatever" \
"add-symbol-file missing address"
# Load the object file.
+set readnow_re "Expand(ing|ed) full symbols from ${binfile}\.(\.\.)?"
gdb_test "add-symbol-file ${binfile} 0" \
- "Reading symbols from .*${testfile}\\.o\\.\\.\\.(|\r\nUsing host libthread_db library .*libthread_db.so.*\\.)" \
+ "Reading symbols from .*${testfile}\\.o\\.\\.\\.(\r\n$readnow_re)?(|\r\nUsing host libthread_db library .*libthread_db.so.*\\.)" \
"add-symbol-file ${testfile}.o 0" \
"add symbol table from file \".*${testfile}\\.o\" at\[ \t\r\n\]+\.text_addr = 0x0\[\r\n\]+\\(y or n\\) " \
"y"
@@ -198,7 +199,7 @@ gdb_test_no_output "set \$offset = 0x10000"
# Load the object file.
gdb_test "add-symbol-file ${binfile} \$offset" \
- "Reading symbols from .*${testfile}\\.o\\.\\.\\.(|\r\nUsing host libthread_db library .*libthread_db.so.*\\.)" \
+ "Reading symbols from .*${testfile}\\.o\\.\\.\\.(\r\n$readnow_re)?(|\r\nUsing host libthread_db library .*libthread_db.so.*\\.)" \
"add-symbol-file ${testfile}.o \$offset" \
"add symbol table from file \".*${testfile}\\.o\" at\[ \t\r\n\]+\.text_addr = 0x10000\[\r\n\]+\\(y or n\\) " \
"y"
@@ -218,7 +219,6 @@ if { "${function_foo_addr}" == "${new_function_foo_addr}" } {
set offset 0x10000
clean_restart
-set readnow_re "Expanding full symbols from ${binfile}\.\.\."
gdb_test "symbol-file -o $offset $binfile" \
"Reading symbols from ${binfile}\.\.\.(\r\n$readnow_re)?" \
"symbol-file with offset"
diff --git a/gdb/testsuite/gdb.base/style.exp b/gdb/testsuite/gdb.base/style.exp
index 222f17ee096..2553f3adc82 100644
--- a/gdb/testsuite/gdb.base/style.exp
+++ b/gdb/testsuite/gdb.base/style.exp
@@ -281,7 +281,7 @@ proc run_style_tests { } {
set pass_re \
[multi_line \
$pass_re \
- "Expanding full symbols from [limited_style $quoted file]\.\.\."]
+ "Expand(ing|ed) full symbols from [limited_style $quoted file]\.(\.\.)?"]
}
gdb_test "file $binfile" \
$pass_re \
diff --git a/gdb/testsuite/gdb.base/sym-file.exp b/gdb/testsuite/gdb.base/sym-file.exp
index 13febdac2db..78cd725bd0b 100644
--- a/gdb/testsuite/gdb.base/sym-file.exp
+++ b/gdb/testsuite/gdb.base/sym-file.exp
@@ -91,7 +91,7 @@ proc do_test { remove_expr } {
# 3) Add the library's symbols using 'add-symbol-file'.
set result [gdb_test "add-symbol-file ${lib_syms} addr" \
- "Reading symbols from .*${lib_syms}\\.\\.\\." \
+ "Reading symbols from .*${lib_syms}\\.(\\.\\.)?" \
"add-symbol-file ${lib_basename}.so addr" \
"add symbol table from file \".*${lib_basename}\\.so\"\
at.*\\(y or n\\) " \
@@ -175,7 +175,7 @@ proc do_test { remove_expr } {
# Load the library's symbols.
gdb_test "add-symbol-file ${lib_syms} addr" \
- "Reading symbols from .*${lib_syms}\\.\\.\\." \
+ "Reading symbols from .*${lib_syms}\\.(\\.\\.)?" \
"add-symbol-file ${lib_basename}.so addr" \
"add symbol table from file \".*${lib_syms}\"\
at.*\\(y or n\\) " \
diff --git a/gdb/testsuite/gdb.cp/cp-relocate.exp b/gdb/testsuite/gdb.cp/cp-relocate.exp
index 836f5fb6158..493ff57085e 100644
--- a/gdb/testsuite/gdb.cp/cp-relocate.exp
+++ b/gdb/testsuite/gdb.cp/cp-relocate.exp
@@ -121,7 +121,7 @@ clean_restart
set host_binfile [gdb_remote_download host $binfile]
gdb_test "add-symbol-file $host_binfile 0 -s ${func1_sec} 0x10000 -s ${func2_sec} 0x20000" \
- "Reading symbols from .*${testfile}\\.o\\.\\.\\.(|\r\nUsing host libthread_db library .*libthread_db.so.*\\.)" \
+ "Reading symbols from .*${testfile}\\.o\\.(\\.\\.)?(|\r\nUsing host libthread_db library .*libthread_db.so.*\\.)" \
"add-symbol-file ${testfile}.o" \
"add symbol table from file \".*${testfile}\\.o\" at.*\\(y or n\\) " \
"y"
diff --git a/gdb/testsuite/gdb.debuginfod/build-id-no-debug-warning.exp b/gdb/testsuite/gdb.debuginfod/build-id-no-debug-warning.exp
index e56538f721d..59251cad909 100644
--- a/gdb/testsuite/gdb.debuginfod/build-id-no-debug-warning.exp
+++ b/gdb/testsuite/gdb.debuginfod/build-id-no-debug-warning.exp
@@ -79,7 +79,7 @@ gdb_test_no_output "set debug-file-directory ${debug_file_directory}" \
# Now load the file into GDB, and look for the warning.
set debug_file_re [string_to_regexp $build_id_debug_file]
-set expanding_re "\r\nExpanding full symbols from $debug_file_re\\.\\.\\."
+set expanding_re "\r\nExpand(ing|ed) full symbols from $debug_file_re\\.(.\\.\\.)?"
gdb_test "file ${build_id_debug_file}" \
[multi_line \
"Reading symbols from $debug_file_re\\.\\.\\.($expanding_re)?" \
@@ -98,7 +98,7 @@ with_test_prefix "check styling" {
# Now load the file into GDB, and look for the warning.
set debug_file_re [style [string_to_regexp $build_id_debug_file] file]
- set expanding_re "\r\nExpanding full symbols from $debug_file_re\\.\\.\\."
+ set expanding_re "\r\nExpand(ing|ed) full symbols from $debug_file_re\\.(\\.\\.)?"
gdb_test "file ${build_id_debug_file}" \
[multi_line \
@@ -142,7 +142,7 @@ proc_with_prefix local_debuginfod { } {
[multi_line \
"Reading symbols from ${build_id_debug_file}\\.\\.\\." \
"Downloading\[^\r\n\]*separate debug info for ${build_id_debug_file}\\.\\.\\." \
- "Reading symbols from ${cache}/\[^\r\n\]+\\.\\.\\.(?:\r\nExpanding full symbols from \[^\r\n\]+)*"] \
+ "Reading symbols from ${cache}/\[^\r\n\]+\\.\\.\\.(?:\r\nExpand(ing|ed) full symbols from \[^\r\n\]+)*"] \
"debuginfod running, info downloaded, no warnings"
}
diff --git a/gdb/testsuite/gdb.debuginfod/crc_mismatch.exp b/gdb/testsuite/gdb.debuginfod/crc_mismatch.exp
index 2771d333d46..785088e95bb 100644
--- a/gdb/testsuite/gdb.debuginfod/crc_mismatch.exp
+++ b/gdb/testsuite/gdb.debuginfod/crc_mismatch.exp
@@ -47,7 +47,7 @@ remote_exec build "mkdir $debugdir"
remote_exec build "mkdir -p [file dirname $debugfile]"
remote_exec build "mv -f [standard_output_file ${testfile}.debug] $debugfile"
-set expanding_re "\r\nExpanding full symbols from .+\\.\\.\\."
+set expanding_re "\r\nExpand(ing|ed) full symbols from .+\\.(\\.\\.)?"
# Test CRC mismatch is reported.
if {[build_executable crc_mismatch.exp crc_mismatch-2 crc_mismatch-2.c debug] != -1
@@ -124,7 +124,7 @@ proc_with_prefix local_debuginfod { } {
[multi_line \
"Reading symbols from ${escapedobjdirsubdir}/crc_mismatch-2\\.\\.\\." \
"Downloading.*separate debug info for ${escapedobjdirsubdir}/crc_mismatch-2\\.\\.\\." \
- "Reading symbols from ${cache}/\[^\r\n\]+\\.\\.\\.(?:\r\nExpanding full symbols from \[^\r\n\]+)*"] \
+ "Reading symbols from ${cache}/\[^\r\n\]+\\.\\.\\.(?:\r\nExpand(ing|ed) full symbols from \[^\r\n\]+)*"] \
"debuginfod running, info downloaded, no CRC mismatch"
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-missing-cu-tag.exp b/gdb/testsuite/gdb.dwarf2/dw2-missing-cu-tag.exp
index 998b614a193..60e1cb62208 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-missing-cu-tag.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-missing-cu-tag.exp
@@ -63,7 +63,7 @@ set pattern1 \
set pattern2 \
[multi_line \
"Reading symbols from \[^\r\n\]+" \
- "Expanding full symbols from \[^\r\n\]+" \
+ "Expand(ing|ed) full symbols from \[^\r\n\]+" \
"DWARF Error: unexpected tag 'DW_TAG_subprogram' at offset $hex"]
# Load the executable, we expect an error from the DWARF parser.
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-objfile-overlap.exp b/gdb/testsuite/gdb.dwarf2/dw2-objfile-overlap.exp
index 25b3c0ee2e3..47ff7a0b9f0 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-objfile-overlap.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-objfile-overlap.exp
@@ -37,7 +37,7 @@ clean_restart $executable_outer
set host_binfile_inner [gdb_remote_download host $binfile_inner]
gdb_test "add-symbol-file $host_binfile_inner outer_inner" \
- {Reading symbols from .*\.\.\.} "add-symbol-file" \
+ {Reading symbols from .*\.(\.\.)?} "add-symbol-file" \
"\r\n\t\\.text_addr = 0x\[0-9a-f\]+\r\n\\(y or n\\) \$" "y"
# Expand symtab for ${binfile_outer}.
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-using-debug-str.exp b/gdb/testsuite/gdb.dwarf2/dw2-using-debug-str.exp
index 5349cc4b00d..20f1abc2ca8 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-using-debug-str.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-using-debug-str.exp
@@ -158,7 +158,7 @@ set pattern1 \
set pattern2 \
[multi_line \
$line1 \
- "Expanding full symbols from \[^\r\n\]+" \
+ "Expand(ing|ed) full symbols from \[^\r\n\]+" \
$dwarf_error]
# This pattern is hit when gcc adds an index (e.g. running with
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-zero-range.exp b/gdb/testsuite/gdb.dwarf2/dw2-zero-range.exp
index 79e48b24af1..2f16107dc48 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-zero-range.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-zero-range.exp
@@ -173,7 +173,7 @@ foreach_with_prefix ranges_sect {ranges rnglists} {
# Expanded full symbols from ...
#
set complaint_re \
- "${complaint_re}(\r\nExpanding full .*)?"
+ "${complaint_re}(\r\nExpand(ing|ed) full .*)?"
set readnow_p [readnow]
diff --git a/gdb/testsuite/gdb.dwarf2/per-bfd-sharing.exp b/gdb/testsuite/gdb.dwarf2/per-bfd-sharing.exp
index 0ae36128a70..453368b3842 100644
--- a/gdb/testsuite/gdb.dwarf2/per-bfd-sharing.exp
+++ b/gdb/testsuite/gdb.dwarf2/per-bfd-sharing.exp
@@ -63,7 +63,7 @@ proc load_binary { method } {
gdb_test_no_output "set index-cache enabled off"
} elseif { $method == "readnow" } {
gdb_test "file -readnow $::host_binfile" \
- "Reading symbols from .*Expanding full symbols from .*" \
+ "Reading symbols from .*Expand(ing|ed) full symbols from .*" \
"file readnow"
} else {
error "unknown method"
diff --git a/gdb/testsuite/gdb.multi/remove-inferiors.exp b/gdb/testsuite/gdb.multi/remove-inferiors.exp
index 52e6cb060a6..58285a57465 100644
--- a/gdb/testsuite/gdb.multi/remove-inferiors.exp
+++ b/gdb/testsuite/gdb.multi/remove-inferiors.exp
@@ -50,7 +50,7 @@ proc test_remove_inferiors { } {
set binfile_re [string_to_regexp ${binfile}]
gdb_test "file ${binfile}" \
[multi_line "Reading symbols from ${binfile_re}\.\.\.(" \
- "Expanding full symbols from ${binfile_re}\.\.\.)?" ] \
+ "Expand(ing|ed) full symbols from ${binfile_re}\.(\.\.)?)?" ] \
"load binary"
if {![runto_main]} {
diff --git a/gdb/testsuite/gdb.server/target-exec-file.exp b/gdb/testsuite/gdb.server/target-exec-file.exp
index 8705217fdf8..567c6d9c7f8 100644
--- a/gdb/testsuite/gdb.server/target-exec-file.exp
+++ b/gdb/testsuite/gdb.server/target-exec-file.exp
@@ -118,7 +118,7 @@ gdb_test_multiple "file target:$target_exec" "run file command" {
exp_continue
}
- -re "^Expanding full symbols from \[^\r\n\]+\r\n" {
+ -re "^Expand(ing|ed) full symbols from \[^\r\n\]+\r\n" {
exp_continue
}
@@ -171,7 +171,7 @@ proc start_inferior { testname expect_reread } {
-re "^Reading \[^\r\n\]+ from remote target\\.\\.\\.\r\n" {
exp_continue
}
- -re "^Expanding full symbols from \[^\r\n\]+\\.\\.\\.\r\n" {
+ -re "^Expand(ing|ed) full symbols from \[^\r\n\]+\\.\\.\\.\r\n" {
exp_continue
}
-re "^Temporary breakpoint $::decimal at $::hex: \[^\r\n\]+\r\n" {
diff --git a/gdb/testsuite/gdb.threads/detach-step-over.exp b/gdb/testsuite/gdb.threads/detach-step-over.exp
index 98b412cfcfd..92e3e58a97c 100644
--- a/gdb/testsuite/gdb.threads/detach-step-over.exp
+++ b/gdb/testsuite/gdb.threads/detach-step-over.exp
@@ -88,7 +88,7 @@ proc attach_to {testpid} {
# Seen when "set debug libthread_db" is on.
exp_continue
}
- -re "Reading symbols from|Expanding full symbols from" {
+ -re "Reading symbols from|Expand(ing|ed) full symbols from" {
# Prevent -readnow timeout.
exp_continue
}
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 82bb511bccc..5cad00719f6 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -7777,7 +7777,7 @@ proc gdb_load_no_complaints { arg } {
set re \
[multi_line \
"^(Reading symbols from \[^\r\n\]*" \
- ")+(Expanding full symbols from \[^\r\n\]*" \
+ ")+(Expand(ing|ed) full symbols from \[^\r\n\]*" \
")?$gdb_prompt $"]
gdb_assert {[regexp $re $gdb_file_cmd_msg]} "No complaints"
}
--
2.51.0
^ permalink raw reply [flat|nested] 22+ messages in thread* Re: [PATCH v2 13/13] gdb: update message in symbol_file_add_with_addrs after changes in readnow_functions
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ý
0 siblings, 1 reply; 22+ messages in thread
From: Tom Tromey @ 2025-12-02 17:29 UTC (permalink / raw)
To: Jan Vrany; +Cc: gdb-patches
>>>>> "Jan" == Jan Vrany <jan.vrany@labware.com> writes:
Jan> When loading a file with -readnow, GDB prints message like:
Jan> Reading symbols from some_program...
Jan> Expanding full symbols from some_program...
Jan> I assume the reason for the second message ("Expanding ...") is to let
Jan> the user know what's happening as symbol expansion may take time.
Yeah.
I wonder if instead of rewriting expand_all_symtabs in this series, you
could leave most of that patch in place but still have
readnow_functions::expand_all_symtabs actually do the work.
Then when/if readnow_functions is moved out of the DWARF reader, the
DWARF reader could subclass it to just add the one new method.
This way the message would still arrive at the right time, which seems
friendlier to users.
Jan> This commit therefore checks if there are any unexpanded CUs and if
Jan> so, prints "Expanding full..." message as before. If all CUs are already
Jan> expanded, say just "Expanded full...".
Also if there are multiple debug readers for an objfile, we could get
the "wrong" message here through no fault of the reader itself, if that
makes sense.
Tom
^ permalink raw reply [flat|nested] 22+ messages in thread* Re: [PATCH v2 13/13] gdb: update message in symbol_file_add_with_addrs after changes in readnow_functions
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
0 siblings, 2 replies; 22+ messages in thread
From: Jan Vraný @ 2025-12-02 18:48 UTC (permalink / raw)
To: tom; +Cc: gdb-patches
On Tue, 2025-12-02 at 10:29 -0700, Tom Tromey wrote:
> > > > > > "Jan" == Jan Vrany <jan.vrany@labware.com> writes:
>
> Jan> When loading a file with -readnow, GDB prints message like:
> Jan> Reading symbols from some_program...
> Jan> Expanding full symbols from some_program...
>
> Jan> I assume the reason for the second message ("Expanding ...") is to let
> Jan> the user know what's happening as symbol expansion may take time.
>
> Yeah.
>
> I wonder if instead of rewriting expand_all_symtabs in this series, you
> could leave most of that patch in place but still have
> readnow_functions::expand_all_symtabs actually do the work.
Sure.
>
> Then when/if readnow_functions is moved out of the DWARF reader,
I already have a patch that does this and planed to submit it once this
one is in. The reason I stared digging around readnow_function is that
search-via-psyms series broke my "Python JIT API" code as well as JIT
reader precisely because they do not install any quick functions.
Maybe better way to go about it might be:
1) introduce new quick functions, say "default_symbol_functions" with
the code from this (V2) series.
2) then DWARF's readnow_functions may inherit from "default_symbol_functions"
and override what's desirable
and then JIT reader would just use these new "default_symbol_functions".
> the
> DWARF reader could subclass it to just add the one new method.
>
> This way the message would still arrive at the right time, which seems
> friendlier to users.
>
> Jan> This commit therefore checks if there are any unexpanded CUs and if
> Jan> so, prints "Expanding full..." message as before. If all CUs are already
> Jan> expanded, say just "Expanded full...".
>
> Also if there are multiple debug readers for an objfile, we could get
> the "wrong" message here through no fault of the reader itself, if that
> makes sense.
I'm lost. In what situation we'd get "wrong" message?
Thanks!
Jan
>
> Tom
^ permalink raw reply [flat|nested] 22+ messages in thread* Re: [PATCH v2 13/13] gdb: update message in symbol_file_add_with_addrs after changes in readnow_functions
2025-12-02 18:48 ` Jan Vraný
@ 2025-12-02 18:57 ` Tom Tromey
2025-12-02 19:03 ` Tom Tromey
1 sibling, 0 replies; 22+ messages in thread
From: Tom Tromey @ 2025-12-02 18:57 UTC (permalink / raw)
To: Jan Vraný; +Cc: tom, gdb-patches
>> Also if there are multiple debug readers for an objfile, we could get
>> the "wrong" message here through no fault of the reader itself, if that
>> makes sense.
Jan> I'm lost. In what situation we'd get "wrong" message?
Looking at the code again maybe it's reasonable/ok.
At least if the sequencing issue is fixed.
Tom
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v2 13/13] gdb: update message in symbol_file_add_with_addrs after changes in readnow_functions
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ý
1 sibling, 1 reply; 22+ messages in thread
From: Tom Tromey @ 2025-12-02 19:03 UTC (permalink / raw)
To: Jan Vraný; +Cc: tom, gdb-patches
>>>>> "Jan" == Jan Vraný <Jan.Vrany@labware.com> writes:
Jan> Maybe better way to go about it might be:
Jan> 1) introduce new quick functions, say "default_symbol_functions" with
Jan> the code from this (V2) series.
Jan> 2) then DWARF's readnow_functions may inherit from "default_symbol_functions"
Jan> and override what's desirable
Jan> and then JIT reader would just use these new "default_symbol_functions".
I am not overly fond of the name "default_symbol_functions" but I think
the general idea holds.
Tom
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v2 13/13] gdb: update message in symbol_file_add_with_addrs after changes in readnow_functions
2025-12-02 19:03 ` Tom Tromey
@ 2025-12-03 17:46 ` Jan Vraný
0 siblings, 0 replies; 22+ messages in thread
From: Jan Vraný @ 2025-12-03 17:46 UTC (permalink / raw)
To: tom; +Cc: gdb-patches
On Tue, 2025-12-02 at 12:03 -0700, Tom Tromey wrote:
> > > > > > "Jan" == Jan Vraný <Jan.Vrany@labware.com> writes:
>
> Jan> Maybe better way to go about it might be:
>
> Jan> 1) introduce new quick functions, say "default_symbol_functions" with
> Jan> the code from this (V2) series.
> Jan> 2) then DWARF's readnow_functions may inherit from "default_symbol_functions"
> Jan> and override what's desirable
>
> Jan> and then JIT reader would just use these new "default_symbol_functions".
>
> I am not overly fond of the name "default_symbol_functions" but I think
> the general idea holds.
On a second thought, it won't be that easy. One cannot just implement readnow_functions
by merely subclassing "default_symbol_functions" and overriding expand_all_symtabs()
to do what it does right now.
The problem is that compunit_symtab is not instantiated and installed into an objfile
until call to dw2_instantiate_symtab().
So even if one specifies -readnow, more work is done when objfile is loaded, but still CUs are
not instantiated (no call to dw2_instantiate_symtab()). If then corresponding ::search is
implemented so that it iterates objfile->compunits() then it won't see them.
This is why commit "gdb: implement readnow_functions::expand_all_symtabs" from this series
calls (new) dw2_instantiate_all_symtabs() from dwarf2_initialize_objfile().
And if we do call dw2_instantiate_all_symtabs(), then doing the same thing in expand_all_symtabs
makes no sense.
In other words: if we want to keep current readnow_functions::expand_all_symtabs() then it would well mean
keeping other methods too and then we may well keep it as it is.
Still, for JIT reader created objfiles (and for future "Python JIT API"-created ones) we will need
"default_symbol_functions" so we'll end up with "default_symbol_functions" alongside existing
readnow_functions. I'm fine with that.
And yes, I do not like name "default_symbol_function" either, I just don't have a better name
right now.
Jan
>
> Tom
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v2 00/13] reimplement readnow_functions
2025-11-24 19:55 [PATCH v2 00/13] reimplement readnow_functions Jan Vrany
` (12 preceding siblings ...)
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 13:39 ` Jan Vraný
13 siblings, 0 replies; 22+ messages in thread
From: Jan Vraný @ 2025-12-02 13:39 UTC (permalink / raw)
To: gdb-patches
Polite ping.
Thanks!
Jan
On Mon, 2025-11-24 at 19:55 +0000, Jan Vrany wrote:
> Hi,
>
> this v2 of a series that refactors readnow_functions without using DWARF
> data structures.
>
> The v1 submission is here:
>
> https://inbox.sourceware.org/gdb-patches/20251119200105.3172938-1-jan.vrany@labware.com/
>
> Changes since v1:
>
> * I have updated readnow_function::search() and find_pc_sect_compunit_symtab()
> as Tom suggested
>
> * I have added two more commits to this series:
>
> gdb: update message in symbol_file_add_with_addrs after changes in readnow_functions
> gdb/testsuite: fix few tests after change in readnow_functions
>
> (the latter fixing some test failures I accidentally missed)
>
> * I have re-run regression tests (with and without -readnow).
>
> Thanks,
> Jan
>
> --
>
>
> Jan Vrany (13):
> gdb: reimplement readnow_functions::search
> gdb: implement readnow_functions::has_symbols
> gdb: implement readnow_functions::has_unexpanded_symtabs
> gdb: implement readnow_functions::find_last_source_symtab
> gdb: implement readnow_functions::forget_cached_source_info
> gdb: implement readnow_functions::lookup_global_symbol_language
> gdb: implement readnow_functions::print_stats
> gdb: implement readnow_functions::expand_all_symtabs
> gdb: implement readnow_functions::find_pc_sect_compunit_symtab
> gdb: implement readnow_functions::map_symbol_filenames
> gdb: make readnow_functions to inherit from quick_symbol_functions
> gdb/testsuite: fix few tests after change in readnow_functions
> gdb: update message in symbol_file_add_with_addrs after changes in
> readnow_functions
>
> gdb/dwarf2/read.c | 136 ++++++++++++++----
> gdb/symfile.c | 17 ++-
> gdb/testsuite/gdb.base/bfd-errors.exp | 2 +-
> gdb/testsuite/gdb.base/cached-source-file.exp | 2 +-
> gdb/testsuite/gdb.base/code_elim.exp | 10 +-
> gdb/testsuite/gdb.base/relocate.exp | 12 +-
> gdb/testsuite/gdb.base/style.exp | 2 +-
> gdb/testsuite/gdb.base/sym-file.exp | 4 +-
> gdb/testsuite/gdb.cp/cp-relocate.exp | 2 +-
> .../build-id-no-debug-warning.exp | 12 +-
> gdb/testsuite/gdb.debuginfod/crc_mismatch.exp | 12 +-
> .../gdb.dwarf2/dw2-missing-cu-tag.exp | 2 +-
> .../gdb.dwarf2/dw2-objfile-overlap.exp | 2 +-
> .../gdb.dwarf2/dw2-using-debug-str.exp | 2 +-
> gdb/testsuite/gdb.dwarf2/dw2-zero-range.exp | 10 ++
> gdb/testsuite/gdb.dwarf2/per-bfd-sharing.exp | 2 +-
> gdb/testsuite/gdb.multi/remove-inferiors.exp | 2 +-
> gdb/testsuite/gdb.server/target-exec-file.exp | 4 +-
> .../gdb.threads/detach-step-over.exp | 2 +-
> gdb/testsuite/lib/gdb.exp | 2 +-
> 20 files changed, 170 insertions(+), 69 deletions(-)
^ permalink raw reply [flat|nested] 22+ messages in thread