forked from qt-creator/qt-creator
Debugger: Mark unexpected state transitions of mixed engine
... prominently with red color in the log. Change-Id: Id9d86227bbcc269a0870ff93e372f28ab4b2618b Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
@@ -52,6 +52,15 @@ enum { debug = 0 };
|
|||||||
|
|
||||||
#define EDEBUG(s) do { if (debug) qDebug() << s; } while (0)
|
#define EDEBUG(s) do { if (debug) qDebug() << s; } while (0)
|
||||||
|
|
||||||
|
#define CHECK_STATE(s) \
|
||||||
|
do { \
|
||||||
|
if (state() != s) { \
|
||||||
|
showMessage(QString::fromLatin1("UNEXPECTED STATE: %1 WANTED: %2 IN %3:%4") \
|
||||||
|
.arg(state()).arg(s).arg(QLatin1String(__FILE__)).arg(__LINE__), LogError); \
|
||||||
|
QTC_ASSERT(false, qDebug() << state() << s); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
DebuggerEngine *createQmlCppEngine(const DebuggerStartParameters &sp,
|
DebuggerEngine *createQmlCppEngine(const DebuggerStartParameters &sp,
|
||||||
QString *errorMessage)
|
QString *errorMessage)
|
||||||
{
|
{
|
||||||
@@ -497,8 +506,8 @@ void QmlCppEngine::slaveEngineStateChanged
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EngineSetupRequested: {
|
case EngineSetupRequested: {
|
||||||
// set by queueSetupEngine()
|
// Set by queueSetupEngine()
|
||||||
QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state());
|
CHECK_STATE(EngineSetupRequested);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EngineSetupFailed: {
|
case EngineSetupFailed: {
|
||||||
@@ -511,8 +520,8 @@ void QmlCppEngine::slaveEngineStateChanged
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case InferiorSetupRequested: {
|
case InferiorSetupRequested: {
|
||||||
// set by queueSetupInferior()
|
// Set by queueSetupInferior()
|
||||||
QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
|
CHECK_STATE(InferiorSetupRequested);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case InferiorSetupFailed: {
|
case InferiorSetupFailed: {
|
||||||
@@ -539,20 +548,20 @@ void QmlCppEngine::slaveEngineStateChanged
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case InferiorRunRequested: {
|
case InferiorRunRequested: {
|
||||||
// might be set already by notifyInferiorRunRequested()
|
// Might be set already by notifyInferiorRunRequested()
|
||||||
QTC_ASSERT(state() == InferiorRunRequested
|
if (state() != InferiorRunRequested) {
|
||||||
|| state() == InferiorStopOk, qDebug() << state());
|
CHECK_STATE(InferiorStopOk);
|
||||||
if (state() != InferiorRunRequested)
|
|
||||||
notifyInferiorRunRequested();
|
notifyInferiorRunRequested();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case InferiorRunOk: {
|
case InferiorRunOk: {
|
||||||
QTC_ASSERT(state() == EngineRunRequested
|
|
||||||
|| state() == InferiorRunRequested, qDebug() << state());
|
|
||||||
if (state() == EngineRunRequested)
|
if (state() == EngineRunRequested)
|
||||||
notifyEngineRunAndInferiorRunOk();
|
notifyEngineRunAndInferiorRunOk();
|
||||||
else if (state() == InferiorRunRequested)
|
else if (state() == InferiorRunRequested)
|
||||||
notifyInferiorRunOk();
|
notifyInferiorRunOk();
|
||||||
|
else
|
||||||
|
QTC_ASSERT(false, qDebug() << state());
|
||||||
|
|
||||||
if (qmlEngine()->state() == InferiorStopOk) {
|
if (qmlEngine()->state() == InferiorStopOk) {
|
||||||
// track qml engine again
|
// track qml engine again
|
||||||
@@ -569,17 +578,14 @@ void QmlCppEngine::slaveEngineStateChanged
|
|||||||
}
|
}
|
||||||
case InferiorStopRequested: {
|
case InferiorStopRequested: {
|
||||||
if (m_activeEngine == cppEngine()) {
|
if (m_activeEngine == cppEngine()) {
|
||||||
// might be set by doInterruptInferior()
|
if (state() == InferiorRunOk) {
|
||||||
QTC_ASSERT(state() == InferiorStopRequested
|
|
||||||
|| state() == InferiorRunOk, qDebug() << state());
|
|
||||||
if (state() == InferiorRunOk)
|
|
||||||
setState(InferiorStopRequested);
|
setState(InferiorStopRequested);
|
||||||
} else {
|
} else {
|
||||||
// we're debugging qml, but got an interrupt, or abort
|
// Might be set by doInterruptInferior()
|
||||||
QTC_ASSERT(state() == InferiorRunOk
|
CHECK_STATE(InferiorStopRequested);
|
||||||
|| state() == InferiorStopOk
|
}
|
||||||
|| state() == InferiorRunRequested, qDebug() << state());
|
} else {
|
||||||
|
// We're debugging qml, but got an interrupt, or abort
|
||||||
if (state() == InferiorRunOk) {
|
if (state() == InferiorRunOk) {
|
||||||
setState(InferiorStopRequested);
|
setState(InferiorStopRequested);
|
||||||
} else if (state() == InferiorStopOk) {
|
} else if (state() == InferiorStopOk) {
|
||||||
@@ -589,6 +595,8 @@ void QmlCppEngine::slaveEngineStateChanged
|
|||||||
} else if (state() == InferiorRunRequested) {
|
} else if (state() == InferiorRunRequested) {
|
||||||
notifyInferiorRunOk();
|
notifyInferiorRunOk();
|
||||||
setState(InferiorStopRequested);
|
setState(InferiorStopRequested);
|
||||||
|
} else {
|
||||||
|
QTC_ASSERT(false, qDebug() << state());
|
||||||
}
|
}
|
||||||
// now track cpp engine
|
// now track cpp engine
|
||||||
setActiveEngine(m_cppEngine);
|
setActiveEngine(m_cppEngine);
|
||||||
@@ -613,12 +621,6 @@ void QmlCppEngine::slaveEngineStateChanged
|
|||||||
showStatusMessage(tr("C++ debugger activated"));
|
showStatusMessage(tr("C++ debugger activated"));
|
||||||
setActiveEngine(m_cppEngine);
|
setActiveEngine(m_cppEngine);
|
||||||
}
|
}
|
||||||
|
|
||||||
QTC_ASSERT(state() == InferiorStopRequested
|
|
||||||
|| state() == InferiorRunRequested
|
|
||||||
|| state() == EngineRunRequested
|
|
||||||
|| state() == InferiorRunOk
|
|
||||||
|| state() == InferiorStopOk, qDebug() << state());
|
|
||||||
switch (state()) {
|
switch (state()) {
|
||||||
case InferiorStopRequested:
|
case InferiorStopRequested:
|
||||||
EDEBUG("... CPP ENGINE STOPPED EXPECTEDLY");
|
EDEBUG("... CPP ENGINE STOPPED EXPECTEDLY");
|
||||||
@@ -636,13 +638,14 @@ void QmlCppEngine::slaveEngineStateChanged
|
|||||||
// can happen if qml engine was active
|
// can happen if qml engine was active
|
||||||
notifyInferiorRunFailed();
|
notifyInferiorRunFailed();
|
||||||
default:
|
default:
|
||||||
|
CHECK_STATE(InferiorStopOk);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case InferiorStopFailed: {
|
case InferiorStopFailed: {
|
||||||
QTC_ASSERT(state() == InferiorStopRequested, qDebug() << state());
|
CHECK_STATE(InferiorStopRequested);
|
||||||
notifyInferiorStopFailed();
|
notifyInferiorStopFailed();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -653,16 +656,17 @@ void QmlCppEngine::slaveEngineStateChanged
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case InferiorShutdownRequested: {
|
case InferiorShutdownRequested: {
|
||||||
// might be set by queueShutdownInferior() already
|
if (state() == InferiorStopOk) {
|
||||||
QTC_ASSERT(state() == InferiorShutdownRequested
|
|
||||||
|| state() == InferiorStopOk, qDebug() << state());
|
|
||||||
if (state() == InferiorStopOk)
|
|
||||||
setState(InferiorShutdownRequested);
|
setState(InferiorShutdownRequested);
|
||||||
|
} else {
|
||||||
|
// might be set by queueShutdownInferior() already
|
||||||
|
CHECK_STATE(InferiorShutdownRequested);
|
||||||
|
}
|
||||||
qmlEngine()->quitDebugger();
|
qmlEngine()->quitDebugger();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case InferiorShutdownFailed: {
|
case InferiorShutdownFailed: {
|
||||||
QTC_ASSERT(state() == InferiorShutdownRequested, qDebug() << state());
|
CHECK_STATE(InferiorShutdownRequested);
|
||||||
notifyInferiorShutdownFailed();
|
notifyInferiorShutdownFailed();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -677,22 +681,22 @@ void QmlCppEngine::slaveEngineStateChanged
|
|||||||
}
|
}
|
||||||
case EngineShutdownRequested: {
|
case EngineShutdownRequested: {
|
||||||
// set by queueShutdownEngine()
|
// set by queueShutdownEngine()
|
||||||
QTC_ASSERT(state() == EngineShutdownRequested, qDebug() << state());
|
CHECK_STATE(EngineShutdownRequested);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EngineShutdownFailed: {
|
case EngineShutdownFailed: {
|
||||||
QTC_ASSERT(state() == EngineShutdownRequested, qDebug() << state());
|
CHECK_STATE(EngineShutdownRequested);
|
||||||
notifyEngineShutdownFailed();
|
notifyEngineShutdownFailed();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EngineShutdownOk: {
|
case EngineShutdownOk: {
|
||||||
QTC_ASSERT(state() == EngineShutdownRequested, qDebug() << state());
|
CHECK_STATE(EngineShutdownRequested);
|
||||||
notifyEngineShutdownOk();
|
notifyEngineShutdownOk();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DebuggerFinished: {
|
case DebuggerFinished: {
|
||||||
// set by queueFinishDebugger()
|
// set by queueFinishDebugger()
|
||||||
QTC_ASSERT(state() == DebuggerFinished, qDebug() << state());
|
CHECK_STATE(DebuggerFinished);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -714,19 +718,17 @@ void QmlCppEngine::slaveEngineStateChanged
|
|||||||
setActiveEngine(m_qmlEngine);
|
setActiveEngine(m_qmlEngine);
|
||||||
}
|
}
|
||||||
|
|
||||||
QTC_ASSERT(state() == InferiorRunOk
|
|
||||||
|| state() == InferiorStopRequested
|
|
||||||
|| state() == InferiorShutdownRequested, qDebug() << state());
|
|
||||||
|
|
||||||
if (state() == InferiorRunOk)
|
if (state() == InferiorRunOk)
|
||||||
notifyInferiorSpontaneousStop();
|
notifyInferiorSpontaneousStop();
|
||||||
else if (state() == InferiorStopRequested)
|
else if (state() == InferiorStopRequested)
|
||||||
notifyInferiorStopOk();
|
notifyInferiorStopOk();
|
||||||
|
else
|
||||||
|
CHECK_STATE(InferiorShutdownRequested);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (newState == InferiorRunOk) {
|
} else if (newState == InferiorRunOk) {
|
||||||
if (m_activeEngine == qmlEngine()) {
|
if (m_activeEngine == qmlEngine()) {
|
||||||
QTC_ASSERT(state() == InferiorRunRequested, qDebug() << state());
|
CHECK_STATE(InferiorRunRequested);
|
||||||
notifyInferiorRunOk();
|
notifyInferiorRunOk();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user