summaryrefslogtreecommitdiff
path: root/cpu
diff options
context:
space:
mode:
Diffstat (limited to 'cpu')
-rw-r--r--cpu/profile.cc8
-rw-r--r--cpu/profile.hh2
2 files changed, 9 insertions, 1 deletions
diff --git a/cpu/profile.cc b/cpu/profile.cc
index f4aa81c2b..1a38792a0 100644
--- a/cpu/profile.cc
+++ b/cpu/profile.cc
@@ -29,6 +29,8 @@
#include <string>
#include "base/bitfield.hh"
+#include "base/callback.hh"
+#include "base/statistics.hh"
#include "base/trace.hh"
#include "cpu/base.hh"
#include "cpu/exec_context.hh"
@@ -80,12 +82,16 @@ ProfileNode::clear()
}
FunctionProfile::FunctionProfile(const SymbolTable *_symtab)
- : symtab(_symtab)
+ : reset(0), symtab(_symtab)
{
+ reset = new MakeCallback<FunctionProfile, &FunctionProfile::clear>(this);
+ Stats::registerResetCallback(reset);
}
FunctionProfile::~FunctionProfile()
{
+ if (reset)
+ delete reset;
}
ProfileNode *
diff --git a/cpu/profile.hh b/cpu/profile.hh
index b7526ab6a..58cd7e79f 100644
--- a/cpu/profile.hh
+++ b/cpu/profile.hh
@@ -54,9 +54,11 @@ class ProfileNode
void clear();
};
+class Callback;
class FunctionProfile
{
private:
+ Callback *reset;
const SymbolTable *symtab;
ProfileNode top;
std::map<Addr, Counter> pc_count;