Minor cleanups in abbrev_table
authorTom Tromey <tom@tromey.com>
Sat, 8 Feb 2020 20:40:54 +0000 (13:40 -0700)
committerTom Tromey <tom@tromey.com>
Sat, 8 Feb 2020 20:43:24 +0000 (13:43 -0700)
This cleans up the DWARF abbrev_table API a bit, primarily by making
various methods and members private.

2020-02-08  Tom Tromey  <tom@tromey.com>

* dwarf2/read.c (read_cutu_die_from_dwo): Update.
(cutu_reader): Update.
(build_type_psymtabs_1): Update.
* dwarf2/abbrev.c (abbrev_table::read): Rename.
(abbrev_table::alloc_abbrev): Update.
* dwarf2/abbrev.h (abbrev_table_up): Move earlier.
(abbrev_table::read): New static method, renamed from
abbrev_table_read_table.
(abbrev_table::alloc_abbrev)
(abbrev_table::add_abbrev): Now private.
(abbrev_table::abbrev_table): Now private.
(abbrev_table::m_abbrev_obstack): Now private.  Rename.

Change-Id: I320dca83b799f672909ae66f73b7aca266adbaf9

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

index 014c85831daab7d6a797da7f8aaf60f7f960a8ee..8fae30b7936a3abaa2ede6ae42dd3d4bd7969278 100644 (file)
@@ -1,3 +1,18 @@
+2020-02-08  Tom Tromey  <tom@tromey.com>
+
+       * dwarf2/read.c (read_cutu_die_from_dwo): Update.
+       (cutu_reader): Update.
+       (build_type_psymtabs_1): Update.
+       * dwarf2/abbrev.c (abbrev_table::read): Rename.
+       (abbrev_table::alloc_abbrev): Update.
+       * dwarf2/abbrev.h (abbrev_table_up): Move earlier.
+       (abbrev_table::read): New static method, renamed from
+       abbrev_table_read_table.
+       (abbrev_table::alloc_abbrev)
+       (abbrev_table::add_abbrev): Now private.
+       (abbrev_table::abbrev_table): Now private.
+       (abbrev_table::m_abbrev_obstack): Now private.  Rename.
+
 2020-02-08  Tom Tromey  <tom@tromey.com>
 
        * dwarf2/read.c (set_die_type, get_die_type_at_offset): Update.
