]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb/dwarf: pass section to dwarf2_per_cu_data constructor
authorSimon Marchi <simon.marchi@polymtl.ca>
Mon, 17 Feb 2025 19:59:34 +0000 (14:59 -0500)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 19 Feb 2025 16:14:41 +0000 (11:14 -0500)
Same as the previous patch, but for the containing section.

Change-Id: I469147cce21525d61b3cf6edd9a9f4b12027c176
Approved-By: Tom Tromey <tom@tromey.com>
gdb/dwarf2/read-gdb-index.c
gdb/dwarf2/read.c
gdb/dwarf2/read.h

index 1d4f56aa919a60c7a44f87af2f3d4c85b4a304c9..103fc734778b03ab4a031974fc6e4849a6c62f01 100644 (file)
@@ -1380,9 +1380,9 @@ create_signatured_type_table_from_gdb_index
       signature = extract_unsigned_integer (bytes + 16, 8, BFD_ENDIAN_LITTLE);
       bytes += 3 * 8;
 
-      sig_type = per_bfd->allocate_signatured_type (sect_off, signature);
+      sig_type
+       = per_bfd->allocate_signatured_type (section, sect_off, signature);
       sig_type->type_offset_in_tu = type_offset_in_tu;
-      sig_type->section = section;
 
       slot = htab_find_slot (sig_types_hash.get (), sig_type.get (), INSERT);
       *slot = sig_type.get ();
