[binutils-gdb] Remove C++ special case from process_imported_unit_die

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=8544a41622d446adbc1e2ca5ee1206d60f5b2d2c

commit 8544a41622d446adbc1e2ca5ee1206d60f5b2d2c
Author: Tom Tromey <[email protected]>
Date:   Sat Jan 24 14:56:16 2026 -0700

    Remove C++ special case from process_imported_unit_die
    
    process_imported_unit_die has a special case for C++, added as a
    performance improvement.
    
    While I somewhat agree with the general idea of this snippet --
    importing a compilation unit seems like a strange thing to do, given
    that partial units exist -- I think there are two issues with it.
    
    First, it is specific to C++.  I don't see any real reason that this
    should be the case.
    
    Second, it does not have a corresponding bit of code in the indexer.
    This means that the cooked index's view of the DWARF differs from the
    full reader's view here.  This causes regressions in this series,
    because the indexer assumes that reading a CU will cause all the
    imported CUs to be read as a side effect -- but that does not happen
    here.
    
    I think fixing this in the indexer is not trivial.  The reason for
    this is that the indexer works in parallel, and once a reader has
    acquired the "scan" bit for a CU, it is obligated to read it.
    However, in this case this would require making a new cooked indexer.
    
    Instead, because (1) this is weird and rare DWARF anyway, and (2) this
    is just a performance optimization, I propose removing this.
    
    Acked-By: Tom de Vries <[email protected]>
    Approved-By: Simon Marchi <[email protected]>

Diff:
---
 gdb/dwarf2/read.c | 9 ---------
 1 file changed, 9 deletions(-)

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index a9796daa6dd..ebf6133e38f 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -4804,15 +4804,6 @@ process_imported_unit_die (die_info *die, dwarf2_cu *source_cu)
       dwarf2_per_cu *per_cu
 	= dwarf2_find_containing_unit ({ &section, sect_off }, per_objfile);
 
-      /* We're importing a C++ compilation unit with tag DW_TAG_compile_unit
-	 into another compilation unit, at root level.  Regard this as a hint,
-	 and ignore it.  This is a best effort, it only works if unit_type and
-	 lang are already set.  */
-      if (die->parent && die->parent->parent == NULL
-	  && per_cu->unit_type (false) == DW_UT_compile
-	  && per_cu->lang (false) == language_cplus)
-	return;
-
       /* Load its DIEs and add it to the queue.  */
       if (dwarf2_cu *dst_cu = ensure_loaded_comp_unit (per_cu, per_objfile,
 						       false,
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.