Add tests for new alias default-args related commands and arguments.
[deliverable/binutils-gdb.git] / gdb / dwarf2 / abbrev.h
index df83c093be2768a4f48cf46ea13411faabd860f7..888f04ebebbbad6f27f1cf60474904b18959edf8 100644 (file)
@@ -27,6 +27,8 @@
 #ifndef GDB_DWARF2_ABBREV_H
 #define GDB_DWARF2_ABBREV_H
 
+#include "hashtab.h"
+
 /* This data structure holds the information of an abbrev.  */
 struct abbrev_info
   {
@@ -35,7 +37,6 @@ struct abbrev_info
     unsigned short has_children;               /* boolean */
     unsigned short num_attrs;  /* number of attributes */
     struct attr_abbrev *attrs; /* an array of attribute descriptions */
-    struct abbrev_info *next;  /* next in chain */
   };
 
 struct attr_abbrev
@@ -47,57 +48,52 @@ struct attr_abbrev
     LONGEST implicit_const;
   };
 
-/* 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
 {
-  explicit abbrev_table (sect_offset off)
-    : sect_off (off)
-  {
-    m_abbrevs =
-      XOBNEWVEC (&abbrev_obstack, struct abbrev_info *, ABBREV_HASH_SIZE);
-    memset (m_abbrevs, 0, ABBREV_HASH_SIZE * sizeof (struct abbrev_info *));
-  }
-
-  DISABLE_COPY_AND_ASSIGN (abbrev_table);
-
-  /* Allocate space for a struct abbrev_info object in
-     ABBREV_TABLE.  */
-  struct abbrev_info *alloc_abbrev ();
-
-  /* Add an abbreviation to the table.  */
-  void add_abbrev (unsigned int abbrev_number, struct abbrev_info *abbrev);
+  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);
+  struct abbrev_info *lookup_abbrev (unsigned int abbrev_number)
+  {
+    struct abbrev_info search;
+    search.number = abbrev_number;
 
+    return (struct abbrev_info *) htab_find_with_hash (m_abbrevs.get (),
+                                                      &search,
+                                                      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;
-};
+  explicit abbrev_table (sect_offset off);
 
-typedef std::unique_ptr<struct abbrev_table> abbrev_table_up;
+  DISABLE_COPY_AND_ASSIGN (abbrev_table);
+
+  /* Allocate space for a struct abbrev_info object in
+     ABBREV_TABLE.  */
+  struct abbrev_info *alloc_abbrev ();
+
+  /* Add an abbreviation to the table.  */
+  void add_abbrev (struct abbrev_info *abbrev);
 
-extern abbrev_table_up abbrev_table_read_table
-  (struct objfile *objfile,
-   struct dwarf2_section_info *section,
-   sect_offset sect_off);
+  /* Hash table of abbrevs.  */
+  htab_up m_abbrevs;
+
+  /* Storage for the abbrev table.  */
+  auto_obstack m_abbrev_obstack;
+};
 
 #endif /* GDB_DWARF2_ABBREV_H */
This page took 0.029577 seconds and 4 git commands to generate.