public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2 07/12] Introduce objfile::reset_psymtabs
  2018-11-25 19:20 [PATCH v2 00/12] Work toward making psymtabs reusable Tom Tromey
                   ` (8 preceding siblings ...)
  2018-11-25 19:20 ` [PATCH v2 10/12] Add psymtab_storage::allocate_dependencies Tom Tromey
@ 2018-11-25 19:20 ` Tom Tromey
  2018-11-25 19:20 ` [PATCH v2 08/12] Allocate the address map on the psymtab obstack Tom Tromey
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Tom Tromey @ 2018-11-25 19:20 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This introduces a new method, objfile::reset_psymtabs, and changes
reread_symbols to use it.  This method simply destroys the existing
partial symbols and recreates the psymtab_storage object.

This patch fixes a latent bug -- namely, that reread_symbols should
clear objfile::psymbol_map, but does not.  I can submit that
separately if you'd prefer.

gdb/ChangeLog
2018-11-25  Tom Tromey  <tom@tromey.com>

	* symfile.c (reread_symbols): Call objfile->reset_psymtabs.
	* objfiles.h (objfile::reset_psymtabs): New method.
---
 gdb/ChangeLog  |  5 +++++
 gdb/objfiles.h |  9 +++++++++
 gdb/symfile.c  | 12 +-----------
 3 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index a3ec3884cf..7b132db395 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -291,6 +291,15 @@ struct objfile
 
   DISABLE_COPY_AND_ASSIGN (objfile);
 
+  /* Reset the storage for the partial symbol tables.  */
+
+  void reset_psymtabs ()
+  {
+    psymbol_map.clear ();
+    partial_symtabs.reset (new psymtab_storage (this));
+  }
+
+
   /* All struct objfile's are chained together by their next pointers.
      The program space field "objfiles"  (frequently referenced via
      the macro "object_files") points to the first link in this chain.  */
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 64fbfb43db..f2d29066b5 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -2479,23 +2479,13 @@ reread_symbols (void)
 	  memcpy (offsets, objfile->section_offsets,
 		  SIZEOF_N_SECTION_OFFSETS (num_offsets));
 
-	  /* FIXME: Do we have to free a whole linked list, or is this
-	     enough?  */
-	  objfile->partial_symtabs->global_psymbols.clear ();
-	  objfile->partial_symtabs->static_psymbols.clear ();
-
-	  /* Free the obstacks for non-reusable objfiles.  */
-	  psymbol_bcache_free (objfile->partial_symtabs->psymbol_cache);
-	  objfile->partial_symtabs->psymbol_cache = psymbol_bcache_init ();
+	  objfile->reset_psymtabs ();
 
 	  /* NB: after this call to obstack_free, objfiles_changed
 	     will need to be called (see discussion below).  */
 	  obstack_free (&objfile->objfile_obstack, 0);
 	  objfile->sections = NULL;
 	  objfile->compunit_symtabs = NULL;
-	  objfile->partial_symtabs->psymtabs = NULL;
-	  objfile->partial_symtabs->psymtabs_addrmap = NULL;
-	  objfile->partial_symtabs->free_psymtabs = NULL;
 	  objfile->template_symbols = NULL;
 	  objfile->static_links = NULL;
 
-- 
2.17.2

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v2 12/12] Move psymtabs to their own obstack
  2018-11-25 19:20 [PATCH v2 00/12] Work toward making psymtabs reusable Tom Tromey
                   ` (3 preceding siblings ...)
  2018-11-25 19:20 ` [PATCH v2 01/12] Remove parameters from start_psymtab_common Tom Tromey
@ 2018-11-25 19:20 ` Tom Tromey
  2018-11-25 19:20 ` [PATCH v2 03/12] Simplify calls to init_psymbol_list Tom Tromey
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Tom Tromey @ 2018-11-25 19:20 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Previously, the psymtab obstack was just a pointer to the objfile
obstack.  This patch changes psymtabs to use their own obstack,
instead.  A gdb::optional is used to avoid unnecessary allocation when
the obstack is not needed.

After this patch, the psymtab code lifetime model is that, in the core
psymtab code, objects allocated on the psymtab obstack may point to
other such objects, or to objects on the per-BFD obstack -- but never
to the objfile obstack.

Note however that this invariant is only obeyed the core psymtab code.
Symbol readers are free to work however they like; and in particular,
even after this patch, in practice all symbol readers violate this
invariant via the read_symtab_private field.

gdb/ChangeLog
2018-11-25  Tom Tromey  <tom@tromey.com>

	* objfiles.h (objfile::reset_psymtabs): Update.
	* objfiles.c (objfile::objfile): Update.
	* psymtab.h (psymtab_storage::obstack): Update.
	(psymtab_storage::m_obstack): Use gdb::optional.
	(class psymtab_storage): Update comment.  Remove objfile
	parameter.
	* psymtab.c (psymtab_storage::psymtab_storage): Update.
---
 gdb/ChangeLog  | 10 ++++++++++
 gdb/objfiles.c |  2 +-
 gdb/objfiles.h |  2 +-
 gdb/psymtab.c  |  5 ++---
 gdb/psymtab.h  | 26 +++++++++++++++++++++-----
 5 files changed, 35 insertions(+), 10 deletions(-)

diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index b1fa36609b..dde4f0d55d 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -369,7 +369,7 @@ build_objfile_section_table (struct objfile *objfile)
 objfile::objfile (bfd *abfd, const char *name, objfile_flags flags_)
   : flags (flags_),
     pspace (current_program_space),
