From: Andreas Sandberg Date: Tue, 24 Sep 2019 17:46:23 +0000 (+0100) Subject: stats: Don't output index in vectors of length 1 X-Git-Tag: v19.0.0.0~517 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4f52287500cca19325cc58e9cbef374526572e44;p=gem5.git stats: Don't output index in vectors of length 1 New-world stats didn't implement the old gem5 quirk where the index of an element in a vector of size 1 is ignored. This affects the object path when printed in a stat file. Implement the same quirk as the original code to make sure names of old- and new-world stats are compatible. Change-Id: I12696d40baaed2d0bb1ef061e87c3b1d0f4bb4b1 Signed-off-by: Andreas Sandberg Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/21163 Tested-by: kokoro Reviewed-by: Daniel Carvalho --- diff --git a/src/python/m5/stats/__init__.py b/src/python/m5/stats/__init__.py index ab11a9d61..e2e1909f7 100644 --- a/src/python/m5/stats/__init__.py +++ b/src/python/m5/stats/__init__.py @@ -257,8 +257,11 @@ def _bindStatHierarchy(root): if isNullPointer(obj): return if m5.SimObject.isSimObjectVector(obj): - for idx, obj in enumerate(obj): - _bind_obj("{}{}".format(name, idx), obj) + if len(obj) == 1: + _bind_obj(name, obj[0]) + else: + for idx, obj in enumerate(obj): + _bind_obj("{}{}".format(name, idx), obj) else: # We need this check because not all obj.getCCObject() is an # instance of Stat::Group. For example, sc_core::sc_module, the C++