systemc: Detach child events in the Object destructor.
authorGabe Black <gabeblack@google.com>
Fri, 5 Oct 2018 22:31:50 +0000 (15:31 -0700)
committerGabe Black <gabeblack@google.com>
Tue, 16 Oct 2018 00:56:25 +0000 (00:56 +0000)
This way they don't try to detach themselves from a parent object which
no longer exists.

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

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

index aa4a7131546473df2fcb5ea25beded7f3104dd91..120b51476d2211d48e8164331107d7aa3e65587c 100644 (file)
@@ -191,6 +191,16 @@ Event::triggered() const
     return _triggeredStamp == scheduler.changeStamp();
 }
 
+void
+Event::clearParent()
+{
+    if (!parent)
+        return;
+    Object::getFromScObject(parent)->delChildEvent(sc_event());
+    parent = nullptr;
+    topLevelEvents.emplace(topLevelEvents.end(), sc_event());
+}
+
 Events topLevelEvents;
 Events allEvents;
 
index 2d620c91bb0aa4cf4764414994749d97ae9071ea..532d983435547cdea44b6fa8035f2c92ef9976b5 100644 (file)
@@ -138,6 +138,8 @@ class Event
         }
     }
 
+    void clearParent();
+
   private:
     sc_core::sc_event *_sc_event;
 
index 91e3cb36a449a59030f5d3ea8d3f2b3b0ba8da10..781e6d6d11125b0f4769c1cbdd7dbf323782bf09 100644 (file)
@@ -145,6 +145,9 @@ Object::~Object()
     }
     children.clear();
 
+    for (auto event: events)
+        Event::getFromScEvent(event)->clearParent();
+
     if (parent)
         popObject(&parent->_gem5_object->children, _name);
     else