Commit cdee3dc6 authored by hjk's avatar hjk
Browse files

debugger: some start up state consolidation

parent f245ee6f
......@@ -191,6 +191,7 @@ public:
~DebuggerEnginePrivate() {}
public slots:
void doSetupEngine();
void doSetupInferior();
void doRunEngine();
void doShutdownEngine();
......@@ -198,6 +199,20 @@ public slots:
void doInterruptInferior();
void doFinishDebugger();
void queueSetupEngine()
{
m_engine->setState(EngineSetupRequested);
m_engine->showMessage(_("QUEUE: SETUP ENGINE"));
QTimer::singleShot(0, this, SLOT(doSetupEngine()));
}
void queueSetupInferior()
{
m_engine->setState(InferiorSetupRequested);
m_engine->showMessage(_("QUEUE: SETUP INFERIOR"));
QTimer::singleShot(0, this, SLOT(doSetupInferior()));
}
void queueRunEngine()
{
m_engine->setState(EngineRunRequested);
......@@ -528,10 +543,8 @@ void DebuggerEngine::startDebugger(DebuggerRunControl *runControl)
qDebug() << state());
d->m_lastGoodState = DebuggerNotReady;
d->m_targetState = DebuggerNotReady;
setState(EngineSetupRequested);
d->m_progress.setProgressValue(200);
setupEngine();
d->queueSetupEngine();
}
void DebuggerEngine::resetLocation()
......@@ -744,6 +757,19 @@ static bool isAllowedTransition(DebuggerState from, DebuggerState to)
return false;
}
void DebuggerEngine::setupSlaveEngine()
{
QTC_ASSERT(state() == DebuggerNotReady, /**/);
d->queueSetupEngine();
}
void DebuggerEnginePrivate::doSetupEngine()
{
m_engine->showMessage(_("CALL: SETUP ENGINE"));
QTC_ASSERT(state() == EngineSetupRequested, qDebug() << m_engine << state());
m_engine->setupEngine();
}
void DebuggerEngine::notifyEngineSetupFailed()
{
showMessage(_("NOTE: ENGINE SETUP FAILED"));
......@@ -761,16 +787,20 @@ void DebuggerEngine::notifyEngineSetupOk()
setState(EngineSetupOk);
showMessage(_("QUEUE: SETUP INFERIOR"));
if (isMasterEngine())
QTimer::singleShot(0, d, SLOT(doSetupInferior()));
d->queueSetupInferior();
}
void DebuggerEngine::setupSlaveInferior()
{
QTC_ASSERT(state() == EngineSetupOk, /**/);
d->queueSetupInferior();
}
void DebuggerEnginePrivate::doSetupInferior()
{
QTC_ASSERT(isMasterEngine(), return);
m_engine->showMessage(_("CALL: SETUP INFERIOR"));
QTC_ASSERT(state() == EngineSetupOk, qDebug() << m_engine << state());
QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << m_engine << state());
m_progress.setProgressValue(250);
m_engine->setState(InferiorSetupRequested);
m_engine->setupInferior();
}
......@@ -792,9 +822,15 @@ void DebuggerEngine::notifyInferiorSetupOk()
d->queueRunEngine();
}
void DebuggerEngine::runSlaveEngine()
{
QTC_ASSERT(isSlaveEngine(), return);
QTC_ASSERT(state() == InferiorSetupOk, /**/);
d->queueRunEngine();
}
void DebuggerEnginePrivate::doRunEngine()
{
QTC_ASSERT(isMasterEngine(), return);
m_engine->showMessage(_("CALL: RUN ENGINE"));
QTC_ASSERT(state() == EngineRunRequested, qDebug() << m_engine << state());
m_progress.setProgressValue(300);
......@@ -964,6 +1000,13 @@ void DebuggerEngine::notifyInferiorIll()
d->queueShutdownInferior();
}
void DebuggerEngine::shutdownSlaveEngine()
{
QTC_ASSERT(state() == InferiorShutdownOk, /**/);
setState(EngineShutdownRequested);
shutdownEngine();
}
void DebuggerEnginePrivate::doShutdownEngine()
{
QTC_ASSERT(isMasterEngine(), qDebug() << m_engine; return);
......
......@@ -345,6 +345,11 @@ protected:
bool isStateDebugging() const;
void setStateDebugging(bool on);
virtual void setupSlaveInferior();
virtual void setupSlaveEngine();
virtual void runSlaveEngine();
virtual void shutdownSlaveEngine();
private:
// Wrapper engine needs access to state of its subengines.
friend class Internal::QmlCppEngine;
......
......@@ -323,12 +323,8 @@ void QmlCppEngine::frameDown()
void QmlCppEngine::setupEngine()
{
qDebug() << "\nMASTER SETUP ENGINE";
QTC_ASSERT(d->m_cppEngine->state() == DebuggerNotReady, /**/);
QTC_ASSERT(d->m_qmlEngine->state() == DebuggerNotReady, /**/);
d->m_qmlEngine->setSilentState(EngineSetupRequested);
d->m_cppEngine->setSilentState(EngineSetupRequested);
d->m_qmlEngine->setupEngine(); // Always succeeds.
d->m_cppEngine->setupEngine(); // May fail.
d->m_qmlEngine->setupSlaveEngine();
d->m_cppEngine->setupSlaveEngine();
}
void QmlCppEngine::notifyEngineRunAndInferiorRunOk()
......@@ -358,23 +354,15 @@ void QmlCppEngine::notifyInferiorShutdownOk()
void QmlCppEngine::setupInferior()
{
qDebug() << "\nMASTER SETUP INFERIOR";
QTC_ASSERT(d->m_cppEngine->state() == EngineSetupOk, /**/);
QTC_ASSERT(d->m_qmlEngine->state() == EngineSetupOk, /**/);
d->m_qmlEngine->setSilentState(InferiorSetupRequested);
d->m_cppEngine->setSilentState(InferiorSetupRequested);
d->m_cppEngine->setupInferior();
d->m_qmlEngine->setupInferior();
d->m_qmlEngine->setupSlaveInferior();
d->m_cppEngine->setupSlaveInferior();
}
void QmlCppEngine::runEngine()
{
qDebug() << "\nMASTER RUN ENGINE";
QTC_ASSERT(d->m_cppEngine->state() == InferiorSetupOk, /**/);
QTC_ASSERT(d->m_qmlEngine->state() == InferiorSetupOk, /**/);
d->m_qmlEngine->setSilentState(EngineRunRequested);
d->m_cppEngine->setSilentState(EngineRunRequested);
d->m_cppEngine->runEngine();
d->m_qmlEngine->runEngine();
d->m_qmlEngine->runSlaveEngine();
d->m_cppEngine->runSlaveEngine();
}
void QmlCppEngine::shutdownInferior()
......@@ -386,12 +374,8 @@ void QmlCppEngine::shutdownInferior()
void QmlCppEngine::shutdownEngine()
{
qDebug() << "\nMASTER SHUTDOWN ENGINE";
QTC_ASSERT(d->m_cppEngine->state() == InferiorShutdownOk, /**/);
QTC_ASSERT(d->m_qmlEngine->state() == InferiorShutdownOk, /**/);
d->m_qmlEngine->setSilentState(EngineShutdownRequested);
d->m_cppEngine->setSilentState(EngineShutdownRequested);
d->m_qmlEngine->shutdownEngine();
d->m_cppEngine->shutdownEngine();
d->m_qmlEngine->shutdownSlaveEngine();
d->m_cppEngine->shutdownSlaveEngine();
}
void QmlCppEngine::setState(DebuggerState newState, bool forced)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment