public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Make objfile::static_links an htab_up
@ 2019-04-19 20:28 Tom Tromey
  0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2019-04-19 20:28 UTC (permalink / raw)
  To: gdb-cvs

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

commit cf250e36790aaa255bb486e2122bb83c95c7669b
Author: Tom Tromey <tom@tromey.com>
Date:   Sun Apr 7 15:39:37 2019 -0600

    Make objfile::static_links an htab_up
    
    This changes objfile::static_links to be an htab_up, so that ~objfile
    no longer has to explicitly destroy it.
    
    Tested by the buildbot.
    
    gdb/ChangeLog
    2019-04-19  Tom Tromey  <tom@tromey.com>
    
    	* symfile.c (reread_symbols): Update.
    	* objfiles.c (objfile_register_static_link)
    	(objfile_lookup_static_link): Update
    	(~objfile) Don't delete static_links.
    	* objfiles.h (struct objfile) <static_links>: Now an htab_up.

Diff:
---
 gdb/ChangeLog  |  8 ++++++++
 gdb/objfiles.c | 16 +++++-----------
 gdb/objfiles.h |  2 +-
 gdb/symfile.c  |  2 +-
 4 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 45f8fa5..ac56b09 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,13 @@
 2019-04-19  Tom Tromey  <tom@tromey.com>
 
+	* symfile.c (reread_symbols): Update.
+	* objfiles.c (objfile_register_static_link)
+	(objfile_lookup_static_link): Update
+	(~objfile) Don't delete static_links.
+	* objfiles.h (struct objfile) <static_links>: Now an htab_up.
+
+2019-04-19  Tom Tromey  <tom@tromey.com>
+
 	* type-stack.h (struct type_stack) <insert>: Constify string.
 	* type-stack.c (type_stack::insert): Constify string.
 	* gdbtypes.h (lookup_template_type): Update.
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index e055365..1b0ea29 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -231,14 +231,14 @@ objfile_register_static_link (struct objfile *objfile,
   struct static_link_htab_entry *entry;
 
   if (objfile->static_links == NULL)
-    objfile->static_links = htab_create_alloc
+    objfile->static_links.reset (htab_create_alloc
       (1, &static_link_htab_entry_hash, static_link_htab_entry_eq, NULL,
-       xcalloc, xfree);
+       xcalloc, xfree));
 
   /* Create a slot for the mapping, make sure it's the first mapping for this
      block and then create the mapping itself.  */
   lookup_entry.block = block;
-  slot = htab_find_slot (objfile->static_links, &lookup_entry, INSERT);
+  slot = htab_find_slot (objfile->static_links.get (), &lookup_entry, INSERT);
   gdb_assert (*slot == NULL);
 
   entry = XOBNEW (&objfile->objfile_obstack, static_link_htab_entry);
@@ -260,9 +260,8 @@ objfile_lookup_static_link (struct objfile *objfile,
   if (objfile->static_links == NULL)
     return NULL;
   lookup_entry.block = block;
-  entry
-    = (struct static_link_htab_entry *) htab_find (objfile->static_links,
-						   &lookup_entry);
+  entry = ((struct static_link_htab_entry *)
+	   htab_find (objfile->static_links.get (), &lookup_entry));
   if (entry == NULL)
     return NULL;
 
@@ -691,11 +690,6 @@ objfile::~objfile ()
 
   /* Rebuild section map next time we need it.  */
   get_objfile_pspace_data (pspace)->section_map_dirty = 1;
-
-  /* Free the map for static links.  There's no need to free static link
-     themselves since they were allocated on the objstack.  */
-  if (static_links != NULL)
-    htab_delete (static_links);
 }
 
 /* Free all the object files at once and clean up their users.  */
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index 168f7fc..e0ff834 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -615,7 +615,7 @@ struct objfile
      Very few blocks have a static link, so it's more memory efficient to
      store these here rather than in struct block.  Static links must be
      allocated on the objfile's obstack.  */
-  htab_t static_links {};
+  htab_up static_links;
 };
 
 /* Declarations for functions defined in objfiles.c */
diff --git a/gdb/symfile.c b/gdb/symfile.c
index dd9c4ae..5736666 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -2549,7 +2549,7 @@ reread_symbols (void)
 	  objfile->sections = NULL;
 	  objfile->compunit_symtabs = NULL;
 	  objfile->template_symbols = NULL;
-	  objfile->static_links = NULL;
+	  objfile->static_links.reset (nullptr);
 
 	  /* obstack_init also initializes the obstack so it is
 	     empty.  We could use obstack_specify_allocation but


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

only message in thread, other threads:[~2019-04-19 20:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-19 20:28 [binutils-gdb] Make objfile::static_links an htab_up 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).