From: Nikos Nikoleris Date: Tue, 7 Apr 2020 15:04:41 +0000 (+0100) Subject: base, python, sim: Add support for resoving a stat using its name X-Git-Tag: v20.0.0.0~102 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1afe851d1574615aafc56339d25af5488a1a4291;p=gem5.git base, python, sim: Add support for resoving a stat using its name This CL adds resolve, a function in the Stats namespace that allows access to a stat as specified by its name. Change-Id: I4fa8bed394b4cb35d9c6cf5d8db062b8d6bb9ca5 Signed-off-by: Nikos Nikoleris Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/27891 Reviewed-by: Andreas Sandberg Maintainer: Andreas Sandberg Tested-by: kokoro --- diff --git a/src/base/statistics.cc b/src/base/statistics.cc index 036029b4a..e4315baf9 100644 --- a/src/base/statistics.cc +++ b/src/base/statistics.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Arm Limited + * Copyright (c) 2019-2020 Arm Limited * All rights reserved. * * The license below extends only to copyright in the software and shall @@ -54,6 +54,7 @@ #include "base/str.hh" #include "base/time.hh" #include "base/trace.hh" +#include "sim/root.hh" using namespace std; @@ -573,6 +574,17 @@ reset() fatal("No registered Stats::reset handler"); } +const Info * +resolve(const std::string &name) +{ + const auto &it = nameMap().find(name); + if (it != nameMap().cend()) { + return it->second; + } else { + return Root::root()->resolveStat(name); + } +} + void registerDumpCallback(Callback *cb) { diff --git a/src/base/statistics.hh b/src/base/statistics.hh index 24a0d06de..8f665fe0e 100644 --- a/src/base/statistics.hh +++ b/src/base/statistics.hh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Arm Limited + * Copyright (c) 2019-2020 Arm Limited * All rights reserved. * * The license below extends only to copyright in the software and shall @@ -3349,6 +3349,7 @@ void dump(); void reset(); void enable(); bool enabled(); +const Info* resolve(const std::string &name); /** * Register reset and dump handlers. These are the functions which