aboutsummaryrefslogtreecommitdiff
path: root/gold/merge.cc
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@google.com>2007-12-18 21:24:10 +0000
committerIan Lance Taylor <iant@google.com>2007-12-18 21:24:10 +0000
commit38c5e8b493ec72879187ffca3d8533acd2c014a5 (patch)
treeda1699c0936f8c22611469fe0bafae8e117a6658 /gold/merge.cc
parentcb2dde36a0abb8f59c950187153a245264759fa1 (diff)
downloadgdb-38c5e8b493ec72879187ffca3d8533acd2c014a5.zip
gdb-38c5e8b493ec72879187ffca3d8533acd2c014a5.tar.gz
gdb-38c5e8b493ec72879187ffca3d8533acd2c014a5.tar.bz2
Print statistics about merge sections with --stats.
Diffstat (limited to 'gold/merge.cc')
-rw-r--r--gold/merge.cc64
1 files changed, 64 insertions, 0 deletions
diff --git a/gold/merge.cc b/gold/merge.cc
index 25aac76..65acf82 100644
--- a/gold/merge.cc
+++ b/gold/merge.cc
@@ -414,6 +414,8 @@ Output_merge_data::do_add_input_section(Relobj* object, unsigned int shndx)
if (len % entsize != 0)
return false;
+ this->input_count_ += len / entsize;
+
for (section_size_type i = 0; i < len; i += entsize, p += entsize)
{
// Add the constant to the section contents. If we find that it
@@ -467,6 +469,18 @@ Output_merge_data::do_write_to_buffer(unsigned char* buffer)
memcpy(buffer, this->p_, this->len_);
}
+// Print merge stats to stderr.
+
+void
+Output_merge_data::do_print_merge_stats(const char* section_name)
+{
+ fprintf(stderr,
+ _("%s: %s merged constants size: %lu; input: %zu; output: %zu\n"),
+ program_name, section_name,
+ static_cast<unsigned long>(this->entsize()),
+ this->input_count_, this->hashtable_.size());
+}
+
// Class Output_merge_string.
// Add an input section to a merged string section.
@@ -489,6 +503,8 @@ Output_merge_string<Char_type>::do_add_input_section(Relobj* object,
return false;
}
+ size_t count = 0;
+
// The index I is in bytes, not characters.
section_size_type i = 0;
while (i < len)
@@ -512,8 +528,11 @@ Output_merge_string<Char_type>::do_add_input_section(Relobj* object,
p = pl + 1;
i += bytelen_with_null;
+ ++count;
}
+ this->input_count_ += count;
+
return true;
}
@@ -565,6 +584,51 @@ Output_merge_string<Char_type>::do_write_to_buffer(unsigned char* buffer)
this->stringpool_.write_to_buffer(buffer, this->data_size());
}
+// Return the name of the types of string to use with
+// do_print_merge_stats.
+
+template<typename Char_type>
+const char*
+Output_merge_string<Char_type>::string_name()
+{
+ gold_unreachable();
+ return NULL;
+}
+
+template<>
+const char*
+Output_merge_string<char>::string_name()
+{
+ return "strings";
+}
+
+template<>
+const char*
+Output_merge_string<uint16_t>::string_name()
+{
+ return "16-bit strings";
+}
+
+template<>
+const char*
+Output_merge_string<uint32_t>::string_name()
+{
+ return "32-bit strings";
+}
+
+// Print merge stats to stderr.
+
+template<typename Char_type>
+void
+Output_merge_string<Char_type>::do_print_merge_stats(const char* section_name)
+{
+ char buf[200];
+ snprintf(buf, sizeof buf, "%s merged %s", section_name, this->string_name());
+ fprintf(stderr, _("%s: %s input: %zu\n"),
+ program_name, buf, this->input_count_);
+ this->stringpool_.print_stats(buf);
+}
+
// Instantiate the templates we need.
template