diff options
author | Ian Lance Taylor <iant@google.com> | 2007-10-12 05:51:25 +0000 |
---|---|---|
committer | Ian Lance Taylor <iant@google.com> | 2007-10-12 05:51:25 +0000 |
commit | e44fcf3bcf912ddf4ce94f9c3f71c253d473d692 (patch) | |
tree | 3f5de3fdbbc7b5ba332f8d2123f017c2e8437ce6 /gold/fileread.cc | |
parent | 6ca8706da5d2154ee86544024f708fda30efba26 (diff) | |
download | gdb-e44fcf3bcf912ddf4ce94f9c3f71c253d473d692.zip gdb-e44fcf3bcf912ddf4ce94f9c3f71c253d473d692.tar.gz gdb-e44fcf3bcf912ddf4ce94f9c3f71c253d473d692.tar.bz2 |
Add --stats option to print runtime and memory usage statistics.
Diffstat (limited to 'gold/fileread.cc')
-rw-r--r-- | gold/fileread.cc | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/gold/fileread.cc b/gold/fileread.cc index 88ac126..97773d2 100644 --- a/gold/fileread.cc +++ b/gold/fileread.cc @@ -48,6 +48,8 @@ File_read::View::~View() if (::munmap(const_cast<unsigned char*>(this->data_), this->size_) != 0) fprintf(stderr, _("%s: munmap failed: %s\n"), program_name, strerror(errno)); + + File_read::current_mapped_bytes -= this->size_; } } @@ -72,6 +74,11 @@ File_read::View::is_locked() // Class File_read. +// The File_read static variables. +unsigned long long File_read::total_mapped_bytes; +unsigned long long File_read::current_mapped_bytes; +unsigned long long File_read::maximum_mapped_bytes; + // The File_read class is designed to support file descriptor caching, // but this is not currently implemented. @@ -146,7 +153,15 @@ File_read::unlock() gold_assert(this->lock_count_ > 0); --this->lock_count_; if (this->lock_count_ == 0) - this->clear_views(false); + { + File_read::total_mapped_bytes += this->mapped_bytes_; + File_read::current_mapped_bytes += this->mapped_bytes_; + this->mapped_bytes_ = 0; + if (File_read::current_mapped_bytes > File_read::maximum_mapped_bytes) + File_read::maximum_mapped_bytes = File_read::current_mapped_bytes; + + this->clear_views(false); + } } bool @@ -289,6 +304,8 @@ File_read::find_or_make_view(off_t start, off_t size, bool cache) gold_exit(false); } + this->mapped_bytes_ += psize; + const unsigned char* pbytes = static_cast<const unsigned char*>(p); v = new File_read::View(poff, psize, pbytes, cache, true); } @@ -355,6 +372,17 @@ File_read::clear_views(bool destroying) } } +// Print statistical information to stderr. This is used for --stats. + +void +File_read::print_stats() +{ + fprintf(stderr, _("%s: total bytes mapped for read: %llu\n"), + program_name, File_read::total_mapped_bytes); + fprintf(stderr, _("%s: maximum bytes mapped for read at one time: %llu\n"), + program_name, File_read::maximum_mapped_bytes); +} + // Class File_view. File_view::~File_view() |