summaryrefslogtreecommitdiff
path: root/base
diff options
context:
space:
mode:
authorNathan Binkert <binkertn@umich.edu>2003-12-20 16:25:48 -0500
committerNathan Binkert <binkertn@umich.edu>2003-12-20 16:25:48 -0500
commit520442b01afb3742a6dde552b8d62351d2200aba (patch)
tree52cd2f5735eb6c50fd44b7d208f7d9266a2dd208 /base
parent598a24073385e421b1369637f64f06edd5a4d11e (diff)
downloadgem5-520442b01afb3742a6dde552b8d62351d2200aba.tar.xz
Fix a bunch of memory leak type bugs, and add some better
checking in places to make sure stuff is behaving properly. base/statistics.cc: separate the per stat check from the general stats check. We always want the general stuff to happen base/statistics.hh: - separate the per stat check from the general stats check. we always want the general stuff to happen - make every stat check that its bin is at least initialized - set the vector2d x and y coordinates in init to prevent an uninitialized memory access test/Makefile: don't need sim_time.o to test stats test/stattest.cc: don't make x and y the same on the 2d test so that we make sure that the two dimensions are correct --HG-- extra : convert_revision : 81320325056ac1c09f6842474fb6ee3bcc030a8e
Diffstat (limited to 'base')
-rw-r--r--base/statistics.cc2
-rw-r--r--base/statistics.hh28
2 files changed, 19 insertions, 11 deletions
diff --git a/base/statistics.cc b/base/statistics.cc
index 726ea3c60..81b8856ca 100644
--- a/base/statistics.cc
+++ b/base/statistics.cc
@@ -344,7 +344,7 @@ StatData::less(StatData *stat1, StatData *stat2)
}
bool
-StatData::check() const
+StatData::baseCheck() const
{
if (!init) {
#ifdef STAT_DEBUG
diff --git a/base/statistics.hh b/base/statistics.hh
index ed3278e4a..3fc019edc 100644
--- a/base/statistics.hh
+++ b/base/statistics.hh
@@ -184,7 +184,8 @@ struct StatData
* use
* @return true for success
*/
- virtual bool check() const;
+ virtual bool check() const = 0;
+ bool baseCheck() const;
/**
* Checks if the first stat's name is alphabetically less than the second.
@@ -215,6 +216,7 @@ class ScalarData : public ScalarDataBase
ScalarData(T &stat) : s(stat) {}
virtual bool binned() const { return s.binned(); }
+ virtual bool check() const { return s.check(); }
virtual result_t val() const { return s.val(); }
virtual result_t total() const { return s.total(); }
virtual void reset() { s.reset(); }
@@ -254,6 +256,7 @@ class VectorData : public VectorDataBase
VectorData(T &stat) : s(stat) {}
virtual bool binned() const { return s.binned(); }
+ virtual bool check() const { return s.check(); }
virtual bool zero() const { return s.zero(); }
virtual void reset() { s.reset(); }
@@ -309,6 +312,7 @@ class DistData : public DistDataBase
DistData(T &stat) : s(stat) {}
virtual bool binned() const { return s.binned(); }
+ virtual bool check() const { return s.check(); }
virtual void reset() { s.reset(); }
virtual bool zero() const { return s.zero(); }
virtual void update() { return s.update(this); }
@@ -348,6 +352,7 @@ class VectorDistData : public VectorDistDataBase
VectorDistData(T &stat) : s(stat) {}
virtual bool binned() const { return T::bin_t::binned; }
+ virtual bool check() const { return s.check(); }
virtual void reset() { s.reset(); }
virtual size_t size() const { return s.size(); }
virtual bool zero() const { return s.zero(); }
@@ -388,12 +393,13 @@ class Vector2dData : public Vector2dDataBase
Vector2dData(T &stat) : s(stat) {}
virtual bool binned() const { return T::bin_t::binned; }
+ virtual bool check() const { return s.check(); }
virtual void reset() { s.reset(); }
virtual bool zero() const { return s.zero(); }
virtual void update()
{
Vector2dDataBase::update();
- return s.update(this);
+ s.update(this);
}
};
@@ -854,6 +860,8 @@ class ScalarBase : public DataAccess
*/
bool binned() const { return bin_t::binned; }
+ bool check() const { return bin.initialized(); }
+
/**
* Reset stat value to default
*/
@@ -963,7 +971,7 @@ class VectorBase : public DataAccess
return false;
}
- bool check() const { return true; }
+ bool check() const { return bin.initialized(); }
void reset() { bin.reset(); }
public:
@@ -1167,8 +1175,6 @@ class Vector2dBase : public DataAccess
void update(Vector2dDataBase *data)
{
- data->x = x;
- data->y = y;
int size = this->size();
data->vec.resize(size);
for (int i = 0; i < size; ++i)
@@ -1188,7 +1194,7 @@ class Vector2dBase : public DataAccess
*/
void reset() { bin.reset(); }
- bool check() { return true; }
+ bool check() { return bin.initialized(); }
};
template <typename T, template <typename T> class Storage, class Bin>
@@ -1665,7 +1671,7 @@ class DistBase : public DataAccess
bin.reset();
}
- bool check() { return true; }
+ bool check() { return bin.initialized(); }
};
template <typename T, template <typename T> class Storage, class Bin>
@@ -1718,7 +1724,7 @@ class VectorDistBase : public DataAccess
*/
void reset() { bin.reset(); }
- bool check() { return true; }
+ bool check() { return bin.initialized(); }
void update(VectorDistDataBase *base)
{
int size = this->size();
@@ -2509,8 +2515,8 @@ class Vector2d : public WrapVec2d<Vector2d<T, Bin>, Vector2dBase<T, StatStor, Bi
{
public:
Vector2d &init(size_t _x, size_t _y) {
- x = _x;
- y = _y;
+ statData()->x = x = _x;
+ statData()->y = y = _y;
bin.init(x * y, params);
setInit();
@@ -2732,6 +2738,8 @@ class FormulaBase : public DataAccess
*/
bool binned() const;
+ bool check() const { return true; }
+
/**
* Formulas don't need to be reset
*/