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 <gabeblack@google.com>
Maintainer: Gabe Black <gabeblack@google.com>
This commit is contained in:
Gabe Black
2018-10-05 15:31:50 -07:00
parent f4a671e1eb
commit 834846f802
3 changed files with 15 additions and 0 deletions

View 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;

View File

@@ -138,6 +138,8 @@ class Event
}
}
void clearParent();
private:
sc_core::sc_event *_sc_event;

View 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