Remove objfile parameter from abbrev_table::read
authorTom Tromey <tom@tromey.com>
Fri, 6 Nov 2020 01:27:43 +0000 (18:27 -0700)
committerTom Tromey <tom@tromey.com>
Fri, 6 Nov 2020 01:27:43 +0000 (18:27 -0700)
In a longer series that I am working on, I needed to remove the
objfile parameter from abbrev_table::read.  It seemed to me that this
was a simple and relatively harmless patch, so I'm sending it now.

gdb/ChangeLog
2020-11-05  Tom Tromey  <tom@tromey.com>

* dwarf2/read.c (read_cutu_die_from_dwo)
(cutu_reader::cutu_reader, cutu_reader::cutu_reader)
(build_type_psymtabs_1): Update.
* dwarf2/abbrev.h (struct abbrev_table): Remove objfile
parameter.
* dwarf2/abbrev.c (abbrev_table::read): Remove objfile parameter.
Don't read section.  Add assert.

gdb/ChangeLog
gdb/dwarf2/abbrev.c
gdb/dwarf2/abbrev.h
gdb/dwarf2/read.c

index c03eacc904fd2ea0f663cabc68dafcfa72d8ab4e..8a05f20ca905c6104adf445de1df2cb9a1691dfa 100644 (file)
@@ -1,3 +1,13 @@
+2020-11-05  Tom Tromey  <tom@tromey.com>
+
+       * dwarf2/read.c (read_cutu_die_from_dwo)
+       (cutu_reader::cutu_reader, cutu_reader::cutu_reader)
+       (build_type_psymtabs_1): Update.
+       * dwarf2/abbrev.h (struct abbrev_table): Remove objfile
+       parameter.
+       * dwarf2/abbrev.c (abbrev_table::read): Remove objfile parameter.
+       Don't read section.  Add assert.
+
 2020-11-04  Tom Tromey  <tromey@adacore.com>
 
        * ada-typeprint.c (ada_print_type): Handle __XVL fields.
index 86789e56beca2810df10d1bc0991f1700eb357b0..9067df07659ea3e9a2b62c17e8cafb395e64ed01 100644 (file)
@@ -91,8 +91,7 @@ abbrev_table::add_abbrev (struct abbrev_info *abbrev)
 /* Read in an abbrev table.  */
 
 abbrev_table_up
-abbrev_table::read (struct objfile *objfile,
-                   struct dwarf2_section_info *section,
+abbrev_table::read (struct dwarf2_section_info *section,
                    sect_offset sect_off)
 {
   bfd *abfd = section->get_bfd_owner ();
@@ -104,7 +103,8 @@ abbrev_table::read (struct objfile *objfile,
 
   abbrev_table_up abbrev_table (new struct abbrev_table (sect_off));
 
-  section->read (objfile);
+  /* Caller must ensure this.  */
+  gdb_assert (section->readin);
   abbrev_ptr = section->buffer + to_underlying (sect_off);
   abbrev_number = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
   abbrev_ptr += bytes_read;
index 888f04ebebbbad6f27f1cf60474904b18959edf8..d52d00b42bfd8abe65bfc57d3cd03f609dc9ce7e 100644 (file)
@@ -55,8 +55,11 @@ typedef std::unique_ptr<struct abbrev_table> abbrev_table_up;
 
 struct abbrev_table
 {
-  static abbrev_table_up read (struct objfile *objfile,
-                              struct dwarf2_section_info *section,
+  /* Read an abbrev table from the indicated section, at the given
+     offset.  The caller is responsible for ensuring that the section
+     has already been read.  */
+
+  static abbrev_table_up read (struct dwarf2_section_info *section,
                               sect_offset sect_off);
 
   /* Look up an abbrev in the table.
index 57db648061e538434fe08b2e574f214131ef281b..dbf0a3e25b93999d7dc17600e559d70bcb6e960b 100644 (file)
@@ -6926,9 +6926,9 @@ read_cutu_die_from_dwo (dwarf2_cu *cu,
       dwo_unit->length = cu->header.get_length ();
     }
 
+  dwo_abbrev_section->read (objfile);
   *result_dwo_abbrev_table
-    = abbrev_table::read (objfile, dwo_abbrev_section,
-                         cu->header.abbrev_sect_off);
+    = abbrev_table::read (dwo_abbrev_section, cu->header.abbrev_sect_off);
   init_cu_die_reader (result_reader, cu, section, dwo_unit->dwo_file,
                      result_dwo_abbrev_table->get ());
 
@@ -7216,9 +7216,9 @@ cutu_reader::cutu_reader (dwarf2_per_cu_data *this_cu,
     gdb_assert (cu->header.abbrev_sect_off == abbrev_table->sect_off);
   else
     {
+      abbrev_section->read (objfile);
       m_abbrev_table_holder
-       = abbrev_table::read (objfile, abbrev_section,
-                             cu->header.abbrev_sect_off);
+       = abbrev_table::read (abbrev_section, cu->header.abbrev_sect_off);
       abbrev_table = m_abbrev_table_holder.get ();
     }
 
@@ -7360,9 +7360,9 @@ cutu_reader::cutu_reader (dwarf2_per_cu_data *this_cu,
       return;
     }
 
+  abbrev_section->read (objfile);
   m_abbrev_table_holder
-    = abbrev_table::read (objfile, abbrev_section,
-                         m_new_cu->header.abbrev_sect_off);
+    = abbrev_table::read (abbrev_section, m_new_cu->header.abbrev_sect_off);
 
   init_cu_die_reader (this, m_new_cu.get (), section, dwo_file,
                      m_abbrev_table_holder.get ());
@@ -7862,9 +7862,9 @@ build_type_psymtabs_1 (dwarf2_per_objfile *per_objfile)
          || tu.abbrev_offset != abbrev_offset)
        {
          abbrev_offset = tu.abbrev_offset;
+         per_objfile->per_bfd->abbrev.read (per_objfile->objfile);
          abbrev_table =
-           abbrev_table::read (per_objfile->objfile,
-                               &per_objfile->per_bfd->abbrev, abbrev_offset);
+           abbrev_table::read (&per_objfile->per_bfd->abbrev, abbrev_offset);
          ++tu_stats->nr_uniq_abbrev_tables;
        }