Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jan Vrany <jan.vrany@labware.com>
To: gdb-patches@sourceware.org
Cc: Jan Vrany <jan.vrany@labware.com>, Tom Tromey <tom@tromey.com>
Subject: [PATCH v2 08/13] gdb: implement readnow_functions::expand_all_symtabs
Date: Mon, 24 Nov 2025 19:55:30 +0000	[thread overview]
Message-ID: <20251124195535.2116845-9-jan.vrany@labware.com> (raw)
In-Reply-To: <20251124195535.2116845-1-jan.vrany@labware.com>

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


  parent reply	other threads:[~2025-11-24 20:09 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 ` [PATCH v2 01/13] gdb: reimplement readnow_functions::search 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
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 ` Jan Vrany [this message]
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-9-jan.vrany@labware.com \
    --to=jan.vrany@labware.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.com \
    /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