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 #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(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 pc_count;