-    partial_symtabs (new psymtab_storage (this)),
+    partial_symtabs (new psymtab_storage ()),
     obfd (abfd)
 {
   const char *expanded_name;
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index 7b132db395..776f5d9dea 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -296,7 +296,7 @@ struct objfile
   void reset_psymtabs ()
   {
     psymbol_map.clear ();
-    partial_symtabs.reset (new psymtab_storage (this));
+    partial_symtabs.reset (new psymtab_storage ());
   }
 
 
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 50236f2de3..1f757291e7 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -67,9 +67,8 @@ static struct compunit_symtab *psymtab_to_symtab (struct objfile *objfile,
 
 \f
 
-psymtab_storage::psymtab_storage (struct objfile *objfile)
-  : psymbol_cache (psymbol_bcache_init ()),
-    m_obstack (&objfile->objfile_obstack)
+psymtab_storage::psymtab_storage ()
+  : psymbol_cache (psymbol_bcache_init ())
 {
 }
 
diff --git a/gdb/psymtab.h b/gdb/psymtab.h
index 061b63dcdf..a01c2450b3 100644
--- a/gdb/psymtab.h
+++ b/gdb/psymtab.h
@@ -30,13 +30,26 @@ struct partial_symbol;
 struct psymbol_bcache;
 
 /* An instance of this class manages the partial symbol tables and
-   partial symbols for a given objfile.  */
+   partial symbols for a given objfile.
+
+   The core psymtab functions -- those in psymtab.c -- arrange for
+   nearly all psymtab- and psymbol-related allocations to happen
+   either in the psymtab_storage object (either on its obstack or in
+   other memory managed by this class), or on the per-BFD object.  The
+   only link from the psymtab storage object back to the objfile (or
+   objfile_obstack) that is made by the core psymtab code is the
+   compunit_symtab member in the psymtab.
+
+   However, it is up to each symbol reader to maintain this invariant
+   in other ways, if it wants to reuse psymtabs across multiple
+   objfiles.  The main issue here is ensuring that read_symtab_private
+   does not point into objfile_obstack.  */
 
 class psymtab_storage
 {
 public:
 
-  explicit psymtab_storage (struct objfile *objfile);
+  psymtab_storage ();
 
   ~psymtab_storage ();
 
@@ -59,7 +72,9 @@ public:
 
   struct obstack *obstack ()
   {
-    return m_obstack;
+    if (!m_obstack.has_value ())
+      m_obstack.emplace ();
+    return &*m_obstack;
   }
 
   /* Allocate storage for the "dependencies" field of a psymtab.
@@ -107,9 +122,10 @@ private:
 
   struct partial_symtab *free_psymtabs = nullptr;
 
-  /* The obstack where allocations are made.  */
+  /* The obstack where allocations are made.  This is lazily allocated
+     so that we don't waste memory when there are no psymtabs.  */
 
-  struct obstack *m_obstack;
+  gdb::optional<auto_obstack> m_obstack;
 };
 
 
-- 
2.17.2

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v2 08/12] Allocate the address map on the psymtab obstack
  2018-11-25 19:20 [PATCH v2 00/12] Work toward making psymtabs reusable Tom Tromey
                   ` (9 preceding siblings ...)
  2018-11-25 19:20 ` [PATCH v2 07/12] Introduce objfile::reset_psymtabs Tom Tromey
@ 2018-11-25 19:20 ` Tom Tromey
  2018-11-25 19:22 ` [PATCH v2 06/12] Introduce class psymtab_storage Tom Tromey
  2019-01-10 14:09 ` [PATCH v2 00/12] Work toward making psymtabs reusable Tom Tromey
  12 siblings, 0 replies; 14+ messages in thread
From: Tom Tromey @ 2018-11-25 19:20 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

After this patch, the psymtab address map will now be allocated on the
psymtab obstack rather than the objfile obstack.  This also changes
the psymtab storage object to make the obstack private; this will be
used later.

gdb/ChangeLog
2018-11-25  Tom Tromey  <tom@tromey.com>

	* psymtab.h (psymtab_storage::obstack): New method.
	<m_obstack>: Rename from obstack; now private.
	* psymtab.c (psymtab_storage): Update.
	* dwarf2read.c (create_addrmap_from_index)
	(create_addrmap_from_aranges, dwarf2_build_psymtabs_hard):
	Update.
---
 gdb/ChangeLog    |  9 +++++++++
 gdb/dwarf2read.c |  6 +++---
 gdb/psymtab.c    |  4 ++--
 gdb/psymtab.h    | 17 +++++++++++++----
 4 files changed, 27 insertions(+), 9 deletions(-)

diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 26fc47b669..35717aa6a3 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -3191,7 +3191,7 @@ create_addrmap_from_index (struct dwarf2_per_objfile *dwarf2_per_objfile,
     }
 
   objfile->partial_symtabs->psymtabs_addrmap
-    = addrmap_create_fixed (mutable_map, &objfile->objfile_obstack);
+    = addrmap_create_fixed (mutable_map, objfile->partial_symtabs->obstack ());
 }
 
 /* Read the address map data from DWARF-5 .debug_aranges, and use it to
@@ -3352,7 +3352,7 @@ create_addrmap_from_aranges (struct dwarf2_per_objfile *dwarf2_per_objfile,
     }
 
   objfile->partial_symtabs->psymtabs_addrmap
-    = addrmap_create_fixed (mutable_map, &objfile->objfile_obstack);
+    = addrmap_create_fixed (mutable_map, objfile->partial_symtabs->obstack ());
 }
 
 /* Find a slot in the mapped index INDEX for the object named NAME.
@@ -8485,7 +8485,7 @@ dwarf2_build_psymtabs_hard (struct dwarf2_per_objfile *dwarf2_per_objfile)
 
   objfile->partial_symtabs->psymtabs_addrmap
     = addrmap_create_fixed (objfile->partial_symtabs->psymtabs_addrmap,
-			    &objfile->objfile_obstack);
+			    objfile->partial_symtabs->obstack ());
   /* At this point we want to keep the address map.  */
   save_psymtabs_addrmap.release ();
 
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index c06ff0c70e..d4152bdba4 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -68,8 +68,8 @@ static struct compunit_symtab *psymtab_to_symtab (struct objfile *objfile,
 \f
 
 psymtab_storage::psymtab_storage (struct objfile *objfile)
-  : obstack (&objfile->objfile_obstack),
-    psymbol_cache (psymbol_bcache_init ())
+  : psymbol_cache (psymbol_bcache_init ()),
+    m_obstack (&objfile->objfile_obstack)
 {
 }
 
diff --git a/gdb/psymtab.h b/gdb/psymtab.h
index 7bdb9d185f..d0b446b5ed 100644
--- a/gdb/psymtab.h
+++ b/gdb/psymtab.h
@@ -54,6 +54,13 @@ public:
 
   void discard_psymtab (struct partial_symtab *pst);
 
+  /* Return the obstack that is used for storage by this object.  */
+
+  struct obstack *obstack ()
+  {
+    return m_obstack;
+  }
+
 
   /* Each objfile points to a linked list of partial symtabs derived from
      this file, one partial symtab structure for each compilation unit
@@ -72,10 +79,6 @@ public:
 
   struct partial_symtab *free_psymtabs = nullptr;
 
-  /* The obstack where allocations are made.  */
-
-  struct obstack *obstack;
-
   /* A byte cache where we can stash arbitrary "chunks" of bytes that
      will not change.  */
 
@@ -86,6 +89,12 @@ public:
 
   std::vector<partial_symbol *> global_psymbols;
   std::vector<partial_symbol *> static_psymbols;
+
+private:
+
+  /* The obstack where allocations are made.  */
+
+  struct obstack *m_obstack;
 };
 
 
-- 
2.17.2

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v2 11/12] Make psymtab_storage::free_psymtabs private
  2018-11-25 19:20 [PATCH v2 00/12] Work toward making psymtabs reusable Tom Tromey
@ 2018-11-25 19:20 ` Tom Tromey
  2018-11-25 19:20 ` [PATCH v2 09/12] Move more allocations to psymtab obstack Tom Tromey
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Tom Tromey @ 2018-11-25 19:20 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This adds a new psymtab allocation method to psymtab_storage and
changes the free_psymtabs member to be private.  While not strictly
necessary, this seems like a decent cleanup, and also makes it simpler
to move psymtabs off of obstacks entirely, should that prove
desirable.

gdb/ChangeLog
2018-11-25  Tom Tromey  <tom@tromey.com>

	* psymtab.h (psymtab_storage::allocate_psymtab): New method.
	<free_psymtabs>: Now private.
	* psymtab.c (psymtab_storage::allocate_psymtab): Implement.
	(allocate_psymtab): Use new method.
---
 gdb/ChangeLog |  7 +++++++
 gdb/psymtab.c | 42 +++++++++++++++++++++++++-----------------
 gdb/psymtab.h | 14 ++++++++++----
 3 files changed, 42 insertions(+), 21 deletions(-)

diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index bd957e7b62..50236f2de3 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -78,6 +78,29 @@ psymtab_storage::~psymtab_storage ()
   psymbol_bcache_free (psymbol_cache);
 }
 
+/* See psymtab.h.  */
+
+struct partial_symtab *
+psymtab_storage::allocate_psymtab ()
+{
+  struct partial_symtab *psymtab;
+
+  if (free_psymtabs != nullptr)
+    {
+      psymtab = free_psymtabs;
+      free_psymtabs = psymtab->next;
+    }
+  else
+    psymtab = XOBNEW (obstack (), struct partial_symtab);
+
+  memset (psymtab, 0, sizeof (struct partial_symtab));
+
+  psymtab->next = psymtabs;
+  psymtabs = psymtab;
+
+  return psymtab;
+}
+
 \f
 
 /* Ensure that the partial symbols for OBJFILE have been loaded.  This
@@ -1758,29 +1781,14 @@ init_psymbol_list (struct objfile *objfile, int total_symbols)
 struct partial_symtab *
 allocate_psymtab (const char *filename, struct objfile *objfile)
 {
-  struct partial_symtab *psymtab;
+  struct partial_symtab *psymtab
+    = objfile->partial_symtabs->allocate_psymtab ();
 
-  if (objfile->partial_symtabs->free_psymtabs)
-    {
-      psymtab = objfile->partial_symtabs->free_psymtabs;
-      objfile->partial_symtabs->free_psymtabs = psymtab->next;
-    }
-  else
-    psymtab = XOBNEW (objfile->partial_symtabs->obstack (), partial_symtab);
-
-  memset (psymtab, 0, sizeof (struct partial_symtab));
   psymtab->filename
     = (const char *) bcache (filename, strlen (filename) + 1,
 			     objfile->per_bfd->filename_cache);
   psymtab->compunit_symtab = NULL;
 
-  /* Prepend it to the psymtab list for the objfile it belongs to.
-     Psymtabs are searched in most recent inserted -> least recent
-     inserted order.  */
-
-  psymtab->next = objfile->partial_symtabs->psymtabs;
-  objfile->partial_symtabs->psymtabs = psymtab;
-
   if (symtab_create_debug)
     {
       /* Be a bit clever with debugging messages, and don't print objfile
diff --git a/gdb/psymtab.h b/gdb/psymtab.h
index b4cac7834e..061b63dcdf 100644
--- a/gdb/psymtab.h
+++ b/gdb/psymtab.h
@@ -70,6 +70,12 @@ public:
     return OBSTACK_CALLOC (obstack (), number, struct partial_symtab *);
   }
 
+  /* Allocate a new psymtab on the psymtab obstack.  The new psymtab
+     will be linked in to the "psymtabs" list, but otherwise all other
+     fields will be zero.  */
+
+  struct partial_symtab *allocate_psymtab ();
+
 
   /* Each objfile points to a linked list of partial symtabs derived from
      this file, one partial symtab structure for each compilation unit
@@ -84,10 +90,6 @@ public:
 
   struct addrmap *psymtabs_addrmap = nullptr;
 
-  /* List of freed partial symtabs, available for re-use.  */
-
-  struct partial_symtab *free_psymtabs = nullptr;
-
   /* A byte cache where we can stash arbitrary "chunks" of bytes that
      will not change.  */
 
@@ -101,6 +103,10 @@ public:
 
 private:
 
+  /* List of freed partial symtabs, available for re-use.  */
+
+  struct partial_symtab *free_psymtabs = nullptr;
+
   /* The obstack where allocations are made.  */
 
   struct obstack *m_obstack;
-- 
2.17.2

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v2 04/12] Change create_demangled_names_hash to take an objfile_per_bfd_storage
  2018-11-25 19:20 [PATCH v2 00/12] Work toward making psymtabs reusable Tom Tromey
  2018-11-25 19:20 ` [PATCH v2 11/12] Make psymtab_storage::free_psymtabs private Tom Tromey
  2018-11-25 19:20 ` [PATCH v2 09/12] Move more allocations to psymtab obstack Tom Tromey
@ 2018-11-25 19:20 ` Tom Tromey
  2018-11-25 19:20 ` [PATCH v2 01/12] Remove parameters from start_psymtab_common Tom Tromey
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Tom Tromey @ 2018-11-25 19:20 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes create_demangled_names_hash to take an
objfile_per_bfd_storage parameter.  This makes it clearer where it is
storing the objects it allocates.

gdb/ChangeLog
2018-11-25  Tom Tromey  <tom@tromey.com>

	* symtab.c (create_demangled_names_hash): Change argument to be an
	objfile_per_bfd_storage.
	(symbol_set_names): Update.
---
 gdb/ChangeLog | 6 ++++++
 gdb/symtab.c  | 6 +++---
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/gdb/symtab.c b/gdb/symtab.c
index f8c755fdab..2911e5c83c 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -709,14 +709,14 @@ eq_demangled_name_entry (const void *a, const void *b)
    name.  The entry is hashed via just the mangled name.  */
 
 static void
-create_demangled_names_hash (struct objfile *objfile)
+create_demangled_names_hash (struct objfile_per_bfd_storage *per_bfd)
 {
   /* Choose 256 as the starting size of the hash table, somewhat arbitrarily.
      The hash table code will round this up to the next prime number.
      Choosing a much larger table size wastes memory, and saves only about
      1% in symbol reading.  */
 
-  objfile->per_bfd->demangled_names_hash = htab_create_alloc
+  per_bfd->demangled_names_hash = htab_create_alloc
     (256, hash_demangled_name_entry, eq_demangled_name_entry,
      NULL, xcalloc, xfree);
 }
@@ -803,7 +803,7 @@ symbol_set_names (struct general_symbol_info *gsymbol,
     }
 
   if (per_bfd->demangled_names_hash == NULL)
-    create_demangled_names_hash (objfile);
+    create_demangled_names_hash (per_bfd);
 
   if (linkage_name[len] != '\0')
     {
-- 
2.17.2

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v2 10/12] Add psymtab_storage::allocate_dependencies
  2018-11-25 19:20 [PATCH v2 00/12] Work toward making psymtabs reusable Tom Tromey
                   ` (7 preceding siblings ...)
  2018-11-25 19:20 ` [PATCH v2 05/12] Change symbol_set_names to take an objfile_per_bfd_storage Tom Tromey
@ 2018-11-25 19:20 ` Tom Tromey
  2018-11-25 19:20 ` [PATCH v2 07/12] Introduce objfile::reset_psymtabs Tom Tromey
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Tom Tromey @ 2018-11-25 19:20 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This adds a new method to psymtab_storage to allocate storage for
psymtab dependencies, then changes the symbol readers to use it.  This
has the effect of moving the storage to the psymtab storage obstack.

gdb/ChangeLog
2018-11-25  Tom Tromey  <tom@tromey.com>

	* xcoffread.c (xcoff_end_psymtab): Use allocate_dependencies.
	* psymtab.h (psymtab_storage::allocate_dependencies): New method.
	* mdebugread.c (parse_partial_symbols): Use
	allocate_dependencies.
	* dwarf2read.c (dwarf2_create_include_psymtab): Use
	allocate_dependencies.
	(process_psymtab_comp_unit_reader)
	(build_type_psymtab_dependencies): Likewise.
	* dbxread.c (dbx_end_psymtab): Use allocate_dependencies.
---
 gdb/ChangeLog    | 12 ++++++++++++
 gdb/dbxread.c    |  7 +++----
 gdb/dwarf2read.c | 10 ++++------
 gdb/mdebugread.c |  4 ++--
 gdb/psymtab.h    |  9 +++++++++
 gdb/xcoffread.c  |  7 +++----
 6 files changed, 33 insertions(+), 16 deletions(-)

diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index 7130bb13b4..0aea6e3008 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -2027,9 +2027,8 @@ dbx_end_psymtab (struct objfile *objfile, struct partial_symtab *pst,
   pst->number_of_dependencies = number_dependencies;
   if (number_dependencies)
     {
-      pst->dependencies = XOBNEWVEC (&objfile->objfile_obstack,
-				     struct partial_symtab *,
-				     number_dependencies);
+      pst->dependencies
+	= objfile->partial_symtabs->allocate_dependencies (number_dependencies);
       memcpy (pst->dependencies, dependency_list,
 	      number_dependencies * sizeof (struct partial_symtab *));
     }
@@ -2049,7 +2048,7 @@ dbx_end_psymtab (struct objfile *objfile, struct partial_symtab *pst,
       /* We could save slight bits of space by only making one of these,
          shared by the entire set of include files.  FIXME-someday.  */
       subpst->dependencies =
-	XOBNEW (&objfile->objfile_obstack, struct partial_symtab *);
+	objfile->partial_symtabs->allocate_dependencies (1);
       subpst->dependencies[0] = pst;
       subpst->number_of_dependencies = 1;
 
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 35717aa6a3..48e0cdadc4 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -6579,8 +6579,7 @@ dwarf2_create_include_psymtab (const char *name, struct partial_symtab *pst,
       subpst->dirname = pst->dirname;
     }
 
-  subpst->dependencies
-    = XOBNEW (&objfile->objfile_obstack, struct partial_symtab *);
+  subpst->dependencies = objfile->partial_symtabs->allocate_dependencies (1);
   subpst->dependencies[0] = pst;
   subpst->number_of_dependencies = 1;
 
@@ -8055,8 +8054,8 @@ process_psymtab_comp_unit_reader (const struct die_reader_specs *reader,
       /* Fill in 'dependencies' here; we fill in 'users' in a
 	 post-pass.  */
       pst->number_of_dependencies = len;
-      pst->dependencies =
-	XOBNEWVEC (&objfile->objfile_obstack, struct partial_symtab *, len);
+      pst->dependencies
+	= objfile->partial_symtabs->allocate_dependencies (len);
       for (i = 0;
 	   VEC_iterate (dwarf2_per_cu_ptr, cu->per_cu->imported_symtabs,
 			i, iter);
@@ -8309,8 +8308,7 @@ build_type_psymtab_dependencies (void **slot, void *info)
   gdb_assert (IS_TYPE_UNIT_GROUP (per_cu));
 
   pst->number_of_dependencies = len;
-  pst->dependencies =
-    XOBNEWVEC (&objfile->objfile_obstack, struct partial_symtab *, len);
+  pst->dependencies = objfile->partial_symtabs->allocate_dependencies (len);
   for (i = 0;
        VEC_iterate (sig_type_ptr, tu_group->tus, i, iter);
        ++i)
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index 5cc944fefe..2720aca4cf 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -3709,8 +3709,8 @@ parse_partial_symbols (minimal_symbol_reader &reader,
       /* Skip the first file indirect entry as it is a self dependency for
          source files or a reverse .h -> .c dependency for header files.  */
       pst->number_of_dependencies = 0;
-      pst->dependencies = XOBNEWVEC (&objfile->objfile_obstack,
-				     partial_symtab *, (fh->crfd - 1));
+      pst->dependencies
+	= objfile->partial_symtabs->allocate_dependencies (fh->crfd - 1);
       for (s_idx = 1; s_idx < fh->crfd; s_idx++)
 	{
 	  RFDT rh;
diff --git a/gdb/psymtab.h b/gdb/psymtab.h
index d0b446b5ed..b4cac7834e 100644
--- a/gdb/psymtab.h
+++ b/gdb/psymtab.h
@@ -20,6 +20,7 @@
 #ifndef PSYMTAB_H
 #define PSYMTAB_H
 
+#include "gdb_obstack.h"
 #include "symfile.h"
 
 struct partial_symbol;
@@ -61,6 +62,14 @@ public:
     return m_obstack;
   }
 
+  /* Allocate storage for the "dependencies" field of a psymtab.
+     NUMBER says how many dependencies there are.  */
+
+  struct partial_symtab **allocate_dependencies (int number)
+  {
+    return OBSTACK_CALLOC (obstack (), number, struct partial_symtab *);
+  }
+
 
   /* Each objfile points to a linked list of partial symtabs derived from
      this file, one partial symtab structure for each compilation unit
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index daff10db43..9c5fd70e3d 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -2075,9 +2075,8 @@ xcoff_end_psymtab (struct objfile *objfile, struct partial_symtab *pst,
   pst->number_of_dependencies = number_dependencies;
   if (number_dependencies)
     {
-      pst->dependencies = XOBNEWVEC (&objfile->objfile_obstack,
-				     struct partial_symtab *,
-				     number_dependencies);
+      pst->dependencies
+	= objfile->partial_symtabs->allocate_dependencies (number_dependencies);
       memcpy (pst->dependencies, dependency_list,
 	      number_dependencies * sizeof (struct partial_symtab *));
     }
@@ -2096,7 +2095,7 @@ xcoff_end_psymtab (struct objfile *objfile, struct partial_symtab *pst,
       /* We could save slight bits of space by only making one of these,
          shared by the entire set of include files.  FIXME-someday.  */
       subpst->dependencies =
-	  XOBNEW (&objfile->objfile_obstack, struct partial_symtab *);
+	objfile->partial_symtabs->allocate_dependencies (1);
       subpst->dependencies[0] = pst;
       subpst->number_of_dependencies = 1;
 
-- 
2.17.2

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v2 02/12] Change add_psymbol_to_list to use an enum
  2018-11-25 19:20 [PATCH v2 00/12] Work toward making psymtabs reusable Tom Tromey
                   ` (5 preceding siblings ...)
  2018-11-25 19:20 ` [PATCH v2 03/12] Simplify calls to init_psymbol_list Tom Tromey
@ 2018-11-25 19:20 ` Tom Tromey
  2018-11-25 19:20 ` [PATCH v2 05/12] Change symbol_set_names to take an objfile_per_bfd_storage Tom Tromey
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Tom Tromey @ 2018-11-25 19:20 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes add_psymbol_to_list to use an enum, rather than a pointer
to a vector, to decide where to put the new symbol.  This reduces the
number of direct references to the static_psymbols and global_psymbols
members of the objfile, which is handy in a later patch.

gdb/ChangeLog
2018-11-25  Tom Tromey  <tom@tromey.com>

	* xcoffread.c (scan_xcoff_symtab): Update.
	* psymtab.c (add_psymbol_to_list): Replace "list" parameter with
	"where".
	* mdebugread.c (parse_partial_symbols)
	(handle_psymbol_enumerators): Update.
	* dwarf2read.c (add_partial_symbol, load_partial_dies): Update.
	* dbxread.c (read_dbx_symtab): Update.
	* psympriv.h (psymbol_placement): New enum.
	(add_psymbol_to_list): Update.
---
 gdb/ChangeLog    | 12 ++++++++++++
 gdb/dbxread.c    | 18 +++++++++---------
 gdb/dwarf2read.c | 45 ++++++++++++++++++++-------------------------
 gdb/mdebugread.c | 30 +++++++++++++++---------------
 gdb/psympriv.h   | 11 ++++++++++-
 gdb/psymtab.c    |  9 ++++++---
 gdb/xcoffread.c  | 18 +++++++++---------
 7 files changed, 81 insertions(+), 62 deletions(-)

diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index 3cf140381f..abcd2f9048 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -1476,7 +1476,7 @@ read_dbx_symtab (minimal_symbol_reader &reader, struct objfile *objfile)
 	      add_psymbol_to_list (sym_name, sym_len, 1,
 				   VAR_DOMAIN, LOC_STATIC,
 				   data_sect_index,
-				   &objfile->static_psymbols,
+				   psymbol_placement::STATIC,
 				   nlist.n_value, psymtab_language, objfile);
 	      continue;
 
@@ -1486,7 +1486,7 @@ read_dbx_symtab (minimal_symbol_reader &reader, struct objfile *objfile)
 	      add_psymbol_to_list (sym_name, sym_len, 1,
 				   VAR_DOMAIN, LOC_STATIC,
 				   data_sect_index,
-				   &objfile->global_psymbols,
+				   psymbol_placement::GLOBAL,
 				   nlist.n_value, psymtab_language, objfile);
 	      continue;
 
@@ -1503,14 +1503,14 @@ read_dbx_symtab (minimal_symbol_reader &reader, struct objfile *objfile)
 		{
 		  add_psymbol_to_list (sym_name, sym_len, 1,
 				       STRUCT_DOMAIN, LOC_TYPEDEF, -1,
-				       &objfile->static_psymbols,
+				       psymbol_placement::STATIC,
 				       0, psymtab_language, objfile);
 		  if (p[2] == 't')
 		    {
 		      /* Also a typedef with the same name.  */
 		      add_psymbol_to_list (sym_name, sym_len, 1,
 					   VAR_DOMAIN, LOC_TYPEDEF, -1,
-					   &objfile->static_psymbols,
+					   psymbol_placement::STATIC,
 					   0, psymtab_language, objfile);
 		      p += 1;
 		    }
@@ -1522,7 +1522,7 @@ read_dbx_symtab (minimal_symbol_reader &reader, struct objfile *objfile)
 		{
 		  add_psymbol_to_list (sym_name, sym_len, 1,
 				       VAR_DOMAIN, LOC_TYPEDEF, -1,
-				       &objfile->static_psymbols,
+				       psymbol_placement::STATIC,
 				       0, psymtab_language, objfile);
 		}
 	    check_enum:
@@ -1583,7 +1583,7 @@ read_dbx_symtab (minimal_symbol_reader &reader, struct objfile *objfile)
 			 enum constants in psymtabs, just in symtabs.  */
 		      add_psymbol_to_list (p, q - p, 1,
 					   VAR_DOMAIN, LOC_CONST, -1,
-					   &objfile->static_psymbols, 0,
+					   psymbol_placement::STATIC, 0,
 					   psymtab_language, objfile);
 		      /* Point past the name.  */
 		      p = q;
@@ -1601,7 +1601,7 @@ read_dbx_symtab (minimal_symbol_reader &reader, struct objfile *objfile)
 	      /* Constant, e.g. from "const" in Pascal.  */
 	      add_psymbol_to_list (sym_name, sym_len, 1,
 				   VAR_DOMAIN, LOC_CONST, -1,
-				   &objfile->static_psymbols, 0,
+				   psymbol_placement::STATIC, 0,
 				   psymtab_language, objfile);
 	      continue;
 
@@ -1657,7 +1657,7 @@ read_dbx_symtab (minimal_symbol_reader &reader, struct objfile *objfile)
 	      add_psymbol_to_list (sym_name, sym_len, 1,
 				   VAR_DOMAIN, LOC_BLOCK,
 				   SECT_OFF_TEXT (objfile),
-				   &objfile->static_psymbols,
+				   psymbol_placement::STATIC,
 				   nlist.n_value, psymtab_language, objfile);
 	      continue;
 
@@ -1716,7 +1716,7 @@ read_dbx_symtab (minimal_symbol_reader &reader, struct objfile *objfile)
 	      add_psymbol_to_list (sym_name, sym_len, 1,
 				   VAR_DOMAIN, LOC_BLOCK,
 				   SECT_OFF_TEXT (objfile),
-				   &objfile->global_psymbols,
+				   psymbol_placement::GLOBAL,
 				   nlist.n_value, psymtab_language, objfile);
 	      continue;
 
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index f316250f41..355015865d 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -8882,7 +8882,7 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
 			       built_actual_name != NULL,
 			       VAR_DOMAIN, LOC_BLOCK,
 			       SECT_OFF_TEXT (objfile),
-			       &objfile->global_psymbols,
+			       psymbol_placement::GLOBAL,
 			       addr,
 			       cu->language, objfile);
 	}
@@ -8892,7 +8892,7 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
 			       built_actual_name != NULL,
 			       VAR_DOMAIN, LOC_BLOCK,
 			       SECT_OFF_TEXT (objfile),
-			       &objfile->static_psymbols,
+			       psymbol_placement::STATIC,
 			       addr, cu->language, objfile);
 	}
 
@@ -8900,17 +8900,12 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
 	set_objfile_main_name (objfile, actual_name, cu->language);
       break;
     case DW_TAG_constant:
-      {
-	std::vector<partial_symbol *> *list;
-
-	if (pdi->is_external)
-	  list = &objfile->global_psymbols;
-	else
-	  list = &objfile->static_psymbols;
-	add_psymbol_to_list (actual_name, strlen (actual_name),
-			     built_actual_name != NULL, VAR_DOMAIN, LOC_STATIC,
-			     -1, list, 0, cu->language, objfile);
-      }
+      add_psymbol_to_list (actual_name, strlen (actual_name),
+			   built_actual_name != NULL, VAR_DOMAIN, LOC_STATIC,
+			   -1, (pdi->is_external
+				? psymbol_placement::GLOBAL
+				: psymbol_placement::STATIC),
+			   0, cu->language, objfile);
       break;
     case DW_TAG_variable:
       if (pdi->d.locdesc)
@@ -8945,7 +8940,7 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
 				 built_actual_name != NULL,
 				 VAR_DOMAIN, LOC_STATIC,
 				 SECT_OFF_TEXT (objfile),
-				 &objfile->global_psymbols,
+				 psymbol_placement::GLOBAL,
 				 addr, cu->language, objfile);
 	}
       else
@@ -8964,7 +8959,7 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
 			       built_actual_name != NULL,
 			       VAR_DOMAIN, LOC_STATIC,
 			       SECT_OFF_TEXT (objfile),
-			       &objfile->static_psymbols,
+			       psymbol_placement::STATIC,
 			       has_loc ? addr : 0,
 			       cu->language, objfile);
 	}
@@ -8975,7 +8970,7 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
       add_psymbol_to_list (actual_name, strlen (actual_name),
 			   built_actual_name != NULL,
 			   VAR_DOMAIN, LOC_TYPEDEF, -1,
-			   &objfile->static_psymbols,
+			   psymbol_placement::STATIC,
 			   0, cu->language, objfile);
       break;
     case DW_TAG_imported_declaration:
@@ -8983,14 +8978,14 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
       add_psymbol_to_list (actual_name, strlen (actual_name),
 			   built_actual_name != NULL,
 			   VAR_DOMAIN, LOC_TYPEDEF, -1,
-			   &objfile->global_psymbols,
+			   psymbol_placement::GLOBAL,
 			   0, cu->language, objfile);
       break;
     case DW_TAG_module:
       add_psymbol_to_list (actual_name, strlen (actual_name),
 			   built_actual_name != NULL,
 			   MODULE_DOMAIN, LOC_TYPEDEF, -1,
-			   &objfile->global_psymbols,
+			   psymbol_placement::GLOBAL,
 			   0, cu->language, objfile);
       break;
     case DW_TAG_class_type:
@@ -9015,8 +9010,8 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
 			   built_actual_name != NULL,
 			   STRUCT_DOMAIN, LOC_TYPEDEF, -1,
 			   cu->language == language_cplus
-			   ? &objfile->global_psymbols
-			   : &objfile->static_psymbols,
+			   ? psymbol_placement::GLOBAL
+			   : psymbol_placement::STATIC,
 			   0, cu->language, objfile);
 
       break;
@@ -9025,8 +9020,8 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
 			   built_actual_name != NULL,
 			   VAR_DOMAIN, LOC_CONST, -1,
 			   cu->language == language_cplus
-			   ? &objfile->global_psymbols
-			   : &objfile->static_psymbols,
+			   ? psymbol_placement::GLOBAL
+			   : psymbol_placement::STATIC,
 			   0, cu->language, objfile);
       break;
     default:
@@ -18434,7 +18429,7 @@ load_partial_dies (const struct die_reader_specs *reader,
 	  if (building_psymtab && pdi.name != NULL)
 	    add_psymbol_to_list (pdi.name, strlen (pdi.name), 0,
 				 VAR_DOMAIN, LOC_TYPEDEF, -1,
-				 &objfile->static_psymbols,
+				 psymbol_placement::STATIC,
 				 0, cu->language, objfile);
 	  info_ptr = locate_pdi_sibling (reader, &pdi, info_ptr);
 	  continue;
@@ -18469,8 +18464,8 @@ load_partial_dies (const struct die_reader_specs *reader,
 	    add_psymbol_to_list (pdi.name, strlen (pdi.name), 0,
 				 VAR_DOMAIN, LOC_CONST, -1,
 				 cu->language == language_cplus
-				 ? &objfile->global_psymbols
-				 : &objfile->static_psymbols,
+				 ? psymbol_placement::GLOBAL
+				 : psymbol_placement::STATIC,
 				 0, cu->language, objfile);
 
 	  info_ptr = locate_pdi_sibling (reader, &pdi, info_ptr);
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index ba8906a1af..e93f1edc08 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -3048,7 +3048,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
 			add_psymbol_to_list (namestring, p - namestring, 1,
 					     VAR_DOMAIN, LOC_STATIC,
 					     SECT_OFF_DATA (objfile),
-					     &objfile->static_psymbols,
+					     psymbol_placement::STATIC,
 					     sh.value,
 					     psymtab_language, objfile);
 			continue;
@@ -3059,7 +3059,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
 			add_psymbol_to_list (namestring, p - namestring, 1,
 					     VAR_DOMAIN, LOC_STATIC,
 					     SECT_OFF_DATA (objfile),
-					     &objfile->global_psymbols,
+					     psymbol_placement::GLOBAL,
 					     sh.value,
 					     psymtab_language, objfile);
 			continue;
@@ -3078,7 +3078,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
 			    add_psymbol_to_list (namestring, p - namestring, 1,
 						 STRUCT_DOMAIN, LOC_TYPEDEF,
 						 -1,
-						 &objfile->static_psymbols,
+						 psymbol_placement::STATIC,
 						 0, psymtab_language, objfile);
 			    if (p[2] == 't')
 			      {
@@ -3087,7 +3087,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
 						     p - namestring, 1,
 						     VAR_DOMAIN, LOC_TYPEDEF,
 						     -1,
-						     &objfile->static_psymbols,
+						     psymbol_placement::STATIC,
 						     0, psymtab_language,
 						     objfile);
 				p += 1;
@@ -3101,7 +3101,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
 			    add_psymbol_to_list (namestring, p - namestring, 1,
 						 VAR_DOMAIN, LOC_TYPEDEF,
 						 -1,
-						 &objfile->static_psymbols,
+						 psymbol_placement::STATIC,
 						 0, psymtab_language, objfile);
 			  }
 		      check_enum:
@@ -3166,7 +3166,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
 				add_psymbol_to_list (p, q - p, 1,
 						     VAR_DOMAIN, LOC_CONST,
 						     -1,
-						     &objfile->static_psymbols,
+						     psymbol_placement::STATIC,
 						     0, psymtab_language,
 						     objfile);
 				/* Point past the name.  */
@@ -3184,7 +3184,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
 			/* Constant, e.g. from "const" in Pascal.  */
 			add_psymbol_to_list (namestring, p - namestring, 1,
 					     VAR_DOMAIN, LOC_CONST, -1,
-					     &objfile->static_psymbols,
+					     psymbol_placement::STATIC,
 					     0, psymtab_language, objfile);
 			continue;
 
@@ -3198,7 +3198,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
 			add_psymbol_to_list (namestring, p - namestring, 1,
 					     VAR_DOMAIN, LOC_BLOCK,
 					     SECT_OFF_TEXT (objfile),
-					     &objfile->static_psymbols,
+					     psymbol_placement::STATIC,
 					     sh.value,
 					     psymtab_language, objfile);
 			continue;
@@ -3217,7 +3217,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
 			add_psymbol_to_list (namestring, p - namestring, 1,
 					     VAR_DOMAIN, LOC_BLOCK,
 					     SECT_OFF_TEXT (objfile),
-					     &objfile->global_psymbols,
+					     psymbol_placement::GLOBAL,
 					     sh.value,
 					     psymtab_language, objfile);
 			continue;
@@ -3455,13 +3455,13 @@ parse_partial_symbols (minimal_symbol_reader &reader,
 		    add_psymbol_to_list (sym_name, strlen (sym_name), 1,
 					 VAR_DOMAIN, LOC_BLOCK,
 					 section,
-					 &objfile->global_psymbols,
+					 psymbol_placement::GLOBAL,
 					 sh.value, psymtab_language, objfile);
 		  else
 		    add_psymbol_to_list (sym_name, strlen (sym_name), 1,
 					 VAR_DOMAIN, LOC_BLOCK,
 					 section,
-					 &objfile->static_psymbols,
+					 psymbol_placement::STATIC,
 					 sh.value, psymtab_language, objfile);
 
 		  procaddr = sh.value;
@@ -3527,7 +3527,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
 		    {
 		      add_psymbol_to_list (sym_name, strlen (sym_name), 1,
 					   STRUCT_DOMAIN, LOC_TYPEDEF, -1,
-					   &objfile->static_psymbols,
+					   psymbol_placement::STATIC,
 					   0, psymtab_language, objfile);
 		    }
 		  handle_psymbol_enumerators (objfile, fh, sh.st, sh.value);
@@ -3567,7 +3567,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
 	      /* Use this gdb symbol.  */
 	      add_psymbol_to_list (sym_name, strlen (sym_name), 1,
 				   VAR_DOMAIN, theclass, section,
-				   &objfile->static_psymbols,
+				   psymbol_placement::STATIC,
 				   sh.value, psymtab_language, objfile);
 	    skip:
 	      cur_sdx++;	/* Go to next file symbol.  */
@@ -3647,7 +3647,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
 	      add_psymbol_to_list (sym_name, strlen (sym_name), 1,
 				   VAR_DOMAIN, theclass,
 				   section,
-				   &objfile->global_psymbols,
+				   psymbol_placement::GLOBAL,
 				   svalue, psymtab_language, objfile);
 	    }
 	}
@@ -3808,7 +3808,7 @@ handle_psymbol_enumerators (struct objfile *objfile, FDR *fh, int stype,
          in psymtabs, just in symtabs.  */
       add_psymbol_to_list (name, strlen (name), 1,
 			   VAR_DOMAIN, LOC_CONST, -1,
-			   &objfile->static_psymbols, 0,
+			   psymbol_placement::STATIC, 0,
 			   psymtab_language, objfile);
       ext_sym += external_sym_size;
     }
diff --git a/gdb/psympriv.h b/gdb/psympriv.h
index dd495f4cbe..03d666740e 100644
--- a/gdb/psympriv.h
+++ b/gdb/psympriv.h
@@ -271,13 +271,22 @@ struct partial_symtab
   void *read_symtab_private;
 };
 
+/* Specify whether a partial psymbol should be allocated on the global
+   list or the static list.  */
+
+enum class psymbol_placement
+{
+  STATIC,
+  GLOBAL
+};
+
 /* Add any kind of symbol to a partial_symbol vector.  */
 
 extern void add_psymbol_to_list (const char *, int,
 				 int, domain_enum,
 				 enum address_class,
 				 short /* section */,
-				 std::vector<partial_symbol *> *,
+				 enum psymbol_placement,
 				 CORE_ADDR,
 				 enum language, struct objfile *);
 
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index c850404887..b157603396 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -1680,7 +1680,7 @@ add_psymbol_to_list (const char *name, int namelength, int copy_name,
 		     domain_enum domain,
 		     enum address_class theclass,
 		     short section,
-		     std::vector<partial_symbol *> *list,
+		     psymbol_placement where,
 		     CORE_ADDR coreaddr,
 		     enum language language, struct objfile *objfile)
 {
@@ -1693,11 +1693,14 @@ add_psymbol_to_list (const char *name, int namelength, int copy_name,
 				section, coreaddr, language, objfile, &added);
 
   /* Do not duplicate global partial symbols.  */
-  if (list == &objfile->global_psymbols
-      && !added)
+  if (where == psymbol_placement::GLOBAL && !added)
     return;
 
   /* Save pointer to partial symbol in psymtab, growing symtab if needed.  */
+  std::vector<partial_symbol *> *list
+    = (where == psymbol_placement::STATIC
+       ? &objfile->static_psymbols
+       : &objfile->global_psymbols);
   append_psymbol_to_list (list, psym, objfile);
 }
 
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index 6236874233..029f3546aa 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -2654,7 +2654,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
 		add_psymbol_to_list (namestring, p - namestring, 1,
 				     VAR_DOMAIN, LOC_STATIC,
 				     SECT_OFF_DATA (objfile),
-				     &objfile->static_psymbols,
+				     psymbol_placement::STATIC,
 				     symbol.n_value,
 				     psymtab_language, objfile);
 		continue;
@@ -2665,7 +2665,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
 		add_psymbol_to_list (namestring, p - namestring, 1,
 				     VAR_DOMAIN, LOC_STATIC,
 				     SECT_OFF_DATA (objfile),
-				     &objfile->global_psymbols,
+				     psymbol_placement::GLOBAL,
 				     symbol.n_value,
 				     psymtab_language, objfile);
 		continue;
@@ -2683,14 +2683,14 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
 		  {
 		    add_psymbol_to_list (namestring, p - namestring, 1,
 					 STRUCT_DOMAIN, LOC_TYPEDEF, -1,
-					 &objfile->static_psymbols,
+					 psymbol_placement::STATIC,
 					 0, psymtab_language, objfile);
 		    if (p[2] == 't')
 		      {
 			/* Also a typedef with the same name.  */
 			add_psymbol_to_list (namestring, p - namestring, 1,
 					     VAR_DOMAIN, LOC_TYPEDEF, -1,
-					     &objfile->static_psymbols,
+					     psymbol_placement::STATIC,
 					     0, psymtab_language, objfile);
 			p += 1;
 		      }
@@ -2702,7 +2702,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
 		  {
 		    add_psymbol_to_list (namestring, p - namestring, 1,
 					 VAR_DOMAIN, LOC_TYPEDEF, -1,
-					 &objfile->static_psymbols,
+					 psymbol_placement::STATIC,
 					 0, psymtab_language, objfile);
 		  }
 	      check_enum:
@@ -2764,7 +2764,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
 			   enum constants in psymtabs, just in symtabs.  */
 			add_psymbol_to_list (p, q - p, 1,
 					     VAR_DOMAIN, LOC_CONST, -1,
-					     &objfile->static_psymbols,
+					     psymbol_placement::STATIC,
 					     0, psymtab_language, objfile);
 			/* Point past the name.  */
 			p = q;
@@ -2782,7 +2782,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
 		/* Constant, e.g. from "const" in Pascal.  */
 		add_psymbol_to_list (namestring, p - namestring, 1,
 				     VAR_DOMAIN, LOC_CONST, -1,
-				     &objfile->static_psymbols,
+				     psymbol_placement::STATIC,
 				     0, psymtab_language, objfile);
 		continue;
 
@@ -2800,7 +2800,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
 		add_psymbol_to_list (namestring, p - namestring, 1,
 				     VAR_DOMAIN, LOC_BLOCK,
 				     SECT_OFF_TEXT (objfile),
-				     &objfile->static_psymbols,
+				     psymbol_placement::STATIC,
 				     symbol.n_value,
 				     psymtab_language, objfile);
 		continue;
@@ -2830,7 +2830,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
 		add_psymbol_to_list (namestring, p - namestring, 1,
 				     VAR_DOMAIN, LOC_BLOCK,
 				     SECT_OFF_TEXT (objfile),
-				     &objfile->global_psymbols,
+				     psymbol_placement::GLOBAL,
 				     symbol.n_value,
 				     psymtab_language, objfile);
 		continue;
-- 
2.17.2

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v2 03/12] Simplify calls to init_psymbol_list
  2018-11-25 19:20 [PATCH v2 00/12] Work toward making psymtabs reusable Tom Tromey
                   ` (4 preceding siblings ...)
  2018-11-25 19:20 ` [PATCH v2 12/12] Move psymtabs to their own obstack Tom Tromey
@ 2018-11-25 19:20 ` Tom Tromey
  2018-11-25 19:20 ` [PATCH v2 02/12] Change add_psymbol_to_list to use an enum Tom Tromey
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Tom Tromey @ 2018-11-25 19:20 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Existing callers to init_psymbol_list were checking to see if psymbols
had already been initialized.  It seemed better to me to do this check
directly in init_psymbol_list, simplifying the callers.

gdb/ChangeLog
2018-11-25  Tom Tromey  <tom@tromey.com>

	* xcoffread.c (xcoff_initial_scan): Unconditionally call
	init_psymbol_list.
	* psymtab.c (init_psymbol_list): Do nothing if already called.
	* psympriv.h (init_psymbol_list): Add comment.
	* dwarf2read.c (dwarf2_build_psymtabs): Unconditionally call
	init_psymbol_list.
	* dbxread.c (dbx_symfile_read): Unconditionally call
	init_psymbol_list.
---
 gdb/ChangeLog    | 11 +++++++++++
 gdb/dbxread.c    |  4 +---
 gdb/dwarf2read.c |  4 +---
 gdb/psympriv.h   |  6 +++++-
 gdb/psymtab.c    | 21 +++++++++++----------
 gdb/xcoffread.c  | 13 +++++--------
 6 files changed, 34 insertions(+), 25 deletions(-)

diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index abcd2f9048..7130bb13b4 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -536,9 +536,7 @@ dbx_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
     perror_with_name (objfile_name (objfile));
 
   /* Size the symbol table.  */
-  if (objfile->global_psymbols.capacity () == 0
-      && objfile->static_psymbols.capacity () == 0)
-    init_psymbol_list (objfile, DBX_SYMCOUNT (objfile));
+  init_psymbol_list (objfile, DBX_SYMCOUNT (objfile));
 
   symbol_size = DBX_SYMBOL_SIZE (objfile);
   symbol_table_offset = DBX_SYMTAB_OFFSET (objfile);
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 355015865d..9fceb9e7cc 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -6293,9 +6293,7 @@ dwarf2_build_psymtabs (struct objfile *objfile)
   struct dwarf2_per_objfile *dwarf2_per_objfile
     = get_dwarf2_per_objfile (objfile);
 
-  if (objfile->global_psymbols.capacity () == 0
-      && objfile->static_psymbols.capacity () == 0)
-    init_psymbol_list (objfile, 1024);
+  init_psymbol_list (objfile, 1024);
 
   TRY
     {
diff --git a/gdb/psympriv.h b/gdb/psympriv.h
index 03d666740e..b28c946a87 100644
--- a/gdb/psympriv.h
+++ b/gdb/psympriv.h
@@ -290,7 +290,11 @@ extern void add_psymbol_to_list (const char *, int,
 				 CORE_ADDR,
 				 enum language, struct objfile *);
 
-extern void init_psymbol_list (struct objfile *, int);
+/* Initialize storage for partial symbols.  If partial symbol storage
+   has already been initialized, this does nothing.  TOTAL_SYMBOLS is
+   an estimate of how many symbols there will be.  */
+
+extern void init_psymbol_list (struct objfile *objfile, int total_symbols);
 
 extern struct partial_symtab *start_psymtab_common (struct objfile *,
 						    const char *, CORE_ADDR);
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index b157603396..31c0d4d6a2 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -1704,20 +1704,21 @@ add_psymbol_to_list (const char *name, int namelength, int copy_name,
   append_psymbol_to_list (list, psym, objfile);
 }
 
-/* Initialize storage for partial symbols.  */
+/* See psympriv.h.  */
 
 void
 init_psymbol_list (struct objfile *objfile, int total_symbols)
 {
-  /* Free any previously allocated psymbol lists.  */
-  objfile->global_psymbols.clear ();
-  objfile->static_psymbols.clear ();
-
-  /* Current best guess is that approximately a twentieth
-     of the total symbols (in a debugging file) are global or static
-     oriented symbols, then multiply that by slop factor of two.  */
-  objfile->global_psymbols.reserve (total_symbols / 10);
-  objfile->static_psymbols.reserve (total_symbols / 10);
+  if (objfile->global_psymbols.capacity () == 0
+      && objfile->static_psymbols.capacity () == 0)
+    {
+      /* Current best guess is that approximately a twentieth of the
+	 total symbols (in a debugging file) are global or static
+	 oriented symbols, then multiply that by slop factor of
+	 two.  */
+      objfile->global_psymbols.reserve (total_symbols / 10);
+      objfile->static_psymbols.reserve (total_symbols / 10);
+    }
 }
 
 /* See psympriv.h.  */
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index 029f3546aa..daff10db43 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -2991,14 +2991,11 @@ xcoff_initial_scan (struct objfile *objfile, symfile_add_flags symfile_flags)
   if (val != size)
     perror_with_name (_("reading symbol table"));
 
-  /* If we are reinitializing, or if we have never loaded syms yet, init.  */
-  if (objfile->global_psymbols.capacity () == 0
-      && objfile->static_psymbols.capacity () == 0)
-    /* I'm not sure how how good num_symbols is; the rule of thumb in
-       init_psymbol_list was developed for a.out.  On the one hand,
-       num_symbols includes auxents.  On the other hand, it doesn't
-       include N_SLINE.  */
-    init_psymbol_list (objfile, num_symbols);
+  /* I'm not sure how how good num_symbols is; the rule of thumb in
+     init_psymbol_list was developed for a.out.  On the one hand,
+     num_symbols includes auxents.  On the other hand, it doesn't
+     include N_SLINE.  */
+  init_psymbol_list (objfile, num_symbols);
 
   scoped_free_pendings free_pending;
   minimal_symbol_reader reader (objfile);
-- 
2.17.2

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v2 09/12] Move more allocations to psymtab obstack
  2018-11-25 19:20 [PATCH v2 00/12] Work toward making psymtabs reusable Tom Tromey
  2018-11-25 19:20 ` [PATCH v2 11/12] Make psymtab_storage::free_psymtabs private Tom Tromey
@ 2018-11-25 19:20 ` Tom Tromey
  2018-11-25 19:20 ` [PATCH v2 04/12] Change create_demangled_names_hash to take an objfile_per_bfd_storage Tom Tromey
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Tom Tromey @ 2018-11-25 19:20 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This moves a couple more psymtab-related allocations to the psymtab
obstack.

gdb/ChangeLog
2018-11-25  Tom Tromey  <tom@tromey.com>

	* psymtab.c (add_psymbol_to_bcache): Pass psymtab obstack to
	PSYMBOL_SET_LANGUAGE.
	(allocate_psymtab): Allocate psymtab on the psymtab obstack.
---
 gdb/ChangeLog | 6 ++++++
 gdb/psymtab.c | 5 +++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index d4152bdba4..bd957e7b62 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -1680,7 +1680,8 @@ add_psymbol_to_bcache (const char *name, int namelength, int copy_name,
 
   memset (&psymbol.language_specific, 0, sizeof (psymbol.language_specific));
   psymbol.ada_mangled = 0;
-  symbol_set_language (&psymbol, language, &objfile->objfile_obstack);
+  symbol_set_language (&psymbol, language,
+		       objfile->partial_symtabs->obstack ());
   symbol_set_names (&psymbol, name, namelength, copy_name, objfile->per_bfd);
 
   /* Stash the partial symbol away in the cache.  */
@@ -1765,7 +1766,7 @@ allocate_psymtab (const char *filename, struct objfile *objfile)
       objfile->partial_symtabs->free_psymtabs = psymtab->next;
     }
   else
-    psymtab = XOBNEW (&objfile->objfile_obstack, partial_symtab);
+    psymtab = XOBNEW (objfile->partial_symtabs->obstack (), partial_symtab);
 
   memset (psymtab, 0, sizeof (struct partial_symtab));
   psymtab->filename
-- 
2.17.2

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v2 05/12] Change symbol_set_names to take an objfile_per_bfd_storage
  2018-11-25 19:20 [PATCH v2 00/12] Work toward making psymtabs reusable Tom Tromey
                   ` (6 preceding siblings ...)
  2018-11-25 19:20 ` [PATCH v2 02/12] Change add_psymbol_to_list to use an enum Tom Tromey
