base-stats: Print the name of stats sharing the same name
authorHoa Nguyen <hoanguyen@ucdavis.edu>
Sat, 5 Dec 2020 07:57:14 +0000 (23:57 -0800)
committerHoa Nguyen <hoanguyen@ucdavis.edu>
Thu, 10 Dec 2020 05:19:37 +0000 (05:19 +0000)
Having stats of the same name within the same group result in an error.
This commit adds the name to the error message to make it easier to find
the Stats::Group caused the error.

Change-Id: I4010d5d949d1c943d2dd1e2fca0aafcbf62e3ee1
Signed-off-by: Hoa Nguyen <hoanguyen@ucdavis.edu>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/38337
Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br>
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
src/base/stats/group.cc

index f1eda1d6dc6cc2f70d800c03b936fb73e1ab298a..de546cda6d2646b2740c67bf7edff4aa3068926a 100644 (file)
@@ -37,8 +37,7 @@
 
 #include "base/stats/group.hh"
 
-#include <cassert>
-
+#include "base/logging.hh"
 #include "base/stats/info.hh"
 #include "base/trace.hh"
 #include "debug/Stats.hh"
@@ -112,7 +111,8 @@ Group::addStat(Stats::Info *info)
 void
 Group::addStatGroup(const char *name, Group *block)
 {
-    assert(statGroups.find(name) == statGroups.end());
+    panic_if(statGroups.find(name) != statGroups.end(),
+             "Stats of the same group share the same name `%s`.\n", name);
 
     statGroups[name] = block;
 }