From 834846f80259522612d966657d68db3fb10ea90c Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Fri, 5 Oct 2018 15:31:50 -0700 Subject: [PATCH] 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 --- src/systemc/core/event.cc | 10 ++++++++++ src/systemc/core/event.hh | 2 ++ src/systemc/core/object.cc | 3 +++ 3 files changed, 15 insertions(+) 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 -- 2.30.2