This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Make psymtab_storage::free_psymtabs private


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

commit b596a3c77da2387d7e5a3855717d65ce33bdfb58
Author: Tom Tromey <tom@tromey.com>
Date:   Thu May 10 16:23:56 2018 -0600

    Make psymtab_storage::free_psymtabs private
    
    This adds a new psymtab allocation method to psymtab_storage and
    changes the free_psymtabs member to be private.  While not strictly
    necessary, this seems like a decent cleanup, and also makes it simpler
    to move psymtabs off of obstacks entirely, should that prove
    desirable.
    
    gdb/ChangeLog
    2019-01-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.

Diff:
---
 gdb/ChangeLog |  7 +++++++
 gdb/psymtab.c | 42 +++++++++++++++++++++++++-----------------
 gdb/psymtab.h | 14 ++++++++++----
 3 files changed, 42 insertions(+), 21 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 5b7551b..4eeea5c 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,12 @@
 2019-01-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.
+
+2019-01-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
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 4119e83..7ead0eb 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -78,6 +78,29 @@ psymtab_storage::~psymtab_storage ()
   psymbol_bcache_free (psymbol_cache);
 }
 
+/* See psymtab.h.  */
+
+struct partial_symtab *
+psymtab_storage::allocate_psymtab ()
+{
+  struct partial_symtab *psymtab;
+
+  if (free_psymtabs != nullptr)
+    {
+      psymtab = free_psymtabs;
+      free_psymtabs = psymtab->next;
+    }
+  else
+    psymtab = XOBNEW (obstack (), struct partial_symtab);
+
+  memset (psymtab, 0, sizeof (struct partial_symtab));
+
+  psymtab->next = psymtabs;
+  psymtabs = psymtab;
+
+  return psymtab;
+}
+
 
 
 /* See psymtab.h.  */
@@ -1715,29 +1738,14 @@ init_psymbol_list (struct objfile *objfile, int total_symbols)
 struct partial_symtab *
 allocate_psymtab (const char *filename, struct objfile *objfile)
 {
-  struct partial_symtab *psymtab;
-
-  if (objfile->partial_symtabs->free_psymtabs)
-    {
-      psymtab = objfile->partial_symtabs->free_psymtabs;
-      objfile->partial_symtabs->free_psymtabs = psymtab->next;
-    }
-  else
-    psymtab = XOBNEW (objfile->partial_symtabs->obstack (), partial_symtab);
+  struct partial_symtab *psymtab
+    = objfile->partial_symtabs->allocate_psymtab ();
 
-  memset (psymtab, 0, sizeof (struct partial_symtab));
   psymtab->filename
     = (const char *) bcache (filename, strlen (filename) + 1,
 			     objfile->per_bfd->filename_cache);
   psymtab->compunit_symtab = NULL;
 
-  /* Prepend it to the psymtab list for the objfile it belongs to.
-     Psymtabs are searched in most recent inserted -> least recent
-     inserted order.  */
-
-  psymtab->next = objfile->partial_symtabs->psymtabs;
-  objfile->partial_symtabs->psymtabs = psymtab;
-
   if (symtab_create_debug)
     {
       /* Be a bit clever with debugging messages, and don't print objfile
diff --git a/gdb/psymtab.h b/gdb/psymtab.h
index 57570e3..a21e88f 100644
--- a/gdb/psymtab.h
+++ b/gdb/psymtab.h
@@ -71,6 +71,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
@@ -85,10 +91,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.  */
 
@@ -102,6 +104,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;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]