Replace psymbol_allocation_list with std::vector

Message ID 112a72c3-bc3e-1c2a-c108-a4ff19146902@ericsson.com
State New, archived
Headers

Commit Message

Simon Marchi Oct. 14, 2017, 3:01 a.m. UTC
  On 2017-10-13 05:10 PM, Tom Tromey wrote:
>>>>>> "Simon" == Simon Marchi <simon.marchi@ericsson.com> writes:
> 
> Simon> psymbol_allocation_list is basically a vector implementation.  We can
> Simon> replace it with an std::vector, now that objfile has been C++-ified.
> 
> I think this is very nice.
> 
> I wonder how worthwhile it would be to call shrink_to_fit on the vectors
> in require_partial_symbols.

It can't really hurt.  Since those lists are not expected to change after that
point, it seems useless to keep the extra unused memory in the vector.  I would
apply this fixup to my patch, WDYT?
  

Comments

Tom Tromey Oct. 14, 2017, 4:49 a.m. UTC | #1
>>>>> "Simon" == Simon Marchi <simon.marchi@ericsson.com> writes:

Simon> It can't really hurt.  Since those lists are not expected to change after that
Simon> point, it seems useless to keep the extra unused memory in the vector.  I would
Simon> apply this fixup to my patch, WDYT?

It seems reasonable, thanks.  I suppose sometimes it could be slower.
But on the other hand it seems likely to regularly waste memory in the
current state.

Tom
  

Patch

diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 36ae83a..762f9ce 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -86,6 +86,12 @@  require_partial_symbols (struct objfile *objfile, int verbose)
 	      gdb_flush (gdb_stdout);
 	    }
 	  (*objfile->sf->sym_read_psymbols) (objfile);
+
+	  /* Partial symbol lists are not expected to changed after this
+	     point, get rid of the unused memory.  */
+	  objfile->global_psymbols.shrink_to_fit ();
+	  objfile->static_psymbols.shrink_to_fit ();
+
 	  if (verbose)
 	    {
 	      if (!objfile_has_symbols (objfile))