Commit d1783e09 authored by Oswald Buddenhagen's avatar Oswald Buddenhagen
Browse files

fold preparing inferior into starting inferior

after refactoring the trk adapter startup, the split was not necessary
any more. in fact, it seemed fairly arbitrary at this point.
parent 9aaa9532
......@@ -635,7 +635,6 @@ void CdbDebugEngine::startDebugger(const QSharedPointer<DebuggerStartParameters>
m_d->m_inferiorStartupComplete = false;
setState(AdapterStarted, Q_FUNC_INFO, __LINE__);
setState(InferiorPreparing, Q_FUNC_INFO, __LINE__);
const DebuggerStartMode mode = sp->startMode;
// Figure out dumper. @TODO: same in gdb...
const QString dumperLibName = QDir::toNativeSeparators(manager()->qtDumperLibraryName());
......@@ -654,7 +653,6 @@ void CdbDebugEngine::startDebugger(const QSharedPointer<DebuggerStartParameters>
}
m_d->m_dumper->reset(dumperLibName, dumperEnabled);
setState(InferiorPrepared, Q_FUNC_INFO, __LINE__);
setState(InferiorStarting, Q_FUNC_INFO, __LINE__);
manager()->showStatusMessage("Starting Debugger", -1);
......
......@@ -69,9 +69,6 @@ enum DebuggerState
AdapterStarting,
AdapterStarted,
AdapterStartFailed,
InferiorPreparing,
InferiorPrepared,
InferiorPreparationFailed,
InferiorUnrunnable, // Used in the core dump adapter
InferiorStarting,
// InferiorStarted, // Use InferiorRunningRequested or InferiorStopped
......
......@@ -107,10 +107,6 @@
// |
// AdapterStarted
// |
// InferiorPreparing --> InferiorPreparationFailed --> 0
// |
// InferiorPrepared
// |
// InferiorStarting --> InferiorStartFailed --> 0
// |
// (core) | (attach) (remote)
......@@ -199,9 +195,6 @@ static const char *stateName(int s)
SN(AdapterStarting)
SN(AdapterStarted)
SN(AdapterStartFailed)
SN(InferiorPreparing)
SN(InferiorPrepared)
SN(InferiorPreparationFailed)
SN(InferiorStarting)
SN(InferiorStartFailed)
SN(InferiorRunningRequested)
......@@ -1564,15 +1557,8 @@ static bool isAllowedTransition(int from, int to)
case AdapterStarting:
return to == AdapterStarted || to == AdapterStartFailed;
case AdapterStarted:
return to == InferiorPreparing;
case AdapterStartFailed:
return to == DebuggerNotReady;
case InferiorPreparing:
return to == InferiorPrepared || to == InferiorPreparationFailed;
case InferiorPrepared:
return to == InferiorStarting;
case InferiorPreparationFailed:
case AdapterStartFailed:
return to == DebuggerNotReady;
case InferiorStarting:
......@@ -1695,7 +1681,6 @@ bool DebuggerManager::debuggerActionsEnabled() const
if (!d->m_engine)
return false;
switch (state()) {
case InferiorPrepared:
case InferiorStarting:
case InferiorRunningRequested:
case InferiorRunning:
......@@ -1708,8 +1693,6 @@ bool DebuggerManager::debuggerActionsEnabled() const
case AdapterStarting:
case AdapterStarted:
case AdapterStartFailed:
case InferiorPreparing:
case InferiorPreparationFailed:
case InferiorStartFailed:
case InferiorStopFailed:
case InferiorShuttingDown:
......
......@@ -57,7 +57,6 @@ public:
virtual bool isTrkAdapter() const; // isUtterlyBrokenAdapter
virtual void startAdapter() = 0;
virtual void prepareInferior() = 0;
virtual void startInferior() = 0;
virtual void interruptInferior() = 0;
virtual void shutdown() = 0;
......@@ -71,8 +70,6 @@ signals:
void adapterShutdownFailed(const QString &msg);
void adapterCrashed(const QString &msg);
void inferiorPrepared();
void inferiorPreparationFailed(const QString &msg);
void inferiorStartFailed(const QString &msg);
void inferiorShutDown();
void inferiorShutdownFailed(const QString &msg);
......
......@@ -84,14 +84,6 @@ void AttachGdbAdapter::handleGdbError(QProcess::ProcessError error)
shutdown();
}
void AttachGdbAdapter::prepareInferior()
{
QTC_ASSERT(state() == AdapterStarted, qDebug() << state());
setState(InferiorPreparing);
setState(InferiorPrepared);
emit inferiorPrepared();
}
void AttachGdbAdapter::startInferior()
{
QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
......
......@@ -55,7 +55,6 @@ public:
bool dumpersAvailable() const { return false; }
void startAdapter();
void prepareInferior();
void startInferior();
void interruptInferior();
void shutdown();
......
......@@ -84,14 +84,6 @@ void CoreGdbAdapter::handleGdbError(QProcess::ProcessError error)
shutdown();
}
void CoreGdbAdapter::prepareInferior()
{
QTC_ASSERT(state() == AdapterStarted, qDebug() << state());
setState(InferiorPreparing);
setState(InferiorPrepared);
emit inferiorPrepared();
}
void CoreGdbAdapter::startInferior()
{
QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
......@@ -199,7 +191,6 @@ void CoreGdbAdapter::shutdown()
case InferiorUnrunnable:
case InferiorShutDown:
case InferiorPreparationFailed:
setState(AdapterShuttingDown);
m_engine->postCommand(_("-gdb-exit"), CB(handleExit));
return;
......
......@@ -55,7 +55,6 @@ public:
bool dumpersAvailable() const { return false; }
void startAdapter();
void prepareInferior();
void startInferior();
void interruptInferior();
void shutdown();
......
......@@ -111,8 +111,6 @@ static bool stateAcceptsGdbCommands(DebuggerState state)
{
return state == AdapterStarted
|| state == InferiorUnrunnable
|| state == InferiorPreparing
|| state == InferiorPrepared
|| state == InferiorStarting
|| state == InferiorRunningRequested
|| state == InferiorRunning
......@@ -238,11 +236,6 @@ void GdbEngine::connectAdapter()
connect(m_gdbAdapter, SIGNAL(adapterShutdownFailed(QString)),
this, SLOT(handleAdapterShutdownFailed(QString)));
connect(m_gdbAdapter, SIGNAL(inferiorPrepared()),
this, SLOT(handleInferiorPrepared()));
connect(m_gdbAdapter, SIGNAL(inferiorPreparationFailed(QString)),
this, SLOT(handleInferiorPreparationFailed(QString)));
connect(m_gdbAdapter, SIGNAL(inferiorStartFailed(QString)),
this, SLOT(handleInferiorStartFailed(QString)));
connect(m_gdbAdapter, SIGNAL(inferiorShutDown()),
......@@ -710,9 +703,7 @@ void GdbEngine::postCommandHelper(const GdbCommand &cmd)
}
if (cmd.flags & NeedsStop) {
if (state() == InferiorStopped
|| state() == EngineStarting
|| state() == InferiorPrepared) {
if (state() == InferiorStopped || state() == AdapterStarted) {
// Can be safely sent now.
flushCommand(cmd);
} else {
......@@ -4086,24 +4077,7 @@ void GdbEngine::handleAdapterStartFailed(const QString &msg, const QString &sett
void GdbEngine::handleAdapterStarted()
{
debugMessage(_("ADAPTER SUCCESSFULLY STARTED, PREPARING INFERIOR"));
m_gdbAdapter->prepareInferior();
}
void GdbEngine::handleInferiorPreparationFailed(const QString &msg)
{
debugMessage(_("INFERIOR PREPARATION FAILED"));
showMessageBox(QMessageBox::Critical,
tr("Inferior start preparation failed"), msg);
shutdown();
}
void GdbEngine::handleInferiorPrepared()
{
QTC_ASSERT(state() == InferiorPrepared, qDebug() << state());
debugMessage(_("INFERIOR PREPARED"));
// FIXME: Check that inferior is in "stopped" state
showStatusMessage(tr("Inferior prepared for startup."));
debugMessage(_("ADAPTER SUCCESSFULLY STARTED, INITIALIZING GDB"));
postCommand(_("show version"), CB(handleShowVersion));
//postCommand(_("-enable-timings");
......@@ -4196,7 +4170,7 @@ void GdbEngine::handleInferiorPrepared()
void GdbEngine::startInferior()
{
QTC_ASSERT(state() == InferiorPrepared, qDebug() << state());
QTC_ASSERT(state() == AdapterStarted, qDebug() << state());
showStatusMessage(tr("Starting inferior..."));
setState(InferiorStarting);
m_gdbAdapter->startInferior();
......
......@@ -245,8 +245,6 @@ private slots:
void handleAdapterStarted();
void handleAdapterStartFailed(const QString &msg, const QString &settingsIdHint = QString());
void handleInferiorPrepared();
void handleInferiorPreparationFailed(const QString &msg);
void handleInferiorStartFailed(const QString &msg);
void handleInferiorShutDown();
void handleInferiorShutdownFailed(const QString &msg);
......
......@@ -103,10 +103,9 @@ void PlainGdbAdapter::handleGdbError(QProcess::ProcessError error)
emit adapterCrashed(m_engine->errorMessage(error));
}
void PlainGdbAdapter::prepareInferior()
void PlainGdbAdapter::startInferior()
{
QTC_ASSERT(state() == AdapterStarted, qDebug() << state());
setState(InferiorPreparing);
QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
if (!startParameters().processArgs.isEmpty())
m_engine->postCommand(_("-exec-arguments ")
+ startParameters().processArgs.join(_(" ")));
......@@ -117,16 +116,15 @@ void PlainGdbAdapter::prepareInferior()
void PlainGdbAdapter::handleFileExecAndSymbols(const GdbResponse &response)
{
QTC_ASSERT(state() == InferiorPreparing, qDebug() << state());
QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
if (response.resultClass == GdbResultDone) {
//m_breakHandler->clearBreakMarkers();
setState(InferiorPrepared);
emit inferiorPrepared();
setState(InferiorRunningRequested);
m_engine->postCommand(_("-exec-run"), GdbEngine::RunRequest, CB(handleExecRun));
} else {
QString msg = tr("Starting executable failed:\n") +
__(response.data.findChild("msg").data());
setState(InferiorPreparationFailed);
emit inferiorPreparationFailed(msg);
emit inferiorStartFailed(msg);
}
}
......@@ -145,13 +143,6 @@ void PlainGdbAdapter::handleExecRun(const GdbResponse &response)
}
}
void PlainGdbAdapter::startInferior()
{
QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
setState(InferiorRunningRequested);
m_engine->postCommand(_("-exec-run"), GdbEngine::RunRequest, CB(handleExecRun));
}
void PlainGdbAdapter::interruptInferior()
{
debugMessage(_("TRYING TO INTERUPT INFERIOR"));
......
......@@ -56,7 +56,6 @@ public:
bool dumpersAvailable() const { return true; }
void startAdapter();
void prepareInferior();
void startInferior();
void interruptInferior();
void shutdown();
......
......@@ -153,10 +153,9 @@ void RemoteGdbAdapter::readUploadStandardError()
m_engine->gdbOutputAvailable(LogError, QString::fromLocal8Bit(ba, ba.length()));
}
void RemoteGdbAdapter::prepareInferior()
void RemoteGdbAdapter::startInferior()
{
QTC_ASSERT(state() == AdapterStarted, qDebug() << state());
setState(InferiorPreparing);
QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
m_engine->postCommand(_("set architecture %1")
.arg(startParameters().remoteArchitecture));
......@@ -178,7 +177,7 @@ void RemoteGdbAdapter::prepareInferior()
#if 0
void RemoteGdbAdapter::handleSetTargetAsync(const GdbResponse &response)
{
QTC_ASSERT(state() == InferiorPreparing, qDebug() << state());
QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
if (response.resultClass == GdbResultDone) {
//qq->breakHandler()->setAllPending();
QFileInfo fi(startParameters().executable);
......@@ -187,24 +186,28 @@ void RemoteGdbAdapter::handleSetTargetAsync(const GdbResponse &response)
CB(handleFileExecAndSymbols));
} else {
QString msg = tr("Adapter too old: does not support asynchronous mode.");
setState(InferiorPreparationFailed);
emit inferiorPreparationFailed(msg);
emit inferiorStartFailed(msg);
}
}
#endif
void RemoteGdbAdapter::handleFileExecAndSymbols(const GdbResponse &response)
{
QTC_ASSERT(state() == InferiorPreparing, qDebug() << state());
QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
if (response.resultClass == GdbResultDone) {
//m_breakHandler->clearBreakMarkers();
m_engine->setState(InferiorPrepared);
emit inferiorPrepared();
// "target remote" does three things:
// (1) connects to the gdb server
// (2) starts the remote application
// (3) stops the remote application (early, e.g. in the dynamic linker)
QString channel = startParameters().remoteChannel;
m_engine->postCommand(_("target remote %1").arg(channel),
CB(handleTargetRemote));
} else {
QString msg = tr("Starting remote executable failed:\n");
msg += __(response.data.findChild("msg").data());
setState(InferiorPreparationFailed);
emit inferiorPreparationFailed(msg);
emit inferiorStartFailed(msg);
}
}
......@@ -220,24 +223,10 @@ void RemoteGdbAdapter::handleTargetRemote(const GdbResponse &record)
} else {
// 16^error,msg="hd:5555: Connection timed out."
QString msg = msgConnectRemoteServerFailed(__(record.data.findChild("msg").data()));
setState(InferiorPreparationFailed);
emit inferiorStartFailed(msg);
}
}
void RemoteGdbAdapter::startInferior()
{
QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
QString channel = startParameters().remoteChannel;
// "target remote" does three things:
// (1) connects to the gdb server
// (2) starts the remote application
// (3) stops the remote application (early, e.g. in the dynamic linker)
m_engine->postCommand(_("target remote %1").arg(channel),
CB(handleTargetRemote));
}
void RemoteGdbAdapter::interruptInferior()
{
m_engine->postCommand(_("-exec-interrupt"));
......@@ -257,7 +246,7 @@ void RemoteGdbAdapter::shutdown()
QTC_ASSERT(false, qDebug() << state());
// fall through
case InferiorPreparationFailed:
case InferiorStartFailed:
case InferiorShutDown:
setState(AdapterShuttingDown);
m_engine->postCommand(_("-gdb-exit"), CB(handleExit));
......
......@@ -55,7 +55,6 @@ public:
bool dumpersAvailable() const { return true; }
void startAdapter();
void prepareInferior();
void startInferior();
void interruptInferior();
void shutdown();
......
......@@ -391,6 +391,17 @@ void TrkGdbAdapter::slotEmitDelayedAdapterStartFailed()
emit adapterStartFailed(m_adapterFailMessage, TrkOptionsPage::settingsId());
}
void TrkGdbAdapter::emitDelayedInferiorStartFailed(const QString &msg)
{
m_adapterFailMessage = msg;
QTimer::singleShot(0, this, SLOT(slotEmitDelayedInferiorStartFailed()));
}
void TrkGdbAdapter::slotEmitDelayedInferiorStartFailed()
{
emit inferiorStartFailed(m_adapterFailMessage);
}
void TrkGdbAdapter::waitForTrkConnect()
{
QTC_ASSERT(state() == AdapterStarting, qDebug() << state());
......@@ -1634,10 +1645,9 @@ void TrkGdbAdapter::startAdapter()
waitForTrkConnect();
}
void TrkGdbAdapter::prepareInferior()
void TrkGdbAdapter::startInferior()
{
QTC_ASSERT(state() == AdapterStarted, qDebug() << state());
setState(InferiorPreparing);
QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
QByteArray ba;
appendByte(&ba, 0); // ?
......@@ -1651,7 +1661,7 @@ void TrkGdbAdapter::prepareInferior()
void TrkGdbAdapter::handleCreateProcess(const TrkResult &result)
{
QTC_ASSERT(state() == InferiorPreparing, qDebug() << state());
QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
// 40 00 00]
//logMessage(" RESULT: " + result.toString());
// [80 08 00 00 00 01 B5 00 00 01 B6 78 67 40 00 00 40 00 00]
......@@ -1661,7 +1671,7 @@ void TrkGdbAdapter::handleCreateProcess(const TrkResult &result)
.arg(m_remoteExecutable).arg(result.errorString());
// Delay cleanup as not to close a trk device from its read handler,
// which blocks.
emitDelayedAdapterStartFailed(msg);
emitDelayedInferiorStartFailed(msg);
return;
}
const char *data = result.data.data();
......@@ -1689,24 +1699,17 @@ void TrkGdbAdapter::handleCreateProcess(const TrkResult &result)
void TrkGdbAdapter::handleTargetRemote(const GdbResponse &record)
{
QTC_ASSERT(state() == InferiorPreparing, qDebug() << state());
QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
if (record.resultClass == GdbResultDone) {
setState(InferiorPrepared);
emit inferiorPrepared();
setState(InferiorRunningRequested);
m_engine->postCommand(_("-exec-continue"), CB(handleFirstContinue));
} else {
QString msg = tr("Connecting to trk server adapter failed:\n")
+ _(record.data.findChild("msg").data());
emit inferiorPreparationFailed(msg);
emit inferiorStartFailed(msg);
}
}
void TrkGdbAdapter::startInferior()
{
QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
setState(InferiorRunningRequested);
m_engine->postCommand(_("-exec-continue"), CB(handleFirstContinue));
}
void TrkGdbAdapter::handleFirstContinue(const GdbResponse &record)
{
QTC_ASSERT(state() == InferiorRunning, qDebug() << state());
......
......@@ -171,13 +171,14 @@ public:
private:
void startAdapter();
void prepareInferior();
void startInferior();
void interruptInferior();
void shutdown();
void cleanup();
void emitDelayedAdapterStartFailed(const QString &msg);
Q_SLOT void slotEmitDelayedAdapterStartFailed();
void emitDelayedInferiorStartFailed(const QString &msg);
Q_SLOT void slotEmitDelayedInferiorStartFailed();
Q_SLOT void waitForTrkConnect();
void handleKill(const GdbResponse &response);
......
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