public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [RFA 14/15] Make psymtab_storage::free_psymtabs private
  2018-05-10 22:25 [RFA 00/15] Work toward making psymtabs reusable Tom Tromey
  2018-05-10 22:25 ` [RFA 10/15] Introduce objfile::reset_psymtabs Tom Tromey
@ 2018-05-10 22:25 ` Tom Tromey
  2018-07-18 14:36   ` Simon Marchi
  2018-05-10 22:25 ` [RFA 15/15] Move psymtabs to their own obstack Tom Tromey
                   ` (13 subsequent siblings)
  15 siblings, 1 reply; 42+ messages in thread
From: Tom Tromey @ 2018-05-10 22:25 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.

2018-05-10  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 | 44 +++++++++++++++++++++++++-------------------
 gdb/psymtab.h | 14 ++++++++++----
 3 files changed, 42 insertions(+), 23 deletions(-)

diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index d121eace54..f109e9f1ee 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)
+    {
+      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
@@ -1775,30 +1798,13 @@ 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 = (struct partial_symtab *)
-      obstack_alloc (objfile->partial_symtabs->obstack (),
-		     sizeof (struct partial_symtab));
-
-  memset (psymtab, 0, sizeof (struct partial_symtab));
   psymtab->filename
     = (const char *) bcache (filename, strlen (filename) + 1,
 			     objfile->per_bfd->filename_cache);
 
-  /* 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 8aacc30e38..c4b6f3b9ad 100644
--- a/gdb/psymtab.h
+++ b/gdb/psymtab.h
@@ -66,6 +66,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
@@ -80,10 +86,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.  */
 
@@ -97,6 +99,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.13.6

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

* [RFA 05/15] Simplify calls to init_psymbol_list
  2018-05-10 22:25 [RFA 00/15] Work toward making psymtabs reusable Tom Tromey
                   ` (10 preceding siblings ...)
  2018-05-10 22:25 ` [RFA 07/15] Change symbol_set_names to take an objfile_per_bfd_storage Tom Tromey
@ 2018-05-10 22:25 ` Tom Tromey
  2018-07-18  2:51   ` Simon Marchi
  2018-05-10 22:45 ` [RFA 09/15] Introduce class psymtab_storage Tom Tromey
                   ` (3 subsequent siblings)
  15 siblings, 1 reply; 42+ messages in thread
From: Tom Tromey @ 2018-05-10 22:25 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.

2018-05-09  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    |  8 ++++----
 gdb/xcoffread.c  | 13 +++++--------
 6 files changed, 27 insertions(+), 19 deletions(-)

diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index be0483a38b..17d53331a4 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -529,9 +529,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 823f6bfd2a..9e846e75bb 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -6226,9 +6226,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 8dcd82212b..32c9ee1199 100644
--- a/gdb/psympriv.h
+++ b/gdb/psympriv.h
@@ -295,7 +295,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 4fd47bf92b..c1c8cba800 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -1725,14 +1725,14 @@ 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 ();
+  if (objfile->global_psymbols.capacity () == 0
+      && objfile->static_psymbols.capacity () == 0)
+    return;
 
   /* Current best guess is that approximately a twentieth
      of the total symbols (in a debugging file) are global or static
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index 3cb1944554..7ec367a7ac 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -3000,14 +3000,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);
 
   free_pending_blocks ();
 
-- 
2.13.6

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

* [RFA 06/15] Change create_demangled_names_hash to take an objfile_per_bfd_storage
  2018-05-10 22:25 [RFA 00/15] Work toward making psymtabs reusable Tom Tromey
                   ` (4 preceding siblings ...)
  2018-05-10 22:25 ` [RFA 08/15] Remove readin and compunit_symtab fields from psymtab Tom Tromey
@ 2018-05-10 22:25 ` Tom Tromey
  2018-07-18  2:52   ` Simon Marchi
  2018-05-10 22:25 ` [RFA 04/15] Change add_psymbol_to_list to use an enum Tom Tromey
                   ` (9 subsequent siblings)
  15 siblings, 1 reply; 42+ messages in thread
From: Tom Tromey @ 2018-05-10 22:25 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.

2018-05-09  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 e1f033d1d8..7426770e9e 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -708,14 +708,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);
 }
@@ -802,7 +802,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.13.6

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

* [RFA 04/15] Change add_psymbol_to_list to use an enum
  2018-05-10 22:25 [RFA 00/15] Work toward making psymtabs reusable Tom Tromey
                   ` (5 preceding siblings ...)
  2018-05-10 22:25 ` [RFA 06/15] Change create_demangled_names_hash to take an objfile_per_bfd_storage Tom Tromey
@ 2018-05-10 22:25 ` Tom Tromey
  2018-07-18  2:41   ` Simon Marchi
  2018-05-10 22:25 ` [RFA 03/15] Remove parameters from start_psymtab_common Tom Tromey
                   ` (8 subsequent siblings)
  15 siblings, 1 reply; 42+ messages in thread
From: Tom Tromey @ 2018-05-10 22:25 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.

2018-05-09  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 97c4a847e3..be0483a38b 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -1528,7 +1528,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;
 
@@ -1538,7 +1538,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;
 
@@ -1555,14 +1555,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;
 		    }
@@ -1574,7 +1574,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:
@@ -1635,7 +1635,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;
@@ -1653,7 +1653,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;
 
@@ -1715,7 +1715,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;
 
@@ -1780,7 +1780,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 664d0b0e53..823f6bfd2a 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -8820,7 +8820,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);
 	}
@@ -8830,7 +8830,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);
 	}
@@ -8839,17 +8839,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)
@@ -8884,7 +8879,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);
 	}
@@ -8904,7 +8899,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);
 	}
@@ -8915,7 +8910,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:
@@ -8923,14 +8918,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:
@@ -8955,8 +8950,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;
@@ -8965,8 +8960,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:
@@ -18298,7 +18293,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;
@@ -18335,8 +18330,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 7b9af6020d..29fe3455db 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -3078,7 +3078,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;
@@ -3089,7 +3089,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;
@@ -3108,7 +3108,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')
 			      {
@@ -3117,7 +3117,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;
@@ -3131,7 +3131,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:
@@ -3196,7 +3196,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.  */
@@ -3214,7 +3214,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;
 
@@ -3232,7 +3232,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;
@@ -3255,7 +3255,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;
@@ -3496,13 +3496,13 @@ parse_partial_symbols (minimal_symbol_reader &reader,
 		    add_psymbol_to_list (name, strlen (name), 1,
 					 VAR_DOMAIN, LOC_BLOCK,
 					 section,
-					 &objfile->global_psymbols,
+					 psymbol_placement::GLOBAL,
 					 sh.value, psymtab_language, objfile);
 		  else
 		    add_psymbol_to_list (name, strlen (name), 1,
 					 VAR_DOMAIN, LOC_BLOCK,
 					 section,
-					 &objfile->static_psymbols,
+					 psymbol_placement::STATIC,
 					 sh.value, psymtab_language, objfile);
 
 		  procaddr = sh.value;
@@ -3568,7 +3568,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
 		    {
 		      add_psymbol_to_list (name, strlen (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);
@@ -3608,7 +3608,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
 	      /* Use this gdb symbol.  */
 	      add_psymbol_to_list (name, strlen (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.  */
@@ -3689,7 +3689,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
 	      add_psymbol_to_list (name, strlen (name), 1,
 				   VAR_DOMAIN, theclass,
 				   section,
-				   &objfile->global_psymbols,
+				   psymbol_placement::GLOBAL,
 				   svalue, psymtab_language, objfile);
 	    }
 	}
@@ -3854,7 +3854,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 95449e0ada..8dcd82212b 100644
--- a/gdb/psympriv.h
+++ b/gdb/psympriv.h
@@ -276,13 +276,22 @@ set_psymtab_texthigh (struct partial_symtab *pst, CORE_ADDR high)
 #define SET_PSYMTAB_TEXTLOW(PST, V) set_psymtab_textlow ((PST), (V))
 #define SET_PSYMTAB_TEXTHIGH(PST, V) set_psymtab_texthigh ((PST), (V))
 
+/* 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 *> *,
+				 psymbol_placement,
 				 CORE_ADDR,
 				 enum language, struct objfile *);
 
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index fe54f1c407..4fd47bf92b 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -1701,7 +1701,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)
 {
@@ -1714,11 +1714,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 788ea89fe4..3cb1944554 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -2662,7 +2662,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;
@@ -2673,7 +2673,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;
@@ -2691,14 +2691,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;
 		      }
@@ -2710,7 +2710,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:
@@ -2772,7 +2772,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;
@@ -2790,7 +2790,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;
 
@@ -2808,7 +2808,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;
@@ -2838,7 +2838,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.13.6

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

* [RFA 11/15] Allocate the address map on the psymtab obstack
  2018-05-10 22:25 [RFA 00/15] Work toward making psymtabs reusable Tom Tromey
                   ` (7 preceding siblings ...)
  2018-05-10 22:25 ` [RFA 03/15] Remove parameters from start_psymtab_common Tom Tromey
@ 2018-05-10 22:25 ` Tom Tromey
  2018-07-18 14:08   ` Simon Marchi
  2018-05-10 22:25 ` [RFA 01/15] Move some declarations to mdebugread.h Tom Tromey
                   ` (6 subsequent siblings)
  15 siblings, 1 reply; 42+ messages in thread
From: Tom Tromey @ 2018-05-10 22:25 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.

2018-05-10  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    | 15 +++++++++++----
 4 files changed, 25 insertions(+), 9 deletions(-)

diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 03cb4e9d1e..034d5f477f 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -3187,7 +3187,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
@@ -3348,7 +3348,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.
@@ -8424,7 +8424,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 f50d0576f8..a7bec436e0 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 58c4bee98a..36dba3245c 100644
--- a/gdb/psymtab.h
+++ b/gdb/psymtab.h
@@ -55,6 +55,11 @@ public:
 
   void discard_psymtab (struct partial_symtab *pst);
 
+  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
@@ -73,10 +78,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.  */
 
@@ -87,6 +88,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.13.6

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

* [RFA 08/15] Remove readin and compunit_symtab fields from psymtab
  2018-05-10 22:25 [RFA 00/15] Work toward making psymtabs reusable Tom Tromey
                   ` (3 preceding siblings ...)
  2018-05-10 22:25 ` [RFA 02/15] Remove some unneeded psymtab initializations Tom Tromey
@ 2018-05-10 22:25 ` Tom Tromey
  2018-07-18  3:34   ` Simon Marchi
  2018-05-10 22:25 ` [RFA 06/15] Change create_demangled_names_hash to take an objfile_per_bfd_storage Tom Tromey
                   ` (10 subsequent siblings)
  15 siblings, 1 reply; 42+ messages in thread
From: Tom Tromey @ 2018-05-10 22:25 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

In order to move psymtabs off of the objfile obstack, there must be no
backlinks from the psymtab (or associated objects) to anything
allocated on the objfile obstack.

This patch removes the readin and compunit_symtab fields from psymtab
to help achieve this goal, replacing them with per-objfile maps
indicating which psymtabs have been read in.  This split will allow
for psymtab reuse across objfiles in the future.

2018-05-10  Tom Tromey  <tom@tromey.com>

	* symfile.c (reread_symbols): Clear psymtab_map.
	* xcoffread.c (read_xcoff_symtab, xcoff_psymtab_to_symtab_1)
	(xcoff_read_symtab): Update.
	* psymtab.h (associate_psymtab_with_symtab, psymtab_read_in_p)
	(get_psymtab_compunit): Declare.
	* psymtab.c (partial_map_expand_apply)
	(psym_find_pc_sect_compunit_symtab, psym_lookup_symbol)
	(psymtab_to_symtab, psym_find_last_source_symtab, dump_psymtab)
	(psym_print_stats, psym_expand_symtabs_for_function)
	(psym_map_symbol_filenames, psym_map_matching_symbols)
	(psym_expand_symtabs_matching, allocate_psymtab): Update.
	(associate_psymtab_with_symtab, psymtab_read_in_p)
	(get_psymtab_compunit): New functions.
	(maintenance_info_psymtabs, maintenance_check_psymtabs): Update.
	* psympriv.h (struct partial_symtab) <readin, compunit_symtab>:
	Remove.
	* objfiles.h (objfile::psymtab_map): New member.
	* mdebugread.c (psymtab_to_symtab_1): Update.
	* dwarf2read.c (dw2_do_instantiate_symtab, dwarf2_read_symtab)
	(process_queue): Update.
	(psymtab_to_symtab_1): Add 'objfile' parameter.
	(get_compunit_symtab, process_full_comp_unit)
	(process_full_type_unit): Update.
	* dbxread.c (dbx_psymtab_to_symtab_1, read_ofile_symtab): Update.
---
 gdb/ChangeLog    | 27 +++++++++++++++++++
 gdb/dbxread.c    | 13 ++++-----
 gdb/dwarf2read.c | 38 +++++++++++++++------------
 gdb/mdebugread.c |  8 +++---
 gdb/objfiles.h   |  6 +++++
 gdb/psympriv.h   | 11 --------
 gdb/psymtab.c    | 80 ++++++++++++++++++++++++++++++++++++++++----------------
 gdb/psymtab.h    | 27 +++++++++++++++++++
 gdb/symfile.c    |  1 +
 gdb/xcoffread.c  | 16 ++++++------
 10 files changed, 159 insertions(+), 68 deletions(-)

diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index 17d53331a4..c3741fda8a 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -2149,7 +2149,7 @@ dbx_psymtab_to_symtab_1 (struct objfile *objfile, struct partial_symtab *pst)
 {
   int i;
 
-  if (pst->readin)
+  if (psymtab_read_in_p (objfile, pst))
     {
       fprintf_unfiltered (gdb_stderr, "Psymtab for %s already read in.  "
 			  "Shouldn't happen.\n",
@@ -2159,7 +2159,7 @@ dbx_psymtab_to_symtab_1 (struct objfile *objfile, struct partial_symtab *pst)
 
   /* Read in all partial symtabs on which this one is dependent.  */
   for (i = 0; i < pst->number_of_dependencies; i++)
-    if (!pst->dependencies[i]->readin)
+    if (!psymtab_read_in_p (objfile, pst->dependencies[i]))
       {
 	/* Inform about additional files that need to be read in.  */
 	if (info_verbose)
@@ -2189,7 +2189,7 @@ dbx_psymtab_to_symtab_1 (struct objfile *objfile, struct partial_symtab *pst)
       read_ofile_symtab (objfile, pst);
     }
 
-  pst->readin = 1;
+  associate_psymtab_with_symtab (objfile, pst, nullptr, false);
 }
 
 /* Read in all of the symbols for a given psymtab for real.
@@ -2198,7 +2198,7 @@ dbx_psymtab_to_symtab_1 (struct objfile *objfile, struct partial_symtab *pst)
 static void
 dbx_read_symtab (struct partial_symtab *self, struct objfile *objfile)
 {
-  if (self->readin)
+  if (psymtab_read_in_p (objfile, self))
     {
       fprintf_unfiltered (gdb_stderr, "Psymtab for %s already read in.  "
 			  "Shouldn't happen.\n",
@@ -2406,8 +2406,9 @@ read_ofile_symtab (struct objfile *objfile, struct partial_symtab *pst)
   if (last_source_start_addr > text_offset)
     last_source_start_addr = text_offset;
 
-  pst->compunit_symtab = end_symtab (text_offset + text_size,
-				     SECT_OFF_TEXT (objfile));
+  associate_psymtab_with_symtab (objfile, pst,
+				 end_symtab (text_offset + text_size,
+					     SECT_OFF_TEXT (objfile)));
 
   end_stabs ();
 
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 9e846e75bb..bf6e4b865a 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -1458,7 +1458,7 @@ static void add_partial_subprogram (struct partial_die_info *pdi,
 static void dwarf2_read_symtab (struct partial_symtab *,
 				struct objfile *);
 
-static void psymtab_to_symtab_1 (struct partial_symtab *);
+static void psymtab_to_symtab_1 (struct objfile *, struct partial_symtab *);
 
 static abbrev_table_up abbrev_table_read_table
   (struct dwarf2_per_objfile *dwarf2_per_objfile, struct dwarf2_section_info *,
@@ -2867,7 +2867,9 @@ dw2_do_instantiate_symtab (struct dwarf2_per_cu_data *per_cu)
 
   if (dwarf2_per_objfile->using_index
       ? per_cu->v.quick->compunit_symtab == NULL
-      : (per_cu->v.psymtab == NULL || !per_cu->v.psymtab->readin))
+      : (per_cu->v.psymtab == NULL
+	 || !psymtab_read_in_p (dwarf2_per_objfile->objfile,
+				per_cu->v.psymtab)))
     {
       queue_comp_unit (per_cu, language_minimal);
       load_cu (per_cu);
@@ -9330,7 +9332,7 @@ dwarf2_read_symtab (struct partial_symtab *self,
   struct dwarf2_per_objfile *dwarf2_per_objfile
     = get_dwarf2_per_objfile (objfile);
 
-  if (self->readin)
+  if (psymtab_read_in_p (objfile, self))
     {
       warning (_("bug: psymtab for %s is already read in."),
 	       self->filename);
@@ -9359,7 +9361,7 @@ dwarf2_read_symtab (struct partial_symtab *self,
 
       dwarf2_per_objfile->reading_partial_symbols = 0;
 
-      psymtab_to_symtab_1 (self);
+      psymtab_to_symtab_1 (objfile, self);
 
       /* Finish up the debug error message.  */
       if (info_verbose)
@@ -9460,7 +9462,9 @@ process_queue (struct dwarf2_per_objfile *dwarf2_per_objfile)
     {
       if ((dwarf2_per_objfile->using_index
 	   ? !item->per_cu->v.quick->compunit_symtab
-	   : (item->per_cu->v.psymtab && !item->per_cu->v.psymtab->readin))
+	   : (item->per_cu->v.psymtab
+	      && !psymtab_read_in_p (dwarf2_per_objfile->objfile,
+				     item->per_cu->v.psymtab)))
 	  /* Skip dummy CUs.  */
 	  && item->per_cu->cu != NULL)
 	{
@@ -9516,16 +9520,16 @@ process_queue (struct dwarf2_per_objfile *dwarf2_per_objfile)
 /* Read in full symbols for PST, and anything it depends on.  */
 
 static void
-psymtab_to_symtab_1 (struct partial_symtab *pst)
+psymtab_to_symtab_1 (struct objfile *objfile, struct partial_symtab *pst)
 {
   struct dwarf2_per_cu_data *per_cu;
   int i;
 
-  if (pst->readin)
+  if (psymtab_read_in_p (objfile, pst))
     return;
 
   for (i = 0; i < pst->number_of_dependencies; i++)
-    if (!pst->dependencies[i]->readin
+    if (!psymtab_read_in_p (objfile, pst->dependencies[i])
 	&& pst->dependencies[i]->user == NULL)
       {
         /* Inform about additional files that need to be read in.  */
@@ -9540,7 +9544,7 @@ psymtab_to_symtab_1 (struct partial_symtab *pst)
             wrap_here ("");     /* Flush output.  */
             gdb_flush (gdb_stdout);
           }
-        psymtab_to_symtab_1 (pst->dependencies[i]);
+        psymtab_to_symtab_1 (objfile, pst->dependencies[i]);
       }
 
   per_cu = (struct dwarf2_per_cu_data *) pst->read_symtab_private;
@@ -9549,7 +9553,7 @@ psymtab_to_symtab_1 (struct partial_symtab *pst)
     {
       /* It's an include file, no symbols to read for it.
          Everything is in the parent symtab.  */
-      pst->readin = 1;
+      associate_psymtab_with_symtab (objfile, pst, nullptr);
       return;
     }
 
@@ -10108,9 +10112,11 @@ rust_union_quirks (struct dwarf2_cu *cu)
 static struct compunit_symtab *
 get_compunit_symtab (struct dwarf2_per_cu_data *per_cu)
 {
-  return (per_cu->dwarf2_per_objfile->using_index
-	  ? per_cu->v.quick->compunit_symtab
-	  : per_cu->v.psymtab->compunit_symtab);
+  if (per_cu->dwarf2_per_objfile->using_index)
+    return per_cu->v.quick->compunit_symtab;
+
+  struct objfile *objfile = per_cu->dwarf2_per_objfile->objfile;
+  return get_psymtab_compunit (objfile, per_cu->v.psymtab);
 }
 
 /* A helper function for computing the list of all symbol tables
@@ -10344,8 +10350,7 @@ process_full_comp_unit (struct dwarf2_per_cu_data *per_cu,
   else
     {
       struct partial_symtab *pst = per_cu->v.psymtab;
-      pst->compunit_symtab = cust;
-      pst->readin = 1;
+      associate_psymtab_with_symtab (objfile, pst, cust);
     }
 
   /* Push it for inclusion processing later.  */
@@ -10425,8 +10430,7 @@ process_full_type_unit (struct dwarf2_per_cu_data *per_cu,
   else
     {
       struct partial_symtab *pst = per_cu->v.psymtab;
-      pst->compunit_symtab = cust;
-      pst->readin = 1;
+      associate_psymtab_with_symtab (objfile, pst, cust);
     }
 }
 
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index 29fe3455db..785e9dbfa0 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -3902,16 +3902,16 @@ psymtab_to_symtab_1 (struct objfile *objfile,
   int last_symtab_ended = 0;
   struct section_offsets *section_offsets = objfile->section_offsets;
 
-  if (pst->readin)
+  if (psymtab_read_in_p (objfile, pst))
     return;
-  pst->readin = 1;
+  associate_psymtab_with_symtab (objfile, pst, nullptr, false);
 
   /* Read in all partial symbtabs on which this one is dependent.
      NOTE that we do have circular dependencies, sigh.  We solved
      that by setting pst->readin before this point.  */
 
   for (i = 0; i < pst->number_of_dependencies; i++)
-    if (!pst->dependencies[i]->readin)
+    if (!psymtab_read_in_p (objfile, pst->dependencies[i]))
       {
 	/* Inform about additional files to be read in.  */
 	if (info_verbose)
@@ -4291,7 +4291,7 @@ psymtab_to_symtab_1 (struct objfile *objfile,
     }
 
   /* Now link the psymtab and the symtab.  */
-  pst->compunit_symtab = cust;
+  associate_psymtab_with_symtab (objfile, pst, cust);
 
   mdebugread_objfile = NULL;
 }
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index 28e66eca36..225060d22f 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -28,6 +28,7 @@
 #include "registry.h"
 #include "gdb_bfd.h"
 #include <vector>
+#include <unordered_map>
 
 struct bcache;
 struct htab;
@@ -372,6 +373,11 @@ struct objfile
   std::vector<partial_symbol *> global_psymbols;
   std::vector<partial_symbol *> static_psymbols;
 
+  /* Map from a psymtab to its corresponding full symtab.  If a
+     psymtab is read in but fails to resolve to a full symtab, this
+     map will hold an entry for the psymtab that maps to nullptr.  */
+  std::unordered_map<partial_symtab *, compunit_symtab *> psymtab_map;
+
   /* 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 7673eaef39..969215e2f1 100644
--- a/gdb/psympriv.h
+++ b/gdb/psympriv.h
@@ -193,12 +193,6 @@ struct partial_symtab
   int statics_offset;
   int n_static_syms;
 
-  /* Non-zero if the symtab corresponding to this psymtab has been
-     readin.  This is located here so that this structure packs better
-     on 64-bit systems.  */
-
-  unsigned char readin;
-
   /* True iff objfile->psymtabs_addrmap is properly populated for this
      partial_symtab.  For discontiguous overlapping psymtabs is the only usable
      info in PSYMTABS_ADDRMAP.  */
@@ -218,11 +212,6 @@ struct partial_symtab
   unsigned int textlow_valid : 1;
   unsigned int texthigh_valid : 1;
 
-  /* Pointer to compunit eventually allocated for this source file, 0 if
-     !readin or if we haven't looked for the symtab after it was readin.  */
-
-  struct compunit_symtab *compunit_symtab;
-
   /* Pointer to function which will read in the symtab corresponding to
      this psymtab.  */
 
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index a966b39730..f2177c76ee 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -142,7 +142,7 @@ partial_map_expand_apply (struct objfile *objfile,
   gdb_assert (pst->user == NULL);
 
   /* Don't visit already-expanded psymtabs.  */
-  if (pst->readin)
+  if (psymtab_read_in_p (objfile, pst))
     return 0;
 
   /* This may expand more than one symtab, and we want to iterate over
@@ -390,7 +390,7 @@ psym_find_pc_sect_compunit_symtab (struct objfile *objfile,
 						    msymbol);
   if (ps != NULL)
     {
-      if (warn_if_readin && ps->readin)
+      if (warn_if_readin && psymtab_read_in_p (objfile, ps))
 	/* Might want to error() here (in case symtab is corrupt and
 	   will cause a core dump), but maybe we can successfully
 	   continue, so let's not.  */
@@ -398,7 +398,7 @@ psym_find_pc_sect_compunit_symtab (struct objfile *objfile,
 (Internal error: pc %s in read in psymtab, but not in symtab.)\n"),
 		 paddress (get_objfile_arch (objfile), pc));
       psymtab_to_symtab (objfile, ps);
-      return ps->compunit_symtab;
+      return get_psymtab_compunit (objfile, ps);
     }
   return NULL;
 }
@@ -488,8 +488,8 @@ psym_lookup_symbol (struct objfile *objfile,
 
   ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, ps)
   {
-    if (!ps->readin && lookup_partial_symbol (objfile, ps, name,
-					      psymtab_index, domain))
+    if (!psymtab_read_in_p (objfile, ps)
+	&& lookup_partial_symbol (objfile, ps, name, psymtab_index, domain))
       {
 	struct symbol *sym, *with_opaque = NULL;
 	struct compunit_symtab *stab = psymtab_to_symtab (objfile, ps);
@@ -753,19 +753,15 @@ psymtab_to_symtab (struct objfile *objfile, struct partial_symtab *pst)
   while (pst->user != NULL)
     pst = pst->user;
 
-  /* If it's been looked up before, return it.  */
-  if (pst->compunit_symtab)
-    return pst->compunit_symtab;
-
   /* If it has not yet been read in, read it.  */
-  if (!pst->readin)
+  if (!psymtab_read_in_p (objfile, pst))
     {
       scoped_restore decrementer = increment_reading_symtab ();
 
       (*pst->read_symtab) (pst, objfile);
     }
 
-  return pst->compunit_symtab;
+  return get_psymtab_compunit (objfile, pst);
 }
 
 /* Psymtab version of find_last_source_symtab.  See its definition in
@@ -789,7 +785,7 @@ psym_find_last_source_symtab (struct objfile *ofp)
 
   if (cs_pst)
     {
-      if (cs_pst->readin)
+      if (psymtab_read_in_p (ofp, cs_pst))
 	{
 	  internal_error (__FILE__, __LINE__,
 			  _("select_source_symtab: "
@@ -943,11 +939,12 @@ dump_psymtab (struct objfile *objfile, struct partial_symtab *psymtab,
   gdb_print_host_address (objfile, outfile);
   fprintf_unfiltered (outfile, ")\n");
 
-  if (psymtab->readin)
+  if (psymtab_read_in_p (objfile, psymtab))
     {
       fprintf_filtered (outfile,
 			"  Full symtab was read (at ");
-      gdb_print_host_address (psymtab->compunit_symtab, outfile);
+      gdb_print_host_address (get_psymtab_compunit (objfile, psymtab),
+			      outfile);
       fprintf_filtered (outfile, " by function at ");
       gdb_print_host_address (psymtab->read_symtab, outfile);
       fprintf_filtered (outfile, ")\n");
@@ -1004,7 +1001,7 @@ psym_print_stats (struct objfile *objfile)
   i = 0;
   ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, ps)
     {
-      if (ps->readin == 0)
+      if (psymtab_read_in_p (objfile, ps) == 0)
 	i++;
     }
   printf_filtered (_("  Number of psym tables (not yet expanded): %d\n"), i);
@@ -1046,7 +1043,7 @@ psym_expand_symtabs_for_function (struct objfile *objfile,
 
   ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, ps)
   {
-    if (ps->readin)
+    if (psymtab_read_in_p (objfile, ps))
       continue;
 
     if ((lookup_partial_symbol (objfile, ps, func_name, 1, VAR_DOMAIN)
@@ -1109,7 +1106,7 @@ psym_map_symbol_filenames (struct objfile *objfile,
     {
       const char *fullname;
 
-      if (ps->readin)
+      if (psymtab_read_in_p (objfile, ps))
 	continue;
 
       /* We can skip shared psymtabs here, because any file name will be
@@ -1224,7 +1221,7 @@ psym_map_matching_symbols (struct objfile *objfile,
   ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, ps)
     {
       QUIT;
-      if (ps->readin
+      if (psymtab_read_in_p (objfile, ps)
 	  || match_partial_symbol (objfile, ps, global, name, domain, match,
 				   ordered_compare))
 	{
@@ -1356,7 +1353,7 @@ psym_expand_symtabs_matching
     {
       QUIT;
 
-      if (ps->readin)
+      if (psymtab_read_in_p (objfile, ps))
 	continue;
 
       /* We skip shared psymtabs because file-matching doesn't apply
@@ -1762,7 +1759,6 @@ allocate_psymtab (const char *filename, struct objfile *objfile)
   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
@@ -1821,6 +1817,45 @@ discard_psymtab (struct objfile *objfile, struct partial_symtab *pst)
 
 \f
 
+/* See psympriv.h.  */
+
+void
+associate_psymtab_with_symtab (struct objfile *objfile,
+			       partial_symtab *pst,
+			       compunit_symtab *symtab,
+			       bool always_set)
+{
+  if (!always_set)
+    {
+      auto iter = objfile->psymtab_map.find (pst);
+      if (iter != objfile->psymtab_map.end ())
+	return;
+    }
+  objfile->psymtab_map[pst] = symtab;
+}
+
+/* See psympriv.h.  */
+
+bool
+psymtab_read_in_p (struct objfile *objfile, partial_symtab *pst)
+{
+  auto iter = objfile->psymtab_map.find (pst);
+  return iter != objfile->psymtab_map.end ();
+}
+
+/* See psympriv.h.  */
+
+compunit_symtab *
+get_psymtab_compunit (struct objfile *objfile, partial_symtab *pst)
+{
+  auto iter = objfile->psymtab_map.find (pst);
+  if (iter == objfile->psymtab_map.end ())
+    return nullptr;
+  return iter->second;
+}
+
+\f
+
 /* We need to pass a couple of items to the addrmap_foreach function,
    so use a struct.  */
 
@@ -2094,7 +2129,8 @@ maintenance_info_psymtabs (const char *regexp, int from_tty)
 			       host_address_to_string (psymtab));
 
 	      printf_filtered ("    readin %s\n",
-			       psymtab->readin ? "yes" : "no");
+			       psymtab_read_in_p (objfile, psymtab)
+			       ? "yes" : "no");
 	      printf_filtered ("    fullname %s\n",
 			       psymtab->fullname
 			       ? psymtab->fullname : "(null)");
@@ -2181,7 +2217,7 @@ maintenance_check_psymtabs (const char *ignore, int from_tty)
     /* We don't call psymtab_to_symtab here because that may cause symtab
        expansion.  When debugging a problem it helps if checkers leave
        things unchanged.  */
-    cust = ps->compunit_symtab;
+    cust = get_psymtab_compunit (objfile, ps);
 
     /* First do some checks that don't require the associated symtab.  */
     if (PSYMTAB_TEXTHIGH (objfile, ps) < PSYMTAB_TEXTLOW (objfile, ps))
diff --git a/gdb/psymtab.h b/gdb/psymtab.h
index 6d9f257f31..7c5bf80e70 100644
--- a/gdb/psymtab.h
+++ b/gdb/psymtab.h
@@ -24,6 +24,8 @@
 
 /* A bcache for partial symbols.  */
 
+struct compunit_symtab;
+struct partial_symtab;
 struct psymbol_bcache;
 
 extern struct psymbol_bcache *psymbol_bcache_init (void);
@@ -43,4 +45,29 @@ extern const struct quick_symbol_functions dwarf2_debug_names_functions;
 extern struct objfile *require_partial_symbols (struct objfile *objfile,
 						int verbose);
 
+/* Record that, for the given objfile, PST has expanded to SYMTAB.
+   SYMTAB may be nullptr, indicating that an attempt to expand PST was
+   made, but yielded no results (perhaps this was an included
+   psymtab).  By default, this association is always made, but if
+   ALWAYS_SET is false, then an association is only made if one has
+   not been made previously.  */
+
+extern void associate_psymtab_with_symtab (struct objfile *objfile,
+					   partial_symtab *pst,
+					   compunit_symtab *symtab,
+					   bool always_set = true);
+
+/* Return true if PST was ever read in for the given objfile, false
+   otherwise.  This only records whether an attempt was made -- not
+   whether it yielded a full symtab.  */
+
+extern bool psymtab_read_in_p (struct objfile *objfile, partial_symtab *pst);
+
+/* Return the full symtab corresponding to PST.  Returns NULL if the
+   partial symtab was never read, or if the attempt to read it yielded
+   no results.  */
+
+extern compunit_symtab *get_psymtab_compunit (struct objfile *objfile,
+					      partial_symtab *pst);
+
 #endif /* PSYMTAB_H */
diff --git a/gdb/symfile.c b/gdb/symfile.c
index b0a5f11834..8a63fe34d3 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -2399,6 +2399,7 @@ reread_symbols (void)
 	     enough?  */
 	  objfile->global_psymbols.clear ();
 	  objfile->static_psymbols.clear ();
+	  objfile->psymtab_map.clear ();
 
 	  /* Free the obstacks for non-reusable objfiles.  */
 	  psymbol_bcache_free (objfile->psymbol_cache);
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index 7ec367a7ac..218cfaef5e 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -1134,8 +1134,9 @@ read_xcoff_symtab (struct objfile *objfile, struct partial_symtab *pst)
 	{
 	  if (get_last_source_file ())
 	    {
-	      pst->compunit_symtab = end_symtab (cur_src_end_addr,
-						 SECT_OFF_TEXT (objfile));
+	      associate_psymtab_with_symtab
+		(objfile, pst, end_symtab (cur_src_end_addr,
+					   SECT_OFF_TEXT (objfile)));
 	      end_stabs ();
 	    }
 
@@ -1530,8 +1531,7 @@ read_xcoff_symtab (struct objfile *objfile, struct partial_symtab *pst)
          to make sure that we set pst->compunit_symtab to the symtab for the
          file, not to the _globals_ symtab.  I'm not sure whether this
          actually works right or when/if it comes up.  */
-      if (pst->compunit_symtab == NULL)
-	pst->compunit_symtab = cust;
+      associate_psymtab_with_symtab (objfile, pst, cust, false);
       end_stabs ();
     }
 }
@@ -1843,7 +1843,7 @@ xcoff_psymtab_to_symtab_1 (struct objfile *objfile, struct partial_symtab *pst)
   if (!pst)
     return;
 
-  if (pst->readin)
+  if (psymtab_read_in_p (objfile, pst))
     {
       fprintf_unfiltered
 	(gdb_stderr, "Psymtab for %s already read in.  Shouldn't happen.\n",
@@ -1853,7 +1853,7 @@ xcoff_psymtab_to_symtab_1 (struct objfile *objfile, struct partial_symtab *pst)
 
   /* Read in all partial symtabs on which this one is dependent.  */
   for (i = 0; i < pst->number_of_dependencies; i++)
-    if (!pst->dependencies[i]->readin)
+    if (!psymtab_read_in_p (objfile, pst->dependencies[i]))
       {
 	/* Inform about additional files that need to be read in.  */
 	if (info_verbose)
@@ -1879,7 +1879,7 @@ xcoff_psymtab_to_symtab_1 (struct objfile *objfile, struct partial_symtab *pst)
       read_xcoff_symtab (objfile, pst);
     }
 
-  pst->readin = 1;
+  associate_psymtab_with_symtab (objfile, pst, nullptr, false);
 }
 
 /* Read in all of the symbols for a given psymtab for real.
@@ -1888,7 +1888,7 @@ xcoff_psymtab_to_symtab_1 (struct objfile *objfile, struct partial_symtab *pst)
 static void
 xcoff_read_symtab (struct partial_symtab *self, struct objfile *objfile)
 {
-  if (self->readin)
+  if (psymtab_read_in_p (objfile, self))
     {
       fprintf_unfiltered
 	(gdb_stderr, "Psymtab for %s already read in.  Shouldn't happen.\n",
-- 
2.13.6

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

* [RFA 15/15] Move psymtabs to their own obstack
  2018-05-10 22:25 [RFA 00/15] Work toward making psymtabs reusable Tom Tromey
  2018-05-10 22:25 ` [RFA 10/15] Introduce objfile::reset_psymtabs Tom Tromey
  2018-05-10 22:25 ` [RFA 14/15] Make psymtab_storage::free_psymtabs private Tom Tromey
@ 2018-05-10 22:25 ` Tom Tromey
  2018-07-18 14:41   ` Simon Marchi
  2018-05-10 22:25 ` [RFA 02/15] Remove some unneeded psymtab initializations Tom Tromey
                   ` (12 subsequent siblings)
  15 siblings, 1 reply; 42+ messages in thread
From: Tom Tromey @ 2018-05-10 22:25 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-05-10  Tom Tromey  <tom@tromey.com>

	* psymtab.h (psymtab_storage::obstack): Update.
	(psymtab_storage::m_obstack): Use gdb::optional.
	(class psymtab_storage): Update comment.
	* psymtab.c (psymtab_storage::psymtab_storage): Update.
---
 gdb/ChangeLog |  7 +++++++
 gdb/psymtab.c |  3 +--
 gdb/psymtab.h | 23 +++++++++++++++++++----
 3 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index f109e9f1ee..afdeeafc02 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -68,8 +68,7 @@ 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)
+  : psymbol_cache (psymbol_bcache_init ())
 {
 }
 
diff --git a/gdb/psymtab.h b/gdb/psymtab.h
index c4b6f3b9ad..134edfc540 100644
--- a/gdb/psymtab.h
+++ b/gdb/psymtab.h
@@ -31,7 +31,19 @@ struct partial_symtab;
 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 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.  In particular
+   the core psymtab code will not make links from the psymtab_storage
+   object back to the objfile (or objfile_obstack).
+   
+   However, it is up to each symbol reader to maintain this invariant
+   itself, 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
 {
@@ -58,7 +70,9 @@ public:
 
   struct obstack *obstack ()
   {
-    return m_obstack;
+    if (!m_obstack.has_value ())
+      m_obstack.emplace ();
+    return &*m_obstack;
   }
 
   struct partial_symtab **allocate_dependencies (int number)
@@ -103,9 +117,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.13.6

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

* [RFA 01/15] Move some declarations to mdebugread.h
  2018-05-10 22:25 [RFA 00/15] Work toward making psymtabs reusable Tom Tromey
                   ` (8 preceding siblings ...)
  2018-05-10 22:25 ` [RFA 11/15] Allocate the address map on the psymtab obstack Tom Tromey
@ 2018-05-10 22:25 ` Tom Tromey
  2018-07-17 15:20   ` Simon Marchi
  2018-05-10 22:25 ` [RFA 07/15] Change symbol_set_names to take an objfile_per_bfd_storage Tom Tromey
                   ` (5 subsequent siblings)
  15 siblings, 1 reply; 42+ messages in thread
From: Tom Tromey @ 2018-05-10 22:25 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This moves a couple of mdebugread-related declarations from symfile.h
to mdebugread.h, which seemed more appropriate.

gdb/ChangeLog
2018-05-09  Tom Tromey  <tom@tromey.com>

	* symfile.h (mdebug_build_psymtabs, elfmdebug_build_psymtabs):
	Don't declare.
	* mipsread.c: Include mdebugread.h.
	* mdebugread.h (mdebug_build_psymtabs, elfmdebug_build_psymtabs):
	Declare.
	* elfread.c: Include mdebugread.h.
---
 gdb/ChangeLog    |  9 +++++++++
 gdb/elfread.c    |  1 +
 gdb/mdebugread.h |  9 +++++++++
 gdb/mipsread.c   |  1 +
 gdb/symfile.h    | 11 -----------
 5 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/gdb/elfread.c b/gdb/elfread.c
index b4b4a1b24c..ac3a17a890 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -47,6 +47,7 @@
 #include "build-id.h"
 #include "location.h"
 #include "auxv.h"
+#include "mdebugread.h"
 
 /* Forward declarations.  */
 extern const struct sym_fns elf_sym_fns_gdb_index;
diff --git a/gdb/mdebugread.h b/gdb/mdebugread.h
index a3a0c57a5e..817c5072a8 100644
--- a/gdb/mdebugread.h
+++ b/gdb/mdebugread.h
@@ -37,4 +37,13 @@ struct mdebug_extra_func_info
 
 #define MDEBUG_EFI_SYMBOL_NAME "__GDB_EFI_INFO__"
 
+extern void mdebug_build_psymtabs (minimal_symbol_reader &,
+				   struct objfile *,
+				   const struct ecoff_debug_swap *,
+				   struct ecoff_debug_info *);
+
+extern void elfmdebug_build_psymtabs (struct objfile *,
+				      const struct ecoff_debug_swap *,
+				      asection *);
+
 #endif /* MDEBUGREAD_H */
diff --git a/gdb/mipsread.c b/gdb/mipsread.c
index 7b6ec2e48d..bff56b9b55 100644
--- a/gdb/mipsread.c
+++ b/gdb/mipsread.c
@@ -29,6 +29,7 @@
 #include "objfiles.h"
 #include "buildsym.h"
 #include "stabsread.h"
+#include "mdebugread.h"
 
 #include "coff/sym.h"
 #include "coff/internal.h"
diff --git a/gdb/symfile.h b/gdb/symfile.h
index 358e42b3f2..9c149c8922 100644
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -610,17 +610,6 @@ extern void dwarf2_build_frame_info (struct objfile *);
 
 void dwarf2_free_objfile (struct objfile *);
 
-/* From mdebugread.c */
-
-extern void mdebug_build_psymtabs (minimal_symbol_reader &,
-				   struct objfile *,
-				   const struct ecoff_debug_swap *,
-				   struct ecoff_debug_info *);
-
-extern void elfmdebug_build_psymtabs (struct objfile *,
-				      const struct ecoff_debug_swap *,
-				      asection *);
-
 /* From minidebug.c.  */
 
 extern gdb_bfd_ref_ptr find_separate_debug_file_in_section (struct objfile *);
-- 
2.13.6

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

* [RFA 07/15] Change symbol_set_names to take an objfile_per_bfd_storage
  2018-05-10 22:25 [RFA 00/15] Work toward making psymtabs reusable Tom Tromey
                   ` (9 preceding siblings ...)
  2018-05-10 22:25 ` [RFA 01/15] Move some declarations to mdebugread.h Tom Tromey
@ 2018-05-10 22:25 ` Tom Tromey
  2018-05-10 22:25 ` [RFA 05/15] Simplify calls to init_psymbol_list Tom Tromey
                   ` (4 subsequent siblings)
  15 siblings, 0 replies; 42+ messages in thread
