OSDN Git Service

fold preparing inferior into starting inferior
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>
Tue, 13 Oct 2009 07:53:47 +0000 (09:53 +0200)
committerOswald Buddenhagen <oswald.buddenhagen@nokia.com>
Tue, 13 Oct 2009 18:43:12 +0000 (20:43 +0200)
after refactoring the trk adapter startup, the split was not necessary
any more. in fact, it seemed fairly arbitrary at this point.

16 files changed:
src/plugins/debugger/cdb/cdbdebugengine.cpp
src/plugins/debugger/debuggerconstants.h
src/plugins/debugger/debuggermanager.cpp
src/plugins/debugger/gdb/abstractgdbadapter.h
src/plugins/debugger/gdb/attachgdbadapter.cpp
src/plugins/debugger/gdb/attachgdbadapter.h
src/plugins/debugger/gdb/coregdbadapter.cpp
src/plugins/debugger/gdb/coregdbadapter.h
src/plugins/debugger/gdb/gdbengine.cpp
src/plugins/debugger/gdb/gdbengine.h
src/plugins/debugger/gdb/plaingdbadapter.cpp
src/plugins/debugger/gdb/plaingdbadapter.h
src/plugins/debugger/gdb/remotegdbadapter.cpp
src/plugins/debugger/gdb/remotegdbadapter.h
src/plugins/debugger/gdb/trkgdbadapter.cpp
src/plugins/debugger/gdb/trkgdbadapter.h

index 181ed4e..cc991f3 100644 (file)
@@ -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);
 
index a9db768..2100aa8 100644 (file)
@@ -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
index 1669021..d7d9cf3 100644 (file)
 //                          |
 //                     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:
index ecb52f9..7765401 100644 (file)
@@ -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);
index 7095db9..661f558 100644 (file)
@@ -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());
index 8495497..987350d 100644 (file)
@@ -55,7 +55,6 @@ public:
     bool dumpersAvailable() const { return false; }
 
     void startAdapter();
-    void prepareInferior();
     void startInferior();
     void interruptInferior();
     void shutdown();
index 5a522f4..979d049 100644 (file)
@@ -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;
index b097f31..4a3fe67 100644 (file)
@@ -55,7 +55,6 @@ public:
     bool dumpersAvailable() const { return false; }
 
     void startAdapter();
-    void prepareInferior();
     void startInferior();
     void interruptInferior();
     void shutdown();
index 1147d6a..31dbee8 100644 (file)
@@ -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();
index 75f001c..dada820 100644 (file)
@@ -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);
index 100d1f5..5d21af7 100644 (file)
@@ -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"));
index 8be7f94..52311b3 100644 (file)
@@ -56,7 +56,6 @@ public:
     bool dumpersAvailable() const { return true; }
 
     void startAdapter();
-    void prepareInferior();
     void startInferior();
     void interruptInferior();
     void shutdown();
index 732fe7e..632a283 100644 (file)
@@ -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));
index 44600b9..38fc7ac 100644 (file)
@@ -55,7 +55,6 @@ public:
     bool dumpersAvailable() const { return true; }
 
     void startAdapter();
-    void prepareInferior();
     void startInferior();
     void interruptInferior();
     void shutdown();
index 4605044..f2832bd 100644 (file)
@@ -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());
index d5c9243..5e2e493 100644 (file)
@@ -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);