From: Simon Marchi Date: Mon, 17 Mar 2025 14:34:30 +0000 (-0400) Subject: gdb/dwarf: set m_top_level_die directly in read_cutu_die_from_dwo X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6eb9dab4c99725c1de4bccfeb99e766e7ee657a4;p=thirdparty%2Fbinutils-gdb.git gdb/dwarf: set m_top_level_die directly in read_cutu_die_from_dwo read_cutu_die_from_dwo currently returns the dwo's top-level DIE through a parameter. Following the previous patch, all code paths end up setting m_top_level_die. Simplify this by having read_cutu_die_from_dwo set m_top_level_die directly. I think it's easier to understand, because there's one less indirection to follow. Change-Id: Ib659f1d2e38501a8fe2b5dd0ca2add3ef55e8d60 Approved-By: Tom Tromey --- diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 60cd2d5e008..f41723c6945 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -2781,7 +2781,6 @@ void cutu_reader::read_cutu_die_from_dwo (dwarf2_cu *cu, dwo_unit *dwo_unit, die_info *stub_comp_unit_die, const char *stub_comp_dir, - die_info **result_top_level_die, abbrev_table_up *result_dwo_abbrev_table) { dwarf2_per_objfile *per_objfile = cu->per_objfile; @@ -2909,7 +2908,7 @@ cutu_reader::read_cutu_die_from_dwo (dwarf2_cu *cu, dwo_unit *dwo_unit, has the benefit of simplifying the rest of the code - all the work to maintain the illusion of a single DW_TAG_{compile,type}_unit DIE is done here. */ - *result_top_level_die + m_top_level_die = this->read_toplevel_die (gdb::make_array_view (attributes, next_attr_idx)); @@ -3018,7 +3017,7 @@ cutu_reader::init_tu_and_read_dwo_dies (dwarf2_per_cu *this_cu, read_cutu_die_from_dwo (cu, sig_type->dwo_unit, NULL /* stub_comp_unit_die */, sig_type->dwo_unit->dwo_file->comp_dir, - &m_top_level_die, &m_dwo_abbrev_table); + &m_dwo_abbrev_table); prepare_one_comp_unit (cu, pretend_language); } @@ -3195,7 +3194,6 @@ cutu_reader::cutu_reader (dwarf2_per_cu *this_cu, if (dwo_name != nullptr) { struct dwo_unit *dwo_unit; - struct die_info *dwo_comp_unit_die; if (m_top_level_die->has_children) { @@ -3204,14 +3202,11 @@ cutu_reader::cutu_reader (dwarf2_per_cu *this_cu, sect_offset_str (this_cu->sect_off), bfd_get_filename (abfd)); } + dwo_unit = lookup_dwo_unit (cu, m_top_level_die, dwo_name); if (dwo_unit != NULL) - { - read_cutu_die_from_dwo (cu, dwo_unit, m_top_level_die, - nullptr, &dwo_comp_unit_die, - &m_dwo_abbrev_table); - m_top_level_die = dwo_comp_unit_die; - } + read_cutu_die_from_dwo (cu, dwo_unit, m_top_level_die, nullptr, + &m_dwo_abbrev_table); else { /* Yikes, we couldn't find the rest of the DIE, we only have diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h index 0fe51eef5c2..be6549beec7 100644 --- a/gdb/dwarf2/read.h +++ b/gdb/dwarf2/read.h @@ -985,7 +985,6 @@ private: void read_cutu_die_from_dwo (dwarf2_cu *cu, dwo_unit *dwo_unit, die_info *stub_comp_unit_die, const char *stub_comp_dir, - die_info **result_comp_unit_die, abbrev_table_up *result_dwo_abbrev_table); void prepare_one_comp_unit (struct dwarf2_cu *cu,