From: Tom Tromey @ 2018-05-10 22:25 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.

2018-05-09  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/psympriv.h |  4 ++--
 gdb/psymtab.c  |  2 +-
 gdb/symtab.c   |  3 +--
 gdb/symtab.h   |  8 +++++---
 5 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/gdb/psympriv.h b/gdb/psympriv.h
index 32c9ee1199..7673eaef39 100644
--- a/gdb/psympriv.h
+++ b/gdb/psympriv.h
@@ -66,8 +66,8 @@ struct partial_symbol
 
 #define PSYMBOL_SET_LANGUAGE(symbol,language,obstack)	\
   (symbol_set_language (&(symbol)->pginfo, (language), (obstack)))
-#define PSYMBOL_SET_NAMES(symbol,linkage_name,len,copy_name,objfile)	\
-  symbol_set_names (&(symbol)->pginfo, linkage_name, len, copy_name, objfile)
+#define PSYMBOL_SET_NAMES(symbol,linkage_name,len,copy_name,per_bfd)	\
+  symbol_set_names (&(symbol)->pginfo, linkage_name, len, copy_name, per_bfd)
 
 #define PSYMBOL_LINKAGE_NAME(symbol)	(symbol)->pginfo.name
 #define PSYMBOL_DEMANGLED_NAME(symbol) \
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index c1c8cba800..a966b39730 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -1673,7 +1673,7 @@ add_psymbol_to_bcache (const char *name, int namelength, int copy_name,
   PSYMBOL_DOMAIN (&psymbol) = domain;
   PSYMBOL_CLASS (&psymbol) = theclass;
 
-  PSYMBOL_SET_NAMES (&psymbol, name, namelength, copy_name, objfile);
+  PSYMBOL_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 7426770e9e..4af4848859 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -773,13 +773,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 84fc897658..cc97452b3d 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -492,10 +492,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
@@ -732,7 +733,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.13.6

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

* [RFA 10/15] Introduce objfile::reset_psymtabs
  2018-05-10 22:25 [RFA 00/15] Work toward making psymtabs reusable Tom Tromey
@ 2018-05-10 22:25 ` Tom Tromey
  2018-07-18 14:04   ` Simon Marchi
  2018-05-10 22:25 ` [RFA 14/15] Make psymtab_storage::free_psymtabs private Tom Tromey
                   ` (14 subsequent siblings)
  15 siblings, 1 reply; 42+ messages in thread
From: Tom Tromey @ 2018-05-10 22:25 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-05-09  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 | 10 ++++++++++
 gdb/symfile.c  | 13 +------------
 3 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index a49954df60..fd4266d6bf 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -292,6 +292,16 @@ struct objfile
 
   DISABLE_COPY_AND_ASSIGN (objfile);
 
+  /* Reset the storage for the partial symbol tables.  */
+
+  void reset_psymtabs ()
+  {
+    psymbol_map.clear ();
+    psymtab_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 a23c051c3e..98b063ed02 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -2395,24 +2395,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 ();
-	  objfile->psymtab_map.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;
 
 	  /* obstack_init also initializes the obstack so it is
-- 
2.13.6

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

* [RFA 02/15] Remove some unneeded psymtab initializations
  2018-05-10 22:25 [RFA 00/15] Work toward making psymtabs reusable Tom Tromey
                   ` (2 preceding siblings ...)
  2018-05-10 22:25 ` [RFA 15/15] Move psymtabs to their own obstack Tom Tromey
@ 2018-05-10 22:25 ` Tom Tromey
  2018-07-17 15:27   ` Simon Marchi
  2018-05-10 22:25 ` [RFA 08/15] Remove readin and compunit_symtab fields from psymtab Tom Tromey
                   ` (11 subsequent siblings)
  15 siblings, 1 reply; 42+ messages in thread
From: Tom Tromey @ 2018-05-10 22:25 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

allocate_psymtab has long cleared the new psymtab that is returned.
This patch documents this behavior and then removes some redundant
initializations.

gdb/ChangeLog
2018-05-09  Tom Tromey  <tom@tromey.com>

	* xcoffread.c (xcoff_end_psymtab): Remove some initializations.
	* psymtab.c (allocate_psymtab): Add comment.
	* psympriv.h (allocate_psymtab): Add comment.
	* dwarf2read.c (dwarf2_create_include_psymtab): Remove some
	initializations.
	* dbxread.c (dbx_end_psymtab): Remove some initializations.
---
 gdb/ChangeLog    |  9 +++++++++
 gdb/dbxread.c    |  7 -------
 gdb/dwarf2read.c |  6 ------
 gdb/psympriv.h   | 10 ++++++++--
 gdb/psymtab.c    |  2 ++
 gdb/xcoffread.c  |  7 -------
 6 files changed, 19 insertions(+), 22 deletions(-)

diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index 1c4f564f4e..84ade27b4d 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -2127,13 +2127,6 @@ dbx_end_psymtab (struct objfile *objfile, struct partial_symtab *pst,
       subpst->dependencies[0] = pst;
       subpst->number_of_dependencies = 1;
 
-      subpst->globals_offset =
-	subpst->n_global_syms =
-	subpst->statics_offset =
-	subpst->n_static_syms = 0;
-
-      subpst->readin = 0;
-      subpst->compunit_symtab = 0;
       subpst->read_symtab = pst->read_symtab;
     }
 
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 8960fdc38d..be477e3d30 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -6517,13 +6517,7 @@ dwarf2_create_include_psymtab (const char *name, struct partial_symtab *pst,
   subpst->dependencies[0] = pst;
   subpst->number_of_dependencies = 1;
 
-  subpst->globals_offset = 0;
-  subpst->n_global_syms = 0;
-  subpst->statics_offset = 0;
-  subpst->n_static_syms = 0;
-  subpst->compunit_symtab = NULL;
   subpst->read_symtab = pst->read_symtab;
-  subpst->readin = 0;
 
   /* No private part is necessary for include psymtabs.  This property
      can be used to differentiate between such include psymtabs and
diff --git a/gdb/psympriv.h b/gdb/psympriv.h
index 487a34f053..2d81c16b40 100644
--- a/gdb/psympriv.h
+++ b/gdb/psympriv.h
@@ -295,8 +295,14 @@ extern struct partial_symtab *start_psymtab_common (struct objfile *,
 
 extern void end_psymtab_common (struct objfile *, struct partial_symtab *);
 
-extern struct partial_symtab *allocate_psymtab (const char *,
-						struct objfile *)
+/* Allocate a new partial symbol table associated with OBJFILE.
+   FILENAME (which must be non-NULL) is the filename of this partial
+   symbol table; it is copied into the appropriate storage.  A new
+   partial symbol table is returned; aside from "next" and "filename",
+   its fields are initialized to zero.  */
+
+extern struct partial_symtab *allocate_psymtab (const char *filename,
+						struct objfile *objfile)
   ATTRIBUTE_NONNULL (1);
 
 extern void discard_psymtab (struct objfile *, struct partial_symtab *);
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 28935291e4..ee593494f6 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -1740,6 +1740,8 @@ init_psymbol_list (struct objfile *objfile, int total_symbols)
   objfile->static_psymbols.reserve (total_symbols / 10);
 }
 
+/* See psympriv.h.  */
+
 struct partial_symtab *
 allocate_psymtab (const char *filename, struct objfile *objfile)
 {
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index 611e954a08..a26f4fe88c 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -2109,13 +2109,6 @@ xcoff_end_psymtab (struct objfile *objfile, struct partial_symtab *pst,
       subpst->dependencies[0] = pst;
       subpst->number_of_dependencies = 1;
 
-      subpst->globals_offset =
-	subpst->n_global_syms =
-	subpst->statics_offset =
-	subpst->n_static_syms = 0;
-
-      subpst->readin = 0;
-      subpst->compunit_symtab = NULL;
       subpst->read_symtab = pst->read_symtab;
     }
 
-- 
2.13.6

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

* [RFA 03/15] Remove parameters from start_psymtab_common
  2018-05-10 22:25 [RFA 00/15] Work toward making psymtabs reusable Tom Tromey
                   ` (6 preceding siblings ...)
  2018-05-10 22:25 ` [RFA 04/15] Change add_psymbol_to_list to use an enum Tom Tromey
@ 2018-05-10 22:25 ` Tom Tromey
  2018-07-17 15:41   ` Simon Marchi
  2018-05-10 22:25 ` [RFA 11/15] Allocate the address map on the psymtab obstack Tom Tromey
                   ` (7 subsequent siblings)
  15 siblings, 1 reply; 42+ messages in thread
From: Tom Tromey @ 2018-05-10 22:25 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.

2018-05-09  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 84ade27b4d..97c4a847e3 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -291,9 +291,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.  */
 
@@ -1352,9 +1350,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;
 	      }
@@ -1982,12 +1978,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 be477e3d30..664d0b0e53 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -7851,9 +7851,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 32d6f0b8fd..7b9af6020d 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -2648,9 +2648,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 = obstack_alloc (&objfile->objfile_obstack,
 						sizeof (struct symloc));
       memset (pst->read_symtab_private, 0, sizeof (struct symloc));
diff --git a/gdb/psympriv.h b/gdb/psympriv.h
index 2d81c16b40..95449e0ada 100644
--- a/gdb/psympriv.h
+++ b/gdb/psympriv.h
@@ -289,9 +289,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 ee593494f6..fe54f1c407 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -1530,17 +1530,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);
   SET_PSYMTAB_TEXTLOW (psymtab, textlow);
   SET_PSYMTAB_TEXTHIGH (psymtab, PSYMTAB_RAW_TEXTLOW (psymtab)); /* 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 a26f4fe88c..788ea89fe4 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -2031,16 +2031,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);
@@ -2324,9 +2321,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
@@ -2508,9 +2503,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.13.6

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

* [RFA 00/15] Work toward making psymtabs reusable
@ 2018-05-10 22:25 Tom Tromey
  2018-05-10 22:25 ` [RFA 10/15] Introduce objfile::reset_psymtabs Tom Tromey
                   ` (15 more replies)
  0 siblings, 16 replies; 42+ messages in thread
From: Tom Tromey @ 2018-05-10 22:25 UTC (permalink / raw)
  To: gdb-patches

Recently I realized that, while the full objfile splitting project is
still a good idea, many of the potential gains from it could be had
more immediately -- by making psymtabs shareable across objfiles.

The idea behind this is that scanning psymbols is what is noticeably
slow; expanding a given CU is ordinarily pretty fast.  So, if psymbols
could be shared, then the most user-visible slowdown could be avoided,
at least in the multi-inferior case.

As an aside, this case matters to me, because Firefox is now
multi-process by default and each process uses the enormous libxul.so.
Multi-inferior debugging still has a ways to go in gdb, but if you are
working in this area, rest assured that there are people who want to
use the results...

This series does not actually achieve the goal of sharing psymbols.
It is just a bunch of necessary-but-not-sufficient infrastructure.  I
figured I would send it as it is relatively self-contained and already
pretty long.

Also note that it is built on top of my earlier series to make
psymbols independent of the program space.

This series begins (patches 1-7) with some minor cleanups that I found
while working in this area.  Perhaps patches 6 and 7 aren't really
needed; I wrote them when working toward a slightly different end
goal, but I think they are reasonable so I left them in.

Patch 8 is perhaps the ugliest of the bunch.  Because backlinks from
pymtabs to per-objfile objects will be disallowed, the
psymtab->compunit_symtab link had to be broken.  This patch does so
via a map.

The rest, I think, is reasonably straightforward.  Various
psymtab-related objects are moved to a new psymtab state-holding
object, and finally, this object is given its own obstack, moving the
psymbols into a shareable object.

This is the series I referenced in reply to Simon's auto-indexing
series -- I think with this it is pretty easy to picturing handing the
psymtab_storage shared_ptr to a separate thread to write out the index
file.

Regression tested by the buildbot.

There are still some remaining cleanups that could be done.  psymtab.c
uses ALL_OBJFILE_PSYMTABS_REQUIRED everywhere, but in some spots it
doesn't make sense.  Also, ~objfile (indirectly) calls
psym_forget_cached_source_info, but really psymtab_storage should be
handling this in its own destructor.

Tom

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

* [RFA 09/15] Introduce class psymtab_storage
  2018-05-10 22:25 [RFA 00/15] Work toward making psymtabs reusable Tom Tromey
                   ` (11 preceding siblings ...)
  2018-05-10 22:25 ` [RFA 05/15] Simplify calls to init_psymbol_list Tom Tromey
@ 2018-05-10 22:45 ` Tom Tromey
  2018-07-18 14:02   ` Simon Marchi
  2018-05-11 10:53 ` [RFA 12/15] Move more allocations to psymtab obstack Tom Tromey
                   ` (2 subsequent siblings)
  15 siblings, 1 reply; 42+ messages in thread
From: Tom Tromey @ 2018-05-10 22:45 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.

2018-05-10  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        |  32 ++++++-----
 gdb/mdebugread.c        |  11 ++--
 gdb/objfiles.c          |   5 +-
 gdb/objfiles.h          |  29 +---------
 gdb/psympriv.h          |  17 ++++--
 gdb/psymtab.c           | 150 +++++++++++++++++++++++++++++-------------------
 gdb/psymtab.h           |  62 ++++++++++++++++++++
 gdb/symfile.c           |  14 ++---
 gdb/symmisc.c           |  12 ++--
 11 files changed, 265 insertions(+), 136 deletions(-)

diff --git a/gdb/dwarf-index-write.c b/gdb/dwarf-index-write.c
index 03e8542015..669d8bafb6 100644
--- a/gdb/dwarf-index-write.c
+++ b/gdb/dwarf-index-write.c
@@ -476,8 +476,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.
@@ -584,13 +584,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);
@@ -641,12 +641,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);
 }
@@ -837,10 +839,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);
   }
 
@@ -1198,12 +1202,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);
@@ -1557,7 +1561,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 bf6e4b865a..03cb4e9d1e 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -3186,8 +3186,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
@@ -3347,8 +3347,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.
@@ -5233,13 +5233,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;
   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;
 
@@ -7936,7 +7936,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.
@@ -8400,7 +8401,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)
@@ -8421,8 +8422,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 ();
 
@@ -9047,8 +9049,8 @@ add_partial_subprogram (struct partial_die_info *pdi,
 	      highpc = (gdbarch_adjust_dwarf2_addr (gdbarch,
 						    pdi->highpc + baseaddr)
 			- baseaddr);
-	      addrmap_set_empty (objfile->psymtabs_addrmap, lowpc, highpc - 1,
-				 cu->per_cu->v.psymtab);
+	      addrmap_set_empty (objfile->partial_symtabs->psymtabs_addrmap,
+				 lowpc, highpc - 1, cu->per_cu->v.psymtab);
 	    }
         }
 
@@ -14519,8 +14521,8 @@ dwarf2_ranges_read (unsigned offset, CORE_ADDR *low_return,
 					      range_beginning + baseaddr);
 	  highpc = gdbarch_adjust_dwarf2_addr (gdbarch,
 					       range_end + 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 785e9dbfa0..4e07d37f54 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -3784,11 +3784,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;
   do_cleanups (old_chain);
 }
 
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index e0b6ac30a9..aaca3eff70 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -374,8 +374,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;
 
@@ -718,7 +718,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 225060d22f..a49954df60 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>
 #include <unordered_map>
 
@@ -320,22 +321,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.  */
@@ -357,22 +345,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;
-
   /* Map from a psymtab to its corresponding full symtab.  If a
      psymtab is read in but fails to resolve to a full symtab, this
      map will hold an entry for the psymtab that maps to nullptr.  */
