public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 30/30] Remove dwarf2_per_cu_data::v
Date: Wed, 25 Aug 2021 20:19:37 -0600	[thread overview]
Message-ID: <20210826021937.1490292-31-tom@tromey.com> (raw)
In-Reply-To: <20210826021937.1490292-1-tom@tromey.com>

Now that the psymtab reader has been removed, the
dwarf2_per_cu_data::v union is no longer needed.  Instead, we can
simply move the members from dwarf2_per_cu_quick_data into
dwarf2_per_cu_data and remove the "quick" object entirely.
---
 gdb/dwarf2/read.c | 78 +++++++++++------------------------------------
 gdb/dwarf2/read.h | 19 +++++++++---
 2 files changed, 31 insertions(+), 66 deletions(-)

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 2d8397a4dce..58e85efa233 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -1891,25 +1891,6 @@ struct quick_file_names
   const char **real_names;
 };
 
-/* When using the index (and thus not using psymtabs), each CU has an
-   object of this type.  This is used to hold information needed by
-   the various "quick" methods.  */
-struct dwarf2_per_cu_quick_data
-{
-  /* The file table.  This can be NULL if there was no file table
-     or it's currently not read in.
-     NOTE: This points into dwarf2_per_objfile->per_bfd->quick_file_names_table.  */
-  struct quick_file_names *file_names;
-
-  /* A temporary mark bit used when iterating over all CUs in
-     expand_symtabs_matching.  */
-  unsigned int mark : 1;
-
-  /* True if we've tried to read the file table.  There will be no
-     point in trying to read it again next time.  */
-  bool files_read : 1;
-};
-
 struct dwarf2_base_index_functions : public quick_symbol_functions
 {
   bool has_symbols (struct objfile *objfile) override;
@@ -2188,8 +2169,6 @@ create_cu_from_index_list (dwarf2_per_bfd *per_bfd,
   the_cu->sect_off = sect_off;
   the_cu->length = length;
   the_cu->section = section;
-  the_cu->v.quick = OBSTACK_ZALLOC (&per_bfd->obstack,
-				    struct dwarf2_per_cu_quick_data);
   the_cu->is_dwz = is_dwz;
   return the_cu;
 }
@@ -2270,9 +2249,6 @@ create_signatured_type_table_from_index
       sig_type->type_offset_in_tu = type_offset_in_tu;
       sig_type->section = section;
       sig_type->sect_off = sect_off;
-      sig_type->v.quick
-	= OBSTACK_ZALLOC (&per_bfd->obstack,
-			  struct dwarf2_per_cu_quick_data);
 
       slot = htab_find_slot (sig_types_hash.get (), sig_type.get (), INSERT);
       *slot = sig_type.get ();
@@ -2321,9 +2297,6 @@ create_signatured_type_table_from_debug_names
       sig_type->type_offset_in_tu = cu_header.type_cu_offset_in_tu;
       sig_type->section = section;
       sig_type->sect_off = sect_off;
-      sig_type->v.quick
-	= OBSTACK_ZALLOC (&per_objfile->per_bfd->obstack,
-			  struct dwarf2_per_cu_quick_data);
 
       slot = htab_find_slot (sig_types_hash.get (), sig_type.get (), INSERT);
       *slot = sig_type.get ();
@@ -2799,7 +2772,7 @@ dw2_get_file_names_reader (const struct die_reader_specs *reader,
 
   gdb_assert (! this_cu->is_debug_types);
 
-  this_cu->v.quick->files_read = true;
+  this_cu->files_read = true;
   /* Our callers never want to match partial units -- instead they
      will match the enclosing full CU.  */
   if (comp_unit_die->tag == DW_TAG_partial_unit)
@@ -2826,7 +2799,7 @@ dw2_get_file_names_reader (const struct die_reader_specs *reader,
 			     &find_entry, INSERT);
       if (*slot != NULL)
 	{
-	  lh_cu->v.quick->file_names = (struct quick_file_names *) *slot;
+	  lh_cu->file_names = (struct quick_file_names *) *slot;
 	  return;
 	}
 
@@ -2878,7 +2851,7 @@ dw2_get_file_names_reader (const struct die_reader_specs *reader,
 
   qfn->real_names = NULL;
 
-  lh_cu->v.quick->file_names = qfn;
+  lh_cu->file_names = qfn;
 }
 
 /* A helper for the "quick" functions which attempts to read the line
@@ -2893,14 +2866,14 @@ dw2_get_file_names (dwarf2_per_cu_data *this_cu,
   /* Nor type unit groups.  */
   gdb_assert (! this_cu->type_unit_group_p ());
 
-  if (this_cu->v.quick->files_read)
-    return this_cu->v.quick->file_names;
+  if (this_cu->files_read)
+    return this_cu->file_names;
 
   cutu_reader reader (this_cu, per_objfile);
   if (!reader.dummy_p)
     dw2_get_file_names_reader (&reader, reader.comp_unit_die);
 
-  return this_cu->v.quick->file_names;
+  return this_cu->file_names;
 }
 
 /* A helper for the "quick" functions which computes and caches the
@@ -2949,10 +2922,10 @@ dwarf2_base_index_functions::find_last_source_symtab (struct objfile *objfile)
 void
 dwarf2_per_cu_data::free_cached_file_names ()
 {
-  if (per_bfd == nullptr || v.quick == nullptr)
+  if (per_bfd == nullptr)
     return;
 
-  struct quick_file_names *file_data = v.quick->file_names;
+  struct quick_file_names *file_data = file_names;
   if (file_data != nullptr && file_data->real_names != nullptr)
     {
       for (int i = 0; i < file_data->num_file_names; ++i)
@@ -4024,7 +3997,7 @@ dw2_expand_symtabs_matching_one
    gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher,
    gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify)
 {
-  if (file_matcher == NULL || per_cu->v.quick->mark)
+  if (file_matcher == NULL || per_cu->mark)
     {
       bool symtab_was_null = !per_objfile->symtab_set_p (per_cu);
 
@@ -4165,7 +4138,7 @@ dw_expand_symtabs_matching_file_matcher
 
       if (per_cu->is_debug_types)
 	continue;
-      per_cu->v.quick->mark = 0;
+      per_cu->mark = 0;
 
       /* We only need to look at symtabs not already expanded.  */
       if (per_objfile->symtab_set_p (per_cu.get ()))
@@ -4180,7 +4153,7 @@ dw_expand_symtabs_matching_file_matcher
 	continue;
       else if (htab_find (visited_found.get (), file_data) != NULL)
 	{
-	  per_cu->v.quick->mark = 1;
+	  per_cu->mark = 1;
 	  continue;
 	}
 
@@ -4190,7 +4163,7 @@ dw_expand_symtabs_matching_file_matcher
 
 	  if (file_matcher (file_data->file_names[j], false))
 	    {
-	      per_cu->v.quick->mark = 1;
+	      per_cu->mark = 1;
 	      break;
 	    }
 
@@ -4204,12 +4177,12 @@ dw_expand_symtabs_matching_file_matcher
 	  this_real_name = dw2_get_real_path (per_objfile, file_data, j);
 	  if (file_matcher (this_real_name, false))
 	    {
-	      per_cu->v.quick->mark = 1;
+	      per_cu->mark = 1;
 	      break;
 	    }
 	}
 
