From 83c13ff1919a9a123648985009ba9ff4a4c0c52d Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 14 Dec 2017 09:36:41 +0100 Subject: [PATCH] Debugger: Combine the InferiorShutdown{Ok,Failed} states ... into a InferiorShutdownFinished. Change-Id: Icb5394f38f52f7cf300dc83f4eb8f2f0777bbcba Reviewed-by: David Schulz --- share/qtcreator/debugger/lldbbridge.py | 6 ++-- src/plugins/debugger/cdb/cdbengine.cpp | 28 ++++++---------- src/plugins/debugger/debuggerconstants.h | 3 +- src/plugins/debugger/debuggerengine.cpp | 41 ++++++++--------------- src/plugins/debugger/debuggerengine.h | 3 +- src/plugins/debugger/debuggerplugin.cpp | 34 +++++++++---------- src/plugins/debugger/gdb/gdbengine.cpp | 14 ++++---- src/plugins/debugger/lldb/lldbengine.cpp | 6 ++-- src/plugins/debugger/pdb/pdbengine.cpp | 2 +- src/plugins/debugger/qml/qmlcppengine.cpp | 9 ++--- src/plugins/debugger/qml/qmlengine.cpp | 2 +- 11 files changed, 56 insertions(+), 92 deletions(-) diff --git a/share/qtcreator/debugger/lldbbridge.py b/share/qtcreator/debugger/lldbbridge.py index 85f5d8be98..cf3482ad73 100644 --- a/share/qtcreator/debugger/lldbbridge.py +++ b/share/qtcreator/debugger/lldbbridge.py @@ -1511,13 +1511,11 @@ class Dumper(DumperBase): def shutdownInferior(self, args): self.isShuttingDown_ = True - if self.process is None: - self.reportState('inferiorshutdownok') - else: + if self.process is not None: state = self.process.GetState() if state == lldb.eStateStopped: self.process.Kill() - self.reportState('inferiorshutdownok') + self.reportState('inferiorshutdownfinished') self.reportResult('', args) def quit(self, args): diff --git a/src/plugins/debugger/cdb/cdbengine.cpp b/src/plugins/debugger/cdb/cdbengine.cpp index 7e7080635f..531b285cf7 100644 --- a/src/plugins/debugger/cdb/cdbengine.cpp +++ b/src/plugins/debugger/cdb/cdbengine.cpp @@ -675,33 +675,27 @@ void CdbEngine::shutdownInferior() if (!isCdbProcessRunning()) { // Direct launch: Terminated with process. if (debug) - qDebug("notifyInferiorShutdownOk"); - STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyInferiorShutdownOk") - notifyInferiorShutdownOk(); - return; - } - - if (m_accessible) { // except console. + qDebug("notifyInferiorShutdownFinished"); + STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyInferiorShutdownFinished") + } else if (m_accessible) { // except console. if (runParameters().startMode == AttachExternal || runParameters().startMode == AttachCrashedExternal) detachDebugger(); - STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyInferiorShutdownOk") - notifyInferiorShutdownOk(); + STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyInferiorShutdownFinished") } else { // A command got stuck. if (commandsPending()) { showMessage("Cannot shut down inferior due to pending commands.", LogWarning); - STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyInferiorShutdownFailed") - notifyInferiorShutdownFailed(); - return; - } - if (!canInterruptInferior()) { + STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyInferiorShutdownFinished") + } else if (!canInterruptInferior()) { showMessage("Cannot interrupt the inferior.", LogWarning); - STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyInferiorShutdownFailed") - notifyInferiorShutdownFailed(); + STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyInferiorShutdownFinished") + } else { + interruptInferior(); // Calls us again return; } - interruptInferior(); // Calls us again } + + notifyInferiorShutdownFinished(); } /* shutdownEngine/processFinished: diff --git a/src/plugins/debugger/debuggerconstants.h b/src/plugins/debugger/debuggerconstants.h index dc2fb8a2a4..9871bcad1a 100644 --- a/src/plugins/debugger/debuggerconstants.h +++ b/src/plugins/debugger/debuggerconstants.h @@ -95,8 +95,7 @@ enum DebuggerState InferiorStopFailed, // Debuggee not stopped, will kill debugger InferiorShutdownRequested, - InferiorShutdownFailed, - InferiorShutdownOk, + InferiorShutdownFinished, EngineShutdownRequested, EngineShutdownFinished, diff --git a/src/plugins/debugger/debuggerengine.cpp b/src/plugins/debugger/debuggerengine.cpp index 173137e935..2fae13767a 100644 --- a/src/plugins/debugger/debuggerengine.cpp +++ b/src/plugins/debugger/debuggerengine.cpp @@ -344,8 +344,7 @@ QString DebuggerEngine::stateName(int s) SN(InferiorStopOk) SN(InferiorStopFailed) SN(InferiorShutdownRequested) - SN(InferiorShutdownOk) - SN(InferiorShutdownFailed) + SN(InferiorShutdownFinished) SN(EngineShutdownRequested) SN(EngineShutdownFinished) SN(DebuggerFinished) @@ -589,24 +588,22 @@ static bool isAllowedTransition(DebuggerState from, DebuggerState to) return to == InferiorStopOk; case InferiorRunOk: return to == InferiorStopRequested - || to == InferiorStopOk // A spontaneous stop. - || to == InferiorShutdownOk; // A spontaneous exit. + || to == InferiorStopOk // A spontaneous stop. + || to == InferiorShutdownFinished; // A spontaneous exit. case InferiorStopRequested: return to == InferiorStopOk || to == InferiorStopFailed; case InferiorStopOk: return to == InferiorRunRequested || to == InferiorShutdownRequested - || to == InferiorStopOk || to == InferiorShutdownOk; + || to == InferiorStopOk || to == InferiorShutdownFinished; case InferiorStopFailed: return to == EngineShutdownRequested; case InferiorUnrunnable: return to == InferiorShutdownRequested; case InferiorShutdownRequested: - return to == InferiorShutdownOk || to == InferiorShutdownFailed; - case InferiorShutdownOk: - return to == EngineShutdownRequested; - case InferiorShutdownFailed: + return to == InferiorShutdownFinished; + case InferiorShutdownFinished: return to == EngineShutdownRequested; case EngineShutdownRequested: @@ -807,20 +804,11 @@ void DebuggerEnginePrivate::doShutdownInferior() m_engine->shutdownInferior(); } -void DebuggerEngine::notifyInferiorShutdownOk() -{ - showMessage("INFERIOR SUCCESSFULLY SHUT DOWN"); - QTC_ASSERT(state() == InferiorShutdownRequested, qDebug() << this << state()); - setState(InferiorShutdownOk); - if (isMasterEngine()) - d->doShutdownEngine(); -} - -void DebuggerEngine::notifyInferiorShutdownFailed() +void DebuggerEngine::notifyInferiorShutdownFinished() { - showMessage("INFERIOR SHUTDOWN FAILED"); + showMessage("INFERIOR FINISHED SHUT DOWN"); QTC_ASSERT(state() == InferiorShutdownRequested, qDebug() << this << state()); - setState(InferiorShutdownFailed); + setState(InferiorShutdownFinished); if (isMasterEngine()) d->doShutdownEngine(); } @@ -888,8 +876,8 @@ void DebuggerEngine::notifyEngineIll() notifyInferiorStopFailed(); break; case InferiorStopOk: - showMessage("FORWARDING STATE TO InferiorShutdownFailed"); - setState(InferiorShutdownFailed, true); + showMessage("FORWARDING STATE TO InferiorShutdownFinished"); + setState(InferiorShutdownFinished, true); if (isMasterEngine()) d->doShutdownEngine(); break; @@ -920,7 +908,7 @@ void DebuggerEngine::notifyInferiorExited() #endif showMessage("NOTE: INFERIOR EXITED"); d->resetLocation(); - setState(InferiorShutdownOk); + setState(InferiorShutdownFinished); if (isMasterEngine()) d->doShutdownEngine(); } @@ -1102,8 +1090,7 @@ bool DebuggerEngine::debuggerActionsEnabled(DebuggerState state) case EngineRunFailed: case InferiorStopFailed: case InferiorShutdownRequested: - case InferiorShutdownOk: - case InferiorShutdownFailed: + case InferiorShutdownFinished: case EngineShutdownRequested: case EngineShutdownFinished: case DebuggerFinished: @@ -1173,7 +1160,7 @@ void DebuggerEngine::quitDebugger() break; case EngineRunFailed: case DebuggerFinished: - case InferiorShutdownOk: + case InferiorShutdownFinished: break; default: // FIXME: We should disable the actions connected to that. diff --git a/src/plugins/debugger/debuggerengine.h b/src/plugins/debugger/debuggerengine.h index db12028f7d..f8ebb49cad 100644 --- a/src/plugins/debugger/debuggerengine.h +++ b/src/plugins/debugger/debuggerengine.h @@ -411,8 +411,7 @@ protected: virtual void setState(DebuggerState state, bool forced = false); - void notifyInferiorShutdownOk(); - void notifyInferiorShutdownFailed(); + void notifyInferiorShutdownFinished(); void notifyEngineSpontaneousShutdown(); void notifyEngineShutdownFinished(); diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 16bda301f0..d55d04bfde 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -276,21 +276,19 @@ InferiorShutdownRequested + + + (calls *Engine->shutdownInferior()) + - | | + - {notify- {notify- + - Inferior- Inferior- + - ShutdownOk} ShutdownFailed} + - + + + - + + + - #Inferior exited# + + + - | + + + - {notifyInferior- + + + - Exited} + + + - + + + + - + + + + - + + + + - InferiorShutdownOk InferiorShutdownFailed + - * * + + | + + {notifyInferiorShutdownFinished} + + + + + + + + #Inferior exited# + + + | + + + {notifyInferior- + + + Exited} + + + + + + + + + + + + + + + InferiorShutdownFinished + + * + EngineShutdownRequested + + + (calls *Engine->shutdownEngine()) <+-+-+-+-+-+-+-+-+-+-+-+-+-+' @@ -329,12 +327,10 @@ sg1: InferiorRunRequested -> InferiorRunFailed [ label="notifyInferiorRunFaile sg1: InferiorRunFailed -> InferiorStopOk sg1: InferiorStopOk -> InferiorShutdownRequested [ label="Close event" ]; sg1: InferiorUnrunnable -> InferiorShutdownRequested [ label="Close event" ]; -sg1: InferiorShutdownRequested -> InferiorShutdownOk [ label= "Engine::shutdownInferior\nnotifyInferiorShutdownOk", style="dashed" ]; -sg1: InferiorShutdownRequested -> InferiorShutdownFailed [ label="Engine::shutdownInferior\nnotifyInferiorShutdownFailed", style="dashed" ]; +sg1: InferiorShutdownRequested -> InferiorShutdownFinished [ label= "Engine::shutdownInferior\nnotifyInferiorShutdownFinished", style="dashed" ]; sg1: InferiorExited -> InferiorExitOk [ label="notifyInferiorExited", style="dashed"]; sg1: InferiorExitOk -> InferiorShutdownOk -sg1: InferiorShutdownOk -> EngineShutdownRequested -sg1: InferiorShutdownFailed -> EngineShutdownRequested +sg1: InferiorShutdownFinished -> EngineShutdownRequested sg1: EngineShutdownRequested -> EngineShutdownFinished [ label="Engine::shutdownEngine\nnotifyEngineShutdownFinished", style="dashed" ]; sg1: EngineShutdownFinished -> DebuggerFinished [ style = "dotted" ]; sg1: } diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index ec6d911bf9..ed06951a33 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -103,9 +103,8 @@ static bool stateAcceptsGdbCommands(DebuggerState state) case InferiorStopRequested: case InferiorStopOk: case InferiorShutdownRequested: + case InferiorShutdownFinished: case EngineShutdownRequested: - case InferiorShutdownOk: - case InferiorShutdownFailed: return true; case DebuggerNotReady: case InferiorStopFailed: @@ -1739,7 +1738,7 @@ void GdbEngine::handleInferiorShutdown(const DebuggerResponse &response) if (response.resultClass == ResultDone) { // We'll get async thread-group-exited responses to which we react. // Nothing to do here. - // notifyInferiorShutdownOk(); + // notifyInferiorShutdownFinished(); return; } // "kill" got stuck, or similar. @@ -1749,12 +1748,11 @@ void GdbEngine::handleInferiorShutdown(const DebuggerResponse &response) // This happens when someone removed the binary behind our back. // It is not really an error from a user's point of view. showMessage("NOTE: " + msg); - notifyInferiorShutdownOk(); - return; + } else { + AsynchronousMessageBox::critical(tr("Failed to Shut Down Application"), + msgInferiorStopFailed(msg)); } - AsynchronousMessageBox::critical(tr("Failed to Shut Down Application"), - msgInferiorStopFailed(msg)); - notifyInferiorShutdownFailed(); + notifyInferiorShutdownFinished(); } void GdbEngine::handleGdbExit(const DebuggerResponse &response) diff --git a/src/plugins/debugger/lldb/lldbengine.cpp b/src/plugins/debugger/lldb/lldbengine.cpp index 97787929b6..3f945afc15 100644 --- a/src/plugins/debugger/lldb/lldbengine.cpp +++ b/src/plugins/debugger/lldb/lldbengine.cpp @@ -854,10 +854,8 @@ void LldbEngine::handleStateNotification(const GdbMi &reportedState) continueInferior(); } else if (newState == "enginerunokandinferiorunrunnable") notifyEngineRunOkAndInferiorUnrunnable(); - else if (newState == "inferiorshutdownok") - notifyInferiorShutdownOk(); - else if (newState == "inferiorshutdownfailed") - notifyInferiorShutdownFailed(); + else if (newState == "inferiorshutdownfinished") + notifyInferiorShutdownFinished(); else if (newState == "engineshutdownfinished") notifyEngineShutdownFinished(); else if (newState == "inferiorexited") diff --git a/src/plugins/debugger/pdb/pdbengine.cpp b/src/plugins/debugger/pdb/pdbengine.cpp index b7ca1c682b..b54172d5ab 100644 --- a/src/plugins/debugger/pdb/pdbengine.cpp +++ b/src/plugins/debugger/pdb/pdbengine.cpp @@ -102,7 +102,7 @@ void PdbEngine::runCommand(const DebuggerCommand &cmd) void PdbEngine::shutdownInferior() { QTC_ASSERT(state() == InferiorShutdownRequested, qDebug() << state()); - notifyInferiorShutdownOk(); + notifyInferiorShutdownFinished(); } void PdbEngine::shutdownEngine() diff --git a/src/plugins/debugger/qml/qmlcppengine.cpp b/src/plugins/debugger/qml/qmlcppengine.cpp index c5dd63102e..d90799a42a 100644 --- a/src/plugins/debugger/qml/qmlcppengine.cpp +++ b/src/plugins/debugger/qml/qmlcppengine.cpp @@ -587,14 +587,9 @@ void QmlCppEngine::slaveEngineStateChanged m_qmlEngine->quitDebugger(); break; } - case InferiorShutdownFailed: { - CHECK_STATE(InferiorShutdownRequested); - notifyInferiorShutdownFailed(); - break; - } - case InferiorShutdownOk: { + case InferiorShutdownFinished: { if (state() == InferiorShutdownRequested) { - notifyInferiorShutdownOk(); + notifyInferiorShutdownFinished(); } else { // we got InferiorExitOk before, but ignored it ... notifyInferiorExited(); diff --git a/src/plugins/debugger/qml/qmlengine.cpp b/src/plugins/debugger/qml/qmlengine.cpp index 171e8f5354..9fefece817 100644 --- a/src/plugins/debugger/qml/qmlengine.cpp +++ b/src/plugins/debugger/qml/qmlengine.cpp @@ -563,7 +563,7 @@ void QmlEngine::shutdownInferior() stopApplicationLauncher(); closeConnection(); - notifyInferiorShutdownOk(); + notifyInferiorShutdownFinished(); } void QmlEngine::shutdownEngine() -- GitLab