diff --git a/gdb/psympriv.h b/gdb/psympriv.h
index 969215e2f1..c299ce7c18 100644
--- a/gdb/psympriv.h
+++ b/gdb/psympriv.h
@@ -305,7 +305,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,
@@ -316,15 +320,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.  */
@@ -344,7 +347,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 f2177c76ee..f50d0576f8 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.  */
 
@@ -87,8 +102,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)
 	    {
@@ -110,9 +125,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.  */
@@ -315,10 +331,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,
@@ -425,7 +442,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 (SYMBOL_DOMAIN (p) == VAR_DOMAIN
 	  && PSYMBOL_CLASS (p) == LOC_BLOCK
@@ -448,7 +467,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 (SYMBOL_DOMAIN (p) == VAR_DOMAIN
 	  && PSYMBOL_CLASS (p) == LOC_BLOCK
@@ -559,8 +580,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.  */
     {
@@ -669,8 +690,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.  */
     {
@@ -976,15 +997,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");
 }
@@ -1015,10 +1038,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)
 	{
@@ -1279,21 +1302,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
@@ -1399,7 +1426,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
@@ -1446,12 +1473,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);
       }
@@ -1505,12 +1532,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)
     {
@@ -1534,8 +1561,8 @@ start_psymtab_common (struct objfile *objfile,
   psymtab = allocate_psymtab (filename, objfile);
   SET_PSYMTAB_TEXTLOW (psymtab, textlow);
   SET_PSYMTAB_TEXTHIGH (psymtab, PSYMTAB_RAW_TEXTLOW (psymtab)); /* 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;
 }
 
@@ -1544,8 +1571,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);
 }
@@ -1673,7 +1702,9 @@ add_psymbol_to_bcache (const char *name, int namelength, int copy_name,
   PSYMBOL_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.  */
@@ -1717,8 +1748,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);
 }
 
@@ -1727,15 +1758,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)
     return;
 
   /* 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);
 }
 
 /* See psympriv.h.  */
