This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Replace psymbol_allocation_list with std::vector
- From: Simon Marchi <simon dot marchi at ericsson dot com>
- To: Tom Tromey <tom at tromey dot com>
- Cc: <gdb-patches at sourceware dot org>
- Date: Fri, 13 Oct 2017 23:01:55 -0400
- Subject: Re: [PATCH] Replace psymbol_allocation_list with std::vector
- Authentication-results: sourceware.org; auth=none
- Authentication-results: spf=none (sender IP is ) smtp.mailfrom=simon dot marchi at ericsson dot com;
- References: <1507903080-10737-1-git-send-email-simon.marchi@ericsson.com> <87k1zypxdk.fsf@tromey.com>
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
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?
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))