Move die_type_hash to dwarf2_per_objfile
authorSimon Marchi <simon.marchi@efficios.com>
Wed, 27 May 2020 15:13:51 +0000 (11:13 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 27 May 2020 15:15:54 +0000 (11:15 -0400)
The die_type_hash field can't be shared between multiple obfiles, as it
holds `struct type` objects, which are objfile-specific.  Move it from
dwarf2_per_bfd to dwarf2_per_objfile and update all references.

gdb/ChangeLog:

* dwarf2/read.h (struct dwarf2_per_bfd) <die_type_hash>: Move to
struct dwarf2_per_objfile.
(struct dwarf2_per_objfile) <die_type_hash>: Move from struct
dwarf2_per_bfd.
* dwarf2/read.c (set_die_type): Update.
(get_die_type_at_offset): Update.

Change-Id: I3589777ed3579bcabafd2ba859d27babe4502bfb

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

index 55ee15a98cde6d2bc3f01a351330d3b0f533fcae..76b8d7b7e8d39039b636234d7a72b352d3f8db09 100644 (file)
@@ -1,3 +1,12 @@
+2020-05-27  Simon Marchi  <simon.marchi@efficios.com>
+
+       * dwarf2/read.h (struct dwarf2_per_bfd) <die_type_hash>: Move to
+       struct dwarf2_per_objfile.
+       (struct dwarf2_per_objfile) <die_type_hash>: Move from struct
+       dwarf2_per_bfd.
+       * dwarf2/read.c (set_die_type): Update.
+       (get_die_type_at_offset): Update.
+
 2020-05-27  Tom Tromey  <tom@tromey.com>
            Simon Marchi  <simon.marchi@efficios.com>
 
index a7409b5a1ef33f6469b49f3360393a1682774bab..aa39c883b9b1773efefc05f1b9e0e7df6e8f7475 100644 (file)
@@ -23754,8 +23754,8 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
                            cu->per_cu->addr_type ()))
     type->add_dyn_prop (DYN_PROP_DATA_LOCATION, prop);
 
-  if (dwarf2_per_objfile->per_bfd->die_type_hash == NULL)
-    dwarf2_per_objfile->per_bfd->die_type_hash
+  if (dwarf2_per_objfile->die_type_hash == NULL)
+    dwarf2_per_objfile->die_type_hash
       = htab_up (htab_create_alloc (127,
                                    per_cu_offset_and_type_hash,
                                    per_cu_offset_and_type_eq,
@@ -23765,7 +23765,7 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
   ofs.sect_off = die->sect_off;
   ofs.type = type;
   slot = (struct dwarf2_per_cu_offset_and_type **)
-    htab_find_slot (dwarf2_per_objfile->per_bfd->die_type_hash.get (), &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));
@@ -23785,13 +23785,13 @@ get_die_type_at_offset (sect_offset sect_off,
   struct dwarf2_per_cu_offset_and_type *slot, ofs;
   struct dwarf2_per_objfile *dwarf2_per_objfile = per_cu->dwarf2_per_objfile;
 
-  if (dwarf2_per_objfile->per_bfd->die_type_hash == NULL)
+  if (dwarf2_per_objfile->die_type_hash == NULL)
     return NULL;
 
   ofs.per_cu = per_cu;
   ofs.sect_off = sect_off;
   slot = ((struct dwarf2_per_cu_offset_and_type *)
-         htab_find (dwarf2_per_objfile->per_bfd->die_type_hash.get (), &ofs));
+         htab_find (dwarf2_per_objfile->die_type_hash.get (), &ofs));
   if (slot)
     return slot->type;
   else
index 7631938edb0c3e0e7ae506f8b6bdc1503dbf2485..2897ea6e6013c3428028b2ab9bcf5b14e565003d 100644 (file)
@@ -229,11 +229,6 @@ public:
      symbols.  */
   bool reading_partial_symbols = false;
 
-  /* 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_up die_type_hash;
-
   /* The CUs we recently read.  */
   std::vector<dwarf2_per_cu_data *> just_read_cus;
 
@@ -310,6 +305,11 @@ struct dwarf2_per_objfile
      other objfiles backed by the same BFD.  */
   struct dwarf2_per_bfd *per_bfd;
 
+  /* Table mapping type DIEs to their struct type *.
+     This is nullptr if not allocated yet.
+     The mapping is done via (CU/TU + DIE offset) -> type.  */
+  htab_up die_type_hash;
+
 private:
   /* Hold the corresponding compunit_symtab for each CU or TU.  This
      is indexed by dwarf2_per_cu_data::index.  A NULL value means