@@ -1745,10 +1776,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 = (struct partial_symtab *)
@@ -1764,8 +1795,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)
     {
@@ -1791,7 +1822,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;
 
@@ -1804,15 +1835,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
@@ -1917,7 +1948,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;
@@ -1925,8 +1956,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);
     }
 }
 
@@ -2070,7 +2101,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);
@@ -2149,7 +2180,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),
@@ -2160,7 +2192,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),
@@ -2239,7 +2272,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--)
       {
@@ -2257,7 +2291,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 7c5bf80e70..58c4bee98a 100644
--- a/gdb/psymtab.h
+++ b/gdb/psymtab.h
@@ -25,9 +25,71 @@
 /* A bcache for partial symbols.  */
 
 struct compunit_symtab;
+struct partial_symbol;
 struct partial_symtab;
 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 8a63fe34d3..a23c051c3e 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -2397,22 +2397,22 @@ 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 ();
 	  objfile->psymtab_map.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;
 
 	  /* obstack_init also initializes the obstack so it is
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index 91ddc578a8..919c09a5c2 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.13.6

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

* [RFA 13/15] Add psymtab_storage::allocate_dependencies
  2018-05-10 22:25 [RFA 00/15] Work toward making psymtabs reusable Tom Tromey
                   ` (13 preceding siblings ...)
  2018-05-11 10:53 ` [RFA 12/15] Move more allocations to psymtab obstack Tom Tromey
@ 2018-05-11 10:53 ` Tom Tromey
  2018-07-18 14:32   ` Simon Marchi
  2018-06-18 14:42 ` [RFA 00/15] Work toward making psymtabs reusable Tom Tromey
  15 siblings, 1 reply; 42+ messages in thread
From: Tom Tromey @ 2018-05-11 10:53 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.

2018-05-10  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    |  9 ++-------
 gdb/dwarf2read.c | 10 ++++------
 gdb/mdebugread.c |  5 +----
 gdb/psymtab.h    |  6 ++++++
 gdb/xcoffread.c  | 11 +++--------
 6 files changed, 28 insertions(+), 25 deletions(-)

diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index c3741fda8a..e1aed48ff7 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -2092,13 +2092,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);
-      memcpy (pst->dependencies, dependency_list,
-	      number_dependencies * sizeof (struct partial_symtab *));
-    }
+    pst->dependencies
+      = objfile->partial_symtabs->allocate_dependencies (number_dependencies);
   else
     pst->dependencies = 0;
 
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 034d5f477f..eca3c62493 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -6512,8 +6512,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;
 
@@ -7989,8 +7988,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);
@@ -8248,8 +8247,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 4e07d37f54..8a788b7c69 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -3752,10 +3752,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
          source files or a reverse .h -> .c dependency for header files.  */
       pst->number_of_dependencies = 0;
       pst->dependencies =
-	((struct partial_symtab **)
-	 obstack_alloc (&objfile->objfile_obstack,
-			((fh->crfd - 1)
-			 * sizeof (struct partial_symtab *))));
+	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 36dba3245c..8aacc30e38 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"
 
 /* A bcache for partial symbols.  */
@@ -60,6 +61,11 @@ public:
     return m_obstack;
   }
 