@ 2018-11-25 19:20 ` Tom Tromey
  2018-11-25 19:20 ` [PATCH v2 10/12] Add psymtab_storage::allocate_dependencies Tom Tromey
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Tom Tromey @ 2018-11-25 19:20 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes symbol_set_names to take an objfile_per_bfd_storage
argument, and updates the users.  It also changes PSYMBOL_SET_NAMES to
take this argument directly; I feel this clarifies the storage
location of objects created in psymtab.c.

gdb/ChangeLog
2018-11-25  Tom Tromey  <tom@tromey.com>

	* symtab.h (SYMBOL_SET_NAMES): Update.
	(symbol_set_names): Update.
	(MSYMBOL_SET_NAMES): Update.
	* symtab.c (symbol_set_names): Change argument to be an
	objfile_per_bfd_storage.
	* psymtab.c (add_psymbol_to_bcache): Update.
	* psympriv.h (PSYMBOL_SET_NAMES): Take per_bfd argument.
---
 gdb/ChangeLog | 10 ++++++++++
 gdb/psymtab.c |  2 +-
 gdb/symtab.c  |  3 +--
 gdb/symtab.h  |  8 +++++---
 4 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 31c0d4d6a2..ffe99004d4 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -1652,7 +1652,7 @@ add_psymbol_to_bcache (const char *name, int namelength, int copy_name,
   memset (&psymbol.language_specific, 0, sizeof (psymbol.language_specific));
   psymbol.ada_mangled = 0;
   symbol_set_language (&psymbol, language, &objfile->objfile_obstack);
-  symbol_set_names (&psymbol, name, namelength, copy_name, objfile);
+  symbol_set_names (&psymbol, name, namelength, copy_name, objfile->per_bfd);
 
   /* Stash the partial symbol away in the cache.  */
   return psymbol_bcache_full (&psymbol, objfile->psymbol_cache, added);
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 2911e5c83c..55a79640d6 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -774,13 +774,12 @@ symbol_find_demangled_name (struct general_symbol_info *gsymbol,
 void
 symbol_set_names (struct general_symbol_info *gsymbol,
 		  const char *linkage_name, int len, int copy_name,
-		  struct objfile *objfile)
+		  struct objfile_per_bfd_storage *per_bfd)
 {
   struct demangled_name_entry **slot;
   /* A 0-terminated copy of the linkage name.  */
   const char *linkage_name_copy;
   struct demangled_name_entry entry;
-  struct objfile_per_bfd_storage *per_bfd = objfile->per_bfd;
 
   if (gsymbol->language == language_ada)
     {
diff --git a/gdb/symtab.h b/gdb/symtab.h
index e0b870135b..41004f2760 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -493,10 +493,11 @@ extern void symbol_set_language (struct general_symbol_info *symbol,
 /* Set the linkage and natural names of a symbol, by demangling
    the linkage name.  */
 #define SYMBOL_SET_NAMES(symbol,linkage_name,len,copy_name,objfile)	\
-  symbol_set_names (&(symbol)->ginfo, linkage_name, len, copy_name, objfile)
+  symbol_set_names (&(symbol)->ginfo, linkage_name, len, copy_name, \
+		    (objfile)->per_bfd)
 extern void symbol_set_names (struct general_symbol_info *symbol,
 			      const char *linkage_name, int len, int copy_name,
-			      struct objfile *objfile);
+			      struct objfile_per_bfd_storage *per_bfd);
 
 /* Now come lots of name accessor macros.  Short version as to when to
    use which: Use SYMBOL_NATURAL_NAME to refer to the name of the
@@ -733,7 +734,8 @@ struct minimal_symbol
 #define MSYMBOL_SEARCH_NAME(symbol)					 \
    (symbol_search_name (&(symbol)->mginfo))
 #define MSYMBOL_SET_NAMES(symbol,linkage_name,len,copy_name,objfile)	\
-  symbol_set_names (&(symbol)->mginfo, linkage_name, len, copy_name, objfile)
+  symbol_set_names (&(symbol)->mginfo, linkage_name, len, copy_name, \
+		    (objfile)->per_bfd)
 
 #include "minsyms.h"
 
-- 
2.17.2

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v2 01/12] Remove parameters from start_psymtab_common
  2018-11-25 19:20 [PATCH v2 00/12] Work toward making psymtabs reusable Tom Tromey
                   ` (2 preceding siblings ...)
  2018-11-25 19:20 ` [PATCH v2 04/12] Change create_demangled_names_hash to take an objfile_per_bfd_storage Tom Tromey
@ 2018-11-25 19:20 ` Tom Tromey
  2018-11-25 19:20 ` [PATCH v2 12/12] Move psymtabs to their own obstack Tom Tromey
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Tom Tromey @ 2018-11-25 19:20 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

start_psymtab_common takes references to the global_psymbols and
static_psymbols vectors, but it also has an objfile parameter.  This
is redundant, so this patch simplifies the function by removing those
reference parameters.

gdb/ChangeLog
2018-11-25  Tom Tromey  <tom@tromey.com>

	* xcoffread.c (xcoff_start_psymtab): Remove global_psymbols and
	static_psymbols parameters.
	(scan_xcoff_symtab): Update.
	* psymtab.c (start_psymtab_common): Remove global_psymbols and
	static_psymbols parameters.
	* psympriv.h (start_psymtab_common): Update.
	* mdebugread.c (parse_partial_symbols): Update.
	* dwarf2read.c (create_partial_symtab): Update.
	* dbxread.c (read_dbx_symtab): Update.
	(start_psymtab): Remove global_psymbols and static_psymbols
	parameters.
---
 gdb/ChangeLog    | 14 ++++++++++++++
 gdb/dbxread.c    | 14 ++++----------
 gdb/dwarf2read.c |  4 +---
 gdb/mdebugread.c |  4 +---
 gdb/psympriv.h   |  4 +---
 gdb/psymtab.c    |  8 +++-----
 gdb/xcoffread.c  | 15 ++++-----------
 7 files changed, 28 insertions(+), 35 deletions(-)

diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index 21250bcd2f..3cf140381f 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -298,9 +298,7 @@ static void add_old_header_file (const char *, int);
 static void add_this_object_header_file (int);
 
 static struct partial_symtab *start_psymtab (struct objfile *, const char *,
-					     CORE_ADDR, int,
-					     std::vector<partial_symbol *> &,
-					     std::vector<partial_symbol *> &);
+					     CORE_ADDR, int);
 
 /* Free up old header file tables.  */
 
@@ -1302,9 +1300,7 @@ read_dbx_symtab (minimal_symbol_reader &reader, struct objfile *objfile)
 	      {
 		pst = start_psymtab (objfile,
 				     namestring, valu,
-				     first_so_symnum * symbol_size,
-				     objfile->global_psymbols,
-				     objfile->static_psymbols);
+				     first_so_symnum * symbol_size);
 		pst->dirname = dirname_nso;
 		dirname_nso = NULL;
 	      }
@@ -1916,12 +1912,10 @@ read_dbx_symtab (minimal_symbol_reader &reader, struct objfile *objfile)
 
 static struct partial_symtab *
 start_psymtab (struct objfile *objfile, const char *filename, CORE_ADDR textlow,
-	       int ldsymoff, std::vector<partial_symbol *> &global_psymbols,
-	       std::vector<partial_symbol *> &static_psymbols)
+	       int ldsymoff)
 {
   struct partial_symtab *result =
-    start_psymtab_common (objfile, filename, textlow,
-			  global_psymbols, static_psymbols);
+    start_psymtab_common (objfile, filename, textlow);
 
   result->read_symtab_private =
     XOBNEW (&objfile->objfile_obstack, struct symloc);
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index fa7908410e..f316250f41 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -7923,9 +7923,7 @@ create_partial_symtab (struct dwarf2_per_cu_data *per_cu, const char *name)
   struct objfile *objfile = per_cu->dwarf2_per_objfile->objfile;
   struct partial_symtab *pst;
 
-  pst = start_psymtab_common (objfile, name, 0,
-			      objfile->global_psymbols,
-			      objfile->static_psymbols);
+  pst = start_psymtab_common (objfile, name, 0);
 
   pst->psymtabs_addrmap_supported = 1;
 
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index 26687f6c8d..ba8906a1af 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -2619,9 +2619,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
 	textlow = 0;
       pst = start_psymtab_common (objfile,
 				  fdr_name (fh),
-				  textlow,
-				  objfile->global_psymbols,
-				  objfile->static_psymbols);
+				  textlow);
       pst->read_symtab_private = XOBNEW (&objfile->objfile_obstack, symloc);
       memset (pst->read_symtab_private, 0, sizeof (struct symloc));
 
diff --git a/gdb/psympriv.h b/gdb/psympriv.h
index b66250820d..dd495f4cbe 100644
--- a/gdb/psympriv.h
+++ b/gdb/psympriv.h
@@ -284,9 +284,7 @@ extern void add_psymbol_to_list (const char *, int,
 extern void init_psymbol_list (struct objfile *, int);
 
 extern struct partial_symtab *start_psymtab_common (struct objfile *,
-						    const char *, CORE_ADDR,
-						    std::vector<partial_symbol *> &,
-						    std::vector<partial_symbol *> &);
+						    const char *, CORE_ADDR);
 
 extern void end_psymtab_common (struct objfile *, struct partial_symtab *);
 
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 462ddbd878..c850404887 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -1511,17 +1511,15 @@ sort_pst_symbols (struct objfile *objfile, struct partial_symtab *pst)
 struct partial_symtab *
 start_psymtab_common (struct objfile *objfile,
 		      const char *filename,
-		      CORE_ADDR textlow,
-		      std::vector<partial_symbol *> &global_psymbols,
-		      std::vector<partial_symbol *> &static_psymbols)
+		      CORE_ADDR textlow)
 {
   struct partial_symtab *psymtab;
 
   psymtab = allocate_psymtab (filename, objfile);
   psymtab->set_text_low (textlow);
   psymtab->set_text_high (psymtab->raw_text_low ()); /* default */
-  psymtab->globals_offset = global_psymbols.size ();
-  psymtab->statics_offset = static_psymbols.size ();
+  psymtab->globals_offset = objfile->global_psymbols.size ();
+  psymtab->statics_offset = objfile->static_psymbols.size ();
   return psymtab;
 }
 
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index 7330672e17..6236874233 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -2026,16 +2026,13 @@ static unsigned int first_fun_line_offset;
 
 static struct partial_symtab *
 xcoff_start_psymtab (struct objfile *objfile,
-		     const char *filename, int first_symnum,
-		     std::vector<partial_symbol *> &global_psymbols,
-		     std::vector<partial_symbol *> &static_psymbols)
+		     const char *filename, int first_symnum)
 {
   struct partial_symtab *result =
     start_psymtab_common (objfile,
 			  filename,
 			  /* We fill in textlow later.  */
-			  0,
-			  global_psymbols, static_psymbols);
+			  0);
 
   result->read_symtab_private =
     XOBNEW (&objfile->objfile_obstack, struct symloc);
