Change dwarf2_per_objfile::die_type_hash to htab_up
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 changes dwarf2_per_objfile::die_type_hash to be an htab_up,
moving its contents off the objfile obstack.

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

* dwarf2/read.c (set_die_type, get_die_type_at_offset): Update.
* dwarf2/read.h (struct dwarf2_per_objfile) <die_type_hash>: Now
htab_up.

Change-Id: Ic651f99ebf71bf7ad2dc2880192adacf7b60964a

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

index 82e99312b885ebc5d3b7237e51e7b0715c65f11e..014c85831daab7d6a797da7f8aaf60f7f960a8ee 100644 (file)
@@ -1,3 +1,9 @@
+2020-02-08  Tom Tromey  <tom@tromey.com>
+
+       * dwarf2/read.c (set_die_type, get_die_type_at_offset): Update.
+       * dwarf2/read.h (struct dwarf2_per_objfile) <die_type_hash>: Now
+       htab_up.
+
 2020-02-08  Tom Tromey  <tom@tromey.com>
 
        * dwarf2/read.c (struct dwp_file) <loaded_cus, loaded_tus>: Now
index 4c445eae90b5056bda3b17cbd08112154453d47a..e42f4f25795a07dea834ea005d453500148f9a73 100644 (file)
@@ -25184,22 +25184,17 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
     add_dyn_prop (DYN_PROP_DATA_LOCATION, prop, type);
 
   if (dwarf2_per_objfile->die_type_hash == NULL)
-    {
-      dwarf2_per_objfile->die_type_hash =
-       htab_create_alloc_ex (127,
-                             per_cu_offset_and_type_hash,
-                             per_cu_offset_and_type_eq,
-                             NULL,
-                             &objfile->objfile_obstack,
-                             hashtab_obstack_allocate,
-                             dummy_obstack_deallocate);
-    }
+    dwarf2_per_objfile->die_type_hash
+      = htab_up (htab_create_alloc (127,
+                                   per_cu_offset_and_type_hash,
+                                   per_cu_offset_and_type_eq,
+                                   NULL, xcalloc, xfree));
 
   ofs.per_cu = cu->per_cu;
   ofs.sect_off = die->sect_off;
   ofs.type = type;
   slot = (struct dwarf2_per_cu_offset_and_type **)
-    htab_find_slot (dwarf2_per_objfile->die_type_hash, &ofs, INSERT);
+    htab_find_slot (dwarf2_per_objfile->die_type_hash.get (), &ofs, INSERT);
   if (*slot)
     complaint (_("A problem internal to GDB: DIE %s has type already set"),
               sect_offset_str (die->sect_off));
@@ -25225,7 +25220,7 @@ get_die_type_at_offset (sect_offset sect_off,
   ofs.per_cu = per_cu;
   ofs.sect_off = sect_off;
   slot = ((struct dwarf2_per_cu_offset_and_type *)
-         htab_find (dwarf2_per_objfile->die_type_hash, &ofs));
+         htab_find (dwarf2_per_objfile->die_type_hash.get (), &ofs));
   if (slot)
     return slot->type;
   else
index 0f30837d3e2b96216621ab5c0bc00f809752712b..c177747e32e8b7156171fb869b27168c1395604f 100644 (file)
@@ -214,7 +214,7 @@ public:
   /* Table mapping type DIEs to their struct type *.
      This is NULL if not allocated yet.
      The mapping is done via (CU/TU + DIE offset) -> type.  */
-  htab_t die_type_hash {};
+  htab_up die_type_hash;
 
   /* The CUs we recently read.  */
   std::vector<dwarf2_per_cu_data *> just_read_cus;