+  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 218cfaef5e..3f2138caa3 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -2079,13 +2079,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);
-      memcpy (pst->dependencies, dependency_list,
-	      number_dependencies * sizeof (struct partial_symtab *));
-    }
+    pst->dependencies
+      = objfile->partial_symtabs->allocate_dependencies (number_dependencies);
   else
     pst->dependencies = 0;
 
@@ -2102,7 +2097,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.13.6

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

* [RFA 12/15] Move more allocations to psymtab obstack
  2018-05-10 22:25 [RFA 00/15] Work toward making psymtabs reusable Tom Tromey
                   ` (12 preceding siblings ...)
  2018-05-10 22:45 ` [RFA 09/15] Introduce class psymtab_storage Tom Tromey
@ 2018-05-11 10:53 ` Tom Tromey
  2018-07-18 14:24   ` Simon Marchi
  2018-05-11 10:53 ` [RFA 13/15] Add psymtab_storage::allocate_dependencies Tom Tromey
  2018-06-18 14:42 ` [RFA 00/15] Work toward making psymtabs reusable Tom Tromey
  15 siblings, 1 reply; 42+ messages in thread
From: Tom Tromey @ 2018-05-11 10:53 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

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

2018-05-10  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 a7bec436e0..d121eace54 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -1695,7 +1695,8 @@ add_psymbol_to_bcache (const char *name, int namelength, int copy_name,
 
   SET_PSYMBOL_VALUE_ADDRESS (&psymbol, coreaddr);
   PSYMBOL_SECTION (&psymbol) = section;
-  PSYMBOL_SET_LANGUAGE (&psymbol, language, &objfile->objfile_obstack);
+  PSYMBOL_SET_LANGUAGE (&psymbol, language,
+			objfile->partial_symtabs->obstack ());
   PSYMBOL_DOMAIN (&psymbol) = domain;
   PSYMBOL_CLASS (&psymbol) = theclass;
 
@@ -1783,7 +1784,7 @@ allocate_psymtab (const char *filename, struct objfile *objfile)
     }
   else
     psymtab = (struct partial_symtab *)
