[binutils-gdb] gdb/dwarf: make process_full_{comp, type}_unit return a compunit_symtab

Simon Marchi 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=9be58c3767ff743a8eb832a9c0662617f69fe4fa

commit 9be58c3767ff743a8eb832a9c0662617f69fe4fa
Author: Simon Marchi <[email protected]>
Date:   Sat Feb 21 15:07:24 2026 -0500

    gdb/dwarf: make process_full_{comp,type}_unit return a compunit_symtab
    
    This change makes it so that there is a single point in the code where
    compunit symtabs are set (where dwarf2_per_objfile::set_compunit_symtab
    is called), which I think helps understand how things work.
    
    Change-Id: Ie84aa5141ebe1e2c7a990f59a62d95401a4b3e4a
    Approved-By: Tom Tromey <[email protected]>

Diff:
---
 gdb/dwarf2/read.c | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 11b9eea25d6..8aa44c9b51b 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -922,9 +922,9 @@ static void load_full_comp_unit (dwarf2_per_cu *per_cu,
 				 bool skip_partial,
 				 std::optional<language> pretend_language);
 
-static void process_full_comp_unit (dwarf2_cu *cu);
+static compunit_symtab *process_full_comp_unit (dwarf2_cu *cu);
 
-static void process_full_type_unit (dwarf2_cu *cu);
+static compunit_symtab *process_full_type_unit (dwarf2_cu *cu);
 
 static struct type *get_die_type_at_offset (sect_offset,
 					    dwarf2_per_cu *per_cu,
@@ -4025,10 +4025,14 @@ process_queue (dwarf2_per_objfile *per_objfile)
 
 	      ++expanded_count;
 
+	      compunit_symtab *cust;
+
 	      if (per_cu->is_debug_types ())
-		process_full_type_unit (cu);
+		cust = process_full_type_unit (cu);
 	      else
-		process_full_comp_unit (cu);
+		cust = process_full_comp_unit (cu);
+
+	      per_objfile->set_compunit_symtab (cu->per_cu, cust);
 
 	      if (dwarf_read_debug >= debug_print_threshold)
 		{
@@ -4668,7 +4672,7 @@ process_cu_includes (dwarf2_per_objfile *per_objfile)
 /* Generate full symbol information for CU, whose DIEs have
    already been loaded into memory.  */
 
-static void
+static compunit_symtab *
 process_full_comp_unit (dwarf2_cu *cu)
 {
   dwarf2_per_objfile *per_objfile = cu->per_objfile;
@@ -4769,19 +4773,19 @@ process_full_comp_unit (dwarf2_cu *cu)
       cust->set_call_site_htab (std::move (cu->call_site_htab));
     }
 
-  per_objfile->set_compunit_symtab (cu->per_cu, cust);
-
   /* Push it for inclusion processing later.  */
   per_objfile->per_bfd->just_read_cus.push_back (cu->per_cu);
 
   /* Not needed any more.  */
   cu->reset_builder ();
+
+  return cust;
 }
 
 /* Generate full symbol information for type unit CU, whose DIEs have
    already been loaded into memory.  */
 
-static void
+static compunit_symtab *
 process_full_type_unit (dwarf2_cu *cu)
 {
   dwarf2_per_objfile *per_objfile = cu->per_objfile;
@@ -4837,10 +4841,10 @@ process_full_type_unit (dwarf2_cu *cu)
       cust = tug_unshare->compunit_symtab;
     }
 
-  per_objfile->set_compunit_symtab (cu->per_cu, cust);
-
   /* Not needed any more.  */
   cu->reset_builder ();
+
+  return cust;
 }
 
 /* See read.h.  */
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.