Commit 6089bc1b authored by hjk's avatar hjk
Browse files

debugger: rename EngineStart to EngineSetup

parent 3fcafefa
...@@ -376,7 +376,7 @@ void CdbEngine::startupChecks() ...@@ -376,7 +376,7 @@ void CdbEngine::startupChecks()
void CdbEngine::setupEngine() void CdbEngine::setupEngine()
{ {
QTC_ASSERT(state() == EngineStarting, qDebug() << state()); QTC_ASSERT(state() == EngineSettingUp, qDebug() << state());
const DebuggerStartParameters &sp = startParameters(); const DebuggerStartParameters &sp = startParameters();
if (debugCDBExecution) if (debugCDBExecution)
qDebug() << "startDebugger"; qDebug() << "startDebugger";
...@@ -385,14 +385,14 @@ void CdbEngine::setupEngine() ...@@ -385,14 +385,14 @@ void CdbEngine::setupEngine()
m_d->checkVersion(); m_d->checkVersion();
if (m_d->m_hDebuggeeProcess) { if (m_d->m_hDebuggeeProcess) {
warning(QLatin1String("Internal error: Attempt to start debugger while another process is being debugged.")); warning(QLatin1String("Internal error: Attempt to start debugger while another process is being debugged."));
notifyEngineStartFailed(); notifyEngineSetupFailed();
return; return;
} }
switch (sp.startMode) { switch (sp.startMode) {
case AttachCore: case AttachCore:
case AttachToRemote: case AttachToRemote:
warning(QLatin1String("Internal error: Mode not supported.")); warning(QLatin1String("Internal error: Mode not supported."));
notifyEngineStartFailed(); notifyEngineSetupFailed();
break; break;
default: default:
break; break;
...@@ -421,7 +421,7 @@ void CdbEngine::setupEngine() ...@@ -421,7 +421,7 @@ void CdbEngine::setupEngine()
} }
} }
m_d->m_dumper->reset(dumperLibName, dumperEnabled); m_d->m_dumper->reset(dumperLibName, dumperEnabled);
notifyEngineStartOk(); notifyEngineSetupOk();
} }
void CdbEngine::setupInferior() void CdbEngine::setupInferior()
......
...@@ -79,9 +79,9 @@ enum DebuggerState ...@@ -79,9 +79,9 @@ enum DebuggerState
{ {
DebuggerNotReady, // Debugger not started DebuggerNotReady, // Debugger not started
EngineStarting, // Engine starts EngineSettingUp, // Engine starts
EngineStartFailed, EngineSetupFailed,
EngineStarted, EngineSetupOk,
InferiorUnrunnable, // Used in the core dump adapter InferiorUnrunnable, // Used in the core dump adapter
InferiorSettingUp, InferiorSettingUp,
......
...@@ -143,9 +143,9 @@ const char *DebuggerEngine::stateName(int s) ...@@ -143,9 +143,9 @@ const char *DebuggerEngine::stateName(int s)
# define SN(x) case x: return #x; # define SN(x) case x: return #x;
switch (s) { switch (s) {
SN(DebuggerNotReady) SN(DebuggerNotReady)
SN(EngineStarting) SN(EngineSettingUp)
SN(EngineStarted) SN(EngineSetupOk)
SN(EngineStartFailed) SN(EngineSetupFailed)
SN(InferiorSettingUp) SN(InferiorSettingUp)
SN(InferiorSetupFailed) SN(InferiorSetupFailed)
SN(InferiorSetupOk) SN(InferiorSetupOk)
...@@ -228,6 +228,7 @@ public slots: ...@@ -228,6 +228,7 @@ public slots:
void doSetupInferior(); void doSetupInferior();
void doRunEngine(); void doRunEngine();
void doShutdown(); void doShutdown();
void doInterruptInferior();
public: public:
DebuggerEngine *m_engine; // Not owned. DebuggerEngine *m_engine; // Not owned.
...@@ -372,7 +373,7 @@ void DebuggerEngine::handleCommand(int role, const QVariant &value) ...@@ -372,7 +373,7 @@ void DebuggerEngine::handleCommand(int role, const QVariant &value)
break; break;
case RequestExecInterruptRole: case RequestExecInterruptRole:
interruptInferior(); d->doInterruptInferior();
break; break;
case RequestExecResetRole: case RequestExecResetRole:
...@@ -613,12 +614,12 @@ void DebuggerEngine::showMessage(const QString &msg, int channel, int timeout) c ...@@ -613,12 +614,12 @@ void DebuggerEngine::showMessage(const QString &msg, int channel, int timeout) c
void DebuggerEngine::startDebugger(DebuggerRunControl *runControl) void DebuggerEngine::startDebugger(DebuggerRunControl *runControl)
{ {
QTC_ASSERT(runControl, notifyEngineStartFailed(); return); QTC_ASSERT(runControl, notifyEngineSetupFailed(); return);
QTC_ASSERT(!d->m_runControl, notifyEngineStartFailed(); return); QTC_ASSERT(!d->m_runControl, notifyEngineSetupFailed(); return);
DebuggerEngine *sessionTemplate = plugin()->sessionTemplate(); DebuggerEngine *sessionTemplate = plugin()->sessionTemplate();
QTC_ASSERT(sessionTemplate, notifyEngineStartFailed(); return); QTC_ASSERT(sessionTemplate, notifyEngineSetupFailed(); return);
QTC_ASSERT(sessionTemplate != this, notifyEngineStartFailed(); return); QTC_ASSERT(sessionTemplate != this, notifyEngineSetupFailed(); return);
breakHandler()->initializeFromTemplate(sessionTemplate->breakHandler()); breakHandler()->initializeFromTemplate(sessionTemplate->breakHandler());
watchHandler()->initializeFromTemplate(sessionTemplate->watchHandler()); watchHandler()->initializeFromTemplate(sessionTemplate->watchHandler());
...@@ -640,7 +641,7 @@ void DebuggerEngine::startDebugger(DebuggerRunControl *runControl) ...@@ -640,7 +641,7 @@ void DebuggerEngine::startDebugger(DebuggerRunControl *runControl)
theDebuggerAction(OperateByInstruction) theDebuggerAction(OperateByInstruction)
->setEnabled(engineCapabilities & DisassemblerCapability); ->setEnabled(engineCapabilities & DisassemblerCapability);
setState(EngineStarting); setState(EngineSettingUp);
setupEngine(); setupEngine();
} }
...@@ -911,13 +912,13 @@ static bool isAllowedTransition(int from, int to) ...@@ -911,13 +912,13 @@ static bool isAllowedTransition(int from, int to)
return to == DebuggerNotReady; return to == DebuggerNotReady;
case DebuggerNotReady: case DebuggerNotReady:
return to == EngineStarting || to == DebuggerNotReady; return to == EngineSettingUp || to == DebuggerNotReady;
case EngineStarting: case EngineSettingUp:
return to == EngineStarted || to == EngineStartFailed; return to == EngineSetupOk || to == EngineSetupFailed;
case EngineStartFailed: case EngineSetupFailed:
return to == DebuggerNotReady; return to == DebuggerNotReady;
case EngineStarted: case EngineSetupOk:
return to == InferiorSettingUp || to == EngineShuttingDown; return to == InferiorSettingUp || to == EngineShuttingDown;
case InferiorSettingUp: case InferiorSettingUp:
...@@ -963,26 +964,26 @@ static bool isAllowedTransition(int from, int to) ...@@ -963,26 +964,26 @@ static bool isAllowedTransition(int from, int to)
return false; return false;
} }
void DebuggerEngine::notifyEngineStartFailed() void DebuggerEngine::notifyEngineSetupFailed()
{ {
QTC_ASSERT(state() == EngineStarting, qDebug() << state()); QTC_ASSERT(state() == EngineSettingUp, qDebug() << state());
setState(EngineStartFailed); setState(EngineSetupFailed);
d->m_runControl->debuggingFinished(); d->m_runControl->debuggingFinished();
d->m_runControl->startFailed(); d->m_runControl->startFailed();
QTimer::singleShot(0, this, SLOT(doShutdown())); QTimer::singleShot(0, this, SLOT(doShutdown()));
} }
void DebuggerEngine::notifyEngineStartOk() void DebuggerEngine::notifyEngineSetupOk()
{ {
QTC_ASSERT(state() == EngineStarting, qDebug() << state()); QTC_ASSERT(state() == EngineSettingUp, qDebug() << state());
setState(EngineStarted); setState(EngineSetupOk);
d->m_runControl->startSuccessful(); d->m_runControl->startSuccessful();
QTimer::singleShot(0, d, SLOT(doSetupInferior())); QTimer::singleShot(0, d, SLOT(doSetupInferior()));
} }
void DebuggerEnginePrivate::doSetupInferior() void DebuggerEnginePrivate::doSetupInferior()
{ {
QTC_ASSERT(m_state == EngineStarted, qDebug() << m_state); QTC_ASSERT(m_state == EngineSetupOk, qDebug() << m_state);
m_engine->setState(InferiorSettingUp); m_engine->setState(InferiorSettingUp);
m_engine->setupInferior(); m_engine->setupInferior();
} }
...@@ -990,7 +991,7 @@ void DebuggerEnginePrivate::doSetupInferior() ...@@ -990,7 +991,7 @@ void DebuggerEnginePrivate::doSetupInferior()
// Default implemention, can be overridden. // Default implemention, can be overridden.
void DebuggerEngine::setupInferior() void DebuggerEngine::setupInferior()
{ {
QTC_ASSERT(state() == EngineStarted, qDebug() << state()); QTC_ASSERT(state() == EngineSetupOk, qDebug() << state());
notifyInferiorSetupOk(); notifyInferiorSetupOk();
} }
...@@ -1020,6 +1021,24 @@ void DebuggerEngine::runEngine() ...@@ -1020,6 +1021,24 @@ void DebuggerEngine::runEngine()
QTC_ASSERT(state() == InferiorSetupOk, qDebug() << state()); QTC_ASSERT(state() == InferiorSetupOk, qDebug() << state());
} }
void DebuggerEngine::notifyInferiorRunning()
{
QTC_ASSERT(m_state == InferiorRunningRequested, qDebug() << m_state);
setState(InferiorRunning);
}
void DebuggerEngine::notifyInferiorStopped()
{
QTC_ASSERT(m_state == InferiorRunningStoppint, qDebug() << m_state);
setState(InferiorStopped);
}
void DebuggerEnginePrivate::doInterruptInferior()
{
QTC_ASSERT(m_state == InferiorRunning, qDebug() << m_state);
m_engine->interruptInferior();
}
void DebuggerEnginePrivate::doShutdown() void DebuggerEnginePrivate::doShutdown()
{ {
m_engine->shutdown(); m_engine->shutdown();
...@@ -1064,9 +1083,9 @@ bool DebuggerEngine::debuggerActionsEnabled(DebuggerState state) ...@@ -1064,9 +1083,9 @@ bool DebuggerEngine::debuggerActionsEnabled(DebuggerState state)
case InferiorStopped: case InferiorStopped:
return true; return true;
case DebuggerNotReady: case DebuggerNotReady:
case EngineStarting: case EngineSettingUp:
case EngineStarted: case EngineSetupOk:
case EngineStartFailed: case EngineSetupFailed:
case InferiorSetupOk: case InferiorSetupOk:
case InferiorSetupFailed: case InferiorSetupFailed:
case InferiorRunningRequested_Kill: case InferiorRunningRequested_Kill:
......
...@@ -189,11 +189,6 @@ protected: ...@@ -189,11 +189,6 @@ protected:
virtual void frameUp(); virtual void frameUp();
virtual void frameDown(); virtual void frameDown();
public slots:
// Convenience
void showMessage(const QString &msg, int channel = LogDebug, int timeout = -1) const;
void showStatusMessage(const QString &msg, int timeout = -1) const;
public: public:
DebuggerPlugin *plugin() const; DebuggerPlugin *plugin() const;
const DebuggerStartParameters &startParameters() const; const DebuggerStartParameters &startParameters() const;
...@@ -248,7 +243,10 @@ public: ...@@ -248,7 +243,10 @@ public:
bool isReverseDebugging() const; bool isReverseDebugging() const;
void handleCommand(int role, const QVariant &value); void handleCommand(int role, const QVariant &value);
public slots: // Convenience
void showMessage(const QString &msg, int channel = LogDebug, int timeout = -1) const;
void showStatusMessage(const QString &msg, int timeout = -1) const;
void resetLocation(); void resetLocation();
void openFile(const QString &fileName, int lineNumber = -1); void openFile(const QString &fileName, int lineNumber = -1);
void gotoLocation(const QString &fileName, int lineNumber, bool setMarker); void gotoLocation(const QString &fileName, int lineNumber, bool setMarker);
...@@ -257,12 +255,18 @@ public slots: ...@@ -257,12 +255,18 @@ public slots:
virtual void quitDebugger() { exitDebugger(); } // called by DebuggerRunControl virtual void quitDebugger() { exitDebugger(); } // called by DebuggerRunControl
protected: protected:
void notifyEngineStartOk(); void notifyEngineSetupOk();
void notifyEngineStartFailed(); void notifyEngineSetupFailed();
void notifyInferiorSetupOk(); void notifyInferiorSetupOk();
void notifyInferiorSetupFailed(); void notifyInferiorSetupFailed();
void notifyInferiorRunning();
void notifyInferiorStopped();
// Called to initiate shutdown.
void notifyInferiorIll();
virtual void setupInferior(); virtual void setupInferior();
virtual void runEngine(); virtual void runEngine();
......
...@@ -167,7 +167,7 @@ ...@@ -167,7 +167,7 @@
// DebuggerNotReady // DebuggerNotReady
// + // +
// + // +
// EngineStarting // EngineSettingUp
// + // +
// + // +
// (calls *Engine->setupEngine()) // (calls *Engine->setupEngine())
...@@ -176,13 +176,13 @@ ...@@ -176,13 +176,13 @@
// Engine- Engine- // Engine- Engine-
// StartOk} StartFailed} // StartOk} StartFailed}
// | | // | |
// | `---> EngineStartFailed // | `---> EngineSetupFailed
// | + // | +
// | [calls RunControl->startFailed] // | [calls RunControl->startFailed]
// | + // | +
// | DebuggerNotReady // | DebuggerNotReady
// v // v
// EngineStarted // EngineSetupOk
// + // +
// [calls RunControl->StartSuccessful] // [calls RunControl->StartSuccessful]
// + // +
...@@ -222,7 +222,7 @@ ...@@ -222,7 +222,7 @@
// DebuggerNotReady // DebuggerNotReady
// //
// GdbEngine specific startup. All happens in EngineStarting state // GdbEngine specific startup. All happens in EngineSettingUp state
// //
// Transitions marked by '---' are done in the individual adapters. // Transitions marked by '---' are done in the individual adapters.
// Transitions marked by '+-+' are done in the GdbEngine. // Transitions marked by '+-+' are done in the GdbEngine.
...@@ -234,7 +234,7 @@ ...@@ -234,7 +234,7 @@
// | | // | |
// | `---> handleAdapterStartFailed() // | `---> handleAdapterStartFailed()
// | + // | +
// | EngineStartFailed // | EngineSetupFailed
// | // |
// handleAdapterStarted() // handleAdapterStarted()
// + // +
...@@ -242,11 +242,11 @@ ...@@ -242,11 +242,11 @@
// | | // | |
// | `---> handleAdapterStartFailed() // | `---> handleAdapterStartFailed()
// | + // | +
// | EngineStartFailed // | EngineSetupFailed
// | // |
// handleInferiorPrepared() // handleInferiorPrepared()
// + // +
// EngineStarted // EngineSetupOk
...@@ -2120,7 +2120,7 @@ void DebuggerPluginPrivate::updateState(DebuggerEngine *engine) ...@@ -2120,7 +2120,7 @@ void DebuggerPluginPrivate::updateState(DebuggerEngine *engine)
|| m_state == InferiorStopping || m_state == InferiorStopping
|| m_state == InferiorStopped; || m_state == InferiorStopped;
const bool starting = m_state == EngineStarting; const bool starting = m_state == EngineSettingUp;
//const bool running = m_state == InferiorRunning; //const bool running = m_state == InferiorRunning;
m_startExternalAction->setEnabled(!started && !starting); m_startExternalAction->setEnabled(!started && !starting);
...@@ -2686,8 +2686,8 @@ bool DebuggerListener::coreAboutToClose() ...@@ -2686,8 +2686,8 @@ bool DebuggerListener::coreAboutToClose()
switch (plugin->state()) { switch (plugin->state()) {
case DebuggerNotReady: case DebuggerNotReady:
return true; return true;
case EngineStarted: // Most importantly, terminating a running case EngineSetupOk: // Most importantly, terminating a running
case EngineStartFailed: // debuggee can cause problems. case EngineSetupFailed: // debuggee can cause problems.
case InferiorUnrunnable: case InferiorUnrunnable:
case InferiorSetupFailed: case InferiorSetupFailed:
case InferiorStopped: case InferiorStopped:
......
...@@ -56,7 +56,7 @@ AttachGdbAdapter::AttachGdbAdapter(GdbEngine *engine, QObject *parent) ...@@ -56,7 +56,7 @@ AttachGdbAdapter::AttachGdbAdapter(GdbEngine *engine, QObject *parent)
void AttachGdbAdapter::startAdapter() void AttachGdbAdapter::startAdapter()
{ {
QTC_ASSERT(state() == EngineStarting, qDebug() << state()); QTC_ASSERT(state() == EngineSettingUp, qDebug() << state());
showMessage(_("TRYING TO START ADAPTER")); showMessage(_("TRYING TO START ADAPTER"));
if (!m_engine->startGdb()) if (!m_engine->startGdb())
......
...@@ -59,7 +59,7 @@ CoreGdbAdapter::CoreGdbAdapter(GdbEngine *engine, QObject *parent) ...@@ -59,7 +59,7 @@ CoreGdbAdapter::CoreGdbAdapter(GdbEngine *engine, QObject *parent)
void CoreGdbAdapter::startAdapter() void CoreGdbAdapter::startAdapter()
{ {
QTC_ASSERT(state() == EngineStarting, qDebug() << state()); QTC_ASSERT(state() == EngineSettingUp, qDebug() << state());
showMessage(_("TRYING TO START ADAPTER")); showMessage(_("TRYING TO START ADAPTER"));
if (!m_engine->startGdb()) if (!m_engine->startGdb())
......
...@@ -122,9 +122,9 @@ QByteArray GdbEngine::tooltipIName(const QString &exp) ...@@ -122,9 +122,9 @@ QByteArray GdbEngine::tooltipIName(const QString &exp)
static bool stateAcceptsGdbCommands(DebuggerState state) static bool stateAcceptsGdbCommands(DebuggerState state)
{ {
switch (state) { switch (state) {
case EngineStarting: case EngineSettingUp:
case EngineStarted: case EngineSetupOk:
case EngineStartFailed: case EngineSetupFailed:
case InferiorUnrunnable: case InferiorUnrunnable:
case InferiorSettingUp: case InferiorSettingUp:
case InferiorSetupFailed: case InferiorSetupFailed:
...@@ -737,7 +737,7 @@ void GdbEngine::postCommandHelper(const GdbCommand &cmd) ...@@ -737,7 +737,7 @@ void GdbEngine::postCommandHelper(const GdbCommand &cmd)
} else if ((cmd.flags & NeedsStop) } else if ((cmd.flags & NeedsStop)
|| !m_commandsToRunOnTemporaryBreak.isEmpty()) { || !m_commandsToRunOnTemporaryBreak.isEmpty()) {
if (state() == InferiorStopped || state() == InferiorUnrunnable if (state() == InferiorStopped || state() == InferiorUnrunnable
|| state() == InferiorSettingUp || state() == EngineStarted) { || state() == InferiorSettingUp || state() == EngineSetupOk) {
// Can be safely sent now. // Can be safely sent now.
flushCommand(cmd); flushCommand(cmd);
} else { } else {
...@@ -1603,11 +1603,11 @@ void GdbEngine::shutdown() ...@@ -1603,11 +1603,11 @@ void GdbEngine::shutdown()
case InferiorRunningRequested_Kill: case InferiorRunningRequested_Kill:
case InferiorStopping_Kill: case InferiorStopping_Kill:
break; break;
case EngineStarting: // GDB is up, adapter is "doing something" case EngineSettingUp: // GDB is up, adapter is "doing something"
setState(EngineStartFailed); setState(EngineSetupFailed);
m_gdbAdapter->shutdown(); m_gdbAdapter->shutdown();
// fall-through // fall-through
case EngineStartFailed: // Adapter "did something", but it did not help case EngineSetupFailed: // Adapter "did something", but it did not help
if (gdbProc()->state() == QProcess::Running) { if (gdbProc()->state() == QProcess::Running) {
m_commandsToRunOnTemporaryBreak.clear(); m_commandsToRunOnTemporaryBreak.clear();
postCommand("-gdb-exit", GdbEngine::ExitRequest, CB(handleGdbExit)); postCommand("-gdb-exit", GdbEngine::ExitRequest, CB(handleGdbExit));
...@@ -1623,7 +1623,7 @@ void GdbEngine::shutdown() ...@@ -1623,7 +1623,7 @@ void GdbEngine::shutdown()
postCommand(m_gdbAdapter->inferiorShutdownCommand(), postCommand(m_gdbAdapter->inferiorShutdownCommand(),
NeedsStop | LosesChild, CB(handleInferiorShutdown)); NeedsStop | LosesChild, CB(handleInferiorShutdown));
break; break;
case EngineStarted: // We can't get here, really case EngineSetupOk: // We can't get here, really
case InferiorSetupOk: case InferiorSetupOk:
case InferiorSetupFailed: case InferiorSetupFailed:
case InferiorShutDown: case InferiorShutDown:
...@@ -1764,7 +1764,7 @@ AbstractGdbAdapter *GdbEngine::createAdapter() ...@@ -1764,7 +1764,7 @@ AbstractGdbAdapter *GdbEngine::createAdapter()
void GdbEngine::setupEngine() void GdbEngine::setupEngine()
{ {
//qDebug() << "GDB START DEBUGGER"; //qDebug() << "GDB START DEBUGGER";
QTC_ASSERT(state() == EngineStarting, qDebug() << state()); QTC_ASSERT(state() == EngineSettingUp, qDebug() << state());
QTC_ASSERT(m_debuggingHelperState == DebuggingHelperUninitialized, /**/); QTC_ASSERT(m_debuggingHelperState == DebuggingHelperUninitialized, /**/);
QTC_ASSERT(m_gdbAdapter == 0, /**/); QTC_ASSERT(m_gdbAdapter == 0, /**/);
...@@ -1788,7 +1788,7 @@ void GdbEngine::setupEngine() ...@@ -1788,7 +1788,7 @@ void GdbEngine::setupEngine()
} }
m_progress->setProgressValue(20); m_progress->setProgressValue(20);
QTC_ASSERT(state() == EngineStarting, /**/); QTC_ASSERT(state() == EngineSettingUp, /**/);
m_gdbAdapter->startAdapter(); m_gdbAdapter->startAdapter();
} }
...@@ -3055,7 +3055,7 @@ void GdbEngine::activateSnapshot2() ...@@ -3055,7 +3055,7 @@ void GdbEngine::activateSnapshot2()
{ {
// Otherwise the stack data might be stale. // Otherwise the stack data might be stale.
// See http://sourceware.org/bugzilla/show_bug.cgi?id=1124. // See http://sourceware.org/bugzilla/show_bug.cgi?id=1124.
setState(EngineStarting); setState(EngineSettingUp);
postCommand("set stack-cache off"); postCommand("set stack-cache off");
handleAdapterStarted(); handleAdapterStarted();
} }
...@@ -4177,7 +4177,7 @@ void GdbEngine::handleGdbFinished(int code, QProcess::ExitStatus type) ...@@ -4177,7 +4177,7 @@ void GdbEngine::handleGdbFinished(int code, QProcess::ExitStatus type)
} else if (state() == EngineShuttingDown) { } else if (state() == EngineShuttingDown) {
showMessage(_("GOING TO SHUT DOWN ADAPTER")); showMessage(_("GOING TO SHUT DOWN ADAPTER"));
m_gdbAdapter->shutdown(); m_gdbAdapter->shutdown();
} else if (state() != EngineStartFailed) { } else if (state() != EngineSetupFailed) {
QString msg = tr("The gdb process exited unexpectedly (%1).") QString msg = tr("The gdb process exited unexpectedly (%1).")
.arg((type == QProcess::CrashExit) .arg((type == QProcess::CrashExit)
? tr("crashed") : tr("code %1").arg(code));