gdb: Convert language la_watch_location_expression field to a method
[deliverable/binutils-gdb.git] / gdb / dwarf2 / abbrev.h
index 52103b0a683623002aa01ff3f89a14d55afd9a99..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,9 +48,6 @@ 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;
 
@@ -64,8 +62,15 @@ struct abbrev_table
   /* 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.  */
@@ -73,13 +78,7 @@ struct abbrev_table
 
 private:
 
-  explicit abbrev_table (sect_offset off)
-    : sect_off (off)
-  {
-    m_abbrevs =
-      XOBNEWVEC (&m_abbrev_obstack, struct abbrev_info *, ABBREV_HASH_SIZE);
-    memset (m_abbrevs, 0, ABBREV_HASH_SIZE * sizeof (struct abbrev_info *));
-  }
+  explicit abbrev_table (sect_offset off);
 
   DISABLE_COPY_AND_ASSIGN (abbrev_table);
 
@@ -88,13 +87,10 @@ private:
   struct abbrev_info *alloc_abbrev ();
 
   /* Add an abbreviation to the table.  */
-  void add_abbrev (unsigned int abbrev_number, struct abbrev_info *abbrev);
+  void add_abbrev (struct abbrev_info *abbrev);
 
-  /* 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;
+  /* Hash table of abbrevs.  */
+  htab_up m_abbrevs;
 
   /* Storage for the abbrev table.  */
   auto_obstack m_abbrev_obstack;
This page took 0.025224 seconds and 4 git commands to generate.