summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Binkert <nate@binkert.org>2009-02-23 12:03:06 -0800
committerNathan Binkert <nate@binkert.org>2009-02-23 12:03:06 -0800
commitf69ea20fc64c240b9f97ce584716693aa9b79d58 (patch)
tree451589cd1b8985597fe81e6e7b841b8af7e5a5bd
parent3fa9812e1d572cd06f95cec138b87d590160e4b4 (diff)
downloadgem5-f69ea20fc64c240b9f97ce584716693aa9b79d58.tar.xz
stats: cleanup static stats to make startup work.
This is mainly to allow the unit test to run without requiring the standard M5 stats from being initialized (e.g. sim_seconds, sim_ticks, host_seconds)
-rw-r--r--src/sim/stat_control.cc31
-rw-r--r--src/sim/stats.hh1
2 files changed, 21 insertions, 11 deletions
diff --git a/src/sim/stat_control.cc b/src/sim/stat_control.cc
index 25c5be104..2dcf4798d 100644
--- a/src/sim/stat_control.cc
+++ b/src/sim/stat_control.cc
@@ -44,14 +44,6 @@
using namespace std;
-Stats::Formula hostInstRate;
-Stats::Formula hostTickRate;
-Stats::Value hostMemory;
-Stats::Value hostSeconds;
-
-Stats::Value simTicks;
-Stats::Value simInsts;
-Stats::Value simFreq;
Stats::Formula simSeconds;
namespace Stats {
@@ -84,8 +76,21 @@ statElapsedTicks()
SimTicksReset simTicksReset;
-void
-initSimStats()
+struct Global
+{
+ Stats::Formula hostInstRate;
+ Stats::Formula hostTickRate;
+ Stats::Value hostMemory;
+ Stats::Value hostSeconds;
+
+ Stats::Value simTicks;
+ Stats::Value simInsts;
+ Stats::Value simFreq;
+
+ Global();
+};
+
+Global::Global()
{
simInsts
.functor(BaseCPU::numSimulatedInstructions)
@@ -146,6 +151,12 @@ initSimStats()
registerResetCallback(&simTicksReset);
}
+void
+initSimStats()
+{
+ static Global global;
+}
+
class _StatEvent : public Event
{
private:
diff --git a/src/sim/stats.hh b/src/sim/stats.hh
index 97251283d..481c36cf6 100644
--- a/src/sim/stats.hh
+++ b/src/sim/stats.hh
@@ -34,6 +34,5 @@
#include "base/statistics.hh"
extern Stats::Formula simSeconds;
-extern Stats::Value simTicks;
#endif // __SIM_SIM_STATS_HH__