-      obstack_alloc (&objfile->objfile_obstack,
+      obstack_alloc (objfile->partial_symtabs->obstack (),
 		     sizeof (struct partial_symtab));
 
   memset (psymtab, 0, sizeof (struct partial_symtab));
-- 
2.13.6

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

* Re: [RFA 00/15] Work toward making psymtabs reusable
  2018-05-10 22:25 [RFA 00/15] Work toward making psymtabs reusable Tom Tromey
                   ` (14 preceding siblings ...)
  2018-05-11 10:53 ` [RFA 13/15] Add psymtab_storage::allocate_dependencies Tom Tromey
@ 2018-06-18 14:42 ` Tom Tromey
  2018-07-16 16:33   ` Tom Tromey
  15 siblings, 1 reply; 42+ messages in thread
From: Tom Tromey @ 2018-06-18 14:42 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

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

Tom> Recently I realized that, while the full objfile splitting project is
Tom> still a good idea, many of the potential gains from it could be had
Tom> more immediately -- by making psymtabs shareable across objfiles.

[...]

Ping.

Tom

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

* Re: [RFA 00/15] Work toward making psymtabs reusable
  2018-06-18 14:42 ` [RFA 00/15] Work toward making psymtabs reusable Tom Tromey
@ 2018-07-16 16:33   ` Tom Tromey
  0 siblings, 0 replies; 42+ messages in thread
From: Tom Tromey @ 2018-07-16 16:33 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

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

>>>>> "Tom" == Tom Tromey <tom@tromey.com> writes:
Tom> Recently I realized that, while the full objfile splitting project is
Tom> still a good idea, many of the potential gains from it could be had
Tom> more immediately -- by making psymtabs shareable across objfiles.

Tom> [...]

Tom> Ping.

Ping.

Tom

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

* Re: [RFA 01/15] Move some declarations to mdebugread.h
  2018-05-10 22:25 ` [RFA 01/15] Move some declarations to mdebugread.h Tom Tromey
@ 2018-07-17 15:20   ` Simon Marchi
  0 siblings, 0 replies; 42+ messages in thread
From: Simon Marchi @ 2018-07-17 15:20 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 2018-05-10 18:23, Tom Tromey wrote:
> This moves a couple of mdebugread-related declarations from symfile.h
> to mdebugread.h, which seemed more appropriate.

LGTM.  It can be pushed as a cleanup on its own.

Simon

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

* Re: [RFA 02/15] Remove some unneeded psymtab initializations
  2018-05-10 22:25 ` [RFA 02/15] Remove some unneeded psymtab initializations Tom Tromey
@ 2018-07-17 15:27   ` Simon Marchi
  2018-07-18  2:29     ` Simon Marchi
  0 siblings, 1 reply; 42+ messages in thread
From: Simon Marchi @ 2018-07-17 15:27 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

Hi Tom,

This LGTM, I just have one comment.  I think it can be pushed on its own 
too.

On 2018-05-10 18:23, Tom Tromey wrote:
> diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
> index 8960fdc38d..be477e3d30 100644
> --- a/gdb/dwarf2read.c
> +++ b/gdb/dwarf2read.c
> @@ -6517,13 +6517,7 @@ dwarf2_create_include_psymtab (const char
> *name, struct partial_symtab *pst,
>    subpst->dependencies[0] = pst;
>    subpst->number_of_dependencies = 1;
> 
> -  subpst->globals_offset = 0;
> -  subpst->n_global_syms = 0;
> -  subpst->statics_offset = 0;
> -  subpst->n_static_syms = 0;
> -  subpst->compunit_symtab = NULL;
>    subpst->read_symtab = pst->read_symtab;
> -  subpst->readin = 0;

Just above this, there is:

   subpst->textlow = 0;
   subpst->texthigh = 0;

Can they be removed too?  Same thing in xcoffread.

Simon

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

* Re: [RFA 03/15] Remove parameters from start_psymtab_common
  2018-05-10 22:25 ` [RFA 03/15] Remove parameters from start_psymtab_common Tom Tromey
@ 2018-07-17 15:41   ` Simon Marchi
  0 siblings, 0 replies; 42+ messages in thread
From: Simon Marchi @ 2018-07-17 15:41 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 2018-05-10 18:23, Tom Tromey wrote:
> 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.

LGTM.

Simon

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

* Re: [RFA 02/15] Remove some unneeded psymtab initializations
  2018-07-17 15:27   ` Simon Marchi
@ 2018-07-18  2:29     ` Simon Marchi
  0 siblings, 0 replies; 42+ messages in thread
From: Simon Marchi @ 2018-07-18  2:29 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 2018-07-17 11:27 AM, Simon Marchi wrote:
> Hi Tom,
> 
> This LGTM, I just have one comment.  I think it can be pushed on its own 
> too.
> 
> On 2018-05-10 18:23, Tom Tromey wrote:
>> diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
>> index 8960fdc38d..be477e3d30 100644
>> --- a/gdb/dwarf2read.c
>> +++ b/gdb/dwarf2read.c
>> @@ -6517,13 +6517,7 @@ dwarf2_create_include_psymtab (const char
>> *name, struct partial_symtab *pst,
>>    subpst->dependencies[0] = pst;
>>    subpst->number_of_dependencies = 1;
>>
>> -  subpst->globals_offset = 0;
>> -  subpst->n_global_syms = 0;
>> -  subpst->statics_offset = 0;
>> -  subpst->n_static_syms = 0;
>> -  subpst->compunit_symtab = NULL;
>>    subpst->read_symtab = pst->read_symtab;
>> -  subpst->readin = 0;
> 
> Just above this, there is:
> 
>    subpst->textlow = 0;
>    subpst->texthigh = 0;
> 
> Can they be removed too?  Same thing in xcoffread.
> 
> Simon
> 

Ahh, when the series is applied on top of the other psymtab series (as you
mention in the cover letter), these bits are already gone.  Sorry about that.

Simon

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

* Re: [RFA 04/15] Change add_psymbol_to_list to use an enum
  2018-05-10 22:25 ` [RFA 04/15] Change add_psymbol_to_list to use an enum Tom Tromey
@ 2018-07-18  2:41   ` Simon Marchi
  0 siblings, 0 replies; 42+ messages in thread
From: Simon Marchi @ 2018-07-18  2:41 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2018-05-10 06:23 PM, Tom Tromey wrote:
> 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.

LGTM.

Simon

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

* Re: [RFA 05/15] Simplify calls to init_psymbol_list
  2018-05-10 22:25 ` [RFA 05/15] Simplify calls to init_psymbol_list Tom Tromey
@ 2018-07-18  2:51   ` Simon Marchi
  2018-09-23 21:12     ` Tom Tromey
  0 siblings, 1 reply; 42+ messages in thread
From: Simon Marchi @ 2018-07-18  2:51 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2018-05-10 06:23 PM, Tom Tromey wrote:
> diff --git a/gdb/psymtab.c b/gdb/psymtab.c
> index 4fd47bf92b..c1c8cba800 100644
> --- a/gdb/psymtab.c
> +++ b/gdb/psymtab.c
> @@ -1725,14 +1725,14 @@ 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 ();
> +  if (objfile->global_psymbols.capacity () == 0
> +      && objfile->static_psymbols.capacity () == 0)
> +    return;

Hmm, isn't the condition backwards?  If the capacity is zero, we want to
reserve some space.  But maybe we can skip the check completely... if we
have already reserved the same space previously, calling reserve again
does nothing (is harmless).

Would LGTM with the condition fixed (assuming I am not the one being confused)
or removed.

Simon

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

* Re: [RFA 06/15] Change create_demangled_names_hash to take an objfile_per_bfd_storage
  2018-05-10 22:25 ` [RFA 06/15] Change create_demangled_names_hash to take an objfile_per_bfd_storage Tom Tromey
@ 2018-07-18  2:52   ` Simon Marchi
  0 siblings, 0 replies; 42+ messages in thread
From: Simon Marchi @ 2018-07-18  2:52 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2018-05-10 06:23 PM, Tom Tromey wrote:
> 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.

LGTM.

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

* Re: [RFA 08/15] Remove readin and compunit_symtab fields from psymtab
  2018-05-10 22:25 ` [RFA 08/15] Remove readin and compunit_symtab fields from psymtab Tom Tromey
@ 2018-07-18  3:34   ` Simon Marchi
  2018-07-18 18:56     ` Tom Tromey
  2018-09-28  5:02     ` Tom Tromey
  0 siblings, 2 replies; 42+ messages in thread
From: Simon Marchi @ 2018-07-18  3:34 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2018-05-10 06:23 PM, Tom Tromey wrote:
> In order to move psymtabs off of the objfile obstack, there must be no
> backlinks from the psymtab (or associated objects) to anything
> allocated on the objfile obstack.
> 
> This patch removes the readin and compunit_symtab fields from psymtab
> to help achieve this goal, replacing them with per-objfile maps
> indicating which psymtabs have been read in.  This split will allow
> for psymtab reuse across objfiles in the future.

This LGTM, but I have two question.  In the future, is the intent to also
make symtabs (compunit_symtab) independent from program spaces, and
shareable across objfiles, or would that not be possible?  If it is
possible, would the compunit_symtab pointer in psymtab re-appear, since
there would now again be a single compunit_symtab for each psymtab?

As Pedro pointed out a few times, unordered_map is an hash map with open
hashing.  So we change what was previously a single pointer dereference
to a lookup in a hash table, followed with a linear search in a linked
list.  If this map is looked up very frequently, maybe we should consider
using an htab_t instead?  Some profiling data would help, but it seems
like psymtab_read_in_p is called quite a bit when looking up symbols...

Simon

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

* Re: [RFA 09/15] Introduce class psymtab_storage
  2018-05-10 22:45 ` [RFA 09/15] Introduce class psymtab_storage Tom Tromey
@ 2018-07-18 14:02   ` Simon Marchi
  0 siblings, 0 replies; 42+ messages in thread
From: Simon Marchi @ 2018-07-18 14:02 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2018-05-10 06:23 PM, Tom Tromey wrote:
> 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.

This patch LGTM.

Simon

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

* Re: [RFA 10/15] Introduce objfile::reset_psymtabs
  2018-05-10 22:25 ` [RFA 10/15] Introduce objfile::reset_psymtabs Tom Tromey
@ 2018-07-18 14:04   ` Simon Marchi
  0 siblings, 0 replies; 42+ messages in thread
From: Simon Marchi @ 2018-07-18 14:04 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2018-05-10 06:23 PM, Tom Tromey wrote:
> 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.

LGTM.

Simon

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

* Re: [RFA 11/15] Allocate the address map on the psymtab obstack
  2018-05-10 22:25 ` [RFA 11/15] Allocate the address map on the psymtab obstack Tom Tromey
@ 2018-07-18 14:08   ` Simon Marchi
  0 siblings, 0 replies; 42+ messages in thread
From: Simon Marchi @ 2018-07-18 14:08 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2018-05-10 06:23 PM, Tom Tromey wrote:
> 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.

LGTM.

Simon

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

* Re: [RFA 12/15] Move more allocations to psymtab obstack
  2018-05-11 10:53 ` [RFA 12/15] Move more allocations to psymtab obstack Tom Tromey
@ 2018-07-18 14:24   ` Simon Marchi
  0 siblings, 0 replies; 42+ messages in thread
From: Simon Marchi @ 2018-07-18 14:24 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2018-05-10 06:23 PM, Tom Tromey wrote:
> This moves a couple more psymtab-related allocations to the psymtab
> obstack.

LGTM.

Simon

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

* Re: [RFA 13/15] Add psymtab_storage::allocate_dependencies
  2018-05-11 10:53 ` [RFA 13/15] Add psymtab_storage::allocate_dependencies Tom Tromey
@ 2018-07-18 14:32   ` Simon Marchi
  2018-09-23 21:25     ` Tom Tromey
  0 siblings, 1 reply; 42+ messages in thread
From: Simon Marchi @ 2018-07-18 14:32 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2018-05-10 06:23 PM, Tom Tromey wrote:
> diff --git a/gdb/dbxread.c b/gdb/dbxread.c
> index c3741fda8a..e1aed48ff7 100644
> --- a/gdb/dbxread.c
> +++ b/gdb/dbxread.c
> @@ -2092,13 +2092,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);
> -      memcpy (pst->dependencies, dependency_list,
> -	      number_dependencies * sizeof (struct partial_symtab *));
> -    }
> +    pst->dependencies
> +      = objfile->partial_symtabs->allocate_dependencies (number_dependencies);

There is a memcpy that disappears here, probably not intended?  Same in xcoffread.

Otherwise, LGTM.

Simon

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

* Re: [RFA 14/15] Make psymtab_storage::free_psymtabs private
  2018-05-10 22:25 ` [RFA 14/15] Make psymtab_storage::free_psymtabs private Tom Tromey
@ 2018-07-18 14:36   ` Simon Marchi
  2018-09-23 21:13     ` Tom Tromey
  0 siblings, 1 reply; 42+ messages in thread
From: Simon Marchi @ 2018-07-18 14:36 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2018-05-10 06:23 PM, Tom Tromey wrote:
> 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.
> 
> 2018-05-10  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 | 44 +++++++++++++++++++++++++-------------------
>  gdb/psymtab.h | 14 ++++++++++----
>  3 files changed, 42 insertions(+), 23 deletions(-)
> 
> diff --git a/gdb/psymtab.c b/gdb/psymtab.c
> index d121eace54..f109e9f1ee 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

Otherwise, LGTM.

Simon

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

* Re: [RFA 15/15] Move psymtabs to their own obstack
  2018-05-10 22:25 ` [RFA 15/15] Move psymtabs to their own obstack Tom Tromey
@ 2018-07-18 14:41   ` Simon Marchi
  2018-09-23 21:34     ` Tom Tromey
  0 siblings, 1 reply; 42+ messages in thread
From: Simon Marchi @ 2018-07-18 14:41 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2018-05-10 06:23 PM, Tom Tromey wrote:
> 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.

Thanks, LGTM.

I think you can remove the objfile parameter in the psymtab_storage constructor,
it is not used (this shows that psymtab_storage no longer relies on the objfile
for allocations).

Simon

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

* Re: [RFA 08/15] Remove readin and compunit_symtab fields from psymtab
  2018-07-18  3:34   ` Simon Marchi
@ 2018-07-18 18:56     ` Tom Tromey
  2018-09-28  5:02     ` Tom Tromey
  1 sibling, 0 replies; 42+ messages in thread
From: Tom Tromey @ 2018-07-18 18:56 UTC (permalink / raw)
  To: Simon Marchi; +Cc: Tom Tromey, gdb-patches

>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:

>> In order to move psymtabs off of the objfile obstack, there must be no
>> backlinks from the psymtab (or associated objects) to anything
>> allocated on the objfile obstack.

>> This patch removes the readin and compunit_symtab fields from psymtab
>> to help achieve this goal, replacing them with per-objfile maps
>> indicating which psymtabs have been read in.  This split will allow
>> for psymtab reuse across objfiles in the future.

Simon> This LGTM, but I have two question.  In the future, is the intent to also
Simon> make symtabs (compunit_symtab) independent from program spaces, and
Simon> shareable across objfiles, or would that not be possible?  If it is
Simon> possible, would the compunit_symtab pointer in psymtab re-appear, since
Simon> there would now again be a single compunit_symtab for each psymtab?

I think it is a good long-term goal, but not the only possible one in
this area.

The main downside is that it is hard to do.  There's a reasonably
complete to-do list here:

    https://sourceware.org/gdb/wiki/ObjfileSplitting

Some of these steps are tricky and/or laborious.

So, my thought with this second series was that perhaps gdb could get
most of the benefits of the split without the full implementation.

To my mind the performance issue is the major one to solve, with memory
use being second.  So, for instance, if gdb had this psymbol series,
plus maybe incremental expansion of partial symbol tables, perhaps that
would be enough.  This is based in my belief that psymtab reading is the
obvious spot where gdb spends its time, and that CU expansion is
generally fast (but with the occasional counterexample).

So maybe the full objfile splitting project will not even happen (and so
the backlink would never be restored).

Simon> As Pedro pointed out a few times, unordered_map is an hash map with open
Simon> hashing.  So we change what was previously a single pointer dereference
Simon> to a lookup in a hash table, followed with a linear search in a linked
Simon> list.  If this map is looked up very frequently, maybe we should consider
Simon> using an htab_t instead?  Some profiling data would help, but it seems
Simon> like psymtab_read_in_p is called quite a bit when looking up symbols...

I will look into it a bit.

Tom

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

* Re: [RFA 05/15] Simplify calls to init_psymbol_list
  2018-07-18  2:51   ` Simon Marchi
@ 2018-09-23 21:12     ` Tom Tromey
  0 siblings, 0 replies; 42+ messages in thread
From: Tom Tromey @ 2018-09-23 21:12 UTC (permalink / raw)
  To: Simon Marchi; +Cc: Tom Tromey, gdb-patches

>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:

>> void
>> init_psymbol_list (struct objfile *objfile, int total_symbols)
>> {
>> -  /* Free any previously allocated psymbol lists.  */
>> -  objfile->global_psymbols.clear ();
>> -  objfile->static_psymbols.clear ();
>> +  if (objfile->global_psymbols.capacity () == 0
>> +      && objfile->static_psymbols.capacity () == 0)
>> +    return;

Simon> Hmm, isn't the condition backwards?

Yep.

Simon> Would LGTM with the condition fixed (assuming I am not the one being confused)
Simon> or removed.

I've fixed it locally.

Tom

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

* Re: [RFA 14/15] Make psymtab_storage::free_psymtabs private
  2018-07-18 14:36   ` Simon Marchi
@ 2018-09-23 21:13     ` Tom Tromey
  0 siblings, 0 replies; 42+ messages in thread
From: Tom Tromey @ 2018-09-23 21:13 UTC (permalink / raw)
  To: Simon Marchi; +Cc: Tom Tromey, gdb-patches

>>>>> "Simon" == Simon Marchi <simon.marchi@ericsson.com> writes:

>> +struct partial_symtab *
>> +psymtab_storage::allocate_psymtab ()
>> +{
>> +  struct partial_symtab *psymtab;
>> +
>> +  if (free_psymtabs)

Simon> != nullptr

Simon> Otherwise, LGTM.

I made this change.

Tom

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

* Re: [RFA 13/15] Add psymtab_storage::allocate_dependencies
  2018-07-18 14:32   ` Simon Marchi
@ 2018-09-23 21:25     ` Tom Tromey
  0 siblings, 0 replies; 42+ messages in thread
From: Tom Tromey @ 2018-09-23 21:25 UTC (permalink / raw)
  To: Simon Marchi; +Cc: Tom Tromey, gdb-patches

>>>>> "Simon" == Simon Marchi <simon.marchi@ericsson.com> writes:

Simon> On 2018-05-10 06:23 PM, Tom Tromey wrote:
>> diff --git a/gdb/dbxread.c b/gdb/dbxread.c
>> index c3741fda8a..e1aed48ff7 100644
>> --- a/gdb/dbxread.c
>> +++ b/gdb/dbxread.c
>> @@ -2092,13 +2092,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);
>> -      memcpy (pst->dependencies, dependency_list,
>> -	      number_dependencies * sizeof (struct partial_symtab *));
>> -    }
>> +    pst->dependencies
>> +      = objfile->partial_symtabs->allocate_dependencies (number_dependencies);

Simon> There is a memcpy that disappears here, probably not intended?  Same in xcoffread.

Thanks, I fixed this.  There was also a spot in dbxread.c where there
should have been another change to call allocate_dependencies; I fixed
this as well.

Tom

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

* Re: [RFA 15/15] Move psymtabs to their own obstack
  2018-07-18 14:41   ` Simon Marchi
@ 2018-09-23 21:34     ` Tom Tromey
  0 siblings, 0 replies; 42+ messages in thread
From: Tom Tromey @ 2018-09-23 21:34 UTC (permalink / raw)
  To: Simon Marchi; +Cc: Tom Tromey, gdb-patches

>>>>> "Simon" == Simon Marchi <simon.marchi@ericsson.com> writes:

Simon> I think you can remove the objfile parameter in the psymtab_storage constructor,
Simon> it is not used (this shows that psymtab_storage no longer relies on the objfile
Simon> for allocations).

I've made this change locally.

Tom

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

* Re: [RFA 08/15] Remove readin and compunit_symtab fields from psymtab
  2018-07-18  3:34   ` Simon Marchi
  2018-07-18 18:56     ` Tom Tromey
@ 2018-09-28  5:02     ` Tom Tromey
  2018-10-06  1:24       ` Tom Tromey
  1 sibling, 1 reply; 42+ messages in thread
From: Tom Tromey @ 2018-09-28  5:02 UTC (permalink / raw)
  To: Simon Marchi; +Cc: Tom Tromey, gdb-patches

>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:

Simon> As Pedro pointed out a few times, unordered_map is an hash map with open
Simon> hashing.  So we change what was previously a single pointer dereference
Simon> to a lookup in a hash table, followed with a linear search in a linked
Simon> list.  If this map is looked up very frequently, maybe we should consider
Simon> using an htab_t instead?  Some profiling data would help, but it seems
Simon> like psymtab_read_in_p is called quite a bit when looking up symbols...

I went ahead and switched this to an htab_t.

I considered, a little, porting over the GCC C++ hash table.
I wasn't sure where to put it, though.  I suppose we'd need a new
library.  Also, the GCC one has some GCC-isms (the GC stuff), plus the
unusual "empty" method Pedro has mentioned here before.


I still haven't tried any performance measurements.
I'm not quite sure what to try.

If it performs poorly, maybe a single element cache would help.

Also I should probably look to see if there are any spots that iterate
over psymtabs that could be changed to iterate over the map directly.

I'm sort of considering dropping just this one patch and trying to get
the rest in.

Tom

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

* Re: [RFA 08/15] Remove readin and compunit_symtab fields from psymtab
  2018-09-28  5:02     ` Tom Tromey
@ 2018-10-06  1:24       ` Tom Tromey
  2018-10-07 22:04         ` Simon Marchi
  0 siblings, 1 reply; 42+ messages in thread
From: Tom Tromey @ 2018-10-06  1:24 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Simon Marchi, gdb-patches

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

>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:
Simon> As Pedro pointed out a few times, unordered_map is an hash map with open
Simon> hashing.  So we change what was previously a single pointer dereference
Simon> to a lookup in a hash table, followed with a linear search in a linked
Simon> list.  If this map is looked up very frequently, maybe we should consider
Simon> using an htab_t instead?  Some profiling data would help, but it seems
Simon> like psymtab_read_in_p is called quite a bit when looking up symbols...

[...]

Tom> I still haven't tried any performance measurements.
Tom> I'm not quite sure what to try.

I ran the gdb.perf tests and on some tests, it seems that the results
are within the noise; but on backtrace (2048) and skip-function-3000 (4000)
gdb is about 4% slower.  I don't know if this is enough to worry about.

Tom

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

* Re: [RFA 08/15] Remove readin and compunit_symtab fields from psymtab
  2018-10-06  1:24       ` Tom Tromey
@ 2018-10-07 22:04         ` Simon Marchi
  2018-10-08  0:01           ` Tom Tromey
  0 siblings, 1 reply; 42+ messages in thread
From: Simon Marchi @ 2018-10-07 22:04 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 2018-10-05 9:24 p.m., Tom Tromey wrote:
>>>>>> "Tom" == Tom Tromey <tom@tromey.com> writes:
> 
>>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:
> Simon> As Pedro pointed out a few times, unordered_map is an hash map with open
> Simon> hashing.  So we change what was previously a single pointer dereference
> Simon> to a lookup in a hash table, followed with a linear search in a linked
> Simon> list.  If this map is looked up very frequently, maybe we should consider
> Simon> using an htab_t instead?  Some profiling data would help, but it seems
> Simon> like psymtab_read_in_p is called quite a bit when looking up symbols...
> 
> [...]
> 
> Tom> I still haven't tried any performance measurements.
> Tom> I'm not quite sure what to try.
> 
> I ran the gdb.perf tests and on some tests, it seems that the results
> are within the noise; but on backtrace (2048) and skip-function-3000 (4000)
> gdb is about 4% slower.  I don't know if this is enough to worry about.
> 
> Tom
> 

That sounds like a reasonable trade-off in exchange for the feature of decoupling
psymtabs from objfiles.  Perhaps we can put it on the list of "candidates for htab_t"
(could be a comment next to the field), for when we finally bring the C++ wrappers
from gcc :).

