systemc: Make orphans top level objects instead of panic-ing.
authorGabe Black <gabeblack@google.com>
Fri, 20 Jul 2018 00:12:31 +0000 (17:12 -0700)
committerGabe Black <gabeblack@google.com>
Tue, 11 Sep 2018 21:41:31 +0000 (21:41 +0000)
When a simulation ends, the sc_objects it contains are destroyed one
by one, not necessarily in hierarchy order. That means that a parent
object can legitimately be destroyed before its children. Instead of
panic-ing when that inevitably happens, this change makes gem5 turn
those children into top level objects.

Change-Id: Icad9c99310fbc3ddcadbbb4f8a990b4fbfe35bdf
Reviewed-on: https://gem5-review.googlesource.com/12035
Reviewed-by: Gabe Black <gabeblack@google.com>
Maintainer: Gabe Black <gabeblack@google.com>

src/systemc/core/object.cc
src/systemc/core/object.hh

index 68c52eb065a73532c7f78f58769b4b7cb7d9e449..39403ca34de84220afc0e8cd1355e85a00a7da63 100644 (file)
@@ -118,7 +118,12 @@ Object::operator = (const Object &)
 
 Object::~Object()
 {
-    panic_if(!children.empty(), "Parent object still has children.\n");
+    // Promote all children to be top level objects.
+    for (auto child: children) {
+        addObject(&topLevelObjects, child);
+        child->_gem5_object->parent = nullptr;
+    }
+    children.clear();
 
     if (parent)
         popObject(&parent->_gem5_object->children, _name);
index 1317986bcea7e23b2472b1f9dc8dae8889c744d1..c87a98b2dc970fd6265b5a39ada39d9c8ecd0c04 100644 (file)
@@ -99,7 +99,6 @@ class Object
     Objects children;
     Events events;
     sc_core::sc_object *parent;
-    ObjectsIt parentIt;
 
     sc_core::sc_attr_cltn cltn;
 };