public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Delete DWARF psymtab code
@ 2022-04-12 15:41 Tom Tromey
  0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2022-04-12 15:41 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=6209cde4ddb85a991ed1dda6f143ef08b75558df

commit 6209cde4ddb85a991ed1dda6f143ef08b75558df
Author: Tom Tromey <tom@tromey.com>
Date:   Sun May 30 08:00:19 2021 -0600

    Delete DWARF psymtab code
    
    This removes the DWARF psymtab reader.

Diff:
---
 gdb/dwarf2/cu.c                                |    1 +
 gdb/dwarf2/index-write.c                       |  338 +--
 gdb/dwarf2/line-header.h                       |    3 -
 gdb/dwarf2/public.h                            |    2 +-
 gdb/dwarf2/read.c                              | 3262 +++---------------------
 gdb/dwarf2/read.h                              |   54 +-
 gdb/testsuite/gdb.dwarf2/gdb-index-nodebug.exp |    8 +
 7 files changed, 455 insertions(+), 3213 deletions(-)

diff --git a/gdb/dwarf2/cu.c b/gdb/dwarf2/cu.c
index d70eb0e25f9..fcb0d77623b 100644
--- a/gdb/dwarf2/cu.c
+++ b/gdb/dwarf2/cu.c
@@ -20,6 +20,7 @@
 #include "defs.h"
 #include "dwarf2/cu.h"
 #include "dwarf2/read.h"
+#include "objfiles.h"
 
 /* Initialize dwarf2_cu to read PER_CU, in the context of PER_OBJFILE.  */
 
diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c
index 8efe370acaf..58b0f0b98e3 100644
--- a/gdb/dwarf2/index-write.c
+++ b/gdb/dwarf2/index-write.c
@@ -36,7 +36,6 @@
 #include "gdb/gdb-index.h"
 #include "gdbcmd.h"
 #include "objfiles.h"
-#include "psympriv.h"
 #include "ada-lang.h"
 
 #include <algorithm>