@@ -2317,9 +2314,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
 			    pst = xcoff_start_psymtab
 			      (objfile,
 			       filestring,
-			       symnum_before,
-			       objfile->global_psymbols,
-			       objfile->static_psymbols);
+			       symnum_before);
 			  }
 		      }
 		    /* Activate the misc_func_recorded mechanism for
@@ -2501,9 +2496,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
 
 	    pst = xcoff_start_psymtab (objfile,
 				       filestring,
-				       symnum_before,
-				       objfile->global_psymbols,
-				       objfile->static_psymbols);
+				       symnum_before);
 	    last_csect_name = NULL;
 	  }
 	  break;
-- 
2.17.2

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v2 00/12] Work toward making psymtabs reusable
@ 2018-11-25 19:20 Tom Tromey
  2018-11-25 19:20 ` [PATCH v2 11/12] Make psymtab_storage::free_psymtabs private Tom Tromey
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: Tom Tromey @ 2018-11-25 19:20 UTC (permalink / raw)
  To: gdb-patches

This is version 2 of my series to improve psymtabs a bit.  In
particular this moves most psymtab allocation to a special obstack, to
make it simpler to reason about.  Mostly this is preparation for
(hopeful) future patches to make psymtabs independent of the objfile.

Version 1 was here:

https://sourceware.org/ml/gdb-patches/2018-05/msg00276.html

... with reviews mostly happening in July.

This addresses all the review comments.  I've also dropped the patch
that removed the psymtab->symtab backlink and updated various comments
accordingly.  That patch caused a small performance regression, and in
the absence of supporting comments it seemed simpler to remove it.  I
may make another push for it later, when it's more needed.

Regression tested on the buildbot.

Tom


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v2 06/12] Introduce class psymtab_storage
  2018-11-25 19:20 [PATCH v2 00/12] Work toward making psymtabs reusable Tom Tromey
                   ` (10 preceding siblings ...)
  2018-11-25 19:20 ` [PATCH v2 08/12] Allocate the address map on the psymtab obstack Tom Tromey
@ 2018-11-25 19:22 ` Tom Tromey
  2019-01-10 14:09 ` [PATCH v2 00/12] Work toward making psymtabs reusable Tom Tromey
  12 siblings, 0 replies; 14+ messages in thread
From: Tom Tromey @ 2018-11-25 19:22 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This introduces a new psymtab_storage class, which holds all
psymbol-related objects that are independent of the objfile.  (This
latter contraint explains why psymbol_map was not moved; though this
could still be done with some work.)

This patch does not yet change where psymtab allocation is done --
that comes later.  This just wraps everything in a single object to
make further transformations simpler.

Note that a shared_ptr is used to link from the objfile to the
psymtab_storage object.  The end goal here is to allow a given symbol
reader to simply attach to the psymtab_storage object to the BFD, then
reuse it in later invocations; shared_ptr makes this simple to reason
about.

gdb/ChangeLog
2018-11-25  Tom Tromey  <tom@tromey.com>

	* symmisc.c (print_symbol_bcache_statistics): Update.
	(print_objfile_statistics): Update.
	* symfile.c (reread_symbols): Update.
	* psymtab.h (class psymtab_storage): New.
	* psymtab.c (psymtab_storage): New constructor.
	(~psymtab_storage): New destructor.
	(require_partial_symbols): Update.
	(ALL_OBJFILE_PSYMTABS_REQUIRED): Rewrite.
	(find_pc_sect_psymtab, find_pc_sect_psymbol)
	(match_partial_symbol, lookup_partial_symbol, dump_psymtab)
	(psym_dump, recursively_search_psymtabs, psym_has_symbols)
	(psym_find_compunit_symtab_by_address, sort_pst_symbols)
	(start_psymtab_common, end_psymtab_common)
	(add_psymbol_to_bcache, add_psymbol_to_list, init_psymbol_list)
	(allocate_psymtab): Update.
	(psymtab_storage::discard_psymtab): Rename from discard_psymtab.
	Update.
	(dump_psymtab_addrmap, maintenance_print_psymbols)
	(maintenance_check_psymtabs): Update.
	* psympriv.h (discard_psymtab): Now inline.
	(psymtab_discarder::psymtab_discarder): Update.
	(psymtab_discarder::~psymtab_discarder): Update.
	(ALL_OBJFILE_PSYMTABS): Rewrite.
	* objfiles.h (struct objfile) <psymtabs, psymtabs_addrmap,
	free_psymtabs, psymbol_cache, global_psymbols, static_psymbols>:
	Remove fields.
	<partial_symtabs>: New field.
	* objfiles.c (objfile::objfile): Initialize partial_symtabs, not
	psymbol_cache.
	(objfile::~objfile): Don't destroy psymbol_cache.
	* mdebugread.c (parse_partial_symbols): Update.
	* dwarf2read.c (create_addrmap_from_index)
	(create_addrmap_from_aranges, dw2_find_pc_sect_compunit_symtab)
	(process_psymtab_comp_unit_reader, dwarf2_build_psymtabs_hard)
	(add_partial_subprogram, dwarf2_ranges_read): Update.
	* dwarf-index-write.c (write_address_map)
	(write_one_signatured_type, recursively_write_psymbols)
	(class debug_names, class debug_names, write_psymtabs_to_index):
	Update.
---
 gdb/ChangeLog           |  42 +++++++++++
 gdb/dwarf-index-write.c |  27 +++++---
 gdb/dwarf2read.c        |  30 ++++----
 gdb/mdebugread.c        |  11 +--
 gdb/objfiles.c          |   5 +-
 gdb/objfiles.h          |  29 +-------
 gdb/psympriv.h          |  17 +++--
 gdb/psymtab.c           | 150 ++++++++++++++++++++++++----------------
 gdb/psymtab.h           |  63 +++++++++++++++++
 gdb/symfile.c           |  14 ++--
 gdb/symmisc.c           |  12 ++--
 11 files changed, 265 insertions(+), 135 deletions(-)

diff --git a/gdb/dwarf-index-write.c b/gdb/dwarf-index-write.c
index 8a4c1c7ea4..56ef355b03 100644
--- a/gdb/dwarf-index-write.c
+++ b/gdb/dwarf-index-write.c
@@ -474,8 +474,8 @@ write_address_map (struct objfile *objfile, data_buf &addr_vec,
   addrmap_index_data.objfile = objfile;
   addrmap_index_data.previous_valid = 0;
 
-  addrmap_foreach (objfile->psymtabs_addrmap, add_address_entry_worker,
-		   &addrmap_index_data);
+  addrmap_foreach (objfile->partial_symtabs->psymtabs_addrmap,
+		   add_address_entry_worker, &addrmap_index_data);
 
   /* It's highly unlikely the last entry (end address = 0xff...ff)
      is valid, but we should still handle it.
@@ -582,13 +582,13 @@ write_one_signatured_type (void **slot, void *d)
 
   write_psymbols (info->symtab,
 		  info->psyms_seen,
-		  (info->objfile->global_psymbols.data ()
+		  (info->objfile->partial_symtabs->global_psymbols.data ()
 		   + psymtab->globals_offset),
 		  psymtab->n_global_syms, info->cu_index,
 		  0);
   write_psymbols (info->symtab,
 		  info->psyms_seen,
-		  (info->objfile->static_psymbols.data ()
+		  (info->objfile->partial_symtabs->static_psymbols.data ()
 		   + psymtab->statics_offset),
 		  psymtab->n_static_syms, info->cu_index,
 		  1);
@@ -639,12 +639,14 @@ recursively_write_psymbols (struct objfile *objfile,
 
   write_psymbols (symtab,
 		  psyms_seen,
-		  objfile->global_psymbols.data () + psymtab->globals_offset,
+		  (objfile->partial_symtabs->global_psymbols.data ()
+		   + psymtab->globals_offset),
 		  psymtab->n_global_syms, cu_index,
 		  0);
   write_psymbols (symtab,
 		  psyms_seen,
-		  objfile->static_psymbols.data () + psymtab->statics_offset,
+		  (objfile->partial_symtabs->static_psymbols.data ()
+		   + psymtab->statics_offset),
 		  psymtab->n_static_syms, cu_index,
 		  1);
 }
@@ -835,10 +837,12 @@ public:
 				    psyms_seen, cu_index);
 
     write_psymbols (psyms_seen,
-		    objfile->global_psymbols.data () + psymtab->globals_offset,
+		    (objfile->partial_symtabs->global_psymbols.data ()
+		     + psymtab->globals_offset),
 		    psymtab->n_global_syms, cu_index, false, unit_kind::cu);
     write_psymbols (psyms_seen,
-		    objfile->static_psymbols.data () + psymtab->statics_offset,
+		    (objfile->partial_symtabs->static_psymbols.data ()
+		     + psymtab->statics_offset),
 		    psymtab->n_static_syms, cu_index, true, unit_kind::cu);
   }
 
@@ -1195,12 +1199,12 @@ private:
     struct partial_symtab *psymtab = entry->per_cu.v.psymtab;
 
     write_psymbols (info->psyms_seen,
-		    (info->objfile->global_psymbols.data ()
+		    (info->objfile->partial_symtabs->global_psymbols.data ()
 		     + psymtab->globals_offset),
 		    psymtab->n_global_syms, info->cu_index, false,
 		    unit_kind::tu);
     write_psymbols (info->psyms_seen,
-		    (info->objfile->static_psymbols.data ()
+		    (info->objfile->partial_symtabs->static_psymbols.data ()
 		     + psymtab->statics_offset),
 		    psymtab->n_static_syms, info->cu_index, true,
 		    unit_kind::tu);
@@ -1554,7 +1558,8 @@ write_psymtabs_to_index (struct dwarf2_per_objfile *dwarf2_per_objfile,
   if (VEC_length (dwarf2_section_info_def, dwarf2_per_objfile->types) > 1)
     error (_("Cannot make an index when the file has multiple .debug_types sections"));
 
-  if (!objfile->psymtabs || !objfile->psymtabs_addrmap)
+  if (!objfile->partial_symtabs->psymtabs
+      || !objfile->partial_symtabs->psymtabs_addrmap)
     return;
 
   struct stat st;
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 9fceb9e7cc..26fc47b669 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -3190,8 +3190,8 @@ create_addrmap_from_index (struct dwarf2_per_objfile *dwarf2_per_objfile,
 			 dwarf2_per_objfile->get_cu (cu_index));
     }
 
-  objfile->psymtabs_addrmap = addrmap_create_fixed (mutable_map,
-						    &objfile->objfile_obstack);
+  objfile->partial_symtabs->psymtabs_addrmap
+    = addrmap_create_fixed (mutable_map, &objfile->objfile_obstack);
 }
 
 /* Read the address map data from DWARF-5 .debug_aranges, and use it to
@@ -3351,8 +3351,8 @@ create_addrmap_from_aranges (struct dwarf2_per_objfile *dwarf2_per_objfile,
 	}
     }
 
-  objfile->psymtabs_addrmap = addrmap_create_fixed (mutable_map,
-						    &objfile->objfile_obstack);
+  objfile->partial_symtabs->psymtabs_addrmap
+    = addrmap_create_fixed (mutable_map, &objfile->objfile_obstack);
 }
 
 /* Find a slot in the mapped index INDEX for the object named NAME.
@@ -5245,13 +5245,13 @@ dw2_find_pc_sect_compunit_symtab (struct objfile *objfile,
   struct dwarf2_per_cu_data *data;
   struct compunit_symtab *result;
 
-  if (!objfile->psymtabs_addrmap)
+  if (!objfile->partial_symtabs->psymtabs_addrmap)
     return NULL;
 
   CORE_ADDR baseaddr = ANOFFSET (objfile->section_offsets,
 				 SECT_OFF_TEXT (objfile));
-  data = (struct dwarf2_per_cu_data *) addrmap_find (objfile->psymtabs_addrmap,
-						     pc - baseaddr);
+  data = (struct dwarf2_per_cu_data *) addrmap_find
+    (objfile->partial_symtabs->psymtabs_addrmap, pc - baseaddr);
   if (!data)
     return NULL;
 
@@ -8004,7 +8004,8 @@ process_psymtab_comp_unit_reader (const struct die_reader_specs *reader,
 	   - baseaddr - 1);
       /* Store the contiguous range if it is not empty; it can be
 	 empty for CUs with no code.  */
