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] Introduce objfile::reset_psymtabs


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

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

    Introduce objfile::reset_psymtabs
    
    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
    2019-01-10  Tom Tromey  <tom@tromey.com>
    
    	* symfile.c (reread_symbols): Call objfile->reset_psymtabs.
    	* objfiles.h (objfile::reset_psymtabs): New method.

Diff:
---
 gdb/ChangeLog  |  5 +++++
 gdb/objfiles.h |  9 +++++++++
 gdb/symfile.c  | 12 +-----------
 3 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 207194d..211867d 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
 2019-01-10  Tom Tromey  <tom@tromey.com>
 
+	* symfile.c (reread_symbols): Call objfile->reset_psymtabs.
+	* objfiles.h (objfile::reset_psymtabs): New method.
+
+2019-01-10  Tom Tromey  <tom@tromey.com>
+
 	* symmisc.c (print_symbol_bcache_statistics): Update.
 	(print_objfile_statistics): Update.
 	* symfile.c (reread_symbols): Update.
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index 94b415c..cde025d 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -293,6 +293,15 @@ struct objfile
 
   DISABLE_COPY_AND_ASSIGN (objfile);
 
+  /* Reset the storage for the partial symbol tables.  */
+
+  void reset_psymtabs ()
+  {
+    psymbol_map.clear ();
+    partial_symtabs.reset (new psymtab_storage (this));
+  }
+
+
   /* All struct objfile's are chained together by their next pointers.
      The program space field "objfiles"  (frequently referenced via
      the macro "object_files") points to the first link in this chain.  */
diff --git a/gdb/symfile.c b/gdb/symfile.c
index d407461..0419712 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -2524,23 +2524,13 @@ reread_symbols (void)
 	  memcpy (offsets, objfile->section_offsets,
 		  SIZEOF_N_SECTION_OFFSETS (num_offsets));
 
-	  /* FIXME: Do we have to free a whole linked list, or is this
-	     enough?  */
-	  objfile->partial_symtabs->global_psymbols.clear ();
-	  objfile->partial_symtabs->static_psymbols.clear ();
-
-	  /* Free the obstacks for non-reusable objfiles.  */
-	  psymbol_bcache_free (objfile->partial_symtabs->psymbol_cache);
-	  objfile->partial_symtabs->psymbol_cache = psymbol_bcache_init ();
+	  objfile->reset_psymtabs ();
 
 	  /* NB: after this call to obstack_free, objfiles_changed
 	     will need to be called (see discussion below).  */
 	  obstack_free (&objfile->objfile_obstack, 0);
 	  objfile->sections = NULL;
 	  objfile->compunit_symtabs = NULL;
-	  objfile->partial_symtabs->psymtabs = NULL;
-	  objfile->partial_symtabs->psymtabs_addrmap = NULL;
-	  objfile->partial_symtabs->free_psymtabs = NULL;
 	  objfile->template_symbols = NULL;
 	  objfile->static_links = NULL;


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