@@ -412,11 +411,9 @@ typedef std::unordered_map<dwarf2_per_cu_data *, unsigned int> cu_index_map;
 /* Helper struct for building the address table.  */
 struct addrmap_index_data
 {
-  addrmap_index_data (data_buf &addr_vec_, cu_index_map &cu_index_htab_,
-		      bool using_index_)
+  addrmap_index_data (data_buf &addr_vec_, cu_index_map &cu_index_htab_)
     : addr_vec (addr_vec_),
-      cu_index_htab (cu_index_htab_),
-      using_index (using_index_)
+      cu_index_htab (cu_index_htab_)
   {}
 
   data_buf &addr_vec;
@@ -424,8 +421,6 @@ struct addrmap_index_data
 
   int operator() (CORE_ADDR start_addr, void *obj);
 
-  /* True if the DWARF reader uses the new DWARF indexer.  */
-  bool using_index;
   /* True if the previous_* fields are valid.
      We can't write an entry until we see the next entry (since it is only then
      that we know the end of the entry).  */
@@ -452,11 +447,7 @@ add_address_entry (data_buf &addr_vec,
 int
 addrmap_index_data::operator() (CORE_ADDR start_addr, void *obj)
 {
-  dwarf2_per_cu_data *per_cu;
-  if (using_index)
-    per_cu = (dwarf2_per_cu_data *) obj;
-  else
-    per_cu = obj == nullptr ? nullptr : ((dwarf2_psymtab *) obj)->per_cu_data;
+  dwarf2_per_cu_data *per_cu = (dwarf2_per_cu_data *) obj;
 
   if (previous_valid)
     add_address_entry (addr_vec,
@@ -483,10 +474,9 @@ addrmap_index_data::operator() (CORE_ADDR start_addr, void *obj)
 
 static void
 write_address_map (struct addrmap *addrmap, data_buf &addr_vec,
-		   cu_index_map &cu_index_htab, bool using_index)
+		   cu_index_map &cu_index_htab)
 {
-  struct addrmap_index_data addrmap_index_data (addr_vec, cu_index_htab,
-						using_index);
+  struct addrmap_index_data addrmap_index_data (addr_vec, cu_index_htab);
 
   addrmap_foreach (addrmap, addrmap_index_data);
 
@@ -501,142 +491,6 @@ write_address_map (struct addrmap *addrmap, data_buf &addr_vec,
 		       addrmap_index_data.previous_cu_index);
 }
 
-/* Return the symbol kind of PSYM.  */
-
-static gdb_index_symbol_kind
-symbol_kind (struct partial_symbol *psym)
-{
-  domain_enum domain = psym->domain;
-  enum address_class aclass = psym->aclass;
-
-  switch (domain)
-    {
-    case VAR_DOMAIN:
-      switch (aclass)
-	{
-	case LOC_BLOCK:
-	  return GDB_INDEX_SYMBOL_KIND_FUNCTION;
-	case LOC_TYPEDEF:
-	  return GDB_INDEX_SYMBOL_KIND_TYPE;
-	case LOC_COMPUTED:
-	case LOC_CONST_BYTES:
-	case LOC_OPTIMIZED_OUT:
-	case LOC_STATIC:
-	  return GDB_INDEX_SYMBOL_KIND_VARIABLE;
-	case LOC_CONST:
-	  /* Note: It's currently impossible to recognize psyms as enum values
-	     short of reading the type info.  For now punt.  */
-	  return GDB_INDEX_SYMBOL_KIND_VARIABLE;
-	default:
-	  /* There are other LOC_FOO values that one might want to classify
-	     as variables, but dwarf2read.c doesn't currently use them.  */
-	  return GDB_INDEX_SYMBOL_KIND_OTHER;
-	}
-    case STRUCT_DOMAIN:
-      return GDB_INDEX_SYMBOL_KIND_TYPE;
-    default:
-      return GDB_INDEX_SYMBOL_KIND_OTHER;
-    }
-}
-
-/* Add a list of partial symbols to SYMTAB.  */
-
-static void
-write_psymbols (struct mapped_symtab *symtab,
-		std::unordered_set<partial_symbol *> &psyms_seen,
-		const std::vector<partial_symbol *> &symbols,
-		offset_type cu_index,
-		int is_static)
-{
-  for (partial_symbol *psym : symbols)
-    {
-      const char *name = psym->ginfo.search_name ();
-
-      if (psym->ginfo.language () == language_ada)
-	{
-	  /* We want to ensure that the Ada main function's name appears
-	     verbatim in the index.  However, this name will be of the
-	     form "_ada_mumble", and will be rewritten by ada_decode.
-	     So, recognize it specially here and add it to the index by
-	     hand.  */
-	  if (strcmp (main_name (), name) == 0)
-	    {
-	      gdb_index_symbol_kind kind = symbol_kind (psym);
-
-	      add_index_entry (symtab, name, is_static, kind, cu_index);
-	    }
-
-	  /* In order for the index to work when read back into gdb, it
-	     has to supply a funny form of the name: it should be the
-	     encoded name, with any suffixes stripped.  Using the
-	     ordinary encoded name will not work properly with the
-	     searching logic in find_name_components_bounds; nor will
-	     using the decoded name.  Furthermore, an Ada "verbatim"
-	     name (of the form "<MumBle>") must be entered without the
-	     angle brackets.  Note that the current index is unusual,
-	     see PR symtab/24820 for details.  */
-	  std::string decoded = ada_decode (name);
-	  if (decoded[0] == '<')
-	    name = (char *) obstack_copy0 (&symtab->m_string_obstack,
-					   decoded.c_str () + 1,
-					   decoded.length () - 2);
-	  else
-	    name = obstack_strdup (&symtab->m_string_obstack,
-				   ada_encode (decoded.c_str ()));
-	}
-
-      /* Only add a given psymbol once.  */
-      if (psyms_seen.insert (psym).second)
-	{
-	  gdb_index_symbol_kind kind = symbol_kind (psym);
-
-	  add_index_entry (symtab, name, is_static, kind, cu_index);
-	}
-    }
-}
-
-/* Recurse into all "included" dependencies and count their symbols as
-   if they appeared in this psymtab.  */
-
-static void
-recursively_count_psymbols (partial_symtab *psymtab,
-			    size_t &psyms_seen)
-{
-  for (int i = 0; i < psymtab->number_of_dependencies; ++i)
-    if (psymtab->dependencies[i]->user != NULL)
-      recursively_count_psymbols (psymtab->dependencies[i],
-				  psyms_seen);
-
-  psyms_seen += psymtab->global_psymbols.size ();
-  psyms_seen += psymtab->static_psymbols.size ();
-}
-
-/* Recurse into all "included" dependencies and write their symbols as
-   if they appeared in this psymtab.  */
-
-static void
-recursively_write_psymbols (struct objfile *objfile,
-			    partial_symtab *psymtab,
-			    struct mapped_symtab *symtab,
-			    std::unordered_set<partial_symbol *> &psyms_seen,
-			    offset_type cu_index)
-{
-  int i;
-
-  for (i = 0; i < psymtab->number_of_dependencies; ++i)
-    if (psymtab->dependencies[i]->user != NULL)
-      recursively_write_psymbols (objfile,
-				  psymtab->dependencies[i],
-				  symtab, psyms_seen, cu_index);
-
-  write_psymbols (symtab, psyms_seen,
-		  psymtab->global_psymbols, cu_index,
-		  0);
-  write_psymbols (symtab, psyms_seen,
-		  psymtab->static_psymbols, cu_index,
-		  1);
-}
-
 /* DWARF-5 .debug_names builder.  */
 class debug_names
 {
@@ -710,18 +564,6 @@ public:
     value_set.emplace (symbol_value (dwarf_tag, cu_index, is_static, kind));
   }
 
-  void insert (const partial_symbol *psym, int cu_index, bool is_static,
-	       unit_kind kind)
-  {
-    const int dwarf_tag = psymbol_tag (psym);
-    if (dwarf_tag == 0)
-      return;
-    const char *name = psym->ginfo.search_name ();
-
-    insert (dwarf_tag, name, cu_index, is_static, kind,
-	    psym->ginfo.language ());
-  }
-
   void insert (const cooked_index_entry *entry)
   {
     const auto it = m_cu_index_htab.find (entry->per_cu);
@@ -863,25 +705,6 @@ public:
     return m_abbrev_table.size ();
   }
 
-  /* Recurse into all "included" dependencies and store their symbols
-     as if they appeared in this psymtab.  */
-  void recursively_write_psymbols
-    (struct objfile *objfile,
-     partial_symtab *psymtab,
-     std::unordered_set<partial_symbol *> &psyms_seen,
-     int cu_index)
-  {
-    for (int i = 0; i < psymtab->number_of_dependencies; ++i)
-      if (psymtab->dependencies[i]->user != NULL)
-	recursively_write_psymbols
-	  (objfile, psymtab->dependencies[i], psyms_seen, cu_index);
-
-    write_psymbols (psyms_seen, psymtab->global_psymbols,
-		    cu_index, false, unit_kind::cu);
-    write_psymbols (psyms_seen, psymtab->static_psymbols,
-		    cu_index, true, unit_kind::cu);
-  }
-
   /* Return number of bytes the .debug_names section will have.  This
      must be called only after calling the build method.  */
   size_t bytes () const
@@ -1148,59 +971,6 @@ private:
     offset_vec_tmpl<OffsetSize> m_name_table_entry_offs;
   };
 
-  /* Try to reconstruct original DWARF tag for given partial_symbol.
-     This function is not DWARF-5 compliant but it is sufficient for
-     GDB as a DWARF-5 index consumer.  */
-  static int psymbol_tag (const struct partial_symbol *psym)
-  {
-    domain_enum domain = psym->domain;
-    enum address_class aclass = psym->aclass;
-
-    switch (domain)
-      {
-      case VAR_DOMAIN:
-	switch (aclass)
-	  {
-	  case LOC_BLOCK:
-	    return DW_TAG_subprogram;
-	  case LOC_TYPEDEF:
-	    return DW_TAG_typedef;
-	  case LOC_COMPUTED:
-	  case LOC_CONST_BYTES:
-	  case LOC_OPTIMIZED_OUT:
-	  case LOC_STATIC:
-	    return DW_TAG_variable;
-	  case LOC_CONST:
-	    /* Note: It's currently impossible to recognize psyms as enum values
-	       short of reading the type info.  For now punt.  */
-	    return DW_TAG_variable;
-	  default:
-	    /* There are other LOC_FOO values that one might want to classify
-	       as variables, but dwarf2read.c doesn't currently use them.  */
-	    return DW_TAG_variable;
-	  }
-      case STRUCT_DOMAIN:
-	return DW_TAG_structure_type;
-      case MODULE_DOMAIN:
-	return DW_TAG_module;
-      default:
-	return 0;
-      }
-  }
-
-  /* Call insert for all partial symbols and mark them in PSYMS_SEEN.  */
-  void write_psymbols (std::unordered_set<partial_symbol *> &psyms_seen,
-		       const std::vector<partial_symbol *> &symbols,
-		       int cu_index, bool is_static, unit_kind kind)
-  {
-    for (partial_symbol *psym : symbols)
-      {
-	/* Only add a given psymbol once.  */
-	if (psyms_seen.insert (psym).second)
-	  insert (psym, cu_index, is_static, kind);
-      }
-  }
-
   /* Store value of each symbol.  */
   std::unordered_map<c_str_view, std::set<symbol_value>, c_str_view_hasher>
     m_name_to_value_set;
@@ -1252,31 +1022,6 @@ check_dwarf64_offsets (dwarf2_per_objfile *per_objfile)
   return false;
 }
 
-/* The psyms_seen set is potentially going to be largish (~40k
-   elements when indexing a -g3 build of GDB itself).  Estimate the
-   number of elements in order to avoid too many rehashes, which
-   require rebuilding buckets and thus many trips to
-   malloc/free.  */
-
-static size_t
-psyms_seen_size (dwarf2_per_objfile *per_objfile)
-{
-  if (per_objfile->per_bfd->using_index)
-    return 0;
-
-  size_t psyms_count = 0;
-  for (const auto &per_cu : per_objfile->per_bfd->all_comp_units)
-    {
-      partial_symtab *psymtab = per_cu->v.psymtab;
-
-      if (psymtab != NULL && psymtab->user == NULL)
-	recursively_count_psymbols (psymtab, psyms_count);
-    }
-  /* Generating an index for gdb itself shows a ratio of
-     TOTAL_SEEN_SYMS/UNIQUE_SYMS or ~5.  4 seems like a good bet.  */
-  return psyms_count / 4;
-}
-
 /* Assert that FILE's size is EXPECTED_SIZE.  Assumes file's seek
    position is at the end of the file.  */
 
@@ -1346,8 +1091,6 @@ write_cooked_index (dwarf2_per_objfile *per_objfile,
 		    const cu_index_map &cu_index_htab,
 		    struct mapped_symtab *symtab)
 {
-  gdb_assert (per_objfile->per_bfd->using_index);
-
   for (const cooked_index_entry *entry
 	 : per_objfile->per_bfd->cooked_index_table->all_entries ())
     {
@@ -1383,7 +1126,6 @@ static void
 write_gdbindex (dwarf2_per_objfile *per_objfile, FILE *out_file,
 		FILE *dwz_out_file)
 {
-  struct objfile *objfile = per_objfile->objfile;
   mapped_symtab symtab;
   data_buf objfile_cu_list;
   data_buf dwz_cu_list;
@@ -1402,33 +1144,17 @@ write_gdbindex (dwarf2_per_objfile *per_objfile, FILE *out_file,
      work here.  Also, the debug_types entries do not appear in
      all_comp_units, but only in their own hash table.  */
 
-  std::unordered_set<partial_symbol *> psyms_seen
-    (psyms_seen_size (per_objfile));
   int counter = 0;
   int types_counter = 0;
   for (int i = 0; i < per_objfile->per_bfd->all_comp_units.size (); ++i)
     {
       dwarf2_per_cu_data *per_cu
 	= per_objfile->per_bfd->all_comp_units[i].get ();
-      partial_symtab *psymtab = (per_objfile->per_bfd->using_index
-				 ? nullptr
-				 : per_cu->v.psymtab);
 
       int &this_counter = per_cu->is_debug_types ? types_counter : counter;
 
-      if (psymtab != NULL)
-	{
-	  if (psymtab->user == NULL)
-	    recursively_write_psymbols (objfile, psymtab, &symtab,
-					psyms_seen, this_counter);
-	}
-
-      if (psymtab != NULL || per_objfile->per_bfd->using_index)
-	{
-	  const auto insertpair = cu_index_htab.emplace (per_cu,
-							 this_counter);
-	  gdb_assert (insertpair.second);
-	}
+      const auto insertpair = cu_index_htab.emplace (per_cu, this_counter);
+      gdb_assert (insertpair.second);
 
       /* The all_comp_units list contains CUs read from the objfile as well as
 	 from the eventual dwz file.  We need to place the entry in the
@@ -1452,21 +1178,14 @@ write_gdbindex (dwarf2_per_objfile *per_objfile, FILE *out_file,
       ++this_counter;
     }
 
-  if (per_objfile->per_bfd->using_index)
-    write_cooked_index (per_objfile, cu_index_htab, &symtab);
+  write_cooked_index (per_objfile, cu_index_htab, &symtab);
 
   /* Dump the address map.  */
   data_buf addr_vec;
-  if (per_objfile->per_bfd->using_index)
-    {
-      std::vector<addrmap *> addrmaps
-	= per_objfile->per_bfd->cooked_index_table->get_addrmaps ();
-      for (auto map : addrmaps)
-	write_address_map (map, addr_vec, cu_index_htab, true);
-    }
-  else
-    write_address_map (per_objfile->per_bfd->partial_symtabs->psymtabs_addrmap,
-		       addr_vec, cu_index_htab, false);
+  std::vector<addrmap *> addrmaps
+    = per_objfile->per_bfd->cooked_index_table->get_addrmaps ();
+  for (auto map : addrmaps)
+    write_address_map (map, addr_vec, cu_index_htab);
 
   /* Now that we've processed all symbols we can shrink their cu_indices
      lists.  */
@@ -1509,8 +1228,6 @@ write_debug_names (dwarf2_per_objfile *per_objfile,
   data_buf cu_list;
   data_buf types_cu_list;
   debug_names nametable (per_objfile, dwarf5_is_dwarf64, dwarf5_byte_order);
-  std::unordered_set<partial_symbol *>
-    psyms_seen (psyms_seen_size (per_objfile));
   int counter = 0;
   int types_counter = 0;
   for (int i = 0; i < per_objfile->per_bfd->all_comp_units.size (); ++i)
@@ -1520,13 +1237,6 @@ write_debug_names (dwarf2_per_objfile *per_objfile,
 
       int &this_counter = per_cu->is_debug_types ? types_counter : counter;
       data_buf &this_list = per_cu->is_debug_types ? types_cu_list : cu_list;
-      partial_symtab *psymtab = (per_objfile->per_bfd->using_index
-				 ? nullptr
-				 : per_cu->v.psymtab);
-
-      if (psymtab != nullptr && psymtab->user == nullptr)
-	nametable.recursively_write_psymbols (objfile, psymtab, psyms_seen,
-					      this_counter);
 
       nametable.add_cu (per_cu, this_counter);
       this_list.append_uint (nametable.dwarf5_offset_size (),
@@ -1540,10 +1250,9 @@ write_debug_names (dwarf2_per_objfile *per_objfile,
 			  - per_objfile->per_bfd->tu_stats.nr_tus));
   gdb_assert (types_counter == per_objfile->per_bfd->tu_stats.nr_tus);
 
-  if (per_objfile->per_bfd->using_index)
-    for (const cooked_index_entry *entry
-	   : per_objfile->per_bfd->cooked_index_table->all_entries ())
-      nametable.insert (entry);
+  for (const cooked_index_entry *entry
+	 : per_objfile->per_bfd->cooked_index_table->all_entries ())
+    nametable.insert (entry);
 
   nametable.build ();
 
@@ -1677,22 +1386,19 @@ write_dwarf_index (dwarf2_per_objfile *per_objfile, const char *dir,
 		   const char *basename, const char *dwz_basename,
 		   dw_index_kind index_kind)
 {
-  dwarf2_per_bfd *per_bfd = per_objfile->per_bfd;
   struct objfile *objfile = per_objfile->objfile;
 
-  if (per_objfile->per_bfd->using_index
-      && per_objfile->per_bfd->cooked_index_table == nullptr)
-    error (_("Cannot use an index to create the index"));
+  if (per_objfile->per_bfd->cooked_index_table == nullptr)
+    {
+      if (per_objfile->per_bfd->index_table != nullptr
+	  || per_objfile->per_bfd->debug_names_table != nullptr)
+	error (_("Cannot use an index to create the index"));
+      error (_("No debugging symbols"));
+    }
 
   if (per_objfile->per_bfd->types.size () > 1)
     error (_("Cannot make an index when the file has multiple .debug_types sections"));
 
-  if ((per_bfd->partial_symtabs == nullptr
-       || !per_bfd->partial_symtabs->psymtabs
-       || !per_bfd->partial_symtabs->psymtabs_addrmap)
-      && per_bfd->cooked_index_table == nullptr)
-    return;
-
   struct stat st;
   if (stat (objfile_name (objfile), &st) < 0)
     perror_with_name (objfile_name (objfile));
diff --git a/gdb/dwarf2/line-header.h b/gdb/dwarf2/line-header.h
index 252dddd846b..4adfe91b8ac 100644
--- a/gdb/dwarf2/line-header.h
+++ b/gdb/dwarf2/line-header.h
@@ -59,9 +59,6 @@ struct file_entry
 
   unsigned int length {};
 
-  /* True if referenced by the Line Number Program.  */
-  bool included_p {};
-
   /* The associated symbol table, if any.  */
   struct symtab *symtab {};
 };
diff --git a/gdb/dwarf2/public.h b/gdb/dwarf2/public.h
index 1723060a2e8..f002ab2f9b1 100644
--- a/gdb/dwarf2/public.h
+++ b/gdb/dwarf2/public.h
@@ -40,7 +40,7 @@ extern void dwarf2_initialize_objfile (struct objfile *objfile);
 
 struct psymbol_functions;
 extern void dwarf2_build_psymtabs (struct objfile *,
-				   psymbol_functions *psf = nullptr);
+				   bool already_attached = false);
 extern void dwarf2_build_frame_info (struct objfile *);
 
 #endif /* DWARF2_PUBLIC_H */
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 1f72c1bf723..9e3611700a2 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -64,7 +64,6 @@
 #include "block.h"
 #include "addrmap.h"
 #include "typeprint.h"
-#include "psympriv.h"
 #include "c-lang.h"
 #include "go-lang.h"
 #include "valprint.h"
@@ -482,13 +481,8 @@ struct stmt_list_hash
    that can be shared across objfiles.  The non-shareable parts are in
    type_unit_group_unshareable.  */
 
-struct type_unit_group : public dwarf2_per_cu_data
+struct type_unit_group
 {
-  /* The TUs that share this DW_AT_stmt_list entry.
-     This is added to while parsing type units to build partial symtabs,
-     and is deleted afterwards and not used again.  */
-  std::vector<signatured_type *> *tus = nullptr;
-
   /* The data used to construct the hash key.  */
   struct stmt_list_hash hash {};
 };
@@ -838,164 +832,6 @@ private:
   abbrev_table_up m_dwo_abbrev_table;
 };
 
-/* When we construct a partial symbol table entry we only
-   need this much information.  */
-struct partial_die_info : public allocate_on_obstack
-  {
-    partial_die_info (sect_offset sect_off, const struct abbrev_info *abbrev);
-
-    /* Disable assign but still keep copy ctor, which is needed
-       load_partial_dies.   */
-    partial_die_info& operator=(const partial_die_info& rhs) = delete;
-    partial_die_info (const partial_die_info &) = default;
-
-    /* Adjust the partial die before generating a symbol for it.  This
-       function may set the is_external flag or change the DIE's
-       name.  */
-    void fixup (struct dwarf2_cu *cu);
-
-    /* Read a minimal amount of information into the minimal die
-       structure.  */
-    const gdb_byte *read (const struct die_reader_specs *reader,
-			  const struct abbrev_info &abbrev,
-			  const gdb_byte *info_ptr);
-
-    /* Compute the name of this partial DIE.  This memoizes the
-       result, so it is safe to call multiple times.  */
-    const char *name (dwarf2_cu *cu);
-
-    /* Offset of this DIE.  */
-    const sect_offset sect_off;
-
-    /* DWARF-2 tag for this DIE.  */
-    const ENUM_BITFIELD(dwarf_tag) tag : 16;
-
-    /* Assorted flags describing the data found in this DIE.  */
-    const unsigned int has_children : 1;
-
-    unsigned int is_external : 1;
-    unsigned int is_declaration : 1;
-    unsigned int has_type : 1;
-    unsigned int has_specification : 1;
-    unsigned int has_pc_info : 1;
-    unsigned int has_range_info : 1;
-    unsigned int may_be_inlined : 1;
-
-    /* This DIE has been marked DW_AT_main_subprogram.  */
-    unsigned int main_subprogram : 1;
-
-    /* Flag set if the SCOPE field of this structure has been
-       computed.  */
-    unsigned int scope_set : 1;
-
-    /* Flag set if the DIE has a byte_size attribute.  */
-    unsigned int has_byte_size : 1;
-
-    /* Flag set if the DIE has a DW_AT_const_value attribute.  */
-    unsigned int has_const_value : 1;
-
-    /* Flag set if any of the DIE's children are template arguments.  */
-    unsigned int has_template_arguments : 1;
-
-    /* Flag set if fixup has been called on this die.  */
-    unsigned int fixup_called : 1;
-
-    /* Flag set if DW_TAG_imported_unit uses DW_FORM_GNU_ref_alt.  */
-    unsigned int is_dwz : 1;
-
-    /* Flag set if spec_offset uses DW_FORM_GNU_ref_alt.  */
-    unsigned int spec_is_dwz : 1;
-
-    unsigned int canonical_name : 1;
-
-    /* The name of this DIE.  Normally the value of DW_AT_name, but
-       sometimes a default name for unnamed DIEs.  */
-    const char *raw_name = nullptr;
-
-    /* The linkage name, if present.  */
-    const char *linkage_name = nullptr;
-
-    /* The scope to prepend to our children.  This is generally
-       allocated on the comp_unit_obstack, so will disappear
-       when this compilation unit leaves the cache.  */
-    const char *scope = nullptr;
-
-    /* Some data associated with the partial DIE.  The tag determines
-       which field is live.  */
-    union
-    {
-      /* The location description associated with this DIE, if any.  */
-      struct dwarf_block *locdesc;
-      /* The offset of an import, for DW_TAG_imported_unit.  */
-      sect_offset sect_off;
-    } d {};
-
-    union
-    {
-      /* If HAS_PC_INFO, the PC range associated with this DIE.  */
-      struct
-      {
-	CORE_ADDR lowpc;
-	CORE_ADDR highpc;
-      };
-      /* If HAS_RANGE_INFO, the ranges offset associated with this DIE.  */
-      ULONGEST ranges_offset;
-    };
-
-    /* Pointer into the info_buffer (or types_buffer) pointing at the target of
-       DW_AT_sibling, if any.  */
-    /* NOTE: This member isn't strictly necessary, partial_die_info::read
-       could return DW_AT_sibling values to its caller load_partial_dies.  */
-    const gdb_byte *sibling = nullptr;
-
-    /* If HAS_SPECIFICATION, the offset of the DIE referred to by
-       DW_AT_specification (or DW_AT_abstract_origin or
-       DW_AT_extension).  */
-    sect_offset spec_offset {};
-
-    /* Pointers to this DIE's parent, first child, and next sibling,
-       if any.  */
-    struct partial_die_info *die_parent = nullptr;
-    struct partial_die_info *die_child = nullptr;
-    struct partial_die_info *die_sibling = nullptr;
-
-    friend struct partial_die_info *
-    dwarf2_cu::find_partial_die (sect_offset sect_off);
-
-  private:
-    /* Only need to do look up in dwarf2_cu::find_partial_die.  */
-    partial_die_info (sect_offset sect_off)
-      : partial_die_info (sect_off, DW_TAG_padding, 0)
-    {
-    }
-
-    partial_die_info (sect_offset sect_off_, enum dwarf_tag tag_,
-		      int has_children_)
-      : sect_off (sect_off_), tag (tag_), has_children (has_children_)
-    {
-      is_external = 0;
-      is_declaration = 0;
-      has_type = 0;
-      has_specification = 0;
-      has_pc_info = 0;
-      has_range_info = 0;
-      may_be_inlined = 0;
-      main_subprogram = 0;
-      scope_set = 0;
-      has_byte_size = 0;
-      has_const_value = 0;
-      has_template_arguments = 0;
-      fixup_called = 0;
-      is_dwz = 0;
-      spec_is_dwz = 0;
-      canonical_name = 0;
-      /* Don't set these using NSDMI (Non-static data member initialisation),
-	 because g++-4.8 will error out.  */
-      lowpc = 0;
-      highpc = 0;
-    }
-  };
-
 /* FIXME: We might want to set this from BFD via bfd_arch_bits_per_byte,
    but this would require a corresponding change in unpack_field_as_long
    and friends.  */
@@ -1115,63 +951,14 @@ show_dwarf_max_cache_age (struct ui_file *file, int from_tty,
 static void dwarf2_find_base_address (struct die_info *die,
 				      struct dwarf2_cu *cu);
 
-static dwarf2_psymtab *create_partial_symtab
-  (dwarf2_per_cu_data *per_cu, dwarf2_per_objfile *per_objfile,
-   const char *name);
-
 class cooked_index_storage;
 static void build_type_psymtabs_reader (cutu_reader *reader,
 					cooked_index_storage *storage);
 
 static void dwarf2_build_psymtabs_hard (dwarf2_per_objfile *per_objfile);
 
-static void scan_partial_symbols (struct partial_die_info *,
-				  CORE_ADDR *, CORE_ADDR *,
-				  int, struct dwarf2_cu *);
-
-static void add_partial_symbol (struct partial_die_info *,
-				struct dwarf2_cu *);
-
-static void add_partial_namespace (struct partial_die_info *pdi,
-				   CORE_ADDR *lowpc, CORE_ADDR *highpc,
-				   int set_addrmap, struct dwarf2_cu *cu);
-
-static void add_partial_module (struct partial_die_info *pdi, CORE_ADDR *lowpc,
-				CORE_ADDR *highpc, int set_addrmap,
-				struct dwarf2_cu *cu);
-
-static void add_partial_enumeration (struct partial_die_info *enum_pdi,
-				     struct dwarf2_cu *cu);
-
-static void add_partial_subprogram (struct partial_die_info *pdi,
-				    CORE_ADDR *lowpc, CORE_ADDR *highpc,
-				    int need_pc, struct dwarf2_cu *cu);
-
 static unsigned int peek_abbrev_code (bfd *, const gdb_byte *);
 
-static struct partial_die_info *load_partial_dies
-  (const struct die_reader_specs *, const gdb_byte *, int);
-
-/* A pair of partial_die_info and compilation unit.  */
-struct cu_partial_die_info
-{
-  /* The compilation unit of the partial_die_info.  */
-  struct dwarf2_cu *cu;
-  /* A partial_die_info.  */
-  struct partial_die_info *pdi;
-
-  cu_partial_die_info (struct dwarf2_cu *cu, struct partial_die_info *pdi)
-    : cu (cu),
-      pdi (pdi)
-  { /* Nothing.  */ }
-
-private:
-  cu_partial_die_info () = delete;
-};
-
-static const struct cu_partial_die_info find_partial_die (sect_offset, int,
-							  struct dwarf2_cu *);
-
 static const gdb_byte *read_attribute (const struct die_reader_specs *,
 				       struct attribute *,
 				       const struct attr_abbrev *,
@@ -1222,8 +1009,7 @@ static line_header_up dwarf_decode_line_header (sect_offset sect_off,
 						struct dwarf2_cu *cu);
 
 static void dwarf_decode_lines (struct line_header *,
-				const file_and_directory &,
-				struct dwarf2_cu *, dwarf2_psymtab *,
+				struct dwarf2_cu *,
 				CORE_ADDR, int decode_mapping);
 
 static void dwarf2_start_subfile (struct dwarf2_cu *, const char *,
@@ -1460,10 +1246,6 @@ static const gdb_byte *skip_one_die (const struct die_reader_specs *reader,
 				     const struct abbrev_info *abbrev,
 				     bool do_skip_children = true);
 
-static hashval_t partial_die_hash (const void *item);
-
-static int partial_die_eq (const void *item_lhs, const void *item_rhs);
-
 static struct dwarf2_per_cu_data *dwarf2_find_containing_comp_unit
   (sect_offset sect_off, unsigned int offset_in_dwz,
    dwarf2_per_bfd *per_bfd);
@@ -2108,30 +1890,6 @@ struct dwarf2_per_cu_quick_data
   bool files_read : 1;
 };
 
-/* A subclass of psymbol_functions that arranges to read the DWARF
-   partial symbols when needed.  */
-struct lazy_dwarf_reader : public psymbol_functions
-{
-  using psymbol_functions::psymbol_functions;
-
-  bool can_lazily_read_symbols () override
-  {
-    return true;
-  }
-
-  void read_partial_symbols (struct objfile *objfile) override
-  {
-    if (dwarf2_has_info (objfile, nullptr))
-      dwarf2_build_psymtabs (objfile, this);
-  }
-};
-
-static quick_symbol_functions_up
-make_lazy_dwarf_reader ()
-{
-  return quick_symbol_functions_up (new lazy_dwarf_reader);
-}
-
 struct dwarf2_base_index_functions : public quick_symbol_functions
 {
   bool has_symbols (struct objfile *objfile) override;
@@ -2315,11 +2073,6 @@ static void
 dw2_do_instantiate_symtab (dwarf2_per_cu_data *per_cu,
 			   dwarf2_per_objfile *per_objfile, bool skip_partial)
 {
-  /* Skip type_unit_groups, reading the type units they contain
-     is handled elsewhere.  */
-  if (per_cu->type_unit_group_p ())
-    return;
-
   {
     /* The destructor of dwarf2_queue_guard frees any entries left on
        the queue.  After this point we're guaranteed to leave this function
@@ -2362,8 +2115,6 @@ dw2_instantiate_symtab (dwarf2_per_cu_data *per_cu,
 			dwarf2_per_objfile *per_objfile,
 			bool skip_partial)
 {
-  gdb_assert (per_objfile->per_bfd->using_index);
-
   if (!per_objfile->symtab_set_p (per_cu))
     {
       free_cached_comp_units freer (per_objfile);
@@ -3002,7 +2753,6 @@ dwarf2_read_gdb_index
   create_addrmap_from_index (per_objfile, map.get ());
 
   per_bfd->index_table = std::move (map);
-  per_bfd->using_index = 1;
   per_bfd->quick_file_names_table =
     create_quick_file_names_table (per_bfd->all_comp_units.size ());
 
@@ -3116,8 +2866,6 @@ dw2_get_file_names (dwarf2_per_cu_data *this_cu,
 {
   /* This should never be called for TUs.  */
   gdb_assert (! this_cu->is_debug_types);
-  /* 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;
@@ -3178,7 +2926,7 @@ dwarf2_per_cu_data::free_cached_file_names ()
   if (fnd != nullptr)
     fnd->forget_fullname ();
 
-  if (per_bfd == nullptr || !per_bfd->using_index || v.quick == nullptr)
+  if (per_bfd == nullptr || v.quick == nullptr)
     return;
 
   struct quick_file_names *file_data = v.quick->file_names;
@@ -3382,7 +3130,6 @@ dwarf2_gdb_index::dump (struct objfile *objfile)
 {
   dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
 
-  gdb_assert (per_objfile->per_bfd->using_index);
   gdb_printf (".gdb_index:");
   if (per_objfile->per_bfd->index_table != NULL)
     {
@@ -5003,7 +4750,6 @@ dwarf2_read_debug_names (dwarf2_per_objfile *per_objfile)
   create_addrmap_from_aranges (per_objfile, &per_bfd->debug_aranges);
 
   per_bfd->debug_names_table = std::move (map);
-  per_bfd->using_index = 1;
   per_bfd->quick_file_names_table =
     create_quick_file_names_table (per_bfd->all_comp_units.size ());
 
@@ -5429,7 +5175,6 @@ dwarf2_debug_names_index::dump (struct objfile *objfile)
 {
   dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
 
-  gdb_assert (per_objfile->per_bfd->using_index);
   gdb_printf (".debug_names:");
   if (per_objfile->per_bfd->debug_names_table)
     gdb_printf (" exists\n");
@@ -5612,16 +5357,6 @@ dwarf2_initialize_objfile (struct objfile *objfile)
     {
       dwarf_read_debug_printf ("readnow requested");
 
-      /* When using READNOW, the using_index flag (set below) indicates that
-	 PER_BFD was already initialized, when we loaded some other objfile.  */
-      if (per_bfd->using_index)
-	{
-	  dwarf_read_debug_printf ("using_index already set");
-	  objfile->qf.push_front (make_dwarf_gdb_index ());
-	  return;
-	}
-
-      per_bfd->using_index = 1;
       create_all_comp_units (per_objfile);
       per_bfd->quick_file_names_table
 	= create_quick_file_names_table (per_bfd->all_comp_units.size ());
@@ -5666,18 +5401,6 @@ dwarf2_initialize_objfile (struct objfile *objfile)
       return;
     }
 
-  /* There might already be partial symtabs built for this BFD.  This happens
-     when loading the same binary twice with the index-cache enabled.  If so,
-     don't try to read an index.  The objfile / per_objfile initialization will
-     be completed in dwarf2_build_psymtabs, in the standard partial symtabs
-     code path.  */
-  if (per_bfd->partial_symtabs != nullptr)
-    {
-      dwarf_read_debug_printf ("re-using shared partial symtabs");
-      objfile->qf.push_front (make_lazy_dwarf_reader ());
-      return;
-    }
-
   if (dwarf2_read_debug_names (per_objfile))
     {
       dwarf_read_debug_printf ("found debug names");
@@ -5706,7 +5429,6 @@ dwarf2_initialize_objfile (struct objfile *objfile)
     }
 
   global_index_cache.miss ();
-  per_bfd->using_index = true;
   objfile->qf.push_front (make_cooked_index_funcs ());
 }
 
@@ -5715,47 +5437,21 @@ dwarf2_initialize_objfile (struct objfile *objfile)
 /* Build a partial symbol table.  */
 
 void
-dwarf2_build_psymtabs (struct objfile *objfile, psymbol_functions *psf)
+dwarf2_build_psymtabs (struct objfile *objfile, bool already_attached)
 {
   dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
-  dwarf2_per_bfd *per_bfd = per_objfile->per_bfd;
-
-  if (per_bfd->partial_symtabs != nullptr)
-    {
-      /* Partial symbols were already read, so now we can simply
-	 attach them.  */
-      if (psf == nullptr)
-	{
-	  psf = new psymbol_functions (per_bfd->partial_symtabs);
-	  objfile->qf.emplace_front (psf);
-	}
-      else
-	psf->set_partial_symtabs (per_bfd->partial_symtabs);
-      return;
-    }
 
-  if (psf == nullptr)
+  if (already_attached)
     {
-      psf = new psymbol_functions;
-      objfile->qf.emplace_front (psf);
+      if (per_objfile->per_bfd->cooked_index_table != nullptr)
+	return;
     }
-  const std::shared_ptr<psymtab_storage> &partial_symtabs
-    = psf->get_partial_symtabs ();
-
-  /* Set the local reference to partial symtabs, so that we don't try
-     to read them again if reading another objfile with the same BFD.
-     If we can't in fact share, this won't make a difference anyway as
-     the dwarf2_per_bfd object won't be shared.  */
-  per_bfd->partial_symtabs = partial_symtabs;
+  else
+    objfile->qf.push_front (make_cooked_index_funcs ());
 
   try
     {
-      /* This isn't really ideal: all the data we allocate on the
-	 objfile's obstack is still uselessly kept around.  However,
-	 freeing it seems unsafe.  */
-      psymtab_discarder psymtabs (partial_symtabs.get ());
       dwarf2_build_psymtabs_hard (per_objfile);
-      psymtabs.keep ();
 
       /* (maybe) store an index in the cache.  */
       global_index_cache.store (per_objfile);
@@ -5836,111 +5532,6 @@ read_abbrev_offset (dwarf2_per_objfile *per_objfile,
   return (sect_offset) read_offset (abfd, info_ptr, offset_size);
 }
 
-/* A partial symtab that is used only for include files.  */
-struct dwarf2_include_psymtab : public partial_symtab
-{
-  dwarf2_include_psymtab (const char *filename,
-			  psymtab_storage *partial_symtabs,
-			  objfile_per_bfd_storage *objfile_per_bfd)
-    : partial_symtab (filename, partial_symtabs, objfile_per_bfd)
-  {
-  }
-
-  void read_symtab (struct objfile *objfile) override
-  {
-    /* It's an include file, no symbols to read for it.
-       Everything is in the includer symtab.  */
-
-    /* The expansion of a dwarf2_include_psymtab is just a trigger for
-       expansion of the includer psymtab.  We use the dependencies[0] field to
-       model the includer.  But if we go the regular route of calling
-       expand_psymtab here, and having expand_psymtab call expand_dependencies
-       to expand the includer, we'll only use expand_psymtab on the includer
-       (making it a non-toplevel psymtab), while if we expand the includer via
-       another path, we'll use read_symtab (making it a toplevel psymtab).
-       So, don't pretend a dwarf2_include_psymtab is an actual toplevel
-       psymtab, and trigger read_symtab on the includer here directly.  */
-    includer ()->read_symtab (objfile);
-  }
-
-  void expand_psymtab (struct objfile *objfile) override
-  {
-    /* This is not called by read_symtab, and should not be called by any
-       expand_dependencies.  */
-    gdb_assert (false);
-  }
-
-  bool readin_p (struct objfile *objfile) const override
-  {
-    return includer ()->readin_p (objfile);
-  }
-
-  compunit_symtab *get_compunit_symtab (struct objfile *objfile) const override
-  {
-    compunit_symtab *cust = includer ()->get_compunit_symtab (objfile);
-    while (cust != nullptr && cust->user != nullptr)
-      cust = cust->user;
-    return cust;
-  }
-
-private:
-  partial_symtab *includer () const
-  {
-    /* An include psymtab has exactly one dependency: the psymtab that
-       includes it.  */
-    gdb_assert (this->number_of_dependencies == 1);
-    return this->dependencies[0];
-  }
-};
-
-/* Allocate a new partial symtab for file named NAME and mark this new
-   partial symtab as being an include of PST.  */
-
-static void
-dwarf2_create_include_psymtab (dwarf2_per_bfd *per_bfd,
-			       const char *name,
-			       dwarf2_psymtab *pst,
-			       psymtab_storage *partial_symtabs,
-			       objfile_per_bfd_storage *objfile_per_bfd)
-{
-  dwarf2_include_psymtab *subpst
-    = new dwarf2_include_psymtab (name, partial_symtabs, objfile_per_bfd);
-
-  if (!IS_ABSOLUTE_PATH (subpst->filename))
-    subpst->dirname = pst->dirname;
-
-  subpst->dependencies = per_bfd->partial_symtabs->allocate_dependencies (1);
-  subpst->dependencies[0] = pst;
-  subpst->number_of_dependencies = 1;
-}
-
-/* Read the Line Number Program data and extract the list of files
-   included by the source file represented by PST.  Build an include
-   partial symtab for each of these included files.  */
-
-static void
-dwarf2_build_include_psymtabs (struct dwarf2_cu *cu,
-			       struct die_info *die,
-			       const file_and_directory &fnd,
-			       dwarf2_psymtab *pst)
-{
-  line_header_up lh;
-  struct attribute *attr;
-
-  attr = dwarf2_attr (die, DW_AT_stmt_list, cu);
-  if (attr != nullptr && attr->form_is_unsigned ())
-    lh = dwarf_decode_line_header ((sect_offset) attr->as_unsigned (), cu);
-  if (lh == NULL)
-    return;  /* No linetable, so no includes.  */
-
-  /* NOTE: pst->dirname is DW_AT_comp_dir (if present).  Also note
-     that we pass in the raw text_low here; that is ok because we're
-     only decoding the line table to make include partial symtabs, and
-     so the addresses aren't really used.  */
-  dwarf_decode_lines (lh.get (), fnd, cu, pst,
-		      pst->raw_text_low (), 1);
-}
-
 static hashval_t
 hash_signatured_type (const void *item)
 {
@@ -6104,12 +5695,8 @@ 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 ());
-  if (per_objfile->per_bfd->using_index)
-    {
-      sig_type->v.quick =
-	OBSTACK_ZALLOC (&per_objfile->per_bfd->obstack,
-			struct dwarf2_per_cu_quick_data);
-    }
+  sig_type->v.quick = OBSTACK_ZALLOC (&per_objfile->per_bfd->obstack,
+				      struct dwarf2_per_cu_quick_data);
 
   if (slot == NULL)
     {
@@ -6135,13 +5722,8 @@ 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);
-  if (per_bfd->using_index)
-    {
-      gdb_assert (sig_entry->v.quick != NULL);
-      gdb_assert (!per_objfile->symtab_set_p (sig_entry));
-    }
-  else
-      gdb_assert (sig_entry->v.psymtab == 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
 	      || (to_underlying (sig_entry->type_offset_in_section)
@@ -6179,7 +5761,7 @@ lookup_dwo_signatured_type (struct dwarf2_cu *cu, ULONGEST sig)
   struct dwo_unit find_dwo_entry, *dwo_entry;
   void **slot;
 
-  gdb_assert (cu->dwo_unit && per_objfile->per_bfd->using_index);
+  gdb_assert (cu->dwo_unit);
 
   /* If TU skeletons have been removed then we may not have read in any
      TUs yet.  */
@@ -6245,7 +5827,7 @@ lookup_dwp_signatured_type (struct dwarf2_cu *cu, ULONGEST sig)
   struct dwo_unit *dwo_entry;
   void **slot;
 
-  gdb_assert (cu->dwo_unit && per_objfile->per_bfd->using_index);
+  gdb_assert (cu->dwo_unit);
   gdb_assert (dwp_file != NULL);
 
   /* If TU skeletons have been removed then we may not have read in any
@@ -6286,7 +5868,7 @@ lookup_signatured_type (struct dwarf2_cu *cu, ULONGEST sig)
 {
   dwarf2_per_objfile *per_objfile = cu->per_objfile;
 
-  if (cu->dwo_unit && per_objfile->per_bfd->using_index)
+  if (cu->dwo_unit)
     {
       /* We're in a DWO/DWP file, and we're using .gdb_index.
 	 These cases require special processing.  */
@@ -6979,34 +6561,7 @@ allocate_type_unit_groups_table ()
 static std::unique_ptr<type_unit_group>
 create_type_unit_group (struct dwarf2_cu *cu, sect_offset line_offset_struct)
 {
-  dwarf2_per_objfile *per_objfile = cu->per_objfile;
-  dwarf2_per_bfd *per_bfd = per_objfile->per_bfd;
-
   std::unique_ptr<type_unit_group> tu_group (new type_unit_group);
-  tu_group->per_bfd = per_bfd;
-
-  if (per_bfd->using_index)
-    {
-      tu_group->v.quick = OBSTACK_ZALLOC (&per_bfd->obstack,
-					  struct dwarf2_per_cu_quick_data);
-    }
-  else
-    {
-      unsigned int line_offset = to_underlying (line_offset_struct);
-      dwarf2_psymtab *pst;
-      std::string name;
-
-      /* Give the symtab a useful name for debug purposes.  */
-      if ((line_offset & NO_STMT_LIST_TYPE_UNIT_PSYMTAB) != 0)
-	name = string_printf ("<type_units_%d>",
-			      (line_offset & ~NO_STMT_LIST_TYPE_UNIT_PSYMTAB));
-      else
-	name = string_printf ("<type_units_at_0x%x>", line_offset);
-
-      pst = create_partial_symtab (tu_group.get (), per_objfile,
-				   name.c_str ());
-      pst->anonymous = true;
-    }
 
   tu_group->hash.dwo_unit = cu->dwo_unit;
   tu_group->hash.line_sect_off = line_offset_struct;
@@ -7068,30 +6623,6 @@ get_type_unit_group (struct dwarf2_cu *cu, const struct attribute *stmt_list)
   return tu_group;
 }
 \f
-/* Partial symbol tables.  */
-
-/* Create a psymtab named NAME and assign it to PER_CU.
-
-   The caller must fill in the following details:
-   dirname, textlow, texthigh.  */
-
-static dwarf2_psymtab *
-create_partial_symtab (dwarf2_per_cu_data *per_cu,
-		       dwarf2_per_objfile *per_objfile,
-		       const char *name)
-{
-  dwarf2_psymtab *pst
-    = new dwarf2_psymtab (name, per_objfile->per_bfd->partial_symtabs.get (),
-			  per_objfile->objfile->per_bfd, per_cu);
-
-  pst->psymtabs_addrmap_supported = true;
-
-  /* This is the glue that links PST into GDB's symbol API.  */
-  per_cu->v.psymtab = pst;
-
-  return pst;
-}
-\f
 
 /* An instance of this is created when scanning DWARF to create a
    cooked index.  */
@@ -7322,166 +6853,16 @@ private:
   std::vector<deferred_entry> m_deferred_entries;
 };
 
-
-
-/* DIE reader function for process_psymtab_comp_unit.  */
-
-static void
-process_psymtab_comp_unit_reader (const struct die_reader_specs *reader,
-				  const gdb_byte *info_ptr,
-				  struct die_info *comp_unit_die,
-				  enum language pretend_language)
-{
-  struct dwarf2_cu *cu = reader->cu;
-  dwarf2_per_objfile *per_objfile = cu->per_objfile;
-  dwarf2_per_bfd *per_bfd = per_objfile->per_bfd;
-  struct objfile *objfile = per_objfile->objfile;
-  struct gdbarch *gdbarch = objfile->arch ();
-  struct dwarf2_per_cu_data *per_cu = cu->per_cu;
-  CORE_ADDR baseaddr;
-  CORE_ADDR best_lowpc = 0, best_highpc = 0;
-  dwarf2_psymtab *pst;
-  enum pc_bounds_kind cu_bounds_kind;
-
-  gdb_assert (! per_cu->is_debug_types);
-
-  prepare_one_comp_unit (cu, comp_unit_die, pretend_language);
-
-  /* Allocate a new partial symbol table structure.  */
-  static const char artificial[] = "<artificial>";
-  file_and_directory &fnd = find_file_and_directory (comp_unit_die, cu);
-  if (strcmp (fnd.get_name (), artificial) == 0)
-    {
-      gdb::unique_xmalloc_ptr<char> debug_filename
-	(concat (artificial, "@",
-		 sect_offset_str (per_cu->sect_off),
-		 (char *) NULL));
-      fnd.set_name (std::move (debug_filename));
-    }
-
-  pst = create_partial_symtab (per_cu, per_objfile, fnd.get_name ());
-
-  /* This must be done before calling dwarf2_build_include_psymtabs.  */
-  pst->dirname = dwarf2_string_attr (comp_unit_die, DW_AT_comp_dir, cu);
-
-  baseaddr = objfile->text_section_offset ();
-
-  dwarf2_find_base_address (comp_unit_die, cu);
-
-  /* Possibly set the default values of LOWPC and HIGHPC from
-     `DW_AT_ranges'.  */
-  cu_bounds_kind
-    = dwarf2_get_pc_bounds (comp_unit_die, &best_lowpc,
-			    &best_highpc, cu,
-			    per_bfd->partial_symtabs->psymtabs_addrmap,
-			    pst);
-  if (cu_bounds_kind == PC_BOUNDS_HIGH_LOW && best_lowpc < best_highpc)
-    {
-      CORE_ADDR low
-	= (gdbarch_adjust_dwarf2_addr (gdbarch, best_lowpc + baseaddr)
-	   - baseaddr);
-      CORE_ADDR high
-	= (gdbarch_adjust_dwarf2_addr (gdbarch, best_highpc + baseaddr)
-	   - baseaddr - 1);
-      /* Store the contiguous range if it is not empty; it can be
-	 empty for CUs with no code.  */
-      addrmap_set_empty (per_bfd->partial_symtabs->psymtabs_addrmap,
-			 low, high, pst);
-    }
-
-  /* Check if comp unit has_children.
-     If so, read the rest of the partial symbols from this comp unit.
-     If not, there's no more debug_info for this comp unit.  */
-  if (comp_unit_die->has_children)
-    {
-      struct partial_die_info *first_die;
-      CORE_ADDR lowpc, highpc;
-
-      lowpc = ((CORE_ADDR) -1);
-      highpc = ((CORE_ADDR) 0);
-
-      first_die = load_partial_dies (reader, info_ptr, 1);
-
-      scan_partial_symbols (first_die, &lowpc, &highpc,
-			    cu_bounds_kind <= PC_BOUNDS_INVALID, cu);
-
-      /* If we didn't find a lowpc, set it to highpc to avoid
-	 complaints from `maint check'.	 */
-      if (lowpc == ((CORE_ADDR) -1))
-	lowpc = highpc;
-
-      /* If the compilation unit didn't have an explicit address range,
-	 then use the information extracted from its child dies.  */
-      if (cu_bounds_kind <= PC_BOUNDS_INVALID)
-	{
-	  best_lowpc = lowpc;
-	  best_highpc = highpc;
-	}
-    }
-  pst->set_text_low (gdbarch_adjust_dwarf2_addr (gdbarch,
-						 best_lowpc + baseaddr)
-		     - baseaddr);
-  pst->set_text_high (gdbarch_adjust_dwarf2_addr (gdbarch,
-						  best_highpc + baseaddr)
-		      - baseaddr);
-
-  pst->end ();
-
-  if (!cu->per_cu->imported_symtabs_empty ())
-    {
-      int i;
-      int len = cu->per_cu->imported_symtabs_size ();
-
-      /* Fill in 'dependencies' here; we fill in 'users' in a
-	 post-pass.  */
-      pst->number_of_dependencies = len;
-      pst->dependencies
-	= per_bfd->partial_symtabs->allocate_dependencies (len);
-      for (i = 0; i < len; ++i)
-	{
-	  pst->dependencies[i]
-	    = cu->per_cu->imported_symtabs->at (i)->v.psymtab;
-	}
-
-      cu->per_cu->imported_symtabs_free ();
-    }
-
-  /* Get the list of files included in the current compilation unit,
-     and build a psymtab for each of them.  */
-  dwarf2_build_include_psymtabs (cu, comp_unit_die, fnd, pst);
-
-  dwarf_read_debug_printf ("Psymtab for %s unit @%s: %s - %s"
-			   ", %d global, %d static syms",
-			   per_cu->is_debug_types ? "type" : "comp",
-			   sect_offset_str (per_cu->sect_off),
-			   paddress (gdbarch, pst->text_low (objfile)),
-			   paddress (gdbarch, pst->text_high (objfile)),
-			   (int) pst->global_psymbols.size (),
-			   (int) pst->static_psymbols.size ());
-}
-
 /* Subroutine of dwarf2_build_psymtabs_hard to simplify it.
    Process compilation unit THIS_CU for a psymtab.  */
 
 static void
 process_psymtab_comp_unit (dwarf2_per_cu_data *this_cu,
 			   dwarf2_per_objfile *per_objfile,
-			   bool want_partial_unit,
-			   enum language pretend_language,
 			   cooked_index_storage *storage)
 {
-  /* If this compilation unit was already read in, free the
-     cached copy in order to read it in again.	This is
-     necessary because we skipped some symbols when we first
-     read in the compilation unit (see load_partial_dies).
-     This problem could be avoided, but the benefit is unclear.  */
-  if (!per_objfile->per_bfd->using_index)
-    per_objfile->remove_cu (this_cu);
-
   cutu_reader reader (this_cu, per_objfile, nullptr, nullptr, false,
-		      (storage == nullptr
-		       ? nullptr
-		       : storage->get_abbrev_cache ()));
+		      storage->get_abbrev_cache ());
 
   if (reader.comp_unit_die == nullptr)
     return;
@@ -7510,30 +6891,18 @@ process_psymtab_comp_unit (dwarf2_per_cu_data *this_cu,
     }
   else if (this_cu->is_debug_types)
     build_type_psymtabs_reader (&reader, storage);
-  else if (want_partial_unit
-	   || reader.comp_unit_die->tag != DW_TAG_partial_unit)
+  else if (reader.comp_unit_die->tag != DW_TAG_partial_unit)
     {
-      if (per_objfile->per_bfd->using_index)
+      bool nope = false;
+      if (this_cu->scanned.compare_exchange_strong (nope, true))
 	{
-	  bool nope = false;
-	  if (this_cu->scanned.compare_exchange_strong (nope, true))
-	    {
-	      prepare_one_comp_unit (reader.cu, reader.comp_unit_die,
-				     pretend_language);
-	      gdb_assert (storage != nullptr);
-	      cooked_indexer indexer (storage, this_cu,
-				      reader.cu->per_cu->lang);
-	      indexer.make_index (&reader);
-	    }
+	  prepare_one_comp_unit (reader.cu, reader.comp_unit_die,
+				 language_minimal);
+	  gdb_assert (storage != nullptr);
+	  cooked_indexer indexer (storage, this_cu, reader.cu->per_cu->lang);
+	  indexer.make_index (&reader);
 	}
-      else
-	process_psymtab_comp_unit_reader (&reader, reader.info_ptr,
-					  reader.comp_unit_die,
-					  pretend_language);
     }
-
-  /* Age out any secondary CUs.  */
-  per_objfile->age_comp_units ();
 }
 
 /* Reader function for build_type_psymtabs.  */
@@ -7542,52 +6911,20 @@ static void
 build_type_psymtabs_reader (cutu_reader *reader,
 			    cooked_index_storage *storage)
 {
-  dwarf2_per_objfile *per_objfile = reader->cu->per_objfile;
   struct dwarf2_cu *cu = reader->cu;
   struct dwarf2_per_cu_data *per_cu = cu->per_cu;
-  struct signatured_type *sig_type;
-  struct type_unit_group *tu_group;
-  struct attribute *attr;
-  struct partial_die_info *first_die;
-  CORE_ADDR lowpc, highpc;
-  dwarf2_psymtab *pst;
-  const gdb_byte *info_ptr = reader->info_ptr;
   struct die_info *type_unit_die = reader->comp_unit_die;
 
   gdb_assert (per_cu->is_debug_types);
-  sig_type = (struct signatured_type *) per_cu;
 
   if (! type_unit_die->has_children)
     return;
 
-  attr = type_unit_die->attr (DW_AT_stmt_list);
-  tu_group = get_type_unit_group (cu, attr);
-
-  if (tu_group->tus == nullptr)
-    tu_group->tus = new std::vector<signatured_type *>;
-  tu_group->tus->push_back (sig_type);
-
   prepare_one_comp_unit (cu, type_unit_die, language_minimal);
 
-  if (per_objfile->per_bfd->using_index)
-    {
-      gdb_assert (storage != nullptr);
-      cooked_indexer indexer (storage, per_cu, cu->per_cu->lang);
-      indexer.make_index (reader);
-    }
-  else
-    {
-      pst = create_partial_symtab (per_cu, per_objfile, "");
-      pst->anonymous = true;
-
-      first_die = load_partial_dies (reader, info_ptr, 1);
-
-      lowpc = (CORE_ADDR) -1;
-      highpc = (CORE_ADDR) 0;
-      scan_partial_symbols (first_die, &lowpc, &highpc, 0, cu);
-
-      pst->end ();
-    }
+  gdb_assert (storage != nullptr);
+  cooked_indexer indexer (storage, per_cu, cu->per_cu->lang);
+  indexer.make_index (reader);
 }
 
 /* Struct used to sort TUs by their abbreviation table offset.  */
@@ -7721,45 +7058,14 @@ print_tu_stats (dwarf2_per_objfile *per_objfile)
 			   tu_stats->nr_all_type_units_reallocs);
 }
 
-/* Traversal function for build_type_psymtabs.  */
-
-static int
-build_type_psymtab_dependencies (void **slot, void *info)
+struct skeleton_data
 {
-  dwarf2_per_objfile *per_objfile = (dwarf2_per_objfile *) info;
-  dwarf2_per_bfd *per_bfd = per_objfile->per_bfd;
-  struct type_unit_group *tu_group = (struct type_unit_group *) *slot;
-  dwarf2_psymtab *pst = tu_group->v.psymtab;
-  int len = (tu_group->tus == nullptr) ? 0 : tu_group->tus->size ();
-  int i;
+  dwarf2_per_objfile *per_objfile;
+  cooked_index_storage *storage;
+};
 
-  gdb_assert (len > 0);
-  gdb_assert (tu_group->type_unit_group_p ());
-
-  pst->number_of_dependencies = len;
-  pst->dependencies = per_bfd->partial_symtabs->allocate_dependencies (len);
-  for (i = 0; i < len; ++i)
-    {
-      struct signatured_type *iter = tu_group->tus->at (i);
-      gdb_assert (iter->is_debug_types);
-      pst->dependencies[i] = iter->v.psymtab;
-      iter->type_unit_group = tu_group;
-    }
-
-  delete tu_group->tus;
-  tu_group->tus = nullptr;
-
-  return 1;
-}
-
-struct skeleton_data
-{
-  dwarf2_per_objfile *per_objfile;
-  cooked_index_storage *storage;
-};
-
-/* Traversal function for process_skeletonless_type_unit.
-   Read a TU in a DWO file and build partial symbols for it.  */
+/* Traversal function for process_skeletonless_type_unit.
+   Read a TU in a DWO file and build partial symbols for it.  */
 
 static int
 process_skeletonless_type_unit (void **slot, void *info)
@@ -7830,27 +7136,6 @@ process_skeletonless_type_units (dwarf2_per_objfile *per_objfile,
     }
 }
 
-/* Compute the 'user' field for each psymtab in DWARF2_PER_OBJFILE.  */
-
-static void
-set_partial_user (dwarf2_per_objfile *per_objfile)
-{
-  for (const auto &per_cu : per_objfile->per_bfd->all_comp_units)
-    {
-      dwarf2_psymtab *pst = per_cu->v.psymtab;
-
-      if (pst == NULL)
-	continue;
-
-      for (int j = 0; j < pst->number_of_dependencies; ++j)
-	{
-	  /* Set the 'user' field only if it is not already set.  */
-	  if (pst->dependencies[j]->user == NULL)
-	    pst->dependencies[j]->user = pst;
-	}
-    }
-}
-
 /* Build the partial symbol table by doing a quick pass through the
    .debug_info and .debug_abbrev sections.  */
 
@@ -7863,178 +7148,97 @@ dwarf2_build_psymtabs_hard (dwarf2_per_objfile *per_objfile)
   dwarf_read_debug_printf ("Building psymtabs of objfile %s ...",
 			   objfile_name (objfile));
 
-  scoped_restore restore_reading_psyms
-    = make_scoped_restore (&per_bfd->reading_partial_symbols, true);
-
   per_bfd->map_info_sections (objfile);
 
-  /* Any cached compilation units will be linked by the per-objfile
-     read_in_chain.  Make sure to free them when we're done.  */
-  free_cached_comp_units freer (per_objfile);
-
-  /* Create a temporary address map on a temporary obstack.  We later
-     copy this to the final obstack.  */
-  auto_obstack temp_obstack;
-
-  scoped_restore save_psymtabs_addrmap
-    = make_scoped_restore (&per_bfd->partial_symtabs->psymtabs_addrmap,
-			   addrmap_create_mutable (&temp_obstack));
-
   cooked_index_storage index_storage;
-  cooked_index_storage *index_storage_ptr
-    = per_bfd->using_index ? &index_storage : nullptr;
   create_all_comp_units (per_objfile);
-  build_type_psymtabs (per_objfile, index_storage_ptr);
+  build_type_psymtabs (per_objfile, &index_storage);
   std::vector<std::unique_ptr<cooked_index>> indexes;
-  if (per_bfd->using_index)
-    {
-      per_bfd->quick_file_names_table
-	= create_quick_file_names_table (per_bfd->all_comp_units.size ());
 
-      if (!per_bfd->debug_aranges.empty ())
-	read_addrmap_from_aranges (per_objfile, &per_bfd->debug_aranges,
-				   index_storage.get_addrmap ());
+  per_bfd->quick_file_names_table
+    = create_quick_file_names_table (per_bfd->all_comp_units.size ());
+  if (!per_bfd->debug_aranges.empty ())
+    read_addrmap_from_aranges (per_objfile, &per_bfd->debug_aranges,
+			       index_storage.get_addrmap ());
 
+  {
+    /* Ensure that complaints are handled correctly.  */
+    complaint_interceptor complaint_handler;
+
+    using iter_type = typeof (per_bfd->all_comp_units.begin ());
+
+    /* Each thread returns a pair holding a cooked index, and a vector
+       of errors that should be printed.  The latter is done because
+       GDB's I/O system is not thread-safe.  run_on_main_thread could be
+       used, but that would mean the messages are printed after the
+       prompt, which looks weird.  */
+    using result_type = std::pair<std::unique_ptr<cooked_index>,
+				  std::vector<gdb_exception>>;
+    std::vector<result_type> results
+      = gdb::parallel_for_each (1, per_bfd->all_comp_units.begin (),
+				per_bfd->all_comp_units.end (),
+				[=] (iter_type iter, iter_type end)
       {
-	/* Ensure that complaints are handled correctly.  */
-	complaint_interceptor complaint_handler;
-
-	using iter_type = typeof (per_bfd->all_comp_units.begin ());
-
-	/* Each thread returns a pair holding a cooked index, and a vector
-	   of errors that should be printed.  The latter is done because
-	   GDB's I/O system is not thread-safe.  run_on_main_thread could be
-	   used, but that would mean the messages are printed after the
-	   prompt, which looks weird.  */
-	using result_type = std::pair<std::unique_ptr<cooked_index>,
-				      std::vector<gdb_exception>>;
-	std::vector<result_type> results
-	  = gdb::parallel_for_each (1, per_bfd->all_comp_units.begin (),
-				    per_bfd->all_comp_units.end (),
-				    [=] (iter_type iter, iter_type end)
-				    {
-				      std::vector<gdb_exception> errors;
-				      cooked_index_storage thread_storage;
-				      for (; iter != end; ++iter)
-					{
-					  dwarf2_per_cu_data *per_cu = iter->get ();
-					  try
-					    {
-					      process_psymtab_comp_unit (per_cu, per_objfile,
-									 false,
-									 language_minimal,
-									 &thread_storage);
-					    }
-					  catch (gdb_exception &except)
-					    {
-					      errors.push_back (std::move (except));
-					    }
-					}
-				      return result_type (thread_storage.release (),
-							  std::move (errors));
-				    });
-
-	/* Only show a given exception a single time.  */
-	std::unordered_set<gdb_exception> seen_exceptions;
-	for (auto &one_result : results)
+	std::vector<gdb_exception> errors;
+	cooked_index_storage thread_storage;
+	for (; iter != end; ++iter)
 	  {
-	    indexes.push_back (std::move (one_result.first));
-	    for (auto &one_exc : one_result.second)
+	    dwarf2_per_cu_data *per_cu = iter->get ();
+	    try
+	      {
+		process_psymtab_comp_unit (per_cu, per_objfile,
+					   &thread_storage);
+	      }
+	    catch (gdb_exception &except)
 	      {
-		if (seen_exceptions.insert (one_exc).second)
-		  exception_print (gdb_stderr, one_exc);
+		errors.push_back (std::move (except));
 	      }
 	  }
+	return result_type (thread_storage.release (), std::move (errors));
+      });
+
+    /* Only show a given exception a single time.  */
+    std::unordered_set<gdb_exception> seen_exceptions;
+    for (auto &one_result : results)
+      {
+	indexes.push_back (std::move (one_result.first));
+	for (auto &one_exc : one_result.second)
+	  if (seen_exceptions.insert (one_exc).second)
+	    exception_print (gdb_stderr, one_exc);
       }
-    }
-  else
-    {
-      for (const auto &per_cu : per_bfd->all_comp_units)
-	{
-	  if (!per_bfd->using_index && per_cu->v.psymtab != NULL)
-	    /* In case a forward DW_TAG_imported_unit has read the CU
-	       already.  */
-	    continue;
-	  process_psymtab_comp_unit (per_cu.get (), per_objfile, false,
-				     language_minimal, nullptr);
-	}
-    }
+  }
 
   /* This has to wait until we read the CUs, we need the list of DWOs.  */
   process_skeletonless_type_units (per_objfile, &index_storage);
 
-  /* Now that all TUs have been processed we can fill in the dependencies.  */
-  if (!per_bfd->using_index && per_bfd->type_unit_groups != NULL)
-    {
-      htab_traverse_noresize (per_bfd->type_unit_groups.get (),
-			      build_type_psymtab_dependencies, per_objfile);
-    }
-
   if (dwarf_read_debug > 0)
     print_tu_stats (per_objfile);
 
-  if (per_bfd->using_index)
-    {
-      indexes.push_back (index_storage.release ());
-      /* Remove any NULL entries.  This might happen if parallel-for
-	 decides to throttle the number of threads that were used.  */
-      indexes.erase
-	(std::remove_if (indexes.begin (),
-			 indexes.end (),
-			 [] (const std::unique_ptr<cooked_index> &entry)
-			 {
-			   return entry == nullptr;
-			 }),
-	 indexes.end ());
-      indexes.shrink_to_fit ();
-      per_bfd->cooked_index_table.reset
-	(new cooked_index_vector (std::move (indexes)));
-
-      const cooked_index_entry *main_entry
-	= per_bfd->cooked_index_table->get_main ();
-      if (main_entry != nullptr)
-	set_objfile_main_name (objfile, main_entry->name,
-			       main_entry->per_cu->lang);
-    }
-  else
-    {
-      set_partial_user (per_objfile);
+  indexes.push_back (index_storage.release ());
+  /* Remove any NULL entries.  This might happen if parallel-for
+     decides to throttle the number of threads that were used.  */
+  indexes.erase
+    (std::remove_if (indexes.begin (),
+		     indexes.end (),
+		     [] (const std::unique_ptr<cooked_index> &entry)
+		     {
+		       return entry == nullptr;
+		     }),
+     indexes.end ());
+  indexes.shrink_to_fit ();
+  per_bfd->cooked_index_table.reset
+    (new cooked_index_vector (std::move (indexes)));
+
+  const cooked_index_entry *main_entry
+    = per_bfd->cooked_index_table->get_main ();
+  if (main_entry != nullptr)
+    set_objfile_main_name (objfile, main_entry->name,
+			   main_entry->per_cu->lang);
 
-      per_bfd->partial_symtabs->psymtabs_addrmap
-	= addrmap_create_fixed (per_bfd->partial_symtabs->psymtabs_addrmap,
-				per_bfd->partial_symtabs->obstack ());
-      /* At this point we want to keep the address map.  */
-      save_psymtabs_addrmap.release ();
-    }
   dwarf_read_debug_printf ("Done building psymtabs of %s",
 			   objfile_name (objfile));
 }
 
-/* Load the partial DIEs for a secondary CU into memory.
-   This is also used when rereading a primary CU with load_all_dies.  */
-
-static void
-load_partial_comp_unit (dwarf2_per_cu_data *this_cu,
-			dwarf2_per_objfile *per_objfile,
-			dwarf2_cu *existing_cu)
-{
-  cutu_reader reader (this_cu, per_objfile, nullptr, existing_cu, false);
-
-  if (!reader.dummy_p)
-    {
-      prepare_one_comp_unit (reader.cu, reader.comp_unit_die,
-			     language_minimal);
-
-      /* Check if comp unit has_children.
-	 If so, read the rest of the partial symbols from this comp unit.
-	 If not, there's no more debug_info for this comp unit.  */
-      if (reader.comp_unit_die->has_children)
-	load_partial_dies (&reader, reader.info_ptr, 0);
-
-      reader.keep ();
-    }
-}
-
 static void
 read_comp_units_from_section (dwarf2_per_objfile *per_objfile,
 			      struct dwarf2_section_info *section,
@@ -8094,9 +7298,8 @@ read_comp_units_from_section (dwarf2_per_objfile *per_objfile,
       this_cu->is_dwz = is_dwz;
       this_cu->section = section;
 
-      if (per_objfile->per_bfd->using_index)
-	this_cu->v.quick = OBSTACK_ZALLOC (&per_objfile->per_bfd->obstack,
-					   struct dwarf2_per_cu_quick_data);
+      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));
@@ -8135,745 +7338,120 @@ create_all_comp_units (dwarf2_per_objfile *per_objfile)
   per_objfile->per_bfd->signatured_types = std::move (types_htab);
 }
 
-/* Process all loaded DIEs for compilation unit CU, starting at
-   FIRST_DIE.  The caller should pass SET_ADDRMAP == 1 if the compilation
-   unit DIE did not have PC info (DW_AT_low_pc and DW_AT_high_pc, or
-   DW_AT_ranges).  See the comments of add_partial_subprogram on how
-   SET_ADDRMAP is used and how *LOWPC and *HIGHPC are updated.  */
+/* Return the initial uleb128 in the die at INFO_PTR.  */
 
-static void
-scan_partial_symbols (struct partial_die_info *first_die, CORE_ADDR *lowpc,
-		      CORE_ADDR *highpc, int set_addrmap,
-		      struct dwarf2_cu *cu)
+static unsigned int
+peek_abbrev_code (bfd *abfd, const gdb_byte *info_ptr)
 {
-  struct partial_die_info *pdi;
-
-  /* Now, march along the PDI's, descending into ones which have
-     interesting children but skipping the children of the other ones,
-     until we reach the end of the compilation unit.  */
-
-  pdi = first_die;
-
-  while (pdi != NULL)
-    {
-      pdi->fixup (cu);
-
-      /* Anonymous namespaces or modules have no name but have interesting
-	 children, so we need to look at them.  Ditto for anonymous
-	 enums.  */
-
-      if (pdi->raw_name != NULL || pdi->tag == DW_TAG_namespace
-	  || pdi->tag == DW_TAG_module || pdi->tag == DW_TAG_enumeration_type
-	  || pdi->tag == DW_TAG_imported_unit
-	  || pdi->tag == DW_TAG_inlined_subroutine)
-	{
-	  switch (pdi->tag)
-	    {
-	    case DW_TAG_subprogram:
-	    case DW_TAG_inlined_subroutine:
-	      add_partial_subprogram (pdi, lowpc, highpc, set_addrmap, cu);
-	      if (cu->per_cu->lang == language_cplus)
-		scan_partial_symbols (pdi->die_child, lowpc, highpc,
-				      set_addrmap, cu);
-	      break;
-	    case DW_TAG_constant:
-	    case DW_TAG_variable:
-	    case DW_TAG_typedef:
-	    case DW_TAG_union_type:
-	      if (!pdi->is_declaration
-		  || (pdi->tag == DW_TAG_variable && pdi->is_external))
-		{
-		  add_partial_symbol (pdi, cu);
-		}
-	      break;
-	    case DW_TAG_class_type:
-	    case DW_TAG_interface_type:
-	    case DW_TAG_structure_type:
-	      if (!pdi->is_declaration)
-		{
-		  add_partial_symbol (pdi, cu);
-		}
-	      if ((cu->per_cu->lang == language_rust
-		   || cu->per_cu->lang == language_cplus)
-		  && pdi->has_children)
-		scan_partial_symbols (pdi->die_child, lowpc, highpc,
-				      set_addrmap, cu);
-	      break;
-	    case DW_TAG_enumeration_type:
-	      if (!pdi->is_declaration)
-		add_partial_enumeration (pdi, cu);
-	      break;
-	    case DW_TAG_base_type:
-	    case DW_TAG_generic_subrange:
-	    case DW_TAG_subrange_type:
-	      /* File scope base type definitions are added to the partial
-		 symbol table.  */
-	      add_partial_symbol (pdi, cu);
-	      break;
-	    case DW_TAG_namespace:
-	      add_partial_namespace (pdi, lowpc, highpc, set_addrmap, cu);
-	      break;
-	    case DW_TAG_module:
-	      if (!pdi->is_declaration)
-		add_partial_module (pdi, lowpc, highpc, set_addrmap, cu);
-	      break;
-	    case DW_TAG_imported_unit:
-	      {
-		struct dwarf2_per_cu_data *per_cu;
-
-		/* For now we don't handle imported units in type units.  */
-		if (cu->per_cu->is_debug_types)
-		  {
-		    error (_("Dwarf Error: DW_TAG_imported_unit is not"
-			     " supported in type units [in module %s]"),
-			   objfile_name (cu->per_objfile->objfile));
-		  }
-
-		per_cu = dwarf2_find_containing_comp_unit
-			   (pdi->d.sect_off, pdi->is_dwz,
-			    cu->per_objfile->per_bfd);
-
-		/* Go read the partial unit, if needed.  */
-		if (per_cu->v.psymtab == NULL)
-		  process_psymtab_comp_unit (per_cu, cu->per_objfile, true,
-					     cu->per_cu->lang, nullptr);
-
-		if (pdi->die_parent == nullptr
-		    && per_cu->unit_type == DW_UT_compile
-		    && per_cu->lang == language_cplus)
-		  /* Regard import as hint.  See corresponding code in
-		     process_imported_unit_die.  */
-		  break;
-
-		cu->per_cu->imported_symtabs_push (per_cu);
-	      }
-	      break;
-	    case DW_TAG_imported_declaration:
-	      add_partial_symbol (pdi, cu);
-	      break;
-	    default:
-	      break;
-	    }
-	}
-
-      /* If the die has a sibling, skip to the sibling.  */
+  unsigned int bytes_read;
 
-      pdi = pdi->die_sibling;
-    }
+  return read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
 }
 
-/* Functions used to compute the fully scoped name of a partial DIE.
-
-   Normally, this is simple.  For C++, the parent DIE's fully scoped
-   name is concatenated with "::" and the partial DIE's name.
-   Enumerators are an exception; they use the scope of their parent
-   enumeration type, i.e. the name of the enumeration type is not
-   prepended to the enumerator.
+/* Read the initial uleb128 in the die at INFO_PTR in compilation unit
+   READER::CU.  Use READER::ABBREV_TABLE to lookup any abbreviation.
 
-   There are two complexities.  One is DW_AT_specification; in this
-   case "parent" means the parent of the target of the specification,
-   instead of the direct parent of the DIE.  The other is compilers
-   which do not emit DW_TAG_namespace; in this case we try to guess
-   the fully qualified name of structure types from their members'
-   linkage names.  This must be done using the DIE's children rather
-   than the children of any DW_AT_specification target.  We only need
-   to do this for structures at the top level, i.e. if the target of
-   any DW_AT_specification (if any; otherwise the DIE itself) does not
-   have a parent.  */
+   Return the corresponding abbrev, or NULL if the number is zero (indicating
+   an empty DIE).  In either case *BYTES_READ will be set to the length of
+   the initial number.  */
 
-/* Compute the scope prefix associated with PDI's parent, in
-   compilation unit CU.  The result will be allocated on CU's
-   comp_unit_obstack, or a copy of the already allocated PDI->NAME
-   field.  NULL is returned if no prefix is necessary.  */
-static const char *
-partial_die_parent_scope (struct partial_die_info *pdi,
-			  struct dwarf2_cu *cu)
+static const struct abbrev_info *
+peek_die_abbrev (const die_reader_specs &reader,
+		 const gdb_byte *info_ptr, unsigned int *bytes_read)
 {
-  const char *grandparent_scope;
-  struct partial_die_info *parent, *real_pdi;
+  dwarf2_cu *cu = reader.cu;
+  bfd *abfd = reader.abfd;
+  unsigned int abbrev_number
+    = read_unsigned_leb128 (abfd, info_ptr, bytes_read);
 
-  /* We need to look at our parent DIE; if we have a DW_AT_specification,
-     then this means the parent of the specification DIE.  */
+  if (abbrev_number == 0)
+    return NULL;
 
-  real_pdi = pdi;
-  while (real_pdi->has_specification)
+  const abbrev_info *abbrev
+    = reader.abbrev_table->lookup_abbrev (abbrev_number);
+  if (!abbrev)
     {
-      auto res = find_partial_die (real_pdi->spec_offset,
-				   real_pdi->spec_is_dwz, cu);
-      real_pdi = res.pdi;
-      cu = res.cu;
+      error (_("Dwarf Error: Could not find abbrev number %d in %s"
+	       " at offset %s [in module %s]"),
+	     abbrev_number, cu->per_cu->is_debug_types ? "TU" : "CU",
+	     sect_offset_str (cu->header.sect_off), bfd_get_filename (abfd));
     }
 
-  parent = real_pdi->die_parent;
-  if (parent == NULL)
-    return NULL;
-
-  if (parent->scope_set)
-    return parent->scope;
-
-  parent->fixup (cu);
+  return abbrev;
+}
 
-  grandparent_scope = partial_die_parent_scope (parent, cu);
+/* Scan the debug information for CU starting at INFO_PTR in buffer BUFFER.
+   Returns a pointer to the end of a series of DIEs, terminated by an empty
+   DIE.  Any children of the skipped DIEs will also be skipped.  */
 
-  /* GCC 4.0 and 4.1 had a bug (PR c++/28460) where they generated bogus
-     DW_TAG_namespace DIEs with a name of "::" for the global namespace.
-     Work around this problem here.  */
-  if (cu->per_cu->lang == language_cplus
-      && parent->tag == DW_TAG_namespace
-      && strcmp (parent->name (cu), "::") == 0
-      && grandparent_scope == NULL)
+static const gdb_byte *
+skip_children (const struct die_reader_specs *reader, const gdb_byte *info_ptr)
+{
+  while (1)
     {
-      parent->scope = NULL;
-      parent->scope_set = 1;
-      return NULL;
-    }
+      unsigned int bytes_read;
+      const abbrev_info *abbrev = peek_die_abbrev (*reader, info_ptr,
+						   &bytes_read);
 
-  /* Nested subroutines in Fortran get a prefix.  */
-  if (pdi->tag == DW_TAG_enumerator)
-    /* Enumerators should not get the name of the enumeration as a prefix.  */
-    parent->scope = grandparent_scope;
-  else if (parent->tag == DW_TAG_namespace
-      || parent->tag == DW_TAG_module
-      || parent->tag == DW_TAG_structure_type
-      || parent->tag == DW_TAG_class_type
-      || parent->tag == DW_TAG_interface_type
-      || parent->tag == DW_TAG_union_type
-      || parent->tag == DW_TAG_enumeration_type
-      || (cu->per_cu->lang == language_fortran
-	  && parent->tag == DW_TAG_subprogram
-	  && pdi->tag == DW_TAG_subprogram))
-    {
-      if (grandparent_scope == NULL)
-	parent->scope = parent->name (cu);
+      if (abbrev == NULL)
+	return info_ptr + bytes_read;
       else
-	parent->scope = typename_concat (&cu->comp_unit_obstack,
-					 grandparent_scope,
-					 parent->name (cu), 0, cu);
-    }
-  else
-    {
-      /* FIXME drow/2004-04-01: What should we be doing with
-	 function-local names?  For partial symbols, we should probably be
-	 ignoring them.  */
-      complaint (_("unhandled containing DIE tag %s for DIE at %s"),
-		 dwarf_tag_name (parent->tag),
-		 sect_offset_str (pdi->sect_off));
-      parent->scope = grandparent_scope;
+	info_ptr = skip_one_die (reader, info_ptr + bytes_read, abbrev);
     }
-
-  parent->scope_set = 1;
-  return parent->scope;
 }
 
-/* Return the fully scoped name associated with PDI, from compilation unit
-   CU.  The result will be allocated with malloc.  */
+/* Scan the debug information for CU starting at INFO_PTR in buffer BUFFER.
+   INFO_PTR should point just after the initial uleb128 of a DIE, and the
+   abbrev corresponding to that skipped uleb128 should be passed in
+   ABBREV.
+   
+   If DO_SKIP_CHILDREN is true, or if the DIE has no children, this
+   returns a pointer to this DIE's sibling, skipping any children.
+   Otherwise, returns a pointer to the DIE's first child.  */
 
-static gdb::unique_xmalloc_ptr<char>
-partial_die_full_name (struct partial_die_info *pdi,
-		       struct dwarf2_cu *cu)
+static const gdb_byte *
+skip_one_die (const struct die_reader_specs *reader, const gdb_byte *info_ptr,
+	      const struct abbrev_info *abbrev, bool do_skip_children)
 {
-  const char *parent_scope;
+  unsigned int bytes_read;
+  struct attribute attr;
+  bfd *abfd = reader->abfd;
+  struct dwarf2_cu *cu = reader->cu;
+  const gdb_byte *buffer = reader->buffer;
+  const gdb_byte *buffer_end = reader->buffer_end;
+  unsigned int form, i;
 
-  /* If this is a template instantiation, we can not work out the
-     template arguments from partial DIEs.  So, unfortunately, we have
-     to go through the full DIEs.  At least any work we do building
-     types here will be reused if full symbols are loaded later.  */
-  if (pdi->has_template_arguments)
+  if (do_skip_children && abbrev->sibling_offset != (unsigned short) -1)
     {
-      pdi->fixup (cu);
-
-      if (pdi->name (cu) != NULL && strchr (pdi->name (cu), '<') == NULL)
-	{
-	  struct die_info *die;
-	  struct attribute attr;
-	  struct dwarf2_cu *ref_cu = cu;
-
-	  /* DW_FORM_ref_addr is using section offset.  */
-	  attr.name = (enum dwarf_attribute) 0;
-	  attr.form = DW_FORM_ref_addr;
-	  attr.u.unsnd = to_underlying (pdi->sect_off);
-	  die = follow_die_ref (NULL, &attr, &ref_cu);
-
-	  return make_unique_xstrdup (dwarf2_full_name (NULL, die, ref_cu));
-	}
+      /* We only handle DW_FORM_ref4 here.  */
+      const gdb_byte *sibling_data = info_ptr + abbrev->sibling_offset;
+      unsigned int offset = read_4_bytes (abfd, sibling_data);
+      const gdb_byte *sibling_ptr
+	= buffer + to_underlying (cu->header.sect_off) + offset;
+      if (sibling_ptr >= info_ptr && sibling_ptr < reader->buffer_end)
+	return sibling_ptr;
+      /* Fall through to the slow way.  */
     }
-
-  parent_scope = partial_die_parent_scope (pdi, cu);
-  if (parent_scope == NULL)
-    return NULL;
-  else
-    return gdb::unique_xmalloc_ptr<char> (typename_concat (NULL, parent_scope,
-							   pdi->name (cu),
-							   0, cu));
-}
-
-static void
-add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
-{
-  dwarf2_per_objfile *per_objfile = cu->per_objfile;
-  struct objfile *objfile = per_objfile->objfile;
-  struct gdbarch *gdbarch = objfile->arch ();
-  CORE_ADDR addr = 0;
-  const char *actual_name = NULL;
-  CORE_ADDR baseaddr;
-
-  baseaddr = objfile->text_section_offset ();
-
-  gdb::unique_xmalloc_ptr<char> built_actual_name
-    = partial_die_full_name (pdi, cu);
-  if (built_actual_name != NULL)
-    actual_name = built_actual_name.get ();
-
-  if (actual_name == NULL)
-    actual_name = pdi->name (cu);
-
-  partial_symbol psymbol;
-  memset (&psymbol, 0, sizeof (psymbol));
-  psymbol.ginfo.set_language (cu->per_cu->lang,
-			      &objfile->objfile_obstack);
-  psymbol.ginfo.set_section_index (-1);
-
-  /* The code below indicates that the psymbol should be installed by
-     setting this.  */
-  gdb::optional<psymbol_placement> where;
-
-  switch (pdi->tag)
+  else if (abbrev->size_if_constant != 0)
     {
-    case DW_TAG_inlined_subroutine:
-    case DW_TAG_subprogram:
-      addr = (gdbarch_adjust_dwarf2_addr (gdbarch, pdi->lowpc + baseaddr)
-	      - baseaddr);
-      if (pdi->is_external
-	  || cu->per_cu->lang == language_ada
-	  || (cu->per_cu->lang == language_fortran
-	      && pdi->die_parent != NULL
-	      && pdi->die_parent->tag == DW_TAG_subprogram))
-	{
-	  /* Normally, only "external" DIEs are part of the global scope.
-	     But in Ada and Fortran, we want to be able to access nested
-	     procedures globally.  So all Ada and Fortran subprograms are
-	     stored in the global scope.  */
-	  where = psymbol_placement::GLOBAL;
-	}
-      else
-	where = psymbol_placement::STATIC;
-
-      psymbol.domain = VAR_DOMAIN;
-      psymbol.aclass = LOC_BLOCK;
-      psymbol.ginfo.set_section_index (SECT_OFF_TEXT (objfile));
-      psymbol.ginfo.set_value_address (addr);
-
-      if (pdi->main_subprogram && actual_name != NULL)
-	set_objfile_main_name (objfile, actual_name, cu->per_cu->lang);
-      break;
-    case DW_TAG_constant:
-      psymbol.domain = VAR_DOMAIN;
-      psymbol.aclass = LOC_STATIC;
-      where = (pdi->is_external
-	       ? psymbol_placement::GLOBAL
-	       : psymbol_placement::STATIC);
-      break;
-    case DW_TAG_variable:
-      if (pdi->d.locdesc)
-	addr = decode_locdesc (pdi->d.locdesc, cu);
+      info_ptr += abbrev->size_if_constant;
+      if (do_skip_children && abbrev->has_children)
+	return skip_children (reader, info_ptr);
+      return info_ptr;
+    }
 
-      if (pdi->d.locdesc
-	  && addr == 0
-	  && !per_objfile->per_bfd->has_section_at_zero)
+  for (i = 0; i < abbrev->num_attrs; i++)
+    {
+      /* The only abbrev we care about is DW_AT_sibling.  */
+      if (do_skip_children && abbrev->attrs[i].name == DW_AT_sibling)
 	{
-	  /* A global or static variable may also have been stripped
-	     out by the linker if unused, in which case its address
-	     will be nullified; do not add such variables into partial
-	     symbol table then.  */
-	}
-      else if (pdi->is_external)
-	{
-	  /* Global Variable.
-	     Don't enter into the minimal symbol tables as there is
-	     a minimal symbol table entry from the ELF symbols already.
-	     Enter into partial symbol table if it has a location
-	     descriptor or a type.
-	     If the location descriptor is missing, new_symbol will create
-	     a LOC_UNRESOLVED symbol, the address of the variable will then
-	     be determined from the minimal symbol table whenever the variable
-	     is referenced.
-	     The address for the partial symbol table entry is not
-	     used by GDB, but it comes in handy for debugging partial symbol
-	     table building.  */
-
-	  if (pdi->d.locdesc || pdi->has_type)
+	  read_attribute (reader, &attr, &abbrev->attrs[i], info_ptr);
+	  if (attr.form == DW_FORM_ref_addr)
+	    complaint (_("ignoring absolute DW_AT_sibling"));
+	  else
 	    {
-	      psymbol.domain = VAR_DOMAIN;
-	      psymbol.aclass = LOC_STATIC;
-	      psymbol.ginfo.set_section_index (SECT_OFF_TEXT (objfile));
-	      psymbol.ginfo.set_value_address (addr);
-	      where = psymbol_placement::GLOBAL;
-	    }
-	}
-      else
-	{
-	  int has_loc = pdi->d.locdesc != NULL;
-
-	  /* Static Variable.  Skip symbols whose value we cannot know (those
-	     without location descriptors or constant values).  */
-	  if (!has_loc && !pdi->has_const_value)
-	    return;
-
-	  psymbol.domain = VAR_DOMAIN;
-	  psymbol.aclass = LOC_STATIC;
-	  psymbol.ginfo.set_section_index (SECT_OFF_TEXT (objfile));
-	  if (has_loc)
-	    psymbol.ginfo.set_value_address (addr);
-	  where = psymbol_placement::STATIC;
-	}
-      break;
-    case DW_TAG_array_type:
-    case DW_TAG_typedef:
-    case DW_TAG_base_type:
-    case DW_TAG_subrange_type:
-    case DW_TAG_generic_subrange:
-      psymbol.domain = VAR_DOMAIN;
-      psymbol.aclass = LOC_TYPEDEF;
-      where = psymbol_placement::STATIC;
-      break;
-    case DW_TAG_imported_declaration:
-    case DW_TAG_namespace:
-      psymbol.domain = VAR_DOMAIN;
-      psymbol.aclass = LOC_TYPEDEF;
-      where = psymbol_placement::GLOBAL;
-      break;
-    case DW_TAG_module:
-      /* With Fortran 77 there might be a "BLOCK DATA" module
-	 available without any name.  If so, we skip the module as it
-	 doesn't bring any value.  */
-      if (actual_name != nullptr)
-	{
-	  psymbol.domain = MODULE_DOMAIN;
-	  psymbol.aclass = LOC_TYPEDEF;
-	  where = psymbol_placement::GLOBAL;
-	}
-      break;
-    case DW_TAG_class_type:
-    case DW_TAG_interface_type:
-    case DW_TAG_structure_type:
-    case DW_TAG_union_type:
-    case DW_TAG_enumeration_type:
-      /* Skip external references.  The DWARF standard says in the section
-	 about "Structure, Union, and Class Type Entries": "An incomplete
-	 structure, union or class type is represented by a structure,
-	 union or class entry that does not have a byte size attribute
-	 and that has a DW_AT_declaration attribute."  */
-      if (!pdi->has_byte_size && pdi->is_declaration)
-	return;
-
-      /* NOTE: carlton/2003-10-07: See comment in new_symbol about
-	 static vs. global.  */
-      psymbol.domain = STRUCT_DOMAIN;
-      psymbol.aclass = LOC_TYPEDEF;
-      where = (cu->per_cu->lang == language_cplus
-	       ? psymbol_placement::GLOBAL
-	       : psymbol_placement::STATIC);
-      break;
-    case DW_TAG_enumerator:
-      psymbol.domain = VAR_DOMAIN;
-      psymbol.aclass = LOC_CONST;
-      where = (cu->per_cu->lang == language_cplus
-	       ? psymbol_placement::GLOBAL
-	       : psymbol_placement::STATIC);
-      break;
-    default:
-      break;
-    }
-
-  if (where.has_value ())
-    {
-      if (built_actual_name != nullptr)
-	actual_name = objfile->intern (actual_name);
-      if (pdi->linkage_name == nullptr
-	  || cu->per_cu->lang == language_ada)
-	psymbol.ginfo.set_linkage_name (actual_name);
-      else
-	{
-	  psymbol.ginfo.set_demangled_name (actual_name,
-					    &objfile->objfile_obstack);
-	  psymbol.ginfo.set_linkage_name (pdi->linkage_name);
-	}
-      cu->per_cu->v.psymtab->add_psymbol
-	(psymbol, *where, per_objfile->per_bfd->partial_symtabs.get (),
-	 objfile);
-    }
-}
-
-/* Read a partial die corresponding to a namespace; also, add a symbol
-   corresponding to that namespace to the symbol table.  NAMESPACE is
-   the name of the enclosing namespace.  */
-
-static void
-add_partial_namespace (struct partial_die_info *pdi,
-		       CORE_ADDR *lowpc, CORE_ADDR *highpc,
-		       int set_addrmap, struct dwarf2_cu *cu)
-{
-  /* Add a symbol for the namespace.  */
-
-  add_partial_symbol (pdi, cu);
-
-  /* Now scan partial symbols in that namespace.  */
-
-  if (pdi->has_children)
-    scan_partial_symbols (pdi->die_child, lowpc, highpc, set_addrmap, cu);
-}
-
-/* Read a partial die corresponding to a Fortran module.  */
-
-static void
-add_partial_module (struct partial_die_info *pdi, CORE_ADDR *lowpc,
-		    CORE_ADDR *highpc, int set_addrmap, struct dwarf2_cu *cu)
-{
-  /* Add a symbol for the namespace.  */
-
-  add_partial_symbol (pdi, cu);
-
-  /* Now scan partial symbols in that module.  */
-
-  if (pdi->has_children)
-    scan_partial_symbols (pdi->die_child, lowpc, highpc, set_addrmap, cu);
-}
-
-static int dwarf2_ranges_read (unsigned offset, CORE_ADDR *low_return,
-			       CORE_ADDR *high_return, struct dwarf2_cu *cu,
-			       addrmap *map, void *datum, dwarf_tag tag);
-
-/* Read a partial die corresponding to a subprogram or an inlined
-   subprogram and create a partial symbol for that subprogram.
-   When the CU language allows it, this routine also defines a partial
-   symbol for each nested subprogram that this subprogram contains.
-   If SET_ADDRMAP is true, record the covered ranges in the addrmap.
-   Set *LOWPC and *HIGHPC to the lowest and highest PC values found in PDI.
-
-   PDI may also be a lexical block, in which case we simply search
-   recursively for subprograms defined inside that lexical block.
-   Again, this is only performed when the CU language allows this
-   type of definitions.  */
-
-static void
-add_partial_subprogram (struct partial_die_info *pdi,
-			CORE_ADDR *lowpc, CORE_ADDR *highpc,
-			int set_addrmap, struct dwarf2_cu *cu)
-{
-  if (pdi->tag == DW_TAG_subprogram || pdi->tag == DW_TAG_inlined_subroutine)
-    {
-      if (pdi->has_pc_info)
-	{
-	  if (pdi->lowpc < *lowpc)
-	    *lowpc = pdi->lowpc;
-	  if (pdi->highpc > *highpc)
-	    *highpc = pdi->highpc;
-	  if (set_addrmap)
-	    {
-	      struct objfile *objfile = cu->per_objfile->objfile;
-	      dwarf2_per_bfd *per_bfd = cu->per_objfile->per_bfd;
-	      struct gdbarch *gdbarch = objfile->arch ();
-	      CORE_ADDR baseaddr;
-	      CORE_ADDR this_highpc;
-	      CORE_ADDR this_lowpc;
-
-	      baseaddr = objfile->text_section_offset ();
-	      this_lowpc
-		= (gdbarch_adjust_dwarf2_addr (gdbarch,
-					       pdi->lowpc + baseaddr)
-		   - baseaddr);
-	      this_highpc
-		= (gdbarch_adjust_dwarf2_addr (gdbarch,
-					       pdi->highpc + baseaddr)
-		   - baseaddr);
-	      addrmap_set_empty (per_bfd->partial_symtabs->psymtabs_addrmap,
-				 this_lowpc, this_highpc - 1,
-				 cu->per_cu->v.psymtab);
-	    }
-	}
-
-      if (pdi->has_range_info
-	  && dwarf2_ranges_read (pdi->ranges_offset, &pdi->lowpc, &pdi->highpc,
-				 cu,
-				 (set_addrmap
-				  ? cu->per_objfile->per_bfd->partial_symtabs->psymtabs_addrmap
-				  : nullptr),
-				 set_addrmap ? cu->per_cu->v.psymtab : nullptr,
-				 pdi->tag))
-	{
-	  if (pdi->lowpc < *lowpc)
-	    *lowpc = pdi->lowpc;
-	  if (pdi->highpc > *highpc)
-	    *highpc = pdi->highpc;
-	}
-
-      if (pdi->has_pc_info || pdi->has_range_info
-	  || (!pdi->is_external && pdi->may_be_inlined))
-	{
-	  if (!pdi->is_declaration)
-	    /* Ignore subprogram DIEs that do not have a name, they are
-	       illegal.  Do not emit a complaint at this point, we will
-	       do so when we convert this psymtab into a symtab.  */
-	    if (pdi->name (cu))
-	      add_partial_symbol (pdi, cu);
-	}
-    }
-
-  if (! pdi->has_children)
-    return;
-
-  if (cu->per_cu->lang == language_ada
-      || cu->per_cu->lang == language_fortran)
-    {
-      pdi = pdi->die_child;
-      while (pdi != NULL)
-	{
-	  pdi->fixup (cu);
-	  if (pdi->tag == DW_TAG_subprogram
-	      || pdi->tag == DW_TAG_inlined_subroutine
-	      || pdi->tag == DW_TAG_lexical_block)
-	    add_partial_subprogram (pdi, lowpc, highpc, set_addrmap, cu);
-	  pdi = pdi->die_sibling;
-	}
-    }
-}
-
-/* Read a partial die corresponding to an enumeration type.  */
-
-static void
-add_partial_enumeration (struct partial_die_info *enum_pdi,
-			 struct dwarf2_cu *cu)
-{
-  struct partial_die_info *pdi;
-
-  if (enum_pdi->name (cu) != NULL)
-    add_partial_symbol (enum_pdi, cu);
-
-  pdi = enum_pdi->die_child;
-  while (pdi)
-    {
-      if (pdi->tag != DW_TAG_enumerator || pdi->raw_name == NULL)
-	complaint (_("malformed enumerator DIE ignored"));
-      else
-	add_partial_symbol (pdi, cu);
-      pdi = pdi->die_sibling;
-    }
-}
-
-/* Return the initial uleb128 in the die at INFO_PTR.  */
-
-static unsigned int
-peek_abbrev_code (bfd *abfd, const gdb_byte *info_ptr)
-{
-  unsigned int bytes_read;
-
-  return read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
-}
-
-/* Read the initial uleb128 in the die at INFO_PTR in compilation unit
-   READER::CU.  Use READER::ABBREV_TABLE to lookup any abbreviation.
-
-   Return the corresponding abbrev, or NULL if the number is zero (indicating
-   an empty DIE).  In either case *BYTES_READ will be set to the length of
-   the initial number.  */
-
-static const struct abbrev_info *
-peek_die_abbrev (const die_reader_specs &reader,
-		 const gdb_byte *info_ptr, unsigned int *bytes_read)
-{
-  dwarf2_cu *cu = reader.cu;
-  bfd *abfd = reader.abfd;
-  unsigned int abbrev_number
-    = read_unsigned_leb128 (abfd, info_ptr, bytes_read);
-
-  if (abbrev_number == 0)
-    return NULL;
-
-  const abbrev_info *abbrev
-    = reader.abbrev_table->lookup_abbrev (abbrev_number);
-  if (!abbrev)
-    {
-      error (_("Dwarf Error: Could not find abbrev number %d in %s"
-	       " at offset %s [in module %s]"),
-	     abbrev_number, cu->per_cu->is_debug_types ? "TU" : "CU",
-	     sect_offset_str (cu->header.sect_off), bfd_get_filename (abfd));
-    }
-
-  return abbrev;
-}
-
-/* Scan the debug information for CU starting at INFO_PTR in buffer BUFFER.
-   Returns a pointer to the end of a series of DIEs, terminated by an empty
-   DIE.  Any children of the skipped DIEs will also be skipped.  */
-
-static const gdb_byte *
-skip_children (const struct die_reader_specs *reader, const gdb_byte *info_ptr)
-{
-  while (1)
-    {
-      unsigned int bytes_read;
-      const abbrev_info *abbrev = peek_die_abbrev (*reader, info_ptr,
-						   &bytes_read);
-
-      if (abbrev == NULL)
-	return info_ptr + bytes_read;
-      else
-	info_ptr = skip_one_die (reader, info_ptr + bytes_read, abbrev);
-    }
-}
-
-/* Scan the debug information for CU starting at INFO_PTR in buffer BUFFER.
-   INFO_PTR should point just after the initial uleb128 of a DIE, and the
-   abbrev corresponding to that skipped uleb128 should be passed in
-   ABBREV.
-   
-   If DO_SKIP_CHILDREN is true, or if the DIE has no children, this
-   returns a pointer to this DIE's sibling, skipping any children.
-   Otherwise, returns a pointer to the DIE's first child.  */
-
-static const gdb_byte *
-skip_one_die (const struct die_reader_specs *reader, const gdb_byte *info_ptr,
-	      const struct abbrev_info *abbrev, bool do_skip_children)
-{
-  unsigned int bytes_read;
-  struct attribute attr;
-  bfd *abfd = reader->abfd;
-  struct dwarf2_cu *cu = reader->cu;
-  const gdb_byte *buffer = reader->buffer;
-  const gdb_byte *buffer_end = reader->buffer_end;
-  unsigned int form, i;
-
-  if (do_skip_children && abbrev->sibling_offset != (unsigned short) -1)
-    {
-      /* We only handle DW_FORM_ref4 here.  */
-      const gdb_byte *sibling_data = info_ptr + abbrev->sibling_offset;
-      unsigned int offset = read_4_bytes (abfd, sibling_data);
-      const gdb_byte *sibling_ptr
-	= buffer + to_underlying (cu->header.sect_off) + offset;
-      if (sibling_ptr >= info_ptr && sibling_ptr < reader->buffer_end)
-	return sibling_ptr;
-      /* Fall through to the slow way.  */
-    }
-  else if (abbrev->size_if_constant != 0)
-    {
-      info_ptr += abbrev->size_if_constant;
-      if (do_skip_children && abbrev->has_children)
-	return skip_children (reader, info_ptr);
-      return info_ptr;
-    }
-
-  for (i = 0; i < abbrev->num_attrs; i++)
-    {
-      /* The only abbrev we care about is DW_AT_sibling.  */
-      if (do_skip_children && abbrev->attrs[i].name == DW_AT_sibling)
-	{
-	  read_attribute (reader, &attr, &abbrev->attrs[i], info_ptr);
-	  if (attr.form == DW_FORM_ref_addr)
-	    complaint (_("ignoring absolute DW_AT_sibling"));
-	  else
-	    {
-	      sect_offset off = attr.get_ref_die_offset ();
-	      const gdb_byte *sibling_ptr = buffer + to_underlying (off);
+	      sect_offset off = attr.get_ref_die_offset ();
+	      const gdb_byte *sibling_ptr = buffer + to_underlying (off);
 
 	      if (sibling_ptr < info_ptr)
 		complaint (_("DW_AT_sibling points backwards"));
@@ -8987,57 +7565,6 @@ skip_one_die (const struct die_reader_specs *reader, const gdb_byte *info_ptr,
   else
     return info_ptr;
 }
-
-/* Locate ORIG_PDI's sibling.
-   INFO_PTR should point to the start of the next DIE after ORIG_PDI.  */
-
-static const gdb_byte *
-locate_pdi_sibling (const struct die_reader_specs *reader,
-		    struct partial_die_info *orig_pdi,
-		    const gdb_byte *info_ptr)
-{
-  /* Do we know the sibling already?  */
-
-  if (orig_pdi->sibling)
-    return orig_pdi->sibling;
-
-  /* Are there any children to deal with?  */
-
-  if (!orig_pdi->has_children)
-    return info_ptr;
-
-  /* Skip the children the long way.  */
-
-  return skip_children (reader, info_ptr);
-}
-
-/* Expand this partial symbol table into a full symbol table.  SELF is
-   not NULL.  */
-
-void
-dwarf2_psymtab::read_symtab (struct objfile *objfile)
-{
-  dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
-
-  gdb_assert (!per_objfile->symtab_set_p (per_cu_data));
-
-  /* If this psymtab is constructed from a debug-only objfile, the
-     has_section_at_zero flag will not necessarily be correct.  We
-     can get the correct value for this flag by looking at the data
-     associated with the (presumably stripped) associated objfile.  */
-  if (objfile->separate_debug_objfile_backlink)
-    {
-      dwarf2_per_objfile *per_objfile_backlink
-	= get_dwarf2_per_objfile (objfile->separate_debug_objfile_backlink);
-
-      per_objfile->per_bfd->has_section_at_zero
-	= per_objfile_backlink->per_bfd->has_section_at_zero;
-    }
-
-  expand_psymtab (objfile);
-
-  process_cu_includes (per_objfile);
-}
 \f
 /* Reading in full CUs.  */
 
@@ -9085,18 +7612,6 @@ maybe_queue_comp_unit (struct dwarf2_cu *dependent_cu,
 		       dwarf2_per_objfile *per_objfile,
 		       enum language pretend_language)
 {
-  /* We may arrive here during partial symbol reading, if we need full
-     DIEs to process an unusual case (e.g. template arguments).  Do
-     not queue PER_CU, just tell our caller to load its DIEs.  */
-  if (per_cu->per_bfd->reading_partial_symbols)
-    {
-      dwarf2_cu *cu = per_objfile->get_cu (per_cu);
-
-      if (cu == NULL || cu->dies == NULL)
-	return 1;
-      return 0;
-    }
-
   /* Mark the dependence relation so that we don't flush PER_CU
      too early.  */
   if (dependent_cu != NULL)
@@ -9201,39 +7716,6 @@ process_queue (dwarf2_per_objfile *per_objfile)
 			   objfile_name (per_objfile->objfile));
 }
 
-/* Read in full symbols for PST, and anything it depends on.  */
-
-void
-dwarf2_psymtab::expand_psymtab (struct objfile *objfile)
-{
-  gdb_assert (!readin_p (objfile));
-
-  dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
-  free_cached_comp_units freer (per_objfile);
-  expand_dependencies (objfile);
-
-  dw2_do_instantiate_symtab (per_cu_data, per_objfile, false);
-  gdb_assert (get_compunit_symtab (objfile) != nullptr);
-}
-
-/* See psympriv.h.  */
-
-bool
-dwarf2_psymtab::readin_p (struct objfile *objfile) const
-{
-  dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
-  return per_objfile->symtab_set_p (per_cu_data);
-}
-
-/* See psympriv.h.  */
-
-compunit_symtab *
-dwarf2_psymtab::get_compunit_symtab (struct objfile *objfile) const
-{
-  dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
-  return per_objfile->get_symtab (per_cu_data);
-}
-
 /* Trivial hash function for die_info: the hash value of a DIE
    is its offset in .debug_info for this objfile.  */
 
@@ -11041,7 +9523,7 @@ find_file_and_directory (struct die_info *die, struct dwarf2_cu *cu)
 
 static void
 handle_DW_AT_stmt_list (struct die_info *die, struct dwarf2_cu *cu,
-			const file_and_directory &fnd, CORE_ADDR lowpc) /* ARI: editCase function */
+			CORE_ADDR lowpc) /* ARI: editCase function */
 {
   dwarf2_per_objfile *per_objfile = cu->per_objfile;
   struct attribute *attr;
@@ -11129,9 +9611,7 @@ handle_DW_AT_stmt_list (struct die_info *die, struct dwarf2_cu *cu,
       gdb_assert (die->tag != DW_TAG_partial_unit);
     }
   decode_mapping = (die->tag != DW_TAG_partial_unit);
-  dwarf_decode_lines (cu->line_header, fnd, cu, nullptr, lowpc,
-		      decode_mapping);
-
+  dwarf_decode_lines (cu->line_header, cu, lowpc, decode_mapping);
 }
 
 /* Process DW_TAG_compile_unit or DW_TAG_partial_unit.  */
@@ -11176,7 +9656,7 @@ read_file_scope (struct die_info *die, struct dwarf2_cu *cu)
      lnp_state_machine::check_line_address) will fail to properly
      exclude an entry that was removed via --gc-sections.  */
   if (lowpc != highpc)
-    handle_DW_AT_stmt_list (die, cu, fnd, lowpc);
+    handle_DW_AT_stmt_list (die, cu, lowpc);
 
   /* Process all dies in compilation unit.  */
   if (die->child != NULL)
@@ -20080,7 +18560,7 @@ struct cooked_index_functions : public dwarf2_base_index_functions
   void read_partial_symbols (struct objfile *objfile) override
   {
     if (dwarf2_has_info (objfile, nullptr))
-      dwarf2_build_psymtabs (objfile);
+      dwarf2_build_psymtabs (objfile, true);
   }
 };
 
@@ -20103,1029 +18583,208 @@ cooked_index_functions::find_pc_sect_compunit_symtab
     return nullptr;
 
   if (warn_if_readin && per_objfile->symtab_set_p (per_cu))
-    warning (_("(Internal error: pc %s in read in CU, but not in symtab.)"),
-	     paddress (objfile->arch (), pc));
-
-  compunit_symtab *result = (recursively_find_pc_sect_compunit_symtab
-			     (dw2_instantiate_symtab (per_cu, per_objfile,
-						      false),
-			      pc));
-  gdb_assert (result != nullptr);
-  return result;
-}
-
-struct compunit_symtab *
-cooked_index_functions::find_compunit_symtab_by_address
-     (struct objfile *objfile, CORE_ADDR address)
-{
-  if (objfile->sect_index_data == -1)
-    return nullptr;
-
-  dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
-  if (per_objfile->per_bfd->cooked_index_table == nullptr)
-    return nullptr;
-
-  CORE_ADDR baseaddr = objfile->data_section_offset ();
-  dwarf2_per_cu_data *per_cu
-    = per_objfile->per_bfd->cooked_index_table->lookup (address - baseaddr);
-  if (per_cu == nullptr)
-    return nullptr;
-
-  return dw2_instantiate_symtab (per_cu, per_objfile, false);
-}
-
-void
-cooked_index_functions::expand_matching_symbols
-     (struct objfile *objfile,
-      const lookup_name_info &lookup_name,
-      domain_enum domain,
-      int global,
-      symbol_compare_ftype *ordered_compare)
-{
-  dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
-  if (per_objfile->per_bfd->cooked_index_table == nullptr)
-    return;
-  const block_search_flags search_flags = (global
-					   ? SEARCH_GLOBAL_BLOCK
-					   : SEARCH_STATIC_BLOCK);
-  const language_defn *lang = language_def (language_ada);
-  symbol_name_matcher_ftype *name_match
-    = lang->get_symbol_name_matcher (lookup_name);
-
-  for (const cooked_index_entry *entry
-	 : per_objfile->per_bfd->cooked_index_table->all_entries ())
-    {
-      if (entry->parent_entry != nullptr)
-	continue;
-
-      if (!entry->matches (search_flags)
-	  || !entry->matches (domain))
-	continue;
-
-      if (name_match (entry->canonical, lookup_name, nullptr))
-	dw2_instantiate_symtab (entry->per_cu, per_objfile, false);
-    }
-}
-
-bool
-cooked_index_functions::expand_symtabs_matching
-     (struct objfile *objfile,
-      gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher,
-      const lookup_name_info *lookup_name,
-      gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
-      gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
-      block_search_flags search_flags,
-      domain_enum domain,
-      enum search_dom[...]

[diff truncated at 100000 bytes]


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-04-12 15:41 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-12 15:41 [binutils-gdb] Delete DWARF psymtab code Tom Tromey

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).