From abaa399568d8dea6b959350e387968eb746115c9 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 4 Dec 2007 23:11:35 +0000 Subject: [PATCH] Print symbol table statistics with --stats. --- gold/main.cc | 1 + gold/symtab.cc | 14 ++++++++++++++ gold/symtab.h | 4 ++++ 3 files changed, 19 insertions(+) diff --git a/gold/main.cc b/gold/main.cc index a4dcc5a42a5..fe56aade444 100644 --- a/gold/main.cc +++ b/gold/main.cc @@ -106,6 +106,7 @@ main(int argc, char** argv) File_read::print_stats(); fprintf(stderr, _("%s: output file size: %lld bytes\n"), program_name, static_cast(layout.output_file_size())); + symtab.print_stats(); } gold_exit(errors.error_count() == 0); diff --git a/gold/symtab.cc b/gold/symtab.cc index b2901ab9faa..6094c2af1e0 100644 --- a/gold/symtab.cc +++ b/gold/symtab.cc @@ -1897,6 +1897,20 @@ Symbol_table::sized_write_section_symbol(const Output_section* os, of->write_output_view(offset, sym_size, pov); } +// Print statistical information to stderr. This is used for --stats. + +void +Symbol_table::print_stats() const +{ +#if defined(HAVE_TR1_UNORDERED_MAP) || defined(HAVE_EXT_HASH_MAP) + fprintf(stderr, _("%s: symbol table entries: %zu; buckets: %zu\n"), + program_name, this->table_.size(), this->table_.bucket_count()); +#else + fprintf(stderr, _("%s: symbol table entries: %zu\n"), + program_name, this->table_.size()); +#endif +} + // We check for ODR violations by looking for symbols with the same // name for which the debugging information reports that they were // defined in different source locations. When comparing the source diff --git a/gold/symtab.h b/gold/symtab.h index 9c7fb0935c7..6d2577bbdd1 100644 --- a/gold/symtab.h +++ b/gold/symtab.h @@ -1127,6 +1127,10 @@ class Symbol_table void write_section_symbol(const Output_section*, Output_file*, off_t) const; + // Dump statistical information to stderr. + void + print_stats() const; + private: Symbol_table(const Symbol_table&); Symbol_table& operator=(const Symbol_table&); -- 2.30.2