From: Tom Tromey Date: Sun, 1 Nov 2020 16:51:13 +0000 (-0700) Subject: Remove partial symbol statistics X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0684bb51b5207aed1d76098ebaca6243f9c168e7;p=binutils-gdb.git Remove partial symbol statistics The "n_psyms" statistic in the per-objfile stats is not really needed, but its use requires passing the objfile to add_psymbol. This patch removes the field in favor of counting the psyms when needed. Note that this is not exactly equivalent -- in the old approach, a psymbol can in theory be created and then the psymtab discarded, which would increment the counter. This does not seem very important to me. I rewrote the code to count partial symbols; though TBH I think that this information is not really very useful. gdb/ChangeLog 2020-11-01 Tom Tromey * symmisc.c (count_psyms): New function. (print_objfile_statistics): Use it. * psymtab.c (append_psymbol_to_list): Remove. (partial_symtab::add_psymbol): Inline append_psymbol_to_list. * objfiles.h (struct objstats) : Remove. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 967317a0eba..f34932d16b8 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,11 @@ +2020-11-01 Tom Tromey + + * symmisc.c (count_psyms): New function. + (print_objfile_statistics): Use it. + * psymtab.c (append_psymbol_to_list): Remove. + (partial_symtab::add_psymbol): Inline append_psymbol_to_list. + * objfiles.h (struct objstats) : Remove. + 2020-11-01 Tom Tromey * dbxread.c (dbx_end_psymtab): Update. diff --git a/gdb/objfiles.h b/gdb/objfiles.h index 549977ad257..bf3d7fcf253 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -194,9 +194,6 @@ struct obj_section struct objstats { - /* Number of partial symbols read. */ - int n_psyms = 0; - /* Number of full symbols read. */ int n_syms = 0; diff --git a/gdb/psymtab.c b/gdb/psymtab.c index b3deef4107d..dc802a60f3c 100644 --- a/gdb/psymtab.c +++ b/gdb/psymtab.c @@ -1523,17 +1523,6 @@ add_psymbol_to_bcache (const partial_symbol &psymbol, struct objfile *objfile, (&psymbol, sizeof (struct partial_symbol), added)); } -/* Helper function, adds partial symbol to the given partial symbol list. */ - -static void -append_psymbol_to_list (std::vector &list, - struct partial_symbol *psym, - struct objfile *objfile) -{ - list.push_back (psym); - OBJSTAT (objfile, n_psyms++); -} - /* See psympriv.h. */ void @@ -1555,7 +1544,7 @@ partial_symtab::add_psymbol (const partial_symbol &psymbol, = (where == psymbol_placement::STATIC ? static_psymbols : global_psymbols); - append_psymbol_to_list (list, psym, objfile); + list.push_back (psym); } /* See psympriv.h. */ diff --git a/gdb/symmisc.c b/gdb/symmisc.c index fc56cfa9381..8d748b9ebf7 100644 --- a/gdb/symmisc.c +++ b/gdb/symmisc.c @@ -39,6 +39,7 @@ #include "readline/tilde.h" #include "psymtab.h" +#include "psympriv.h" /* Unfortunately for debugging, stderr is usually a macro. This is painful when calling functions that take FILE *'s from the debugger. @@ -73,6 +74,20 @@ print_symbol_bcache_statistics (void) } } +/* Count the number of partial symbols in OBJFILE. */ + +static int +count_psyms (struct objfile *objfile) +{ + int count = 0; + for (partial_symtab *pst : objfile->psymtabs ()) + { + count += pst->global_psymbols.size (); + count += pst->static_psymbols.size (); + } + return count; +} + void print_objfile_statistics (void) { @@ -89,9 +104,11 @@ print_objfile_statistics (void) if (objfile->per_bfd->n_minsyms > 0) printf_filtered (_(" Number of \"minimal\" symbols read: %d\n"), objfile->per_bfd->n_minsyms); - if (OBJSTAT (objfile, n_psyms) > 0) + + int n_psyms = count_psyms (objfile); + if (n_psyms > 0) printf_filtered (_(" Number of \"partial\" symbols read: %d\n"), - OBJSTAT (objfile, n_psyms)); + n_psyms); if (OBJSTAT (objfile, n_syms) > 0) printf_filtered (_(" Number of \"full\" symbols read: %d\n"), OBJSTAT (objfile, n_syms));