-      addrmap_set_empty (objfile->psymtabs_addrmap, low, high, pst);
+      addrmap_set_empty (objfile->partial_symtabs->psymtabs_addrmap,
+			 low, high, pst);
     }
 
   /* Check if comp unit has_children.
@@ -8461,7 +8462,7 @@ dwarf2_build_psymtabs_hard (struct dwarf2_per_objfile *dwarf2_per_objfile)
   auto_obstack temp_obstack;
 
   scoped_restore save_psymtabs_addrmap
-    = make_scoped_restore (&objfile->psymtabs_addrmap,
+    = make_scoped_restore (&objfile->partial_symtabs->psymtabs_addrmap,
 			   addrmap_create_mutable (&temp_obstack));
 
   for (dwarf2_per_cu_data *per_cu : dwarf2_per_objfile->all_comp_units)
@@ -8482,8 +8483,9 @@ dwarf2_build_psymtabs_hard (struct dwarf2_per_objfile *dwarf2_per_objfile)
 
   set_partial_user (dwarf2_per_objfile);
 
-  objfile->psymtabs_addrmap = addrmap_create_fixed (objfile->psymtabs_addrmap,
-						    &objfile->objfile_obstack);
+  objfile->partial_symtabs->psymtabs_addrmap
+    = addrmap_create_fixed (objfile->partial_symtabs->psymtabs_addrmap,
+			    &objfile->objfile_obstack);
   /* At this point we want to keep the address map.  */
   save_psymtabs_addrmap.release ();
 
