From: Gabe Black Date: Fri, 5 Oct 2018 22:31:50 +0000 (-0700) Subject: systemc: Detach child events in the Object destructor. X-Git-Tag: v19.0.0.0~1524 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=834846f80259522612d966657d68db3fb10ea90c;p=gem5.git systemc: Detach child events in the Object destructor. 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 Maintainer: Gabe Black --- diff --git a/src/systemc/core/event.cc b/src/systemc/core/event.cc index aa4a71315..120b51476 100644 --- a/src/systemc/core/event.cc +++ b/src/systemc/core/event.cc @@ -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; diff --git a/src/systemc/core/event.hh b/src/systemc/core/event.hh index 2d620c91b..532d98343 100644 --- a/src/systemc/core/event.hh +++ b/src/systemc/core/event.hh @@ -138,6 +138,8 @@ class Event } } + void clearParent(); + private: sc_core::sc_event *_sc_event; diff --git a/src/systemc/core/object.cc b/src/systemc/core/object.cc index 91e3cb36a..781e6d6d1 100644 --- a/src/systemc/core/object.cc +++ b/src/systemc/core/object.cc @@ -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