Commit 83c13ff1 authored by hjk's avatar hjk

Debugger: Combine the InferiorShutdown{Ok,Failed} states

... into a InferiorShutdownFinished.

Change-Id: Icb5394f38f52f7cf300dc83f4eb8f2f0777bbcba
Reviewed-by: 's avatarDavid Schulz <david.schulz@qt.io>
parent ee9ecf86
......@@ -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):
......
......@@ -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:
......
......@@ -95,8 +95,7 @@ enum DebuggerState
InferiorStopFailed, // Debuggee not stopped, will kill debugger
InferiorShutdownRequested,
InferiorShutdownFailed,
InferiorShutdownOk,
InferiorShutdownFinished,
EngineShutdownRequested,
EngineShutdownFinished,
......
......@@ -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.
......
......@@ -411,8 +411,7 @@ protected:
virtual void setState(DebuggerState state, bool forced = false);
void notifyInferiorShutdownOk();
void notifyInferiorShutdownFailed();
void notifyInferiorShutdownFinished();
void notifyEngineSpontaneousShutdown();
void notifyEngineShutdownFinished();
......
......@@ -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: }
......
......@@ -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)
......
......@@ -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")
......
......@@ -102,7 +102,7 @@ void PdbEngine::runCommand(const DebuggerCommand &cmd)
void PdbEngine::shutdownInferior()
{
QTC_ASSERT(state() == InferiorShutdownRequested, qDebug() << state());
notifyInferiorShutdownOk();
notifyInferiorShutdownFinished();
}
void PdbEngine::shutdownEngine()
......
......@@ -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();
......
......@@ -563,7 +563,7 @@ void QmlEngine::shutdownInferior()
stopApplicationLauncher();
closeConnection();
notifyInferiorShutdownOk();
notifyInferiorShutdownFinished();
}
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