@@ -9107,7 +9109,7 @@ add_partial_subprogram (struct partial_die_info *pdi,
 		= (gdbarch_adjust_dwarf2_addr (gdbarch,
 					       pdi->highpc + baseaddr)
 		   - baseaddr);
-	      addrmap_set_empty (objfile->psymtabs_addrmap,
+	      addrmap_set_empty (objfile->partial_symtabs->psymtabs_addrmap,
 				 this_lowpc, this_highpc - 1,
 				 cu->per_cu->v.psymtab);
 	    }
@@ -14597,8 +14599,8 @@ dwarf2_ranges_read (unsigned offset, CORE_ADDR *low_return,
 	  highpc = (gdbarch_adjust_dwarf2_addr (gdbarch,
 						range_end + baseaddr)
 		    - baseaddr);
-	  addrmap_set_empty (objfile->psymtabs_addrmap, lowpc, highpc - 1,
-			     ranges_pst);
+	  addrmap_set_empty (objfile->partial_symtabs->psymtabs_addrmap,
+			     lowpc, highpc - 1, ranges_pst);
 	}
 
       /* FIXME: This is recording everything as a low-high
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index e93f1edc08..5cc944fefe 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -3739,11 +3739,12 @@ parse_partial_symbols (minimal_symbol_reader &reader,
 
   /* Remove the dummy psymtab created for -O3 images above, if it is
      still empty, to enable the detection of stripped executables.  */
-  if (objfile->psymtabs->next == NULL
-      && objfile->psymtabs->number_of_dependencies == 0
-      && objfile->psymtabs->n_global_syms == 0
-      && objfile->psymtabs->n_static_syms == 0)
-    objfile->psymtabs = NULL;
+  pst = objfile->partial_symtabs->psymtabs;
+  if (pst->next == NULL
+      && pst->number_of_dependencies == 0
+      && pst->n_global_syms == 0
+      && pst->n_static_syms == 0)
+    objfile->partial_symtabs->psymtabs = NULL;
 }
 
 /* If the current psymbol has an enumerated type, we need to add
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index a9b8fa7c58..b1fa36609b 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -369,8 +369,8 @@ build_objfile_section_table (struct objfile *objfile)
 objfile::objfile (bfd *abfd, const char *name, objfile_flags flags_)
   : flags (flags_),
     pspace (current_program_space),
-    obfd (abfd),
-    psymbol_cache (psymbol_bcache_init ())
+    partial_symtabs (new psymtab_storage (this)),
+    obfd (abfd)
 {
   const char *expanded_name;
 
@@ -713,7 +713,6 @@ objfile::~objfile ()
   }
 
   /* Free the obstacks for non-reusable objfiles.  */
-  psymbol_bcache_free (psymbol_cache);
   obstack_free (&objfile_obstack, 0);
 
   /* Rebuild section map next time we need it.  */
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index 7a9087b015..a3ec3884cf 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -27,6 +27,7 @@
 #include "progspace.h"
 #include "registry.h"
 #include "gdb_bfd.h"
+#include "psymtab.h"
 #include <vector>
 
 struct bcache;
@@ -319,22 +320,9 @@ struct objfile
 
   struct compunit_symtab *compunit_symtabs = nullptr;
 
-  /* Each objfile points to a linked list of partial symtabs derived from
-     this file, one partial symtab structure for each compilation unit
-     (source file).  */
+  /* The partial symbol tables.  */
 
-  struct partial_symtab *psymtabs = nullptr;
-
-  /* Map addresses to the entries of PSYMTABS.  It would be more efficient to
-     have a map per the whole process but ADDRMAP cannot selectively remove
-     its items during FREE_OBJFILE.  This mapping is already present even for
-     PARTIAL_SYMTABs which still have no corresponding full SYMTABs read.  */
-
-  struct addrmap *psymtabs_addrmap = nullptr;
-
-  /* List of freed partial symtabs, available for re-use.  */
-
-  struct partial_symtab *free_psymtabs = nullptr;
+  std::shared_ptr<psymtab_storage> partial_symtabs;
 
   /* The object file's BFD.  Can be null if the objfile contains only
      minimal symbols, e.g. the run time common symbols for SunOS4.  */
@@ -356,22 +344,11 @@ struct objfile
 
   struct obstack objfile_obstack {};
 
