Chun-Chen TK Hsu has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/20680 )

Change subject: stats: Ignore non-Group objects in stat hierarchy
......................................................................

stats: Ignore non-Group objects in stat hierarchy

Some objects, such as SystemC modules, are not a subclass of
Stat::Group. Calling the addStatGroup function on them causes errors.
This changes ignores those objects that are not Stat::Group in the stat
hierarchy.

Signed-off-by: Chun-Chen TK Hsu <chunchen...@google.com>
Change-Id: I9b62419417b7af7331461fbfaf15e45a4ee2b35f
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/20680
Reviewed-by: Jason Lowe-Power <ja...@lowepower.com>
Reviewed-by: Andreas Sandberg <andreas.sandb...@arm.com>
Maintainer: Jason Lowe-Power <ja...@lowepower.com>
Maintainer: Andreas Sandberg <andreas.sandb...@arm.com>
Tested-by: kokoro <noreply+kok...@google.com>
---
M src/python/m5/stats/__init__.py
1 file changed, 13 insertions(+), 1 deletion(-)

Approvals:
Jason Lowe-Power: Looks good to me, but someone else must approve; Looks good to me, approved
  Andreas Sandberg: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass



diff --git a/src/python/m5/stats/__init__.py b/src/python/m5/stats/__init__.py
index 77ed5e8..4b118ea 100644
--- a/src/python/m5/stats/__init__.py
+++ b/src/python/m5/stats/__init__.py
@@ -257,7 +257,19 @@
             for idx, obj in enumerate(obj):
                 _bind_obj("{}{}".format(name, idx), obj)
         else:
-            root.addStatGroup(name, obj.getCCObject())
+            # We need this check because not all obj.getCCObject() is an
+ # instance of Stat::Group. For example, sc_core::sc_module, the C++ + # class of SystemC_ScModule, is not a subclass of Stat::Group. So
+            # it will cause a type error if obj is a SystemC_ScModule when
+            # calling addStatGroup().
+            if isinstance(obj.getCCObject(), _m5.stats.Group):
+                parent = root
+                while parent:
+                    if hasattr(parent, 'addStatGroup'):
+                        parent.addStatGroup(name, obj.getCCObject())
+                        break
+                    parent = parent.get_parent();
+
             _bindStatHierarchy(obj)

     for name, obj in root._children.items():

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/20680
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: I9b62419417b7af7331461fbfaf15e45a4ee2b35f
Gerrit-Change-Number: 20680
Gerrit-PatchSet: 4
Gerrit-Owner: Chun-Chen TK Hsu <chunchen...@google.com>
Gerrit-Reviewer: Andreas Sandberg <andreas.sandb...@arm.com>
Gerrit-Reviewer: Chun-Chen TK Hsu <chunchen...@google.com>
Gerrit-Reviewer: Gabe Black <gabebl...@google.com>
Gerrit-Reviewer: Jason Lowe-Power <ja...@lowepower.com>
Gerrit-Reviewer: kokoro <noreply+kok...@google.com>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to