Simon

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

* Re: [RFA 08/15] Remove readin and compunit_symtab fields from psymtab
  2018-10-07 22:04         ` Simon Marchi
@ 2018-10-08  0:01           ` Tom Tromey
  0 siblings, 0 replies; 42+ messages in thread
From: Tom Tromey @ 2018-10-08  0:01 UTC (permalink / raw)
  To: Simon Marchi; +Cc: Tom Tromey, gdb-patches

>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:

>> I ran the gdb.perf tests and on some tests, it seems that the results
>> are within the noise; but on backtrace (2048) and skip-function-3000 (4000)
>> gdb is about 4% slower.  I don't know if this is enough to worry about.

Simon> That sounds like a reasonable trade-off in exchange for the feature of decoupling
Simon> psymtabs from objfiles.  Perhaps we can put it on the list of "candidates for htab_t"
Simon> (could be a comment next to the field), for when we finally bring the C++ wrappers
Simon> from gcc :).

Just to be clear, 4% was the slowdown after I switched it to htab_t.

Tom

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

end of thread, other threads:[~2018-10-08  0:01 UTC | newest]

Thread overview: 42+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-10 22:25 [RFA 00/15] Work toward making psymtabs reusable Tom Tromey
2018-05-10 22:25 ` [RFA 10/15] Introduce objfile::reset_psymtabs Tom Tromey
2018-07-18 14:04   ` Simon Marchi
2018-05-10 22:25 ` [RFA 14/15] Make psymtab_storage::free_psymtabs private Tom Tromey
2018-07-18 14:36   ` Simon Marchi
2018-09-23 21:13     ` Tom Tromey
2018-05-10 22:25 ` [RFA 15/15] Move psymtabs to their own obstack Tom Tromey
2018-07-18 14:41   ` Simon Marchi
2018-09-23 21:34     ` Tom Tromey
2018-05-10 22:25 ` [RFA 02/15] Remove some unneeded psymtab initializations Tom Tromey
2018-07-17 15:27   ` Simon Marchi
2018-07-18  2:29     ` Simon Marchi
2018-05-10 22:25 ` [RFA 08/15] Remove readin and compunit_symtab fields from psymtab Tom Tromey
2018-07-18  3:34   ` Simon Marchi
2018-07-18 18:56     ` Tom Tromey
2018-09-28  5:02     ` Tom Tromey
2018-10-06  1:24       ` Tom Tromey
2018-10-07 22:04         ` Simon Marchi
2018-10-08  0:01           ` Tom Tromey
2018-05-10 22:25 ` [RFA 06/15] Change create_demangled_names_hash to take an objfile_per_bfd_storage Tom Tromey
2018-07-18  2:52   ` Simon Marchi
2018-05-10 22:25 ` [RFA 04/15] Change add_psymbol_to_list to use an enum Tom Tromey
2018-07-18  2:41   ` Simon Marchi
2018-05-10 22:25 ` [RFA 03/15] Remove parameters from start_psymtab_common Tom Tromey
2018-07-17 15:41   ` Simon Marchi
2018-05-10 22:25 ` [RFA 11/15] Allocate the address map on the psymtab obstack Tom Tromey
2018-07-18 14:08   ` Simon Marchi
2018-05-10 22:25 ` [RFA 01/15] Move some declarations to mdebugread.h Tom Tromey
2018-07-17 15:20   ` Simon Marchi
2018-05-10 22:25 ` [RFA 07/15] Change symbol_set_names to take an objfile_per_bfd_storage Tom Tromey
2018-05-10 22:25 ` [RFA 05/15] Simplify calls to init_psymbol_list Tom Tromey
2018-07-18  2:51   ` Simon Marchi
2018-09-23 21:12     ` Tom Tromey
2018-05-10 22:45 ` [RFA 09/15] Introduce class psymtab_storage Tom Tromey
2018-07-18 14:02   ` Simon Marchi
2018-05-11 10:53 ` [RFA 12/15] Move more allocations to psymtab obstack Tom Tromey
2018-07-18 14:24   ` Simon Marchi
2018-05-11 10:53 ` [RFA 13/15] Add psymtab_storage::allocate_dependencies Tom Tromey
2018-07-18 14:32   ` Simon Marchi
2018-09-23 21:25     ` Tom Tromey
2018-06-18 14:42 ` [RFA 00/15] Work toward making psymtabs reusable Tom Tromey
2018-07-16 16:33   ` 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).