-      void **slot = htab_find_slot (per_cu->v.quick->mark
+      void **slot = htab_find_slot (per_cu->mark
 				    ? visited_found.get ()
 				    : visited_not_found.get (),
 				    file_data, INSERT);
@@ -4353,8 +4326,8 @@ dwarf2_base_index_functions::map_symbol_filenames
       if (!per_cu->is_debug_types
 	  && per_objfile->symtab_set_p (per_cu.get ()))
 	{
-	  if (per_cu->v.quick->file_names != nullptr)
-	    qfn_cache.insert (per_cu->v.quick->file_names);
+	  if (per_cu->file_names != nullptr)
+	    qfn_cache.insert (per_cu->file_names);
 	}
     }
 
@@ -5345,14 +5318,6 @@ dwarf2_initialize_objfile (struct objfile *objfile)
       per_bfd->quick_file_names_table
 	= create_quick_file_names_table (per_bfd->all_comp_units.size ());
 
-      for (int i = 0; i < per_bfd->all_comp_units.size (); ++i)
-	{
-	  dwarf2_per_cu_data *per_cu = per_bfd->get_cu (i);
-
-	  per_cu->v.quick = OBSTACK_ZALLOC (&per_bfd->obstack,
-					    struct dwarf2_per_cu_quick_data);
-	}
-
       /* Arrange for gdb to see the "quick" functions.  However, these
 	 functions will be no-ops because we will have expanded all
 	 symtabs.  */
