aboutsummaryrefslogtreecommitdiff
path: root/gold/fileread.h
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@google.com>2007-10-12 05:51:25 +0000
committerIan Lance Taylor <iant@google.com>2007-10-12 05:51:25 +0000
commite44fcf3bcf912ddf4ce94f9c3f71c253d473d692 (patch)
tree3f5de3fdbbc7b5ba332f8d2123f017c2e8437ce6 /gold/fileread.h
parent6ca8706da5d2154ee86544024f708fda30efba26 (diff)
downloadgdb-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.h')
-rw-r--r--gold/fileread.h23
1 files changed, 22 insertions, 1 deletions
diff --git a/gold/fileread.h b/gold/fileread.h
index 349a2b5..cf4b3ab 100644
--- a/gold/fileread.h
+++ b/gold/fileread.h
@@ -46,7 +46,7 @@ class File_read
public:
File_read()
: name_(), descriptor_(-1), size_(0), lock_count_(0), views_(),
- saved_views_(), contents_(NULL)
+ saved_views_(), contents_(NULL), mapped_bytes_(0)
{ }
~File_read();
@@ -109,11 +109,27 @@ class File_read
File_view*
get_lasting_view(off_t start, off_t size, bool cache);
+ // Dump statistical information to stderr.
+ static void
+ print_stats();
+
private:
// This class may not be copied.
File_read(const File_read&);
File_read& operator=(const File_read&);
+ // Total bytes mapped into memory during the link. This variable is
+ // only accessed from the main thread, when unlocking the object.
+ static unsigned long long total_mapped_bytes;
+
+ // Current number of bytes mapped into memory during the link. This
+ // variable is only accessed from the main thread.
+ static unsigned long long current_mapped_bytes;
+
+ // High water mark of bytes mapped into memory during the link.
+ // This variable is only accessed from the main thread.
+ static unsigned long long maximum_mapped_bytes;
+
// A view into the file.
class View
{
@@ -167,6 +183,7 @@ class File_read
bool mapped_;
};
+ friend class View;
friend class File_view;
// Find a view into the file.
@@ -219,6 +236,10 @@ class File_read
Saved_views saved_views_;
// Specified file contents. Used only for testing purposes.
const unsigned char* contents_;
+ // Total amount of space mapped into memory. This is only changed
+ // while the file is locked. When we unlock the file, we transfer
+ // the total to total_mapped_bytes, and reset this to zero.
+ size_t mapped_bytes_;
};
// A view of file data that persists even when the file is unlocked.