diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2025-04-24 16:01:47 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@efficios.com> | 2025-04-29 15:54:17 -0400 |
commit | dbfd92856a3cda8fd08a06c150e5c8f5cf8990be (patch) | |
tree | e64c2dd2534df775e183674db0370fabb80508a6 | |
parent | 605b4e6f36615974635a17eed999c8ee34821e92 (diff) | |
download | binutils-dbfd92856a3cda8fd08a06c150e5c8f5cf8990be.zip binutils-dbfd92856a3cda8fd08a06c150e5c8f5cf8990be.tar.gz binutils-dbfd92856a3cda8fd08a06c150e5c8f5cf8990be.tar.bz2 |
gdb/dwarf: clean up some cutu_reader::is_dummy() calls
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>
-rw-r--r-- | gdb/dwarf2/cooked-indexer.c | 6 | ||||
-rw-r--r-- | gdb/dwarf2/read.c | 4 |
2 files changed, 4 insertions, 6 deletions
diff --git a/gdb/dwarf2/cooked-indexer.c b/gdb/dwarf2/cooked-indexer.c index 5776dc5..c093984 100644 --- a/gdb/dwarf2/cooked-indexer.c +++ b/gdb/dwarf2/cooked-indexer.c @@ -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) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index aa830d4..3219bba 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -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) |