-  /* A byte cache where we can stash arbitrary "chunks" of bytes that
-     will not change.  */
-
-  struct psymbol_bcache *psymbol_cache;
-
   /* Map symbol addresses to the partial symtab that defines the
      object at that address.  */
 
   std::vector<std::pair<CORE_ADDR, partial_symtab *>> psymbol_map;
 
-  /* Vectors of all partial symbols read in from file.  The actual data
-     is stored in the objfile_obstack.  */
-
-  std::vector<partial_symbol *> global_psymbols;
-  std::vector<partial_symbol *> static_psymbols;
-
   /* Structure which keeps track of functions that manipulate objfile's
      of the same type as this objfile.  I.e. the function to read partial
      symbols for example.  Note that this structure is in statically
diff --git a/gdb/psympriv.h b/gdb/psympriv.h
index b28c946a87..f7a5de6093 100644
--- a/gdb/psympriv.h
+++ b/gdb/psympriv.h
@@ -311,7 +311,11 @@ extern struct partial_symtab *allocate_psymtab (const char *filename,
 						struct objfile *objfile)
   ATTRIBUTE_NONNULL (1);
 
-extern void discard_psymtab (struct objfile *, struct partial_symtab *);
+static inline void
+discard_psymtab (struct objfile *objfile, struct partial_symtab *pst)
+{
+  objfile->partial_symtabs->discard_psymtab (pst);
+}
 
 /* Used when recording partial symbol tables.  On destruction,
    discards any partial symbol tables that have been built.  However,
@@ -322,15 +326,14 @@ class psymtab_discarder
 
   psymtab_discarder (struct objfile *objfile)
     : m_objfile (objfile),
-      m_psymtab (objfile->psymtabs)
+      m_psymtab (objfile->partial_symtabs->psymtabs)
   {
   }
 
   ~psymtab_discarder ()
   {
     if (m_objfile != NULL)
-      while (m_objfile->psymtabs != m_psymtab)
-	discard_psymtab (m_objfile, m_objfile->psymtabs);
+      m_objfile->partial_symtabs->discard_psymtabs_to (m_psymtab);
   }
 
   /* Keep any partial symbol tables that were built.  */
@@ -350,7 +353,9 @@ class psymtab_discarder
 
 /* Traverse all psymtabs in one objfile.  */
 