index 1349a657431cf632b8136ba1cb7ddcb1e2d3d05e..de932a82fe0f779ec04635716a44fe2877981596 100644 (file)
@@ -1816,9 +1816,11 @@ dw2_instantiate_symtab (dwarf2_per_cu_data *per_cu,
 /* See read.h.  */
 
 dwarf2_per_cu_data_up
-dwarf2_per_bfd::allocate_per_cu (sect_offset sect_off)
+dwarf2_per_bfd::allocate_per_cu (dwarf2_section_info *section,
+                                sect_offset sect_off)
 {
-  dwarf2_per_cu_data_up result (new dwarf2_per_cu_data (this, sect_off));
+  dwarf2_per_cu_data_up result (new dwarf2_per_cu_data (this, section,
+                                                       sect_off));
   result->index = all_units.size ();
   return result;
 }
@@ -1826,9 +1828,12 @@ dwarf2_per_bfd::allocate_per_cu (sect_offset sect_off)
 /* See read.h.  */
 
 signatured_type_up
-dwarf2_per_bfd::allocate_signatured_type (sect_offset sect_off, ULONGEST signature)
+dwarf2_per_bfd::allocate_signatured_type (dwarf2_section_info *section,
+                                         sect_offset sect_off,
+                                         ULONGEST signature)
 {
-  signatured_type_up result (new signatured_type (this, sect_off, signature));
+  auto result
+    = std::make_unique<signatured_type> (this, section, sect_off, signature);
   result->index = all_units.size ();
   result->is_debug_types = true;
   tu_stats.nr_tus++;
@@ -1843,9 +1848,8 @@ create_cu_from_index_list (dwarf2_per_bfd *per_bfd,
                           int is_dwz,
                           sect_offset sect_off, ULONGEST length)
 {
-  dwarf2_per_cu_data_up the_cu = per_bfd->allocate_per_cu (sect_off);
+  dwarf2_per_cu_data_up the_cu = per_bfd->allocate_per_cu (section, sect_off);
   the_cu->set_length (length);
-  the_cu->section = section;
   the_cu->is_dwz = is_dwz;
   return the_cu;
 }
@@ -2718,14 +2722,14 @@ create_debug_types_hash_table (dwarf2_per_objfile *per_objfile,
    Otherwise we find one.  */
 
 static struct signatured_type *
-add_type_unit (dwarf2_per_bfd *per_bfd, sect_offset sect_off, ULONGEST sig,
-              void **slot)
+add_type_unit (dwarf2_per_bfd *per_bfd, dwarf2_section_info *section,
+              sect_offset sect_off, ULONGEST sig, void **slot)
 {
   if (per_bfd->all_units.size () == per_bfd->all_units.capacity ())
     ++per_bfd->tu_stats.nr_all_type_units_reallocs;
 
   signatured_type_up sig_type_holder
-    = per_bfd->allocate_signatured_type (sect_off, sig);
+    = per_bfd->allocate_signatured_type (section, sect_off, sig);
   signatured_type *sig_type = sig_type_holder.get ();
 
   per_bfd->all_units.emplace_back (sig_type_holder.release ());
@@ -2759,7 +2763,6 @@ fill_in_sig_entry_from_dwo_entry (dwarf2_per_objfile *per_objfile,
   gdb_assert (sig_entry->dwo_unit == NULL
              || sig_entry->dwo_unit == dwo_entry);
 
-  sig_entry->section = dwo_entry->section;
   sig_entry->set_length (dwo_entry->length, false);
   sig_entry->reading_dwo_directly = 1;
   sig_entry->type_offset_in_tu = dwo_entry->type_offset_in_tu;
@@ -2800,7 +2803,7 @@ lookup_dwo_signatured_type (struct dwarf2_cu *cu, ULONGEST sig)
      the TU has an entry in .gdb_index, replace the recorded data from
      .gdb_index with this TU.  */
 
-  signatured_type find_sig_entry (nullptr, sect_offset {}, sig);
+  signatured_type find_sig_entry (nullptr, nullptr, sect_offset {}, sig);
   slot = htab_find_slot (per_bfd->signatured_types.get (), &find_sig_entry,
                         INSERT);
   signatured_type *sig_entry = (struct signatured_type *) *slot;
@@ -2832,7 +2835,8 @@ lookup_dwo_signatured_type (struct dwarf2_cu *cu, ULONGEST sig)
 
   /* If the global table doesn't have an entry for this TU, add one.  */
   if (sig_entry == NULL)
-    sig_entry = add_type_unit (per_bfd, dwo_entry->sect_off, sig, slot);
+    sig_entry = add_type_unit (per_bfd, dwo_entry->section, dwo_entry->sect_off,
+                              sig, slot);
 
   if (sig_entry->dwo_unit == nullptr)
     fill_in_sig_entry_from_dwo_entry (per_objfile, sig_entry, dwo_entry);
@@ -2862,7 +2866,7 @@ lookup_dwp_signatured_type (struct dwarf2_cu *cu, ULONGEST sig)
   if (per_bfd->signatured_types == NULL)
     per_bfd->signatured_types = allocate_signatured_type_table ();
 
-  signatured_type find_sig_entry (nullptr, sect_offset {}, sig);
+  signatured_type find_sig_entry (nullptr, nullptr, sect_offset {}, sig);
   slot = htab_find_slot (per_bfd->signatured_types.get (), &find_sig_entry,
                         INSERT);
   signatured_type *sig_entry = (struct signatured_type *) *slot;
@@ -2880,7 +2884,7 @@ lookup_dwp_signatured_type (struct dwarf2_cu *cu, ULONGEST sig)
   if (dwo_entry == NULL)
     return NULL;
 
-  sig_entry = add_type_unit (per_bfd, dwo_entry->sect_off, sig, slot);
+  sig_entry = add_type_unit (per_bfd, nullptr, dwo_entry->sect_off, sig, slot);
   fill_in_sig_entry_from_dwo_entry (per_objfile, sig_entry, dwo_entry);
 
   return sig_entry;
@@ -2908,7 +2912,7 @@ lookup_signatured_type (struct dwarf2_cu *cu, ULONGEST sig)
     {
       if (per_objfile->per_bfd->signatured_types == NULL)
        return NULL;
-      signatured_type find_entry (nullptr, sect_offset {}, sig);
+      signatured_type find_entry (nullptr, nullptr, sect_offset {}, sig);
       return ((struct signatured_type *)
              htab_find (per_objfile->per_bfd->signatured_types.get (),
                         &find_entry));
@@ -4047,7 +4051,8 @@ process_skeletonless_type_unit (void **slot, void *info)
   if (per_bfd->signatured_types == NULL)
     per_bfd->signatured_types = allocate_signatured_type_table ();
 
-  signatured_type find_entry (nullptr, sect_offset {}, dwo_unit->signature);
+  signatured_type find_entry (nullptr, nullptr, sect_offset {},
+                             dwo_unit->signature);
   slot = htab_find_slot (per_bfd->signatured_types.get (), &find_entry, INSERT);
 
   /* If we've already seen this type there's nothing to do.  What's happening
@@ -4058,7 +4063,8 @@ process_skeletonless_type_unit (void **slot, void *info)
   /* This does the job that create_all_units would have done for
      this TU.  */
   signatured_type *entry
-    = add_type_unit (per_bfd, dwo_unit->sect_off, dwo_unit->signature, slot);
+    = add_type_unit (per_bfd, dwo_unit->section, dwo_unit->sect_off,
+                    dwo_unit->signature, slot);
   fill_in_sig_entry_from_dwo_entry (per_objfile, entry, dwo_unit);
   *slot = entry;
 
@@ -4321,14 +4327,14 @@ read_comp_units_from_section (dwarf2_per_objfile *per_objfile,
 
       /* Save the compilation unit for later lookup.  */
       if (cu_header.unit_type != DW_UT_type)
-       this_cu = per_objfile->per_bfd->allocate_per_cu (sect_off);
+       this_cu = per_objfile->per_bfd->allocate_per_cu (section, sect_off);
       else
        {
          if (types_htab == nullptr)
            types_htab = allocate_signatured_type_table ();
 
          auto sig_type = per_objfile->per_bfd->allocate_signatured_type
-           (sect_off, cu_header.signature);
+           (section, sect_off, cu_header.signature);
          signatured_type *sig_ptr = sig_type.get ();
          sig_type->type_offset_in_tu = cu_header.type_cu_offset_in_tu;
          this_cu.reset (sig_type.release ());
@@ -4346,7 +4352,6 @@ read_comp_units_from_section (dwarf2_per_objfile *per_objfile,
 
       this_cu->set_length (cu_header.get_length_with_initial ());
       this_cu->is_dwz = is_dwz;
-      this_cu->section = section;
       /* Init this asap, to avoid a data race in the set_version in
         cutu_reader::cutu_reader (which may be run in parallel for the cooked
         index case).  */
@@ -7143,9 +7148,8 @@ create_cus_hash_table (dwarf2_per_objfile *per_objfile,
       void **slot;
       sect_offset sect_off = (sect_offset) (info_ptr - section.buffer);
 
-      dwarf2_per_cu_data per_cu (per_bfd, sect_off);
+      dwarf2_per_cu_data per_cu (per_bfd, &section, sect_off);
       per_cu.is_debug_types = 0;
-      per_cu.section = &section;
 
       cutu_reader reader (&per_cu, per_objfile, cu, &dwo_file);
       if (!reader.dummy_p)
@@ -21143,7 +21147,7 @@ run_test ()
   const auto create_dummy_per_cu = [] ()
     {
       return (dwarf2_per_cu_data_up
-             (new dwarf2_per_cu_data (nullptr,sect_offset {})));
+             (new dwarf2_per_cu_data (nullptr, nullptr, sect_offset {})));
     };
 
   dwarf2_per_cu_data_up one = create_dummy_per_cu ();
index d56f08379f34f3f192e639e1764672348002bb06..2aa6e58ddaffe53802804b474ac3097bdaa30143 100644 (file)
@@ -96,7 +96,8 @@ using dwarf2_per_cu_data_up
 
 struct dwarf2_per_cu_data
 {
-  dwarf2_per_cu_data (dwarf2_per_bfd *per_bfd, sect_offset sect_off)
+  dwarf2_per_cu_data (dwarf2_per_bfd *per_bfd, dwarf2_section_info *section,
+                     sect_offset sect_off)
     : sect_off (sect_off),
       is_debug_types (false),
       is_dwz (false),
@@ -108,6 +109,7 @@ struct dwarf2_per_cu_data
       mark (false),
       files_read (false),
       scanned (false),
+      section (section),
       per_bfd (per_bfd)
   {
   }
@@ -369,9 +371,9 @@ public:
 
 struct signatured_type : public dwarf2_per_cu_data
 {
-  signatured_type (dwarf2_per_bfd *per_bfd, sect_offset sect_off,
-                  ULONGEST signature)
-    : dwarf2_per_cu_data (per_bfd, sect_off),
+  signatured_type (dwarf2_per_bfd *per_bfd, dwarf2_section_info *section,
+                  sect_offset sect_off, ULONGEST signature)
+    : dwarf2_per_cu_data (per_bfd, section, sect_off),
       signature (signature)
   {}
 
@@ -448,12 +450,14 @@ struct dwarf2_per_bfd
   /* A convenience function to allocate a dwarf2_per_cu_data.  The
      returned object has its "index" field set properly.  The object
      is allocated on the dwarf2_per_bfd obstack.  */
-  dwarf2_per_cu_data_up allocate_per_cu (sect_offset sect_off);
+  dwarf2_per_cu_data_up allocate_per_cu (dwarf2_section_info *section,
+                                        sect_offset sect_off);
 
   /* A convenience function to allocate a signatured_type.  The
      returned object has its "index" field set properly.  The object
      is allocated on the dwarf2_per_bfd obstack.  */
-  signatured_type_up allocate_signatured_type (sect_offset sect_off,
+  signatured_type_up allocate_signatured_type (dwarf2_section_info *section,
+                                              sect_offset sect_off,
                                               ULONGEST signature);
 
   /* Map all the DWARF section data needed when scanning