@@ -5679,8 +5644,6 @@ add_type_unit (dwarf2_per_objfile *per_objfile, ULONGEST sig, void **slot)
 
   per_objfile->per_bfd->all_comp_units.emplace_back
     (sig_type_holder.release ());
-  sig_type->v.quick = OBSTACK_ZALLOC (&per_objfile->per_bfd->obstack,
-				      struct dwarf2_per_cu_quick_data);
 
   if (slot == NULL)
     {
@@ -5706,7 +5669,6 @@ fill_in_sig_entry_from_dwo_entry (dwarf2_per_objfile *per_objfile,
   /* Make sure we're not clobbering something we don't expect to.  */
   gdb_assert (! sig_entry->queued);
   gdb_assert (per_objfile->get_cu (sig_entry) == NULL);
-  gdb_assert (sig_entry->v.quick != NULL);
   gdb_assert (!per_objfile->symtab_set_p (sig_entry));
   gdb_assert (sig_entry->signature == dwo_entry->signature);
   gdb_assert (to_underlying (sig_entry->type_offset_in_section) == 0
@@ -6541,9 +6503,6 @@ create_type_unit_group (struct dwarf2_cu *cu, sect_offset line_offset_struct)
   std::unique_ptr<type_unit_group> tu_group (new type_unit_group);
   tu_group->per_bfd = per_bfd;
 
-  tu_group->v.quick = OBSTACK_ZALLOC (&per_bfd->obstack,
-				      struct dwarf2_per_cu_quick_data);
-
   tu_group->hash.dwo_unit = cu->dwo_unit;
   tu_group->hash.line_sect_off = line_offset_struct;
 
@@ -7289,9 +7248,6 @@ read_comp_units_from_section (dwarf2_per_objfile *per_objfile,
       this_cu->is_dwz = is_dwz;
       this_cu->section = section;
 
-      this_cu->v.quick = OBSTACK_ZALLOC (&per_objfile->per_bfd->obstack,
-					 struct dwarf2_per_cu_quick_data);
-
       info_ptr = info_ptr + this_cu->length;
       per_objfile->per_bfd->all_comp_units.push_back (std::move (this_cu));
     }
@@ -18677,7 +18633,7 @@ cooked_index_functions::expand_symtabs_matching
 
 	  /* If file-matching was done, we don't need to consider
 	     symbols from unmarked CUs.  */
-	  if (file_matcher != nullptr && !entry->per_cu->v.quick->mark)
+	  if (file_matcher != nullptr && !entry->per_cu->mark)
 	    continue;
 
 	  /* See if the symbol matches the type filter.  */
diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h
index bd3387eb579..0a3ea655bb2 100644
--- a/gdb/dwarf2/read.h
+++ b/gdb/dwarf2/read.h
@@ -103,6 +103,8 @@ struct dwarf2_per_cu_data
       tu_read (false),
       m_header_read_in (false),
       addresses_seen (false),
+      mark (false),
+      files_read (false),
       unit_type {},
       lang (language_unknown),
       scanned (false)
@@ -158,6 +160,14 @@ struct dwarf2_per_cu_data
      .debug_aranges), then this flag is set.  */
   bool addresses_seen : 1;
 
+  /* A temporary mark bit used when iterating over all CUs in
+     expand_symtabs_matching.  */
+  unsigned int mark : 1;
+
+  /* True if we've tried to read the file table.  There will be no
+     point in trying to read it again next time.  */
+  bool files_read : 1;
+
   /* The unit type of this CU.  */
   ENUM_BITFIELD (dwarf_unit_type) unit_type : 8;
 
@@ -188,11 +198,10 @@ struct dwarf2_per_cu_data
      should be private, but we can't make it private at the moment.  */
   mutable comp_unit_head m_header {};
 
-  union
-  {
-    /* Data needed by the "quick" functions.  */
-    struct dwarf2_per_cu_quick_data *quick;
-  } v {};
+  /* The file table.  This can be NULL if there was no file table
+     or it's currently not read in.
+     NOTE: This points into dwarf2_per_objfile->per_bfd->quick_file_names_table.  */
+  struct quick_file_names *file_names = nullptr;
 
   /* The CUs we import using DW_TAG_imported_unit.  This is filled in
      while reading psymtabs, used to compute the psymtab dependencies,
-- 
2.31.1


  parent reply	other threads:[~2021-08-26  4:26 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-26  2:19 [PATCH 00/30] Rewrite the DWARF "partial" reader Tom Tromey
2021-08-26  2:19 ` [PATCH 01/30] Introduce make_unique_xstrndup Tom Tromey
2021-08-26  2:19 ` [PATCH 02/30] Split create_addrmap_from_aranges Tom Tromey
2021-08-26  2:19 ` [PATCH 03/30] Add dwarf2_per_cu_data::addresses_seen Tom Tromey
2021-08-26  2:19 ` [PATCH 04/30] Refactor dwarf2_get_pc_bounds Tom Tromey
2021-08-26  2:19 ` [PATCH 05/30] Allow ada_decode not to decode operators Tom Tromey
2021-08-26  2:19 ` [PATCH 06/30] Let skip_one_die not skip children Tom Tromey
2021-08-26  2:19 ` [PATCH 07/30] Add name splitting Tom Tromey
2021-08-26  2:19 ` [PATCH 08/30] Add new overload of dwarf5_djb_hash Tom Tromey
2021-08-26  2:19 ` [PATCH 09/30] Refactor build_type_psymtabs_reader Tom Tromey
2021-08-26  2:19 ` [PATCH 10/30] Add batching parameter to parallel_for_each Tom Tromey
2021-08-26  2:19 ` [PATCH 11/30] Return vector of results from parallel_for_each Tom Tromey
2021-08-27  6:20   ` Tom de Vries
2021-08-28 19:20     ` Tom Tromey
2021-08-26  2:19 ` [PATCH 12/30] Introduce DWARF abbrev cache Tom Tromey
2021-08-26  2:19 ` [PATCH 13/30] Statically examine abbrev properties Tom Tromey
2021-09-06 22:31   ` Lancelot SIX
2021-11-04 18:00     ` Tom Tromey
2021-08-26  2:19 ` [PATCH 14/30] Update skip_one_die for new " Tom Tromey
2021-08-26  2:19 ` [PATCH 15/30] Introduce the new DWARF index class Tom Tromey
2021-09-09 23:32   ` Lancelot SIX
2021-11-04 18:03     ` Tom Tromey
2021-08-26  2:19 ` [PATCH 16/30] The new DWARF indexer Tom Tromey
2021-08-26  2:19 ` [PATCH 17/30] Implement quick_symbol_functions for cooked DWARF index Tom Tromey
2021-08-26  2:19 ` [PATCH 18/30] Wire in the new DWARF indexer Tom Tromey
2021-08-26  2:19 ` [PATCH 19/30] Pre-read DWARF section data Tom Tromey
2021-08-26  2:19 ` [PATCH 20/30] Parallelize DWARF indexing Tom Tromey
2021-08-26  2:19 ` [PATCH 21/30] "Finalize" the DWARF index in the background Tom Tromey
2021-08-26  2:19 ` [PATCH 22/30] Rename write_psymtabs_to_index Tom Tromey
2021-08-26  2:19 ` [PATCH 23/30] Change the key type in psym_index_map Tom Tromey
2021-08-26  2:19 ` [PATCH 24/30] Change parameters to write_address_map Tom Tromey
2021-08-26  2:19 ` [PATCH 25/30] Genericize addrmap handling in the DWARF index writer Tom Tromey
2021-08-26  2:19 ` [PATCH 26/30] Adapt .gdb_index writer to new DWARF scanner Tom Tromey
2021-08-26  2:19 ` [PATCH 27/30] Adapt .debug_names " Tom Tromey
2021-08-26  2:19 ` [PATCH 28/30] Enable the new DWARF indexer Tom Tromey
2021-08-26  2:19 ` [PATCH 29/30] Delete DWARF psymtab code Tom Tromey
2021-08-26  2:19 ` Tom Tromey [this message]
2021-08-26 20:32 ` [PATCH 00/30] Rewrite the DWARF "partial" reader Tom de Vries
2021-08-26 21:29   ` Tom Tromey
2021-08-27  7:31     ` Tom de Vries
2021-08-30 15:04       ` Tom Tromey
2021-09-06 19:46         ` Tom Tromey
2021-09-07 10:58           ` Tom de Vries
2021-09-07 12:16             ` Tom de Vries
2021-10-29 23:06               ` Tom Tromey
2021-09-09 19:00 ` Wei-min Pan
2021-09-11 21:08   ` Tom Tromey
2021-09-13 16:50     ` Weimin Pan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210826021937.1490292-31-tom@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).