-#define	ALL_OBJFILE_PSYMTABS(objfile, p) \
-    for ((p) = (objfile) -> psymtabs; (p) != NULL; (p) = (p) -> next)
+#define	ALL_OBJFILE_PSYMTABS(objfile, p)		\
+    for ((p) = (objfile) -> partial_symtabs->psymtabs;	\
+	 (p) != NULL;					\
+	 (p) = (p) -> next)
 
 #endif /* PSYMPRIV_H */
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index ffe99004d4..c06ff0c70e 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -65,6 +65,21 @@ static struct partial_symbol *find_pc_sect_psymbol (struct objfile *,
 static struct compunit_symtab *psymtab_to_symtab (struct objfile *objfile,
 						  struct partial_symtab *pst);
 
+\f
+
+psymtab_storage::psymtab_storage (struct objfile *objfile)
+  : obstack (&objfile->objfile_obstack),
+    psymbol_cache (psymbol_bcache_init ())
+{
+}
+
+psymtab_storage::~psymtab_storage ()
+{
+  psymbol_bcache_free (psymbol_cache);
+}
+
+\f
+
 /* Ensure that the partial symbols for OBJFILE have been loaded.  This
    function always returns its argument, as a convenience.  */
 
@@ -84,8 +99,8 @@ require_partial_symbols (struct objfile *objfile, int verbose)
 
 	  /* Partial symbols list are not expected to changed after this
 	     point.  */
-	  objfile->global_psymbols.shrink_to_fit ();
-	  objfile->static_psymbols.shrink_to_fit ();
+	  objfile->partial_symtabs->global_psymbols.shrink_to_fit ();
+	  objfile->partial_symtabs->static_psymbols.shrink_to_fit ();
 
 	  if (verbose && !objfile_has_symbols (objfile))
 	    printf_filtered (_("(No debugging symbols found in %s)\n"),
@@ -99,9 +114,10 @@ require_partial_symbols (struct objfile *objfile, int verbose)
 /* Traverse all psymtabs in one objfile, requiring that the psymtabs
    be read in.  */
 
-#define ALL_OBJFILE_PSYMTABS_REQUIRED(objfile, p)		\
-    for ((p) = require_partial_symbols (objfile, 1)->psymtabs;	\
-	 (p) != NULL;						\
+#define ALL_OBJFILE_PSYMTABS_REQUIRED(objfile, p)			\
+    for ((p) = require_partial_symbols (objfile,			\
+					1)->partial_symtabs->psymtabs;	\
+	 (p) != NULL;							\
 	 (p) = (p)->next)
 
 /* We want to make sure this file always requires psymtabs.  */
@@ -302,10 +318,11 @@ find_pc_sect_psymtab (struct objfile *objfile, CORE_ADDR pc,
   /* Try just the PSYMTABS_ADDRMAP mapping first as it has better granularity
      than the later used TEXTLOW/TEXTHIGH one.  */
 
-  if (objfile->psymtabs_addrmap != NULL)
+  if (objfile->partial_symtabs->psymtabs_addrmap != NULL)
     {
       pst = ((struct partial_symtab *)
-	     addrmap_find (objfile->psymtabs_addrmap, pc - baseaddr));
+	     addrmap_find (objfile->partial_symtabs->psymtabs_addrmap,
+			   pc - baseaddr));
       if (pst != NULL)
 	{
 	  /* FIXME: addrmaps currently do not handle overlayed sections,
@@ -411,7 +428,9 @@ find_pc_sect_psymbol (struct objfile *objfile,
      cache a bad endaddr.  */
   for (int i = 0; i < psymtab->n_global_syms; i++)
     {
-      partial_symbol *p = objfile->global_psymbols[psymtab->globals_offset + i];
+      partial_symbol *p
+	= objfile->partial_symtabs->global_psymbols[psymtab->globals_offset
+						    + i];
 
       if (p->domain == VAR_DOMAIN
 	  && p->aclass == LOC_BLOCK
@@ -433,7 +452,9 @@ find_pc_sect_psymbol (struct objfile *objfile,
 
   for (int i = 0; i < psymtab->n_static_syms; i++)
     {
-      partial_symbol *p = objfile->static_psymbols[psymtab->statics_offset + i];
+      partial_symbol *p
+	= objfile->partial_symtabs->static_psymbols[psymtab->statics_offset
+						    + i];
 
       if (p->domain == VAR_DOMAIN
 	  && p->aclass == LOC_BLOCK
@@ -543,8 +564,8 @@ match_partial_symbol (struct objfile *objfile,
   lookup_name_info lookup_name (name, match_type);
 
   start = (global ?
-	   &objfile->global_psymbols[pst->globals_offset] :
-	   &objfile->static_psymbols[pst->statics_offset]);
+	   &objfile->partial_symtabs->global_psymbols[pst->globals_offset] :
+	   &objfile->partial_symtabs->static_psymbols[pst->statics_offset]);
 
   if (global && ordered_compare)  /* Can use a binary search.  */
     {
@@ -653,8 +674,8 @@ lookup_partial_symbol (struct objfile *objfile,
   lookup_name_info lookup_name (search_name.get (), symbol_name_match_type::FULL);
 
   start = (global ?
-	   &objfile->global_psymbols[pst->globals_offset] :
-	   &objfile->static_psymbols[pst->statics_offset]);
+	   &objfile->partial_symtabs->global_psymbols[pst->globals_offset] :
+	   &objfile->partial_symtabs->static_psymbols[pst->statics_offset]);
 
   if (global)			/* This means we can use a binary search.  */
     {
@@ -959,15 +980,17 @@ dump_psymtab (struct objfile *objfile, struct partial_symtab *psymtab,
     }
   if (psymtab->n_global_syms > 0)
     {
-      print_partial_symbols (gdbarch, objfile,
-			     &objfile->global_psymbols[psymtab->globals_offset],
-			     psymtab->n_global_syms, "Global", outfile);
+      print_partial_symbols
+	(gdbarch, objfile,
+	 &objfile->partial_symtabs->global_psymbols[psymtab->globals_offset],
+	 psymtab->n_global_syms, "Global", outfile);
     }
   if (psymtab->n_static_syms > 0)
     {
-      print_partial_symbols (gdbarch, objfile,
-			     &objfile->static_psymbols[psymtab->statics_offset],
-			     psymtab->n_static_syms, "Static", outfile);
+      print_partial_symbols
+	(gdbarch, objfile,
+	 &objfile->partial_symtabs->static_psymbols[psymtab->statics_offset],
+	 psymtab->n_static_syms, "Static", outfile);
     }
   fprintf_filtered (outfile, "\n");
 }
@@ -998,10 +1021,10 @@ psym_dump (struct objfile *objfile)
 {
   struct partial_symtab *psymtab;
 
-  if (objfile->psymtabs)
+  if (objfile->partial_symtabs->psymtabs)
     {
       printf_filtered ("Psymtabs:\n");
-      for (psymtab = objfile->psymtabs;
+      for (psymtab = objfile->partial_symtabs->psymtabs;
 	   psymtab != NULL;
 	   psymtab = psymtab->next)
 	{
@@ -1263,21 +1286,25 @@ recursively_search_psymtabs
     }
 
   partial_symbol **gbound
-    = objfile->global_psymbols.data () + ps->globals_offset + ps->n_global_syms;
+    = (objfile->partial_symtabs->global_psymbols.data ()
+       + ps->globals_offset + ps->n_global_syms);
   partial_symbol **sbound
-    = objfile->static_psymbols.data () + ps->statics_offset + ps->n_static_syms;
+    = (objfile->partial_symtabs->static_psymbols.data ()
+       + ps->statics_offset + ps->n_static_syms);
   partial_symbol **bound = gbound;
 
   /* Go through all of the symbols stored in a partial
      symtab in one loop.  */
-  partial_symbol **psym = objfile->global_psymbols.data () + ps->globals_offset;
+  partial_symbol **psym = (objfile->partial_symtabs->global_psymbols.data ()
+			   + ps->globals_offset);
   while (keep_going)
     {
       if (psym >= bound)
 	{
 	  if (bound == gbound && ps->n_static_syms != 0)
 	    {
-	      psym = objfile->static_psymbols.data () + ps->statics_offset;
+	      psym = (objfile->partial_symtabs->static_psymbols.data ()
+		      + ps->statics_offset);
 	      bound = sbound;
 	    }
 	  else
@@ -1383,7 +1410,7 @@ psym_expand_symtabs_matching
 static int
 psym_has_symbols (struct objfile *objfile)
 {
-  return objfile->psymtabs != NULL;
+  return objfile->partial_symtabs->psymtabs != NULL;
 }
 
 /* Helper function for psym_find_compunit_symtab_by_address that fills
@@ -1430,12 +1457,12 @@ psym_find_compunit_symtab_by_address (struct objfile *objfile,
       {
 	psym_fill_psymbol_map (objfile, pst,
 			       &seen_addrs,
-			       objfile->global_psymbols,
+			       objfile->partial_symtabs->global_psymbols,
 			       pst->globals_offset,
 			       pst->n_global_syms);
 	psym_fill_psymbol_map (objfile, pst,
 			       &seen_addrs,
-			       objfile->static_psymbols,
+			       objfile->partial_symtabs->static_psymbols,
 			       pst->statics_offset,
 			       pst->n_static_syms);
       }
@@ -1489,12 +1516,12 @@ static void
 sort_pst_symbols (struct objfile *objfile, struct partial_symtab *pst)
 {
   /* Sort the global list; don't sort the static list.  */
-  auto begin = objfile->global_psymbols.begin ();
+  auto begin = objfile->partial_symtabs->global_psymbols.begin ();
   std::advance (begin, pst->globals_offset);
 
   /* The psymbols for this partial_symtab are currently at the end of the
      vector.  */
-  auto end = objfile->global_psymbols.end ();
+  auto end = objfile->partial_symtabs->global_psymbols.end ();
 
   std::sort (begin, end, [] (partial_symbol *s1, partial_symbol *s2)
     {
@@ -1518,8 +1545,8 @@ start_psymtab_common (struct objfile *objfile,
   psymtab = allocate_psymtab (filename, objfile);
   psymtab->set_text_low (textlow);
   psymtab->set_text_high (psymtab->raw_text_low ()); /* default */
-  psymtab->globals_offset = objfile->global_psymbols.size ();
-  psymtab->statics_offset = objfile->static_psymbols.size ();
+  psymtab->globals_offset = objfile->partial_symtabs->global_psymbols.size ();
+  psymtab->statics_offset = objfile->partial_symtabs->static_psymbols.size ();
   return psymtab;
 }
 
@@ -1528,8 +1555,10 @@ start_psymtab_common (struct objfile *objfile,
 void
 end_psymtab_common (struct objfile *objfile, struct partial_symtab *pst)
 {
-  pst->n_global_syms = objfile->global_psymbols.size () - pst->globals_offset;
-  pst->n_static_syms = objfile->static_psymbols.size () - pst->statics_offset;
+  pst->n_global_syms = (objfile->partial_symtabs->global_psymbols.size ()
+			- pst->globals_offset);
+  pst->n_static_syms = (objfile->partial_symtabs->static_psymbols.size ()
+			- pst->statics_offset);
 
   sort_pst_symbols (objfile, pst);
 }
@@ -1655,7 +1684,9 @@ add_psymbol_to_bcache (const char *name, int namelength, int copy_name,
   symbol_set_names (&psymbol, name, namelength, copy_name, objfile->per_bfd);
 
   /* Stash the partial symbol away in the cache.  */
-  return psymbol_bcache_full (&psymbol, objfile->psymbol_cache, added);
+  return psymbol_bcache_full (&psymbol,
+			      objfile->partial_symtabs->psymbol_cache,
+			      added);
 }
 
 /* Helper function, adds partial symbol to the given partial symbol list.  */
@@ -1699,8 +1730,8 @@ add_psymbol_to_list (const char *name, int namelength, int copy_name,
   /* Save pointer to partial symbol in psymtab, growing symtab if needed.  */
   std::vector<partial_symbol *> *list
     = (where == psymbol_placement::STATIC
-       ? &objfile->static_psymbols
-       : &objfile->global_psymbols);
+       ? &objfile->partial_symtabs->static_psymbols
+       : &objfile->partial_symtabs->global_psymbols);
   append_psymbol_to_list (list, psym, objfile);
 }
 
@@ -1709,15 +1740,15 @@ add_psymbol_to_list (const char *name, int namelength, int copy_name,
 void
 init_psymbol_list (struct objfile *objfile, int total_symbols)
 {
-  if (objfile->global_psymbols.capacity () == 0
-      && objfile->static_psymbols.capacity () == 0)
+  if (objfile->partial_symtabs->global_psymbols.capacity () == 0
+      && objfile->partial_symtabs->static_psymbols.capacity () == 0)
     {
       /* Current best guess is that approximately a twentieth of the
 	 total symbols (in a debugging file) are global or static
 	 oriented symbols, then multiply that by slop factor of
 	 two.  */
-      objfile->global_psymbols.reserve (total_symbols / 10);
-      objfile->static_psymbols.reserve (total_symbols / 10);
+      objfile->partial_symtabs->global_psymbols.reserve (total_symbols / 10);
+      objfile->partial_symtabs->static_psymbols.reserve (total_symbols / 10);
     }
 }
 
@@ -1728,10 +1759,10 @@ allocate_psymtab (const char *filename, struct objfile *objfile)
 {
   struct partial_symtab *psymtab;
 
-  if (objfile->free_psymtabs)
+  if (objfile->partial_symtabs->free_psymtabs)
     {
-      psymtab = objfile->free_psymtabs;
-      objfile->free_psymtabs = psymtab->next;
+      psymtab = objfile->partial_symtabs->free_psymtabs;
+      objfile->partial_symtabs->free_psymtabs = psymtab->next;
     }
   else
     psymtab = XOBNEW (&objfile->objfile_obstack, partial_symtab);
@@ -1746,8 +1777,8 @@ allocate_psymtab (const char *filename, struct objfile *objfile)
      Psymtabs are searched in most recent inserted -> least recent
      inserted order.  */
 
-  psymtab->next = objfile->psymtabs;
-  objfile->psymtabs = psymtab;
+  psymtab->next = objfile->partial_symtabs->psymtabs;
+  objfile->partial_symtabs->psymtabs = psymtab;
 
   if (symtab_create_debug)
     {
@@ -1773,7 +1804,7 @@ allocate_psymtab (const char *filename, struct objfile *objfile)
 }
 
 void
-discard_psymtab (struct objfile *objfile, struct partial_symtab *pst)
+psymtab_storage::discard_psymtab (struct partial_symtab *pst)
 {
   struct partial_symtab **prev_pst;
 
@@ -1786,15 +1817,15 @@ discard_psymtab (struct objfile *objfile, struct partial_symtab *pst)
 
   /* First, snip it out of the psymtab chain.  */
 
-  prev_pst = &(objfile->psymtabs);
+  prev_pst = &psymtabs;
   while ((*prev_pst) != pst)
     prev_pst = &((*prev_pst)->next);
   (*prev_pst) = pst->next;
 
   /* Next, put it on a free list for recycling.  */
 
-  pst->next = objfile->free_psymtabs;
-  objfile->free_psymtabs = pst;
+  pst->next = free_psymtabs;
+  free_psymtabs = pst;
 }
 
 \f
@@ -1860,7 +1891,7 @@ dump_psymtab_addrmap (struct objfile *objfile, struct partial_symtab *psymtab,
 
   if ((psymtab == NULL
        || psymtab->psymtabs_addrmap_supported)
-      && objfile->psymtabs_addrmap != NULL)
+      && objfile->partial_symtabs->psymtabs_addrmap != NULL)
     {
       addrmap_dump_data.objfile = objfile;
       addrmap_dump_data.psymtab = psymtab;
@@ -1868,8 +1899,8 @@ dump_psymtab_addrmap (struct objfile *objfile, struct partial_symtab *psymtab,
       addrmap_dump_data.previous_matched = 0;
       fprintf_filtered (outfile, "%sddress map:\n",
 			psymtab == NULL ? "Entire a" : "  A");
-      addrmap_foreach (objfile->psymtabs_addrmap, dump_psymtab_addrmap_1,
-		       &addrmap_dump_data);
+      addrmap_foreach (objfile->partial_symtabs->psymtabs_addrmap,
+		       dump_psymtab_addrmap_1, &addrmap_dump_data);
     }
 }
 
@@ -2013,7 +2044,7 @@ maintenance_print_psymbols (const char *args, int from_tty)
 
       if (address_arg == NULL
 	  && source_arg == NULL
-	  && objfile->psymtabs_addrmap != NULL)
+	  && objfile->partial_symtabs->psymtabs_addrmap != NULL)
 	{
 	  outfile->puts ("\n");
 	  dump_psymtab_addrmap (objfile, NULL, outfile);
@@ -2089,7 +2120,8 @@ maintenance_info_psymtabs (const char *regexp, int from_tty)
 	      printf_filtered ("    globals ");
 	      if (psymtab->n_global_syms)
 		{
-		  auto p = &objfile->global_psymbols[psymtab->globals_offset];
+		  int off = psymtab->globals_offset;
+		  auto p = &objfile->partial_symtabs->global_psymbols[off];
 
 		  printf_filtered ("(* (struct partial_symbol **) %s @ %d)\n",
 				   host_address_to_string (p),
@@ -2100,7 +2132,8 @@ maintenance_info_psymtabs (const char *regexp, int from_tty)
 	      printf_filtered ("    statics ");
 	      if (psymtab->n_static_syms)
 		{
-		  auto p = &objfile->static_psymbols[psymtab->statics_offset];
+		  int off = psymtab->statics_offset;
+		  auto p = &objfile->partial_symtabs->static_psymbols[off];
 
 		  printf_filtered ("(* (struct partial_symbol **) %s @ %d)\n",
 				   host_address_to_string (p),
@@ -2179,7 +2212,8 @@ maintenance_check_psymtabs (const char *ignore, int from_tty)
       continue;
     bv = COMPUNIT_BLOCKVECTOR (cust);
     b = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
-    partial_symbol **psym = &objfile->static_psymbols[ps->statics_offset];
+    partial_symbol **psym
+      = &objfile->partial_symtabs->static_psymbols[ps->statics_offset];
     length = ps->n_static_syms;
     while (length--)
       {
@@ -2197,7 +2231,7 @@ maintenance_check_psymtabs (const char *ignore, int from_tty)
 	psym++;
       }
     b = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
-    psym = &objfile->global_psymbols[ps->globals_offset];
+    psym = &objfile->partial_symtabs->global_psymbols[ps->globals_offset];
     length = ps->n_global_syms;
     while (length--)
       {
diff --git a/gdb/psymtab.h b/gdb/psymtab.h
index 6d9f257f31..7bdb9d185f 100644
--- a/gdb/psymtab.h
+++ b/gdb/psymtab.h
@@ -22,10 +22,73 @@
 
 #include "symfile.h"
 
+struct partial_symbol;
+
 /* A bcache for partial symbols.  */
 
 struct psymbol_bcache;
 
+/* An instance of this class manages the partial symbol tables and
+   partial symbols for a given objfile.  */
+
+class psymtab_storage
+{
+public:
+
+  explicit psymtab_storage (struct objfile *objfile);
+
+  ~psymtab_storage ();
+
+  DISABLE_COPY_AND_ASSIGN (psymtab_storage);
+
+  /* Discard all partial symbol tables starting with "psymtabs" and
+     proceeding until "to" has been discarded.  */
+
+  void discard_psymtabs_to (struct partial_symtab *to)
+  {
+    while (psymtabs != to)
+      discard_psymtab (psymtabs);
+  }
+
+  /* Discard the partial symbol table.  */
+
+  void discard_psymtab (struct partial_symtab *pst);
+
+
+  /* Each objfile points to a linked list of partial symtabs derived from
+     this file, one partial symtab structure for each compilation unit
+     (source file).  */
+
+  struct partial_symtab *psymtabs = nullptr;
+
+  /* Map addresses to the entries of PSYMTABS.  It would be more efficient to
+     have a map per the whole process but ADDRMAP cannot selectively remove
+     its items during FREE_OBJFILE.  This mapping is already present even for
+     PARTIAL_SYMTABs which still have no corresponding full SYMTABs read.  */
+
+  struct addrmap *psymtabs_addrmap = nullptr;
+
+  /* List of freed partial symtabs, available for re-use.  */
+
+  struct partial_symtab *free_psymtabs = nullptr;
+
+  /* The obstack where allocations are made.  */
+
+  struct obstack *obstack;
+
+  /* A byte cache where we can stash arbitrary "chunks" of bytes that
+     will not change.  */
+
+  struct psymbol_bcache *psymbol_cache;
+
+  /* Vectors of all partial symbols read in from file.  The actual data
+     is stored in the objfile_obstack.  */
+
+  std::vector<partial_symbol *> global_psymbols;
+  std::vector<partial_symbol *> static_psymbols;
+};
+
+
 extern struct psymbol_bcache *psymbol_bcache_init (void);
 extern void psymbol_bcache_free (struct psymbol_bcache *);
 extern struct bcache *psymbol_bcache_get_bcache (struct psymbol_bcache *);
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 8ab6a25de7..64fbfb43db 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -2481,21 +2481,21 @@ reread_symbols (void)
 
 	  /* FIXME: Do we have to free a whole linked list, or is this
 	     enough?  */
-	  objfile->global_psymbols.clear ();
-	  objfile->static_psymbols.clear ();
+	  objfile->partial_symtabs->global_psymbols.clear ();
+	  objfile->partial_symtabs->static_psymbols.clear ();
 
 	  /* Free the obstacks for non-reusable objfiles.  */
-	  psymbol_bcache_free (objfile->psymbol_cache);
-	  objfile->psymbol_cache = psymbol_bcache_init ();
+	  psymbol_bcache_free (objfile->partial_symtabs->psymbol_cache);
+	  objfile->partial_symtabs->psymbol_cache = psymbol_bcache_init ();
 
 	  /* NB: after this call to obstack_free, objfiles_changed
 	     will need to be called (see discussion below).  */
 	  obstack_free (&objfile->objfile_obstack, 0);
 	  objfile->sections = NULL;
 	  objfile->compunit_symtabs = NULL;
-	  objfile->psymtabs = NULL;
-	  objfile->psymtabs_addrmap = NULL;
-	  objfile->free_psymtabs = NULL;
+	  objfile->partial_symtabs->psymtabs = NULL;
+	  objfile->partial_symtabs->psymtabs_addrmap = NULL;
+	  objfile->partial_symtabs->free_psymtabs = NULL;
 	  objfile->template_symbols = NULL;
 	  objfile->static_links = NULL;
 
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index d30a35481e..d5087ebe5f 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -70,8 +70,9 @@ print_symbol_bcache_statistics (void)
     QUIT;
     printf_filtered (_("Byte cache statistics for '%s':\n"),
 		     objfile_name (objfile));
-    print_bcache_statistics (psymbol_bcache_get_bcache (objfile->psymbol_cache),
-                             "partial symbol cache");
+    print_bcache_statistics
+      (psymbol_bcache_get_bcache (objfile->partial_symtabs->psymbol_cache),
+       "partial symbol cache");
     print_bcache_statistics (objfile->per_bfd->macro_cache,
 			     "preprocessor macro cache");
     print_bcache_statistics (objfile->per_bfd->filename_cache,
@@ -134,9 +135,10 @@ print_objfile_statistics (void)
     printf_filtered (_("  Total memory used for BFD obstack: %s\n"),
 		     pulongest (obstack_memory_used (&objfile->per_bfd
 						     ->storage_obstack)));
-    printf_filtered (_("  Total memory used for psymbol cache: %d\n"),
-		     bcache_memory_used (psymbol_bcache_get_bcache
-		                          (objfile->psymbol_cache)));
+    printf_filtered
+      (_("  Total memory used for psymbol cache: %d\n"),
+       bcache_memory_used (psymbol_bcache_get_bcache
+			   (objfile->partial_symtabs->psymbol_cache)));
     printf_filtered (_("  Total memory used for macro cache: %d\n"),
 		     bcache_memory_used (objfile->per_bfd->macro_cache));
     printf_filtered (_("  Total memory used for file name cache: %d\n"),
-- 
2.17.2

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v2 00/12] Work toward making psymtabs reusable
  2018-11-25 19:20 [PATCH v2 00/12] Work toward making psymtabs reusable Tom Tromey
                   ` (11 preceding siblings ...)
  2018-11-25 19:22 ` [PATCH v2 06/12] Introduce class psymtab_storage Tom Tromey
@ 2019-01-10 14:09 ` Tom Tromey
  12 siblings, 0 replies; 14+ messages in thread
From: Tom Tromey @ 2019-01-10 14:09 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

>>>>> "Tom" == Tom Tromey <tom@tromey.com> writes:

Tom> This is version 2 of my series to improve psymtabs a bit.
...
Tom> This addresses all the review comments.  I've also dropped the patch
Tom> that removed the psymtab->symtab backlink and updated various comments
Tom> accordingly.

I've rebased this and fixed it up as needed, and re-run it through the
buildbot (just "Fedora-x86_64-m64").  I'm checking it in now.

Tom

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2019-01-10 14:09 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-25 19:20 [PATCH v2 00/12] Work toward making psymtabs reusable Tom Tromey
2018-11-25 19:20 ` [PATCH v2 11/12] Make psymtab_storage::free_psymtabs private Tom Tromey
2018-11-25 19:20 ` [PATCH v2 09/12] Move more allocations to psymtab obstack Tom Tromey
2018-11-25 19:20 ` [PATCH v2 04/12] Change create_demangled_names_hash to take an objfile_per_bfd_storage Tom Tromey
2018-11-25 19:20 ` [PATCH v2 01/12] Remove parameters from start_psymtab_common Tom Tromey
2018-11-25 19:20 ` [PATCH v2 12/12] Move psymtabs to their own obstack Tom Tromey
2018-11-25 19:20 ` [PATCH v2 03/12] Simplify calls to init_psymbol_list Tom Tromey
2018-11-25 19:20 ` [PATCH v2 02/12] Change add_psymbol_to_list to use an enum Tom Tromey
2018-11-25 19:20 ` [PATCH v2 05/12] Change symbol_set_names to take an objfile_per_bfd_storage Tom Tromey
2018-11-25 19:20 ` [PATCH v2 10/12] Add psymtab_storage::allocate_dependencies Tom Tromey
2018-11-25 19:20 ` [PATCH v2 07/12] Introduce objfile::reset_psymtabs Tom Tromey
2018-11-25 19:20 ` [PATCH v2 08/12] Allocate the address map on the psymtab obstack Tom Tromey
2018-11-25 19:22 ` [PATCH v2 06/12] Introduce class psymtab_storage Tom Tromey
2019-01-10 14:09 ` [PATCH v2 00/12] Work toward making psymtabs reusable 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).