]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb/dwarf: clean up some cutu_reader::is_dummy() calls
authorSimon Marchi <simon.marchi@polymtl.ca>
Thu, 24 Apr 2025 20:01:47 +0000 (16:01 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Tue, 29 Apr 2025 19:54:17 +0000 (15:54 -0400)
This patch tries to standardize the places where we check if units are
dummy.  When checking if a unit is dummy, it is not necessary to check
for some other conditions.

 - cutu_reader::is_dummy() is a superset of cutu_reader::cu() returning
   nullptr, so it's not necessary to check if the cu method return
   nullptr if also checking if the unit is dummy.
 - cutu_reader::is_dummy() is a superset of cutu_reader::top_level_die()
   returning nullptr, so same deal.

Remove some spots that check for these conditions in addition to
cutu_reader::is_dummy().

In addition, also remove the checks for:

    !new_reader->top_level_die ()->has_children

in cooked_indexer::ensure_cu_exists.  IMO, it is not useful to special
case the units having a single DIE.  Especially in this function, which
deals with importing things from another unit, a unit with a single DIE
would be an edge case that should not happen with good debug info.  I
think it's preferable to have simpler code.

Change-Id: I4529d7b3a0bd2891a60f41671de8cfd3114adb4a
Approved-By: Tom Tromey <tom@tromey.com>
gdb/dwarf2/cooked-indexer.c
gdb/dwarf2/read.c

index 5776dc5e9562287d9b0ab7e348cb7cc9ec4af1ac..c093984bae02a8b2a06272641f2400768f4f10a9 100644 (file)
@@ -116,15 +116,13 @@ cooked_indexer::ensure_cu_exists (cutu_reader *reader,
                                         nullptr, false, language_minimal,
                                         &abbrev_table_cache);
 
-      if (new_reader->is_dummy () || new_reader->top_level_die () == nullptr
-         || !new_reader->top_level_die ()->has_children)
+      if (new_reader->is_dummy ())
        return nullptr;
 
       result = m_index_storage->preserve (std::move (new_reader));
     }
 
-  if (result->is_dummy () || result->top_level_die () == nullptr
-      || !result->top_level_die ()->has_children)
+  if (result->is_dummy ())
     return nullptr;
 
   if (for_scanning)
index aa830d402c4f04e66885c07a033181a7961b9e2e..3219bbae7b316ba611ccfd6b50f3482dbff9da4a 100644 (file)
@@ -3203,13 +3203,13 @@ process_psymtab_comp_unit (dwarf2_per_cu *this_cu,
                                                       language_minimal,
                                                       &abbrev_table_cache);
 
-      if (new_reader->cu () == nullptr || new_reader->is_dummy ())
+      if (new_reader->is_dummy ())
        return;
 
       reader = storage->preserve (std::move (new_reader));
     }
 
-  if (reader->top_level_die () == nullptr || reader->is_dummy ())
+  if (reader->is_dummy ())
     return;
 
   if (this_cu->is_debug_types)