index 544d5793add19859cd5795b8bc4fb04e1a1239ab..fac7309b93cf64dfc330c149977e890ccdd84040 100644 (file)
@@ -44,7 +44,7 @@ abbrev_table::alloc_abbrev ()
 {
   struct abbrev_info *abbrev;
 
-  abbrev = XOBNEW (&abbrev_obstack, struct abbrev_info);
+  abbrev = XOBNEW (&m_abbrev_obstack, struct abbrev_info);
   memset (abbrev, 0, sizeof (struct abbrev_info));
 
   return abbrev;
@@ -87,9 +87,9 @@ abbrev_table::lookup_abbrev (unsigned int abbrev_number)
 /* Read in an abbrev table.  */
 
 abbrev_table_up
-abbrev_table_read_table (struct objfile *objfile,
-                        struct dwarf2_section_info *section,
-                        sect_offset sect_off)
+abbrev_table::read (struct objfile *objfile,
+                   struct dwarf2_section_info *section,
+                   sect_offset sect_off)
 {
   bfd *abfd = section->get_bfd_owner ();
   const gdb_byte *abbrev_ptr;
@@ -152,7 +152,7 @@ abbrev_table_read_table (struct objfile *objfile,
        }
 
       cur_abbrev->attrs =
-       XOBNEWVEC (&abbrev_table->abbrev_obstack, struct attr_abbrev,
+       XOBNEWVEC (&abbrev_table->m_abbrev_obstack, struct attr_abbrev,
                   cur_abbrev->num_attrs);
       memcpy (cur_abbrev->attrs, cur_attrs.data (),
              cur_abbrev->num_attrs * sizeof (struct attr_abbrev));
index df83c093be2768a4f48cf46ea13411faabd860f7..52103b0a683623002aa01ff3f89a14d55afd9a99 100644 (file)
@@ -50,15 +50,34 @@ struct attr_abbrev
 /* Size of abbrev_table.abbrev_hash_table.  */
 #define ABBREV_HASH_SIZE 121
 
+struct abbrev_table;
+typedef std::unique_ptr<struct abbrev_table> abbrev_table_up;
+
 /* Top level data structure to contain an abbreviation table.  */
 
 struct abbrev_table
 {
+  static abbrev_table_up read (struct objfile *objfile,
+                              struct dwarf2_section_info *section,
+                              sect_offset sect_off);
+
+  /* Look up an abbrev in the table.
+     Returns NULL if the abbrev is not found.  */
+
+  struct abbrev_info *lookup_abbrev (unsigned int abbrev_number);
+
+
+  /* Where the abbrev table came from.
+     This is used as a sanity check when the table is used.  */
+  const sect_offset sect_off;
+
+private:
+
   explicit abbrev_table (sect_offset off)
     : sect_off (off)
   {
     m_abbrevs =
-      XOBNEWVEC (&abbrev_obstack, struct abbrev_info *, ABBREV_HASH_SIZE);
+      XOBNEWVEC (&m_abbrev_obstack, struct abbrev_info *, ABBREV_HASH_SIZE);
     memset (m_abbrevs, 0, ABBREV_HASH_SIZE * sizeof (struct abbrev_info *));
   }
 
@@ -71,33 +90,14 @@ struct abbrev_table
   /* Add an abbreviation to the table.  */
   void add_abbrev (unsigned int abbrev_number, struct abbrev_info *abbrev);
 
-  /* Look up an abbrev in the table.
-     Returns NULL if the abbrev is not found.  */
-
-  struct abbrev_info *lookup_abbrev (unsigned int abbrev_number);
-
-
-  /* Where the abbrev table came from.
-     This is used as a sanity check when the table is used.  */
-  const sect_offset sect_off;
-
-  /* Storage for the abbrev table.  */
-  auto_obstack abbrev_obstack;
-
-private:
-
   /* Hash table of abbrevs.
      This is an array of size ABBREV_HASH_SIZE allocated in abbrev_obstack.
      It could be statically allocated, but the previous code didn't so we
      don't either.  */
   struct abbrev_info **m_abbrevs;
-};
 
-typedef std::unique_ptr<struct abbrev_table> abbrev_table_up;
-
-extern abbrev_table_up abbrev_table_read_table
-  (struct objfile *objfile,
-   struct dwarf2_section_info *section,
-   sect_offset sect_off);
+  /* Storage for the abbrev table.  */
+  auto_obstack m_abbrev_obstack;
+};
 
 #endif /* GDB_DWARF2_ABBREV_H */
index e42f4f25795a07dea834ea005d453500148f9a73..345535af4905db6e13fb65c38b7af8b031427bfe 100644 (file)
@@ -7036,8 +7036,8 @@ read_cutu_die_from_dwo (struct dwarf2_per_cu_data *this_cu,
     }
 
   *result_dwo_abbrev_table
-    = abbrev_table_read_table (objfile, dwo_abbrev_section,
-                              cu->header.abbrev_sect_off);
+    = abbrev_table::read (objfile, 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 ());
 
@@ -7334,8 +7334,8 @@ cutu_reader::cutu_reader (struct dwarf2_per_cu_data *this_cu,
   else
     {
       m_abbrev_table_holder
-       = abbrev_table_read_table (objfile, abbrev_section,
-                                  cu->header.abbrev_sect_off);
+       = abbrev_table::read (objfile, abbrev_section,
+                             cu->header.abbrev_sect_off);
       abbrev_table = m_abbrev_table_holder.get ();
     }
 
@@ -7480,8 +7480,8 @@ cutu_reader::cutu_reader (struct dwarf2_per_cu_data *this_cu,
     }
 
   m_abbrev_table_holder
-    = abbrev_table_read_table (objfile, abbrev_section,
-                              m_new_cu->header.abbrev_sect_off);
+    = abbrev_table::read (objfile, 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 ());
@@ -7969,9 +7969,9 @@ build_type_psymtabs_1 (struct dwarf2_per_objfile *dwarf2_per_objfile)
        {
          abbrev_offset = tu.abbrev_offset;
          abbrev_table =
-           abbrev_table_read_table (dwarf2_per_objfile->objfile,
-                                    &dwarf2_per_objfile->abbrev,
-                                    abbrev_offset);
+           abbrev_table::read (dwarf2_per_objfile->objfile,
+                               &dwarf2_per_objfile->abbrev,
+                               abbrev_offset);
          ++tu_stats->nr_uniq_abbrev_tables;
        }
 
This page took 0.033264 seconds and 4 git commands to generate.