QmlCppDebugger: Decouple states of engines

The main engine now follows mostly the state of the gdb engine,
only if a breakpoint is hit/while stepping the state of the qml
engine is used. This allows us to hit C++ breakpoints at any time
(also when the qml engine hasn't been able to connect yet), and
also fixes the invalid transition warnings.

Change-Id: If67a56fd28b098952be2606d0a46e04c27835f66
Reviewed-on: http://codereview.qt-project.org/5897
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
This commit is contained in:
Kai Koehne
2011-09-29 16:49:18 +02:00
parent 21e25b835b
commit 732334a0b8
3 changed files with 137 additions and 149 deletions

View File

@@ -1208,6 +1208,12 @@ void DebuggerEngine::quitDebugger()
case InferiorRunOk: case InferiorRunOk:
d->doInterruptInferior(); d->doInterruptInferior();
break; break;
case EngineRunRequested:
notifyEngineRunFailed();
break;
case EngineRunFailed:
case DebuggerFinished:
break;
default: default:
// FIXME: We should disable the actions connected to that. // FIXME: We should disable the actions connected to that.
notifyInferiorIll(); notifyInferiorIll();

View File

@@ -283,16 +283,18 @@ void QmlCppEngine::updateAll()
void QmlCppEngine::attemptBreakpointSynchronization() void QmlCppEngine::attemptBreakpointSynchronization()
{ {
if (d->m_qmlEngine->state() == InferiorRunOk d->m_cppEngine->attemptBreakpointSynchronization();
|| d->m_qmlEngine->state() == InferiorRunRequested
|| d->m_qmlEngine->state() == InferiorStopOk switch (d->m_qmlEngine->state()) {
|| d->m_qmlEngine->state() == InferiorStopRequested) { case InferiorRunOk:
// We expect both engines to be set up correctly before hitting case InferiorRunRequested:
// any breakpoints, therefore ignore any breakpoints that would case InferiorStopOk: // fall through
// be hit before QDeclarativeEngine is set up. case InferiorStopRequested:
d->m_cppEngine->attemptBreakpointSynchronization(); d->m_qmlEngine->attemptBreakpointSynchronization();
break;
default:
break;
} }
d->m_qmlEngine->attemptBreakpointSynchronization();
} }
bool QmlCppEngine::acceptsBreakpoint(BreakpointModelId id) const bool QmlCppEngine::acceptsBreakpoint(BreakpointModelId id) const
@@ -470,6 +472,7 @@ void QmlCppEngine::runEngine()
void QmlCppEngine::shutdownInferior() void QmlCppEngine::shutdownInferior()
{ {
EDEBUG("\nMASTER SHUTDOWN INFERIOR"); EDEBUG("\nMASTER SHUTDOWN INFERIOR");
d->m_cppEngine->quitDebugger();
d->m_qmlEngine->quitDebugger(); d->m_qmlEngine->quitDebugger();
} }
@@ -498,173 +501,150 @@ void QmlCppEngine::slaveEngineStateChanged
EDEBUG(" OTHER ENGINE: " << otherEngine << otherEngine->state()); EDEBUG(" OTHER ENGINE: " << otherEngine << otherEngine->state());
EDEBUG(" COMBINED ENGINE: " << this << state() << isDying()); EDEBUG(" COMBINED ENGINE: " << this << state() << isDying());
switch (newState) { // Idea is to follow the state of the cpp engine,
// except where we are stepping in QML
case DebuggerNotReady: if (slaveEngine == d->m_cppEngine) {
break; switch (newState) {
case DebuggerNotReady:
// Can this ever happen?
break;
case EngineSetupRequested:
QTC_CHECK(state() == EngineSetupRequested);
break;
case EngineSetupRequested: case EngineSetupFailed:
break; qmlEngine()->quitDebugger();
notifyEngineSetupFailed();
break;
case EngineSetupFailed: case EngineSetupOk:
notifyEngineSetupFailed();
break;
case EngineSetupOk:
if (otherEngine->state() == EngineSetupOk)
notifyEngineSetupOk(); notifyEngineSetupOk();
else break;
EDEBUG("... WAITING FOR OTHER ENGINE SETUP...");
break;
case InferiorSetupRequested:
break;
case InferiorSetupRequested: case InferiorSetupFailed:
break; qmlEngine()->quitDebugger();
case InferiorSetupFailed:
if (otherEngine->state() == InferiorRunOk)
otherEngine->quitDebugger();
else
notifyInferiorSetupFailed(); notifyInferiorSetupFailed();
break; break;
case InferiorSetupOk: case InferiorSetupOk:
if (otherEngine->state() == InferiorSetupOk)
notifyInferiorSetupOk(); notifyInferiorSetupOk();
else break;
EDEBUG("... WAITING FOR OTHER INFERIOR SETUP...");
break;
case EngineRunRequested:
break;
case EngineRunRequested: case EngineRunFailed:
break; qmlEngine()->quitDebugger();
case EngineRunFailed:
if (otherEngine->state() == InferiorRunOk)
otherEngine->quitDebugger();
else
notifyEngineRunFailed(); notifyEngineRunFailed();
break; break;
case InferiorUnrunnable: case InferiorUnrunnable:
break; notifyInferiorUnrunnable();
break;
case InferiorRunRequested: case InferiorRunRequested:
break; break;
case InferiorRunOk: case InferiorRunOk:
if (state() == EngineRunRequested) { if (state() == EngineRunRequested)
if (otherEngine->state() == InferiorRunOk) {
attemptBreakpointSynchronization();
notifyEngineRunAndInferiorRunOk(); notifyEngineRunAndInferiorRunOk();
} else { else if (state() == InferiorRunRequested)
EDEBUG("... WAITING FOR OTHER INFERIOR RUN");
}
} else {
if (otherEngine->state() == InferiorRunOk) {
EDEBUG("PLANNED INFERIOR RUN");
if (state() == InferiorStopOk) {
notifyInferiorRunRequested();
}
notifyInferiorRunOk(); notifyInferiorRunOk();
} else if (otherEngine->state() == InferiorStopOk) { break;
EDEBUG("PLANNED SINGLE INFERIOR RUN");
case InferiorRunFailed:
qmlEngine()->quitDebugger();
notifyInferiorRunFailed();
break;
case InferiorStopRequested:
break;
case InferiorStopOk:
if (isDying()) {
EDEBUG("... CPP ENGINE STOPPED DURING SHUTDOWN ");
if (state() == InferiorStopRequested)
notifyInferiorStopOk();
} else { } else {
EDEBUG(" **** INFERIOR RUN NOT OK ****"); if (d->m_activeEngine != cppEngine()) {
showStatusMessage(tr("Cpp debugger activated"));
d->m_activeEngine = cppEngine();
}
switch (state()) {
case InferiorStopRequested:
EDEBUG("... CPP ENGINE STOPPED EXPECTEDLY");
notifyInferiorStopOk();
break;
case EngineRunRequested:
EDEBUG("... CPP ENGINE STOPPED ON STARTUP");
notifyEngineRunAndInferiorStopOk();
break;
default:
QTC_CHECK(state() == InferiorRunOk);
EDEBUG("... CPP ENGINE STOPPED SPONTANEOUSLY");
notifyInferiorSpontaneousStop();
break;
}
} }
} break;
break;
case InferiorRunFailed: case InferiorStopFailed:
notifyInferiorRunFailed(); notifyInferiorStopFailed();
break; break;
case InferiorStopRequested: case InferiorExitOk:
break; qmlEngine()->quitDebugger();
notifyInferiorExited();
break;
case InferiorStopOk: case InferiorShutdownRequested:
if (isDying()) { break;
EDEBUG("... AN INFERIOR STOPPED DURING SHUTDOWN ");
if (state() == InferiorStopRequested) {
notifyInferiorStopOk();
}
} else {
if (slaveEngine != d->m_activeEngine) {
QString engineName = slaveEngine == d->m_cppEngine
? QLatin1String("C++") : QLatin1String("QML");
showStatusMessage(tr("%1 debugger activated").arg(engineName));
d->m_activeEngine = slaveEngine;
}
if (otherEngine->state() == InferiorStopOk) {
EDEBUG("... BOTH STOPPED ");
} else if (otherEngine->state() == InferiorShutdownOk) {
EDEBUG("... STOPP ");
} else if (state() == InferiorStopRequested) {
EDEBUG("... AN INFERIOR STOPPED EXPECTEDLY");
notifyInferiorStopOk();
} else if (state() == EngineRunRequested) {
EDEBUG("... AN INFERIOR FAILED STARTUP, OTHER STOPPED EXPECTEDLY");
// wait for failure notification from other engine
} else {
EDEBUG("... AN INFERIOR STOPPED SPONTANEOUSLY");
notifyInferiorSpontaneousStop();
}
}
break;
case InferiorStopFailed: case InferiorShutdownFailed:
notifyInferiorStopFailed(); notifyInferiorShutdownFailed();
break; break;
case InferiorExitOk: case InferiorShutdownOk:
break; if (state() == InferiorShutdownRequested)
case InferiorShutdownRequested:
break;
case InferiorShutdownFailed:
notifyInferiorShutdownFailed();
break;
case InferiorShutdownOk:
if (otherEngine->state() == InferiorShutdownOk) {
if (state() == InferiorRunOk)
notifyInferiorExited();
else
notifyInferiorShutdownOk(); notifyInferiorShutdownOk();
} else if (otherEngine->state() == InferiorRunOk) { break;
otherEngine->quitDebugger();
} else if (otherEngine->state() == InferiorStopOk) {
otherEngine->quitDebugger();
} else if (otherEngine->state() == EngineRunFailed) {
EDEBUG("... INFERIOR STOPPED, OTHER ENGINE FAILED");
notifyEngineRunFailed();
} else if (otherEngine->state() == InferiorSetupFailed) {
EDEBUG("... INFERIOR STOPPED, OTHER INFERIOR FAILED");
notifyInferiorSetupFailed();
}
break;
case EngineShutdownRequested: case EngineShutdownRequested:
break; break;
case EngineShutdownFailed: case EngineShutdownFailed:
notifyEngineShutdownFailed(); qmlEngine()->quitDebugger();
break; notifyEngineShutdownFailed();
break;
case EngineShutdownOk: case EngineShutdownOk: {
if (otherEngine->state() == EngineShutdownOk) qmlEngine()->quitDebugger();
; // Wait for DebuggerFinished.
else
EDEBUG("... WAITING FOR OTHER ENGINE SHUTDOWN...");
break;
case DebuggerFinished:
if (otherEngine->state() == DebuggerFinished)
notifyEngineShutdownOk(); notifyEngineShutdownOk();
else break;
EDEBUG("... WAITING FOR OTHER DEBUGGER TO FINISH..."); }
break;
case DebuggerFinished:
break;
}
} else {
// QML engine state change
if (newState == InferiorStopOk) {
if (d->m_activeEngine != qmlEngine()) {
showStatusMessage(tr("QML debugger activated"));
d->m_activeEngine = qmlEngine();
}
if (state() == InferiorRunOk)
notifyInferiorSpontaneousStop();
else
notifyInferiorStopOk();
} else if (newState == InferiorRunOk) {
if (d->m_activeEngine == qmlEngine())
notifyInferiorRunOk();
}
} }
} }

View File

@@ -249,8 +249,10 @@ void QmlEngine::connectionError(QAbstractSocket::SocketError socketError)
if (socketError == QAbstractSocket::RemoteHostClosedError) if (socketError == QAbstractSocket::RemoteHostClosedError)
showMessage(tr("QML Debugger: Remote host closed connection."), StatusBar); showMessage(tr("QML Debugger: Remote host closed connection."), StatusBar);
notifyInferiorSpontaneousStop(); if (!isSlaveEngine()) { // normal flow for slave engine when gdb exits
notifyInferiorIll(); notifyInferiorSpontaneousStop();
notifyInferiorIll();
}
} }
void QmlEngine::serviceConnectionError(const QString &serviceName) void QmlEngine::serviceConnectionError(const QString &serviceName)