diff --git a/src/base/statistics.hh b/src/base/statistics.hh index e0d268000d..6a7e23e21a 100644 --- a/src/base/statistics.hh +++ b/src/base/statistics.hh @@ -255,7 +255,7 @@ class DataWrap : public InfoAccess parent->addStat(info); if (name) { - info->setName(parent, name); + info->setName(name, parent == nullptr); info->flags.set(display); } diff --git a/src/base/stats/info.cc b/src/base/stats/info.cc index 85bf698bc6..c6024e7d84 100644 --- a/src/base/stats/info.cc +++ b/src/base/stats/info.cc @@ -111,13 +111,7 @@ validateStatName(const std::string &name) } void -Info::setName(const std::string &name) -{ - setName(nullptr, name); -} - -void -Info::setName(const Group *parent, const std::string &name) +Info::setName(const std::string &name, bool old_style) { if (!validateStatName(name)) panic("invalid stat name '%s'", name); @@ -126,12 +120,10 @@ Info::setName(const Group *parent, const std::string &name) // old-style stats without a parent group. New-style stats should // be unique since their names should correspond to a member // variable. - if (!parent) { + if (old_style) { auto p = nameMap().insert(make_pair(name, this)); - if (!p.second) - panic("same statistic name used twice! name=%s\n", - name); + panic_if(!p.second, "same statistic name used twice! name=%s\n", name); } this->name = name; diff --git a/src/base/stats/info.hh b/src/base/stats/info.hh index 6665102d5b..0e7e39883c 100644 --- a/src/base/stats/info.hh +++ b/src/base/stats/info.hh @@ -38,8 +38,6 @@ GEM5_DEPRECATED_NAMESPACE(Stats, statistics); namespace statistics { -class Group; - typedef uint16_t FlagsType; typedef ::Flags Flags; @@ -101,9 +99,15 @@ class Info Info(); virtual ~Info(); - /** Set the name of this statistic */ - void setName(const std::string &name); - void setName(const Group *parent, const std::string &name); + /** + * Set the name of this statistic. Special handling must be done when + * creating an old-style statistic (i.e., stats without a parent group). + * + * @param name The new name. + * @param old_style Whether we are using the old style. + */ + void setName(const std::string &name, bool old_style=true); + void setSeparator(std::string _sep) { separatorString = _sep;} /**