Commit 83c13ff1 authored by hjk's avatar hjk

Debugger: Combine the InferiorShutdown{Ok,Failed} states

... into a InferiorShutdownFinished.

Change-Id: Icb5394f38f52f7cf300dc83f4eb8f2f0777bbcba
Reviewed-by: default avatarDavid Schulz <david.schulz@qt.io>
parent ee9ecf86
...@@ -1511,13 +1511,11 @@ class Dumper(DumperBase): ...@@ -1511,13 +1511,11 @@ class Dumper(DumperBase):
def shutdownInferior(self, args): def shutdownInferior(self, args):
self.isShuttingDown_ = True self.isShuttingDown_ = True
if self.process is None: if self.process is not None:
self.reportState('inferiorshutdownok')
else:
state = self.process.GetState() state = self.process.GetState()
if state == lldb.eStateStopped: if state == lldb.eStateStopped:
self.process.Kill() self.process.Kill()
self.reportState('inferiorshutdownok') self.reportState('inferiorshutdownfinished')
self.reportResult('', args) self.reportResult('', args)
def quit(self, args): def quit(self, args):
......
...@@ -675,33 +675,27 @@ void CdbEngine::shutdownInferior() ...@@ -675,33 +675,27 @@ void CdbEngine::shutdownInferior()
if (!isCdbProcessRunning()) { // Direct launch: Terminated with process. if (!isCdbProcessRunning()) { // Direct launch: Terminated with process.
if (debug) if (debug)
qDebug("notifyInferiorShutdownOk"); qDebug("notifyInferiorShutdownFinished");
STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyInferiorShutdownOk") STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyInferiorShutdownFinished")
notifyInferiorShutdownOk(); } else if (m_accessible) { // except console.
return;
}
if (m_accessible) { // except console.
if (runParameters().startMode == AttachExternal || runParameters().startMode == AttachCrashedExternal) if (runParameters().startMode == AttachExternal || runParameters().startMode == AttachCrashedExternal)
detachDebugger(); detachDebugger();
STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyInferiorShutdownOk") STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyInferiorShutdownFinished")
notifyInferiorShutdownOk();
} else { } else {
// A command got stuck. // A command got stuck.
if (commandsPending()) { if (commandsPending()) {
showMessage("Cannot shut down inferior due to pending commands.", LogWarning); showMessage("Cannot shut down inferior due to pending commands.", LogWarning);
STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyInferiorShutdownFailed") STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyInferiorShutdownFinished")
notifyInferiorShutdownFailed(); } else if (!canInterruptInferior()) {
return;
}
if (!canInterruptInferior()) {
showMessage("Cannot interrupt the inferior.", LogWarning); showMessage("Cannot interrupt the inferior.", LogWarning);
STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyInferiorShutdownFailed") STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyInferiorShutdownFinished")
notifyInferiorShutdownFailed(); } else {
interruptInferior(); // Calls us again
return; return;
} }
interruptInferior(); // Calls us again
} }
notifyInferiorShutdownFinished();
} }
/* shutdownEngine/processFinished: /* shutdownEngine/processFinished:
......
...@@ -95,8 +95,7 @@ enum DebuggerState ...@@ -95,8 +95,7 @@ enum DebuggerState
InferiorStopFailed, // Debuggee not stopped, will kill debugger InferiorStopFailed, // Debuggee not stopped, will kill debugger
InferiorShutdownRequested, InferiorShutdownRequested,
InferiorShutdownFailed, InferiorShutdownFinished,
InferiorShutdownOk,
EngineShutdownRequested, EngineShutdownRequested,
EngineShutdownFinished, EngineShutdownFinished,
......
...@@ -344,8 +344,7 @@ QString DebuggerEngine::stateName(int s) ...@@ -344,8 +344,7 @@ QString DebuggerEngine::stateName(int s)
SN(InferiorStopOk) SN(InferiorStopOk)
SN(InferiorStopFailed) SN(InferiorStopFailed)
SN(InferiorShutdownRequested) SN(InferiorShutdownRequested)
SN(InferiorShutdownOk) SN(InferiorShutdownFinished)
SN(InferiorShutdownFailed)
SN(EngineShutdownRequested) SN(EngineShutdownRequested)
SN(EngineShutdownFinished) SN(EngineShutdownFinished)
SN(DebuggerFinished) SN(DebuggerFinished)
...@@ -590,23 +589,21 @@ static bool isAllowedTransition(DebuggerState from, DebuggerState to) ...@@ -590,23 +589,21 @@ static bool isAllowedTransition(DebuggerState from, DebuggerState to)
case InferiorRunOk: case InferiorRunOk:
return to == InferiorStopRequested return to == InferiorStopRequested
|| to == InferiorStopOk // A spontaneous stop. || to == InferiorStopOk // A spontaneous stop.
|| to == InferiorShutdownOk; // A spontaneous exit. || to == InferiorShutdownFinished; // A spontaneous exit.
case InferiorStopRequested: case InferiorStopRequested:
return to == InferiorStopOk || to == InferiorStopFailed; return to == InferiorStopOk || to == InferiorStopFailed;
case InferiorStopOk: case InferiorStopOk:
return to == InferiorRunRequested || to == InferiorShutdownRequested return to == InferiorRunRequested || to == InferiorShutdownRequested
|| to == InferiorStopOk || to == InferiorShutdownOk; || to == InferiorStopOk || to == InferiorShutdownFinished;
case InferiorStopFailed: case InferiorStopFailed:
return to == EngineShutdownRequested; return to == EngineShutdownRequested;
case InferiorUnrunnable: case InferiorUnrunnable:
return to == InferiorShutdownRequested; return to == InferiorShutdownRequested;
case InferiorShutdownRequested: case InferiorShutdownRequested:
return to == InferiorShutdownOk || to == InferiorShutdownFailed; return to == InferiorShutdownFinished;
case InferiorShutdownOk: case InferiorShutdownFinished:
return to == EngineShutdownRequested;
case InferiorShutdownFailed:
return to == EngineShutdownRequested; return to == EngineShutdownRequested;
case EngineShutdownRequested: case EngineShutdownRequested:
...@@ -807,20 +804,11 @@ void DebuggerEnginePrivate::doShutdownInferior() ...@@ -807,20 +804,11 @@ void DebuggerEnginePrivate::doShutdownInferior()
m_engine->shutdownInferior(); m_engine->shutdownInferior();
} }
void DebuggerEngine::notifyInferiorShutdownOk() void DebuggerEngine::notifyInferiorShutdownFinished()
{
showMessage("INFERIOR SUCCESSFULLY SHUT DOWN");
QTC_ASSERT(state() == InferiorShutdownRequested, qDebug() << this << state());
setState(InferiorShutdownOk);
if (isMasterEngine())
d->doShutdownEngine();
}
void DebuggerEngine::notifyInferiorShutdownFailed()
{ {
showMessage("INFERIOR SHUTDOWN FAILED"); showMessage("INFERIOR FINISHED SHUT DOWN");
QTC_ASSERT(state() == InferiorShutdownRequested, qDebug() << this << state()); QTC_ASSERT(state() == InferiorShutdownRequested, qDebug() << this << state());
setState(InferiorShutdownFailed); setState(InferiorShutdownFinished);
if (isMasterEngine()) if (isMasterEngine())
d->doShutdownEngine(); d->doShutdownEngine();
} }
...@@ -888,8 +876,8 @@ void DebuggerEngine::notifyEngineIll() ...@@ -888,8 +876,8 @@ void DebuggerEngine::notifyEngineIll()
notifyInferiorStopFailed(); notifyInferiorStopFailed();
break; break;
case InferiorStopOk: case InferiorStopOk:
showMessage("FORWARDING STATE TO InferiorShutdownFailed"); showMessage("FORWARDING STATE TO InferiorShutdownFinished");
setState(InferiorShutdownFailed, true); setState(InferiorShutdownFinished, true);
if (isMasterEngine()) if (isMasterEngine())
d->doShutdownEngine(); d->doShutdownEngine();
break; break;
...@@ -920,7 +908,7 @@ void DebuggerEngine::notifyInferiorExited() ...@@ -920,7 +908,7 @@ void DebuggerEngine::notifyInferiorExited()
#endif #endif
showMessage("NOTE: INFERIOR EXITED"); showMessage("NOTE: INFERIOR EXITED");
d->resetLocation(); d->resetLocation();
setState(InferiorShutdownOk); setState(InferiorShutdownFinished);
if (isMasterEngine()) if (isMasterEngine())
d->doShutdownEngine(); d->doShutdownEngine();
} }
...@@ -1102,8 +1090,7 @@ bool DebuggerEngine::debuggerActionsEnabled(DebuggerState state) ...@@ -1102,8 +1090,7 @@ bool DebuggerEngine::debuggerActionsEnabled(DebuggerState state)
case EngineRunFailed: case EngineRunFailed:
case InferiorStopFailed: case InferiorStopFailed:
case InferiorShutdownRequested: case InferiorShutdownRequested:
case InferiorShutdownOk: case InferiorShutdownFinished:
case InferiorShutdownFailed:
case EngineShutdownRequested: case EngineShutdownRequested:
case EngineShutdownFinished: case EngineShutdownFinished:
case DebuggerFinished: case DebuggerFinished:
...@@ -1173,7 +1160,7 @@ void DebuggerEngine::quitDebugger() ...@@ -1173,7 +1160,7 @@ void DebuggerEngine::quitDebugger()
break; break;
case EngineRunFailed: case EngineRunFailed:
case DebuggerFinished: case DebuggerFinished:
case InferiorShutdownOk: case InferiorShutdownFinished:
break; break;
default: default:
// FIXME: We should disable the actions connected to that. // FIXME: We should disable the actions connected to that.
......
...@@ -411,8 +411,7 @@ protected: ...@@ -411,8 +411,7 @@ protected:
virtual void setState(DebuggerState state, bool forced = false); virtual void setState(DebuggerState state, bool forced = false);
void notifyInferiorShutdownOk(); void notifyInferiorShutdownFinished();
void notifyInferiorShutdownFailed();
void notifyEngineSpontaneousShutdown(); void notifyEngineSpontaneousShutdown();
void notifyEngineShutdownFinished(); void notifyEngineShutdownFinished();
......
...@@ -276,21 +276,19 @@ ...@@ -276,21 +276,19 @@
InferiorShutdownRequested + InferiorShutdownRequested +
+ + + +
(calls *Engine->shutdownInferior()) + (calls *Engine->shutdownInferior()) +
| | + | +
{notify- {notify- + {notifyInferiorShutdownFinished} +
Inferior- Inferior- + + +
ShutdownOk} ShutdownFailed} + + +
#Inferior exited# + +
| + +
{notifyInferior- + +
Exited} + +
+ + + + + +
+ + + + + +
#Inferior exited# + + + + + +
| + + + InferiorShutdownFinished +
{notifyInferior- + + + * +
Exited} + + +
+ + + +
+ + + +
+ + + +
InferiorShutdownOk InferiorShutdownFailed +
* * +
EngineShutdownRequested + EngineShutdownRequested +
+ + + +
(calls *Engine->shutdownEngine()) <+-+-+-+-+-+-+-+-+-+-+-+-+-+' (calls *Engine->shutdownEngine()) <+-+-+-+-+-+-+-+-+-+-+-+-+-+'
...@@ -329,12 +327,10 @@ sg1: InferiorRunRequested -> InferiorRunFailed [ label="notifyInferiorRunFaile ...@@ -329,12 +327,10 @@ sg1: InferiorRunRequested -> InferiorRunFailed [ label="notifyInferiorRunFaile
sg1: InferiorRunFailed -> InferiorStopOk sg1: InferiorRunFailed -> InferiorStopOk
sg1: InferiorStopOk -> InferiorShutdownRequested [ label="Close event" ]; sg1: InferiorStopOk -> InferiorShutdownRequested [ label="Close event" ];
sg1: InferiorUnrunnable -> InferiorShutdownRequested [ label="Close event" ]; sg1: InferiorUnrunnable -> InferiorShutdownRequested [ label="Close event" ];
sg1: InferiorShutdownRequested -> InferiorShutdownOk [ label= "Engine::shutdownInferior\nnotifyInferiorShutdownOk", style="dashed" ]; sg1: InferiorShutdownRequested -> InferiorShutdownFinished [ label= "Engine::shutdownInferior\nnotifyInferiorShutdownFinished", style="dashed" ];
sg1: InferiorShutdownRequested -> InferiorShutdownFailed [ label="Engine::shutdownInferior\nnotifyInferiorShutdownFailed", style="dashed" ];
sg1: InferiorExited -> InferiorExitOk [ label="notifyInferiorExited", style="dashed"]; sg1: InferiorExited -> InferiorExitOk [ label="notifyInferiorExited", style="dashed"];
sg1: InferiorExitOk -> InferiorShutdownOk sg1: InferiorExitOk -> InferiorShutdownOk
sg1: InferiorShutdownOk -> EngineShutdownRequested sg1: InferiorShutdownFinished -> EngineShutdownRequested
sg1: InferiorShutdownFailed -> EngineShutdownRequested
sg1: EngineShutdownRequested -> EngineShutdownFinished [ label="Engine::shutdownEngine\nnotifyEngineShutdownFinished", style="dashed" ]; sg1: EngineShutdownRequested -> EngineShutdownFinished [ label="Engine::shutdownEngine\nnotifyEngineShutdownFinished", style="dashed" ];
sg1: EngineShutdownFinished -> DebuggerFinished [ style = "dotted" ]; sg1: EngineShutdownFinished -> DebuggerFinished [ style = "dotted" ];
sg1: } sg1: }
......
...@@ -103,9 +103,8 @@ static bool stateAcceptsGdbCommands(DebuggerState state) ...@@ -103,9 +103,8 @@ static bool stateAcceptsGdbCommands(DebuggerState state)
case InferiorStopRequested: case InferiorStopRequested:
case InferiorStopOk: case InferiorStopOk:
case InferiorShutdownRequested: case InferiorShutdownRequested:
case InferiorShutdownFinished:
case EngineShutdownRequested: case EngineShutdownRequested:
case InferiorShutdownOk:
case InferiorShutdownFailed:
return true; return true;
case DebuggerNotReady: case DebuggerNotReady:
case InferiorStopFailed: case InferiorStopFailed:
...@@ -1739,7 +1738,7 @@ void GdbEngine::handleInferiorShutdown(const DebuggerResponse &response) ...@@ -1739,7 +1738,7 @@ void GdbEngine::handleInferiorShutdown(const DebuggerResponse &response)
if (response.resultClass == ResultDone) { if (response.resultClass == ResultDone) {
// We'll get async thread-group-exited responses to which we react. // We'll get async thread-group-exited responses to which we react.
// Nothing to do here. // Nothing to do here.
// notifyInferiorShutdownOk(); // notifyInferiorShutdownFinished();
return; return;
} }
// "kill" got stuck, or similar. // "kill" got stuck, or similar.
...@@ -1749,12 +1748,11 @@ void GdbEngine::handleInferiorShutdown(const DebuggerResponse &response) ...@@ -1749,12 +1748,11 @@ void GdbEngine::handleInferiorShutdown(const DebuggerResponse &response)
// This happens when someone removed the binary behind our back. // This happens when someone removed the binary behind our back.
// It is not really an error from a user's point of view. // It is not really an error from a user's point of view.
showMessage("NOTE: " + msg); showMessage("NOTE: " + msg);
notifyInferiorShutdownOk(); } else {
return;
}
AsynchronousMessageBox::critical(tr("Failed to Shut Down Application"), AsynchronousMessageBox::critical(tr("Failed to Shut Down Application"),
msgInferiorStopFailed(msg)); msgInferiorStopFailed(msg));
notifyInferiorShutdownFailed(); }
notifyInferiorShutdownFinished();
} }
void GdbEngine::handleGdbExit(const DebuggerResponse &response) void GdbEngine::handleGdbExit(const DebuggerResponse &response)
......
...@@ -854,10 +854,8 @@ void LldbEngine::handleStateNotification(const GdbMi &reportedState) ...@@ -854,10 +854,8 @@ void LldbEngine::handleStateNotification(const GdbMi &reportedState)
continueInferior(); continueInferior();
} else if (newState == "enginerunokandinferiorunrunnable") } else if (newState == "enginerunokandinferiorunrunnable")
notifyEngineRunOkAndInferiorUnrunnable(); notifyEngineRunOkAndInferiorUnrunnable();
else if (newState == "inferiorshutdownok") else if (newState == "inferiorshutdownfinished")
notifyInferiorShutdownOk(); notifyInferiorShutdownFinished();
else if (newState == "inferiorshutdownfailed")
notifyInferiorShutdownFailed();
else if (newState == "engineshutdownfinished") else if (newState == "engineshutdownfinished")
notifyEngineShutdownFinished(); notifyEngineShutdownFinished();
else if (newState == "inferiorexited") else if (newState == "inferiorexited")
......
...@@ -102,7 +102,7 @@ void PdbEngine::runCommand(const DebuggerCommand &cmd) ...@@ -102,7 +102,7 @@ void PdbEngine::runCommand(const DebuggerCommand &cmd)
void PdbEngine::shutdownInferior() void PdbEngine::shutdownInferior()
{ {
QTC_ASSERT(state() == InferiorShutdownRequested, qDebug() << state()); QTC_ASSERT(state() == InferiorShutdownRequested, qDebug() << state());
notifyInferiorShutdownOk(); notifyInferiorShutdownFinished();
} }
void PdbEngine::shutdownEngine() void PdbEngine::shutdownEngine()
......
...@@ -587,14 +587,9 @@ void QmlCppEngine::slaveEngineStateChanged ...@@ -587,14 +587,9 @@ void QmlCppEngine::slaveEngineStateChanged
m_qmlEngine->quitDebugger(); m_qmlEngine->quitDebugger();
break; break;
} }
case InferiorShutdownFailed: { case InferiorShutdownFinished: {
CHECK_STATE(InferiorShutdownRequested);
notifyInferiorShutdownFailed();
break;
}
case InferiorShutdownOk: {
if (state() == InferiorShutdownRequested) { if (state() == InferiorShutdownRequested) {
notifyInferiorShutdownOk(); notifyInferiorShutdownFinished();
} else { } else {
// we got InferiorExitOk before, but ignored it ... // we got InferiorExitOk before, but ignored it ...
notifyInferiorExited(); notifyInferiorExited();
......
...@@ -563,7 +563,7 @@ void QmlEngine::shutdownInferior() ...@@ -563,7 +563,7 @@ void QmlEngine::shutdownInferior()
stopApplicationLauncher(); stopApplicationLauncher();
closeConnection(); closeConnection();
notifyInferiorShutdownOk(); notifyInferiorShutdownFinished();
} }
void QmlEngine::shutdownEngine() void QmlEngine::shutdownEngine()
......
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