public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [RFA 14/15] Make psymtab_storage::free_psymtabs private
Date: Thu, 10 May 2018 22:25:00 -0000	[thread overview]
Message-ID: <20180510222357.27332-15-tom@tromey.com> (raw)
In-Reply-To: <20180510222357.27332-1-tom@tromey.com>

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

  reply	other threads:[~2018-05-10 22:24 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-10 22:25 [RFA 00/15] Work toward making psymtabs reusable Tom Tromey
2018-05-10 22:25 ` Tom Tromey [this message]
2018-07-18 14:36   ` [RFA 14/15] Make psymtab_storage::free_psymtabs private 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 10/15] Introduce objfile::reset_psymtabs Tom Tromey
2018-07-18 14:04   ` 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 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 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:25 ` [RFA 07/15] Change symbol_set_names to take an objfile_per_bfd_storage Tom Tromey
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 03/15] Remove parameters from start_psymtab_common Tom Tromey
2018-07-17 15:41   ` Simon Marchi
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: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

Reply instructions:

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

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

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

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

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

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

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