From 31aa3aa925d201b8a330d77e0553ce3135ebae6d Mon Sep 17 00:00:00 2001 From: adrian Date: Fri, 5 Oct 2012 11:48:39 +0000 Subject: [PATCH] bugfixes in overall coroutine handling to allow the overwriting of onTrigger. git-svn-id: https://www4.informatik.uni-erlangen.de/i4svn/danceos/trunk/devel/fail@1721 8c4709b5-6ec9-48aa-a5cd-a96041d1645a --- src/core/efw/CoroutineManager.cc | 6 ++++-- src/core/sal/SimulatorController.cc | 9 ++++++++- src/core/sal/perf/BreakpointControllerSlice.ah | 12 ++++++++++-- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/core/efw/CoroutineManager.cc b/src/core/efw/CoroutineManager.cc index 82547149..4dd35e4c 100644 --- a/src/core/efw/CoroutineManager.cc +++ b/src/core/efw/CoroutineManager.cc @@ -24,6 +24,9 @@ CoroutineManager::~CoroutineManager() { } void CoroutineManager::toggle(ExperimentFlow* flow) { + assert((co_current() != m_simCoro || flow != SIM_FLOW) && + "FATAL ERROR: We are already in the simulators coroutine flow! \ + (Maybe you forgot to overwrite the (default) onTrigger() method?)"); m_togglerstack.push(co_current()); //std::cerr << "CORO toggle from " << m_togglerstack.top() << " to "; if (flow == SIM_FLOW) { @@ -86,8 +89,7 @@ ExperimentFlow* CoroutineManager::getCurrent() if (it->second == cr) return it->first; - assert(false && "FATAL ERROR: The current flow could not be retrieved!"); - return 0; + return NULL; } const ExperimentFlow* CoroutineManager::SIM_FLOW = NULL; diff --git a/src/core/sal/SimulatorController.cc b/src/core/sal/SimulatorController.cc index 4b67c762..ff924ca8 100644 --- a/src/core/sal/SimulatorController.cc +++ b/src/core/sal/SimulatorController.cc @@ -13,7 +13,14 @@ int interrupt_to_fire = -1; bool SimulatorController::addListener(BaseListener* li) { assert(li != NULL && "FATAL ERROR: Argument (ptr) cannot be NULL!"); - m_LstList.add(li, m_Flows.getCurrent()); + // If addListener() was called from onTrigger(), there is no parent + // to retrieve/assign. In this case, we simple expect the parent-member + // to be valid ('as is'). (Otherwise, the current flow is retrieved by + // calling CoroutineManager::getCurrent().) + ExperimentFlow* pFlow = m_Flows.getCurrent(); + if (pFlow == CoroutineManager::SIM_FLOW) + pFlow = li->getParent(); + m_LstList.add(li, pFlow); // Call the common postprocessing function: if (!li->onAddition()) { // If the return value signals "false"..., m_LstList.remove(li); // ...skip the addition diff --git a/src/core/sal/perf/BreakpointControllerSlice.ah b/src/core/sal/perf/BreakpointControllerSlice.ah index 06c9a3c0..c4b8d4cd 100644 --- a/src/core/sal/perf/BreakpointControllerSlice.ah +++ b/src/core/sal/perf/BreakpointControllerSlice.ah @@ -19,7 +19,11 @@ public: bool addListener(fail::BPSingleListener* sli) { assert(sli != NULL && "FATAL ERROR: Argument (ptr) cannot be NULL!"); - m_LstList.add(sli, m_Flows.getCurrent()); + // Check whether we were called from onTrigger (see SimulatorController.cc@addListener). + ExperimentFlow* pFlow = m_Flows.getCurrent(); + if (pFlow == CoroutineManager::SIM_FLOW) + pFlow = sli->getParent(); + m_LstList.add(sli, pFlow); // Call the common postprocessing function: if (!sli->onAddition()) { // If the return value signals "false"..., m_LstList.remove(sli); // ...skip the addition @@ -32,7 +36,11 @@ public: bool addListener(fail::BPRangeListener* rli) { assert(rli != NULL && "FATAL ERROR: Argument (ptr) cannot be NULL!"); - m_LstList.add(rli, m_Flows.getCurrent()); + // Check whether we were called from onTrigger (see above). + ExperimentFlow* pFlow = m_Flows.getCurrent(); + if (pFlow == CoroutineManager::SIM_FLOW) + pFlow = rli->getParent(); + m_LstList.add(rli, pFlow); // Call the common postprocessing function: if (!rli->onAddition()) { // If the return value signals "false"..., m_LstList.remove(rli); // ...skip the addition