summaryrefslogtreecommitdiff
path: root/src/base/statistics.cc
diff options
context:
space:
mode:
authorNathan Binkert <nate@binkert.org>2009-04-08 22:22:50 -0700
committerNathan Binkert <nate@binkert.org>2009-04-08 22:22:50 -0700
commitc87c9950dfa094b0c3820f9abca721b0d32d2a09 (patch)
tree790df23111653cae3d714c20fabc4c166ff01727 /src/base/statistics.cc
parent18a30524d6afb397df1af764e8dc80ff4e7cdb98 (diff)
downloadgem5-c87c9950dfa094b0c3820f9abca721b0d32d2a09.tar.xz
stats: disallow duplicate statistic names.
Diffstat (limited to 'src/base/statistics.cc')
-rw-r--r--src/base/statistics.cc27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/base/statistics.cc b/src/base/statistics.cc
index 0a59248e7..1f3562384 100644
--- a/src/base/statistics.cc
+++ b/src/base/statistics.cc
@@ -32,7 +32,6 @@
#include <fstream>
#include <list>
#include <map>
-#include <set>
#include <string>
#include "base/callback.hh"
@@ -114,6 +113,14 @@ StorageParams::~StorageParams()
{
}
+typedef map<std::string, Info *> NameMapType;
+NameMapType &
+nameMap()
+{
+ static NameMapType the_map;
+ return the_map;
+}
+
int Info::id_count = 0;
int debug_break_id = -1;
@@ -130,6 +137,24 @@ Info::~Info()
{
}
+void
+Info::setName(const string &name)
+{
+ pair<NameMapType::iterator, bool> p =
+ nameMap().insert(make_pair(name, this));
+
+ Info *other = p.first->second;
+ bool result = p.second;
+
+ if (!result) {
+ // using other->name instead of just name to avoid a compiler
+ // warning. They should be the same.
+ panic("same statistic name used twice! name=%s\n", other->name);
+ }
+
+ this->name = name;
+}
+
bool
Info::less(Info *stat1, Info *stat2)
{