]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb/dwarf: set m_top_level_die directly in read_cutu_die_from_dwo
authorSimon Marchi <simon.marchi@polymtl.ca>
Mon, 17 Mar 2025 14:34:30 +0000 (10:34 -0400)
committerSimon Marchi <simon.marchi@polymtl.ca>
Tue, 18 Mar 2025 13:39:03 +0000 (09:39 -0400)
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 <tom@tromey.com>
gdb/dwarf2/read.c
gdb/dwarf2/read.h

index 60cd2d5e00803ca8afac2ec6e225155ea900b72e..f41723c69456e674ec6b9693a68a85665063401c 100644 (file)
@@ -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
index 0fe51eef5c29b5a293e7b1406f2f7015a1f509cd..be6549beec7f583148362fa25b56157a94f5ffe8 100644 (file)
@@ -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,