diff --git a/src/plugins/debugger/cdb/cdbdebugengine.cpp b/src/plugins/debugger/cdb/cdbdebugengine.cpp
index 853a774bb2c08ef0fa39c34903578373fc3cfcc1..b4e9f6fd67b90dfbcf0291fb7179ce46a735a2a2 100644
--- a/src/plugins/debugger/cdb/cdbdebugengine.cpp
+++ b/src/plugins/debugger/cdb/cdbdebugengine.cpp
@@ -1685,25 +1685,21 @@ bool CdbDebugEnginePrivate::setSymbolPaths(const QStringList &s, QString *errorM
     return true;
 }
 
-} // namespace Internal
-} // namespace Debugger
-
 // Accessed by DebuggerManager
-Debugger::Internal::IDebuggerEngine *createWinEngine(Debugger::Internal::DebuggerManager *parent,
-                                                     bool cmdLineEnabled,
-                                                     QList<Core::IOptionsPage*> *opts)
+IDebuggerEngine *createWinEngine(DebuggerManager *parent,
+                                 bool cmdLineEnabled,
+                                 QList<Core::IOptionsPage*> *opts)
 {
     // Create options page
-    QSharedPointer<Debugger::Internal::CdbOptions> options(new Debugger::Internal::CdbOptions);
+    QSharedPointer<CdbOptions> options(new CdbOptions);
     options->fromSettings(Core::ICore::instance()->settings());
-    Debugger::Internal::CdbOptionsPage *optionsPage = new Debugger::Internal::CdbOptionsPage(options);
+    CdbOptionsPage *optionsPage = new CdbOptionsPage(options);
     opts->push_back(optionsPage);
     if (!cmdLineEnabled || !options->enabled)
         return 0;
     // Create engine
     QString errorMessage;
-    Debugger::Internal::IDebuggerEngine *engine =
-            Debugger::Internal::CdbDebugEngine::create(parent, options, &errorMessage);
+    IDebuggerEngine *engine = CdbDebugEngine::create(parent, options, &errorMessage);
     if (!engine) {
         optionsPage->setFailureMessage(errorMessage);
         qWarning("%s\n" ,qPrintable(errorMessage));
@@ -1711,3 +1707,7 @@ Debugger::Internal::IDebuggerEngine *createWinEngine(Debugger::Internal::Debugge
     QObject::connect(optionsPage, SIGNAL(debuggerPathsChanged()), engine, SLOT(syncDebuggerPaths()));
     return engine;
 }
+
+} // namespace Internal
+} // namespace Debugger
+
diff --git a/src/plugins/debugger/cdb/cdbdebugengine.h b/src/plugins/debugger/cdb/cdbdebugengine.h
index 18b660416520f01f54ffbf6d9cecba4aa65a4733..6b57235fa34ea36b140090207539f5bd5b913fec 100644
--- a/src/plugins/debugger/cdb/cdbdebugengine.h
+++ b/src/plugins/debugger/cdb/cdbdebugengine.h
@@ -99,6 +99,7 @@ public:
     virtual void reloadRegisters();
     virtual void reloadSourceFiles();
     virtual void reloadFullStack() {}
+    virtual void addOptionPages(QList<Core::IOptionsPage*> *) const;
 
 public slots:
     void syncDebuggerPaths();
diff --git a/src/plugins/debugger/debuggermanager.cpp b/src/plugins/debugger/debuggermanager.cpp
index 7779050817c453691c7e7e9ea1e982b5a304f629..bc97bcdd84abc84992574277b6b92990a66ef938 100644
--- a/src/plugins/debugger/debuggermanager.cpp
+++ b/src/plugins/debugger/debuggermanager.cpp
@@ -82,11 +82,17 @@
 #include <QtGui/QToolButton>
 #include <QtGui/QToolTip>
 
+namespace Debugger {
+namespace Internal {
+
+IDebuggerEngine *createGdbEngine(DebuggerManager *parent);
+IDebuggerEngine *createScriptEngine(DebuggerManager *parent);
+IDebuggerEngine *createTcfEngine(DebuggerManager *parent);
 
-// The creation functions take a list of options pages they can add to.
-// This allows for having a "enabled" toggle on the page indepently
-// of the engine.
-using namespace Debugger::Internal;
+// The createWinEngine function takes a list of options pages it can add to.
+// This allows for having a "enabled" toggle on the page independently
+// of the engine. That's good for not enabling the related ActiveX control
+// unnecessarily.
 
 IDebuggerEngine *createWinEngine(DebuggerManager *, bool /* cmdLineEnabled */, QList<Core::IOptionsPage*> *)
 #ifdef CDB_ENABLED
@@ -94,17 +100,8 @@ IDebuggerEngine *createWinEngine(DebuggerManager *, bool /* cmdLineEnabled */, Q
 #else
 { return 0; }
 #endif
-IDebuggerEngine *createScriptEngine(DebuggerManager *parent, QList<Core::IOptionsPage*> *);
-IDebuggerEngine *createTcfEngine(DebuggerManager *parent, QList<Core::IOptionsPage*> *);
 
 
-namespace Debugger {
-namespace Internal {
-
-IDebuggerEngine *createGdbEngine(DebuggerManager *parent, QList<Core::IOptionsPage*> *);
-
-IDebuggerEngine *createSymbianEngine(DebuggerManager *parent, QList<Core::IOptionsPage*> *);
-
 QDebug operator<<(QDebug str, const DebuggerStartParameters &p)
 {
     QDebug nospace = str.nospace();
@@ -185,7 +182,6 @@ void DebuggerStartParameters::clear()
 
 static IDebuggerEngine *gdbEngine = 0;
 static IDebuggerEngine *scriptEngine = 0;
-static IDebuggerEngine *symbianEngine = 0;
 static IDebuggerEngine *tcfEngine = 0;
 static IDebuggerEngine *winEngine = 0;
 
@@ -201,7 +197,6 @@ DebuggerManager::~DebuggerManager()
     #define doDelete(ptr) delete ptr; ptr = 0
     doDelete(gdbEngine);
     doDelete(scriptEngine);
-    doDelete(symbianEngine);
     doDelete(tcfEngine);
     doDelete(winEngine);
     #undef doDelete
@@ -372,10 +367,8 @@ void DebuggerManager::init()
     m_reverseDirectionAction->setChecked(false);
     //m_reverseDirectionAction->setIcon(QIcon(":/debugger/images/debugger_stepoverproc_small.png"));
 
-    // For usuage hints oin focus{In,Out}
     connect(m_continueAction, SIGNAL(triggered()),
         this, SLOT(continueExec()));
-
     connect(m_stopAction, SIGNAL(triggered()),
         this, SLOT(interruptDebuggingRequest()));
     connect(m_resetAction, SIGNAL(triggered()),
@@ -446,15 +439,24 @@ void DebuggerManager::init()
 QList<Core::IOptionsPage*> DebuggerManager::initializeEngines(unsigned enabledTypeFlags)
 {
     QList<Core::IOptionsPage*> rc;
-    if (enabledTypeFlags & GdbEngineType)
-        gdbEngine = createGdbEngine(this, &rc);
-    if (enabledTypeFlags & SymbianEngineType)
-        symbianEngine = createSymbianEngine(this, &rc);
+
+    if (enabledTypeFlags & GdbEngineType) {
+        gdbEngine = createGdbEngine(this);
+        gdbEngine->addOptionPages(&rc);
+    }
+
     winEngine = createWinEngine(this, (enabledTypeFlags & CdbEngineType), &rc);
-    if (enabledTypeFlags & ScriptEngineType)
-        scriptEngine = createScriptEngine(this, &rc);
-    if (enabledTypeFlags & TcfEngineType)
-        tcfEngine = createTcfEngine(this, &rc);
+
+    if (enabledTypeFlags & ScriptEngineType) {
+        scriptEngine = createScriptEngine(this);
+        scriptEngine->addOptionPages(&rc);
+    }
+
+    if (enabledTypeFlags & TcfEngineType) {
+        tcfEngine = createTcfEngine(this);
+        tcfEngine->addOptionPages(&rc);
+    }
+
     m_engine = 0;
     if (Debugger::Constants::Internal::debug)
         qDebug() << Q_FUNC_INFO << gdbEngine << winEngine << scriptEngine << rc.size();
@@ -565,7 +567,7 @@ void DebuggerManager::notifyInferiorRunning()
 void DebuggerManager::notifyInferiorExited()
 {
     setStatus(DebuggerProcessNotReady);
-    showStatusMessage(tr("Stopped."), 5000);
+    showStatusMessage(tr("Exited."), 5000);
 }
 
 void DebuggerManager::notifyInferiorPidChanged(qint64 pid)
@@ -744,13 +746,15 @@ static IDebuggerEngine *determineDebuggerEngine(const QString &executable,
         return scriptEngine;
     }
 
+/*
     if (executable.endsWith(_(".sym"))) {
-        if (!symbianEngine) {
-            *errorMessage = msgEngineNotAvailable("Symbian Engine");
+        if (!gdbEngine) {
+            *errorMessage = msgEngineNotAvailable("Gdb Engine");
             return 0;
         }
-        return symbianEngine;
+        return gdbEngine;
     }
+*/
 
     if (IDebuggerEngine *tce = debuggerEngineForToolChain(
             static_cast<ProjectExplorer::ToolChain::ToolChainType>(toolChainType)))
@@ -1096,7 +1100,7 @@ static bool isAllowedTransition(int from, int to)
 {
     return (from == -1)
       || (from == DebuggerProcessNotReady && to == DebuggerProcessStartingUp)
-      //|| (from == DebuggerProcessStartingUp && to == DebuggerInferiorStopped)
+      || (from == DebuggerProcessStartingUp && to == DebuggerInferiorStopped)
       || (from == DebuggerInferiorStopped && to == DebuggerInferiorRunningRequested)
       || (from == DebuggerInferiorRunningRequested && to == DebuggerInferiorRunning)
       || (from == DebuggerInferiorRunning && to == DebuggerInferiorStopRequested)
@@ -1114,7 +1118,7 @@ void DebuggerManager::setStatus(int status)
     if (status == m_status)
         return;
 
-    if (0 && !isAllowedTransition(m_status, status)) {
+    if (1 && !isAllowedTransition(m_status, status)) {
         const QString msg = QString::fromLatin1("%1: UNEXPECTED TRANSITION: %2 -> %3")
             .arg(_(Q_FUNC_INFO), _(stateName(m_status)), _(stateName(status)));
         qWarning("%s", qPrintable(msg));
@@ -1155,7 +1159,8 @@ void DebuggerManager::setStatus(int status)
     m_runToFunctionAction->setEnabled(ready);
     m_jumpToLineAction->setEnabled(ready);
     m_nextAction->setEnabled(ready);
-    //showStatusMessage(QString("started: %1, running: %2").arg(started).arg(running));
+    //showStatusMessage(QString("started: %1, running: %2")
+    // .arg(started).arg(running));
     emit statusChanged(m_status);
     const bool notbusy = ready || status == DebuggerProcessNotReady;
     setBusyCursor(!notbusy);
@@ -1467,6 +1472,15 @@ void DebuggerManager::setSessionValue(const QString &name, const QVariant &value
     emit setSessionValueRequested(name, value);
 }
 
+void DebuggerManager::showMessageBox(int icon,
+    const QString &title, const QString &text)
+{
+    QMessageBox *mb = new QMessageBox(QMessageBox::Icon(icon),
+        title, text, QMessageBox::NoButton, mainWindow());
+    mb->setAttribute(Qt::WA_DeleteOnClose);
+    mb->show();
+}
+
 //////////////////////////////////////////////////////////////////////
 //
 // Testing
diff --git a/src/plugins/debugger/debuggermanager.h b/src/plugins/debugger/debuggermanager.h
index 5db5c605715e65dc1e696e098cdaa12a7d83dddd..29052449c9e8ba05aa55fc732c65c7393275399c 100644
--- a/src/plugins/debugger/debuggermanager.h
+++ b/src/plugins/debugger/debuggermanager.h
@@ -43,6 +43,7 @@ class QAction;
 class QAbstractItemModel;
 class QDockWidget;
 class QLabel;
+class QMessageBox;
 class QModelIndex;
 class QPoint;
 class QTimer;
@@ -183,12 +184,10 @@ enum DebuggerEngineTypeFlags
     ScriptEngineType  = 0x02,
     CdbEngineType     = 0x04,
     TcfEngineType     = 0x08,
-    SymbianEngineType = 0x10,
     AllEngineTypes = GdbEngineType
         | ScriptEngineType 
         | CdbEngineType 
         | TcfEngineType
-        | SymbianEngineType
 };
 
 // The construct below is not nice but enforces a bit of order. The
@@ -279,6 +278,8 @@ public:
     virtual DebuggerStartParametersPtr startParameters() const;
     virtual qint64 inferiorPid() const;
 
+    void showMessageBox(int icon, const QString &title, const QString &text);
+
 public slots:
     void startNewDebugger(const DebuggerStartParametersPtr &sp);
     void exitDebugger();
diff --git a/src/plugins/debugger/gdb/abstractgdbadapter.h b/src/plugins/debugger/gdb/abstractgdbadapter.h
index ba32496c0db1f2a5ea2c1257e98f5e2904226176..5f055ddfcf357cc30726f09303de5ec66f860b2b 100644
--- a/src/plugins/debugger/gdb/abstractgdbadapter.h
+++ b/src/plugins/debugger/gdb/abstractgdbadapter.h
@@ -81,12 +81,15 @@ public:
     virtual void setEnvironment(const QStringList &env) = 0;
     virtual bool isTrkAdapter() const = 0;
 
-    virtual void startAdapter(const DebuggerStartParametersPtr &sp) = 0;
+    virtual void startAdapter() = 0;
     virtual void prepareInferior() = 0;
     virtual void startInferior() = 0;
     virtual void interruptInferior() = 0;
     virtual void shutdown() = 0;
 
+    virtual const DebuggerStartParameters &startParameters() const
+        { return m_engine->startParameters(); }
+
 signals:
     void adapterStarted();
     void adapterStartFailed(const QString &msg);
diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp
index 092bdbce09de137e5957bc848de8aad2b1112fbb..2a835302fd77f01c36b673592add026cdd744b90 100644
--- a/src/plugins/debugger/gdb/gdbengine.cpp
+++ b/src/plugins/debugger/gdb/gdbengine.cpp
@@ -35,6 +35,7 @@
 #include "trkoptionspage.h"
 #include "plaingdbadapter.h"
 #include "trkgdbadapter.h"
+#include "remotegdbadapter.h"
 
 #include "watchutils.h"
 #include "debuggeractions.h"
@@ -173,6 +174,47 @@ GdbEngine::GdbEngine(DebuggerManager *parent) :
     qq(parent->engineInterface())
 {
     m_gdbAdapter = 0;
+    QSharedPointer<TrkOptions> options(new TrkOptions);
+    options->fromSettings(Core::ICore::instance()->settings());
+    m_plainAdapter = new PlainGdbAdapter(this);
+    m_trkAdapter = new TrkGdbAdapter(this, options);
+    m_remoteAdapter = 0; // FIXME
+
+    // Output
+    connect(&m_outputCollector, SIGNAL(byteDelivery(QByteArray)),
+        this, SLOT(readDebugeeOutput(QByteArray)));
+
+    connect(this, SIGNAL(gdbOutputAvailable(int,QString)),
+        m_manager, SLOT(showDebuggerOutput(int,QString)),
+        Qt::QueuedConnection);
+    connect(this, SIGNAL(gdbInputAvailable(int,QString)),
+        m_manager, SLOT(showDebuggerInput(int,QString)),
+        Qt::QueuedConnection);
+    connect(this, SIGNAL(applicationOutputAvailable(QString)),
+        m_manager, SLOT(showApplicationOutput(QString)),
+        Qt::QueuedConnection);
+}
+
+void GdbEngine::connectDebuggingHelperActions(bool on)
+{
+    if (on) {
+        connect(theDebuggerAction(UseDebuggingHelpers), SIGNAL(valueChanged(QVariant)),
+                this, SLOT(setUseDebuggingHelpers(QVariant)));
+        connect(theDebuggerAction(DebugDebuggingHelpers), SIGNAL(valueChanged(QVariant)),
+                this, SLOT(setDebugDebuggingHelpers(QVariant)));
+        connect(theDebuggerAction(RecheckDebuggingHelpers), SIGNAL(triggered()),
+                this, SLOT(recheckDebuggingHelperAvailability()));
+    } else {
+        disconnect(theDebuggerAction(UseDebuggingHelpers), 0, this, 0);
+        disconnect(theDebuggerAction(DebugDebuggingHelpers), 0, this, 0);
+        disconnect(theDebuggerAction(RecheckDebuggingHelpers), 0, this, 0);
+    }
+}
+   
+DebuggerStartMode GdbEngine::startMode() const
+{
+    QTC_ASSERT(!m_startParameters.isNull(), return NoStartMode);
+    return m_startParameters->startMode;
 }
 
 GdbEngine::~GdbEngine()
@@ -180,19 +222,15 @@ GdbEngine::~GdbEngine()
     // prevent sending error messages afterwards
     if (m_gdbAdapter) {
         m_gdbAdapter->disconnect(this);
-        delete m_gdbAdapter;
+        //delete m_gdbAdapter;
         m_gdbAdapter = 0;
     }
+    delete m_plainAdapter;
+    delete m_trkAdapter;
+    delete m_remoteAdapter;
 }
 
-void GdbEngine::setGdbAdapter(AbstractGdbAdapter *gdbAdapter)
-{
-    m_gdbAdapter = gdbAdapter;
-    initializeVariables();
-    initializeConnections();
-}
-
-void GdbEngine::initializeConnections()
+void GdbEngine::connectAdapter()
 {
     // Gdb Process interaction
     connect(m_gdbAdapter, SIGNAL(error(QProcess::ProcessError)),
@@ -227,28 +265,44 @@ void GdbEngine::initializeConnections()
 
     connect(m_gdbAdapter, SIGNAL(adapterCrashed()),
         m_manager, SLOT(exitDebugger()));
+}
 
-    // Output
-    connect(&m_outputCollector, SIGNAL(byteDelivery(QByteArray)),
-        this, SLOT(readDebugeeOutput(QByteArray)));
 
-    connect(this, SIGNAL(gdbOutputAvailable(int,QString)),
-        m_manager, SLOT(showDebuggerOutput(int,QString)),
-        Qt::QueuedConnection);
-    connect(this, SIGNAL(gdbInputAvailable(int,QString)),
-        m_manager, SLOT(showDebuggerInput(int,QString)),
-        Qt::QueuedConnection);
-    connect(this, SIGNAL(applicationOutputAvailable(QString)),
-        m_manager, SLOT(showApplicationOutput(QString)),
-        Qt::QueuedConnection);
+void GdbEngine::disconnectAdapter()
+{
+    // Gdb Process interaction
+    disconnect(m_gdbAdapter, SIGNAL(error(QProcess::ProcessError)),
+        this, SLOT(gdbProcError(QProcess::ProcessError)));
+    disconnect(m_gdbAdapter, SIGNAL(readyReadStandardOutput()),
+        this, SLOT(readGdbStandardOutput()));
+    disconnect(m_gdbAdapter, SIGNAL(readyReadStandardError()),
+        this, SLOT(readGdbStandardError()));
+
+    disconnect(m_gdbAdapter, SIGNAL(adapterStarted()),
+        this, SLOT(handleAdapterStarted()));
+    disconnect(m_gdbAdapter, SIGNAL(adapterStartFailed(QString)),
+        this, SLOT(handleAdapterStartFailed(QString)));
+    disconnect(m_gdbAdapter, SIGNAL(adapterShutDown()),
+        this, SLOT(handleAdapterShutDown()));
+    disconnect(m_gdbAdapter, SIGNAL(adapterShutdownFailed(QString)),
+        this, SLOT(handleAdapterShutdownFailed(QString)));
+
+    disconnect(m_gdbAdapter, SIGNAL(inferiorPrepared()),
+        this, SLOT(handleInferiorPrepared()));
+    disconnect(m_gdbAdapter, SIGNAL(inferiorPreparationFailed(QString)),
+        this, SLOT(handleInferiorPreparationFailed(QString)));
+
+    disconnect(m_gdbAdapter, SIGNAL(inferiorStarted()),
+        this, SLOT(handleInferiorStarted()));
+    disconnect(m_gdbAdapter, SIGNAL(inferiorStartFailed(QString)),
+        this, SLOT(handleInferiorStartFailed(QString)));
+    disconnect(m_gdbAdapter, SIGNAL(inferiorShutDown()),
+        this, SLOT(handleInferiorShutDown()));
+    disconnect(m_gdbAdapter, SIGNAL(inferiorShutdownFailed(QString)),
+        this, SLOT(handleInferiorShutdownFailed(QString)));
 
-    // FIXME: These trigger even if the engine is not active
-    connect(theDebuggerAction(UseDebuggingHelpers), SIGNAL(valueChanged(QVariant)),
-        this, SLOT(setUseDebuggingHelpers(QVariant)));
-    connect(theDebuggerAction(DebugDebuggingHelpers), SIGNAL(valueChanged(QVariant)),
-        this, SLOT(setDebugDebuggingHelpers(QVariant)));
-    connect(theDebuggerAction(RecheckDebuggingHelpers), SIGNAL(triggered()),
-        this, SLOT(recheckDebuggingHelperAvailability()));
+    disconnect(m_gdbAdapter, SIGNAL(adapterCrashed()),
+        m_manager, SLOT(exitDebugger()));
 }
 
 void GdbEngine::initializeVariables()
@@ -292,13 +346,13 @@ void GdbEngine::gdbProcError(QProcess::ProcessError error)
     bool kill = true;
     switch (error) {
         case QProcess::FailedToStart:
-            kill = false;
+            //kill = false;
             msg = tr("The Gdb process failed to start. Either the "
                 "invoked program '%1' is missing, or you may have insufficient "
                 "permissions to invoke the program.")
                 .arg(theDebuggerStringSetting(GdbLocation));
-            emit startFailed();
-            shutdown();
+            //emit startFailed();
+            //shutdown();
             break;
         case QProcess::Crashed:
             kill = false;
@@ -325,9 +379,9 @@ void GdbEngine::gdbProcError(QProcess::ProcessError error)
     }
 
     showStatusMessage(msg);
-    QMessageBox::critical(mainWindow(), tr("Error"), msg);
+    showMessageBox(QMessageBox::Critical, tr("Error"), msg);
     // act as if it was closed by the core
-    if (kill)
+    //if (kill)
         m_manager->exitDebugger();
 }
 
@@ -489,13 +543,27 @@ void GdbEngine::handleResponse(const QByteArray &buff)
         }
 
         case '~': {
-            static QRegExp re(_("New .hread 0x[0-9a-f]* \\(LWP ([0-9]*)\\)"));
             QByteArray data = GdbMi::parseCString(from, to);
             m_pendingConsoleStreamOutput += data;
-            if (re.indexIn(_(data)) != -1)
-                maybeHandleInferiorPidChanged(re.cap(1));
+
+            // Parse pid from noise.
+            if (!inferiorPid()) {
+                // Linux/Mac gdb: [New [Tt]hread 0x545 (LWP 4554)]
+                static QRegExp re1(_("New .hread 0x[0-9a-f]+ \\(LWP ([0-9]*)\\)"));
+                // MinGW 6.8: [New thread 2437.0x435345]
+                static QRegExp re2(_("New .hread ([0-9]+)\\.0x[0-9a-f]*"));
+                QTC_ASSERT(re1.isValid() && re2.isValid(), return);
+                if (re1.indexIn(_(data)) != -1)
+                    maybeHandleInferiorPidChanged(re1.cap(1));
+                else if (re2.indexIn(_(data)) != -1)
+                    maybeHandleInferiorPidChanged(re2.cap(1));
+            }
+
+            // Show some messages to give the impression something happens.
             if (data.startsWith("Reading symbols from "))
-                showStatusMessage(tr("Reading %1...").arg(_(data.mid(21))));
+                showStatusMessage(tr("Reading %1...").arg(_(data.mid(21))), 1000);
+            if (data.startsWith("[New "))
+                showStatusMessage(_(data), 1000);
             break;
         }
 
@@ -756,8 +824,8 @@ void GdbEngine::handleResultRecord(const GdbResultRecord &record)
         // msg="Cannot find new threads: generic error"
         if (record.resultClass == GdbResultError) {
             QByteArray msg = record.data.findChild("msg").data();
-            QMessageBox::critical(mainWindow(), tr("Error"),
-                tr("Executable failed:\n") + QString::fromLocal8Bit(msg));
+            showMessageBox(QMessageBox::Critical,
+                tr("Executable failed"), QString::fromLocal8Bit(msg));
             showStatusMessage(tr("Process failed to start."));
             exitDebugger();
             //qq->notifyInferiorStopped();
@@ -775,7 +843,7 @@ void GdbEngine::handleResultRecord(const GdbResultRecord &record)
 
     if (record.token < m_oldestAcceptableToken && (cmd.flags & Discardable)) {
         //qDebug() << "### SKIPPING OLD RESULT" << record.toString();
-        //QMessageBox::information(mainWindow(), tr("Skipped"), "xxx");
+        //showMessageBox(QMessageBox::Information(tr("Skipped"), "xxx"));
         return;
     }
 
@@ -1253,11 +1321,8 @@ void GdbEngine::handleStop1(const GdbResultRecord &, const QVariant &cookie)
                     "<tr><td>Signal meaning : </td><td>%2</td></tr></table>")
                     .arg(name.isEmpty() ? tr(" <Unknown> ") : _(name))
                     .arg(meaning.isEmpty() ? tr(" <Unknown> ") : _(meaning));
-                QMessageBox *mb = new QMessageBox(QMessageBox::Information,
-                    tr("Signal received"), msg, QMessageBox::NoButton,
-                    mainWindow());
-                mb->setAttribute(Qt::WA_DeleteOnClose);
-                mb->show();
+                showMessageBox(QMessageBox::Information,
+                    tr("Signal received"), msg);
             }
         }
 
@@ -1344,7 +1409,7 @@ void GdbEngine::handleShowVersion(const GdbResultRecord &response, const QVarian
             err->setMinimumSize(400, 300);
             err->showMessage(msg);
 #else
-            //QMessageBox::information(mainWindow(), tr("Warning"), msg);
+            //showMessageBox(QMessageBox::Information, tr("Warning"), msg);
 #endif
         } else {
             m_gdbVersion = 10000 * supported.cap(2).toInt()
@@ -1364,8 +1429,7 @@ void GdbEngine::handleFileExecAndSymbols(const GdbResultRecord &response, const
         //m_breakHandler->clearBreakMarkers();
     } else if (response.resultClass == GdbResultError) {
         QString msg = __(response.data.findChild("msg").data());
-        QMessageBox::critical(mainWindow(), tr("Error"),
-            tr("Starting executable failed:\n") + msg);
+        showMessageBox(QMessageBox::Critical, tr("Starting executable failed"), msg);
         QTC_ASSERT(status() == DebuggerInferiorRunning, /**/);
         //interruptInferior();
         qq->notifyInferiorExited();
@@ -1380,8 +1444,8 @@ void GdbEngine::handleExecRun(const GdbResultRecord &response, const QVariant &)
     } else {
         QTC_ASSERT(response.resultClass == GdbResultError, /**/);
         const QByteArray &msg = response.data.findChild("msg").data();
-        QMessageBox::critical(mainWindow(), tr("Error"),
-            tr("Starting executable failed:\n") + QString::fromLocal8Bit(msg));
+        showMessageBox(QMessageBox::Critical, tr("Starting executable failed",
+            QString::fromLocal8Bit(msg)));
         QTC_ASSERT(status() == DebuggerInferiorRunning, /**/);
         //interruptInferior();
         qq->notifyInferiorExited();
@@ -1402,8 +1466,8 @@ void GdbEngine::handleExecContinue(const GdbResultRecord &response, const QVaria
             //  "Leaving function..."));
             //stepOutExec();
         } else {
-            QMessageBox::critical(mainWindow(), tr("Error"),
-                tr("Starting executable failed:\n") + QString::fromLocal8Bit(msg));
+            showMessageBox(QMessageBox::Critical, tr("Starting executable failed"),
+                QString::fromLocal8Bit(msg));
             QTC_ASSERT(status() == DebuggerInferiorRunning, /**/);
             //interruptInferior();
             qq->notifyInferiorExited();
@@ -1457,48 +1521,22 @@ void GdbEngine::shutdown()
 
 void GdbEngine::detachDebugger()
 {
-    postCommand(_("detach"));
-    // FIXME: use postCommand(_("detach"), CB(handleExitHelper)) ?
-    postCommand(_("-gdb-exit"), CB(handleExit));
+    postCommand(_("detach"), CB(handleDetach));
 }
 
 void GdbEngine::exitDebugger()
 {
+    connectDebuggingHelperActions(false);
     m_outputCollector.shutdown();
     initializeVariables();
     m_gdbAdapter->shutdown();
 }
 
-void GdbEngine::handleExitHelper(const GdbResultRecord &, const QVariant &)
+void GdbEngine::handleDetach(const GdbResultRecord &, const QVariant &)
 {
-    exitDebugger2();
+    exitDebugger();
 }
 
-void GdbEngine::exitDebugger2()
-{
-/*
-    postCommand(_("-gdb-exit"), CB(handleExit));
-    // 20s can easily happen when loading webkit debug information
-    if (!m_gdbAdapter->waitForFinished(20000)) {
-        debugMessage(_("FORCING TERMINATION: %1")
-            .arg(m_gdbAdapter->state()));
-        m_gdbAdapter->terminate();
-        m_gdbAdapter->waitForFinished(20000);
-    }
-
-    if (m_gdbAdapter->state() != QProcess::NotRunning) {
-        debugMessage(_("PROBLEM STOPPING DEBUGGER: STATE %1")
-            .arg(m_gdbAdapter->state()));
-        m_gdbAdapter->kill();
-    }
-*/
-
-    m_outputCollector.shutdown();
-    initializeVariables();
-    //m_manager->settings()->m_debugDebuggingHelpers = false;
-}
-
-
 int GdbEngine::currentFrame() const
 {
     return qq->stackHandler()->currentIndex();
@@ -1506,20 +1544,30 @@ int GdbEngine::currentFrame() const
 
 void GdbEngine::startDebugger(const DebuggerStartParametersPtr &sp)
 {
+    // This should be set by the constructor or in exitDebugger() 
+    // via initializeVariables()
+    //QTC_ASSERT(m_debuggingHelperState == DebuggingHelperUninitialized,
+    //    initializeVariables());
+    //QTC_ASSERT(m_gdbAdapter == 0, delete m_gdbAdapter; m_gdbAdapter = 0);
+
     m_startParameters = sp;
-    m_gdbAdapter->startAdapter(sp);
-/*
-    // This should be set by the constructor or in exitDebugger().
-    QTC_ASSERT(m_debuggingHelperState == DebuggingHelperUninitialized,
-        initializeVariables());
-
-    if (m_gdbAdapter->state() != QProcess::NotRunning) {
-        debugMessage(_("GDB IS ALREADY RUNNING, STATE: %1").arg(m_gdbAdapter->state()));
-        m_gdbAdapter->kill();
-        emitStartFailed();
-        return;
-    }
+    if (startModeAllowsDumpers())
+        connectDebuggingHelperActions(true);
+
+    if (m_gdbAdapter)
+        disconnectAdapter();
 
+    if (sp->executable.endsWith(_(".sym")))
+        m_gdbAdapter = m_trkAdapter;
+    else 
+        m_gdbAdapter = m_plainAdapter;
+
+    initializeVariables();
+    connectAdapter();
+
+    m_gdbAdapter->startAdapter();
+
+/*
     QStringList gdbArgs;
     gdbArgs.prepend(_("mi"));
     gdbArgs.prepend(_("-i"));
@@ -1527,19 +1575,6 @@ void GdbEngine::startDebugger(const DebuggerStartParametersPtr &sp)
     if (startMode() == AttachCore || startMode() == AttachExternal
             || startMode() == AttachCrashedExternal) {
         // nothing to do
-    } else if (startMode() == StartRemote) {
-        // Start the remote server
-        if (m_startParameters->serverStartScript.isEmpty()) {
-            showStatusMessage(_("No server start script given. "
-                "Assuming server runs already."));
-        } else {
-            if (!m_startParameters->workingDir.isEmpty())
-                m_uploadProc.setWorkingDirectory(m_startParameters->workingDir);
-            if (!m_startParameters->environment.isEmpty())
-                m_uploadProc.setEnvironment(m_startParameters->environment);
-            m_uploadProc.start(_("/bin/sh ") + m_startParameters->serverStartScript);
-            m_uploadProc.waitForStarted();
-        }
     } else if (m_startParameters->useTerminal) {
         m_stubProc.stop(); // We leave the console open, so recycle it now.
 
@@ -1553,7 +1588,7 @@ void GdbEngine::startDebugger(const DebuggerStartParametersPtr &sp)
         }
     } else {
         if (!m_outputCollector.listen()) {
-            QMessageBox::critical(mainWindow(), tr("Debugger Startup Failure"),
+            showMessageBox(QMessageBox::Critical, tr("Debugger Startup Failure"),
                 tr("Cannot set up communication with child process: %1")
                     .arg(m_outputCollector.errorString()));
             emitStartFailed();
@@ -1566,19 +1601,6 @@ void GdbEngine::startDebugger(const DebuggerStartParametersPtr &sp)
         if (!m_startParameters->environment.isEmpty())
             m_gdbAdapter->setEnvironment(m_startParameters->environment);
     }
-
-    #if 0
-    qDebug() << "Command:" << m_manager->settings()->m_gdbCmd;
-    qDebug() << "WorkingDirectory:" << m_gdbAdapter->workingDirectory();
-    qDebug() << "ScriptFile:" << m_manager->settings()->m_scriptFile;
-    qDebug() << "Environment:" << m_gdbAdapter->environment();
-    qDebug() << "Arguments:" << gdbArgs;
-    qDebug() << "BuildDir:" << m_startParameters->buildDir;
-    qDebug() << "ExeFile:" << m_startParameters->executable;
-    #endif
-
-    QString loc = theDebuggerStringSetting(GdbLocation);
-    showStatusMessage(tr("Starting Debugger: ") + loc + _c(' ') + gdbArgs.join(_(" ")));
     m_gdbAdapter->start(loc, gdbArgs);
 */
 }
@@ -1591,6 +1613,7 @@ void GdbEngine::continueInferior()
     postCommand(_("-exec-continue"), CB(handleExecContinue));
 }
 
+#if 0
 void GdbEngine::handleAttach(const GdbResultRecord &, const QVariant &)
 {
     qq->notifyInferiorStopped();
@@ -1644,10 +1667,11 @@ void GdbEngine::handleTargetRemote(const GdbResultRecord &record, const QVariant
         QString msg = __(record.data.findChild("msg").data());
         QString msg1 = tr("Connecting to remote server failed:");
         showStatusMessage(msg1 + _c(' ') + msg);
-        QMessageBox::critical(mainWindow(), tr("Error"), msg1 + _c('\n') + msg);
+        showMessageBox(QMessageBox::Critical, tr("Error"), msg1 + _c('\n') + msg);
         postCommand(_("-gdb-exit"), CB(handleExit));
     }
 }
+#endif
 
 void GdbEngine::handleExit(const GdbResultRecord &, const QVariant &)
 {
@@ -3845,9 +3869,8 @@ void GdbEngine::recheckDebuggingHelperAvailability()
 
 bool GdbEngine::startModeAllowsDumpers() const
 {
-    return startMode() == StartInternal
-        || startMode() == StartExternal
-        || startMode() == AttachExternal;
+    const DebuggerStartMode m = startMode();
+    return m == StartInternal || m == StartExternal || m == AttachExternal;
 }
 
 void GdbEngine::watchPoint(const QPoint &pnt)
@@ -4081,28 +4104,31 @@ void GdbEngine::gotoLocation(const StackFrame &frame, bool setMarker)
 void GdbEngine::handleAdapterStartFailed(const QString &msg)
 {
     debugMessage(_("ADAPTER START FAILED"));
-    m_outputCollector.shutdown();
-    QMessageBox::critical(mainWindow(), tr("Error"), msg);
-    QTC_ASSERT(status() == DebuggerInferiorRunning, /**/);
-    //interruptInferior();
+    showMessageBox(QMessageBox::Critical, tr("Adapter start failed"), msg);
+    qq->notifyInferiorExited();
+    m_manager->exitDebugger();
 }
 
 void GdbEngine::handleAdapterStarted()
 {
     debugMessage(_("ADAPTER SUCCESSFULLY STARTED, PREPARING INFERIOR"));
+    qq->notifyInferiorStopped();
     m_gdbAdapter->prepareInferior();
 }
 
 void GdbEngine::handleInferiorPreparationFailed(const QString &msg)
 {
     debugMessage(_("INFERIOR PREPARATION FAILD"));
-    m_outputCollector.shutdown();
-    QMessageBox::critical(mainWindow(), tr("Error"),
-        tr("Inferior start preparation failed:\n") + msg);
+    showMessageBox(QMessageBox::Critical,
+        tr("Inferior start preparation failed"), msg);
+    shutdown();
+    qq->notifyInferiorExited();
+    m_manager->exitDebugger();
 }
 
 void GdbEngine::handleInferiorPrepared()
 {
+    debugMessage(_("INFERIOR PREPARED"));
     // FIXME: Check that inferior is in "stopped" state
     qq->notifyInferiorStopped();
     showStatusMessage(tr("Inferior prepared for startup."));
@@ -4175,7 +4201,7 @@ void GdbEngine::handleInferiorPrepared()
         if (QFileInfo(scriptFileName).isReadable()) {
             postCommand(_("source ") + scriptFileName);
         } else {
-            QMessageBox::warning(mainWindow(),
+            showMessageBox(QMessageBox::Warning,
             tr("Cannot find debugger initialization script"),
             tr("The debugger settings point to a script file at '%1' "
                "which is not accessible. If a script file is not needed, "
@@ -4230,7 +4256,7 @@ void GdbEngine::handleInferiorPrepared()
 
 void GdbEngine::handleInitialBreakpointsSet()
 {
-    showStatusMessage(tr("Finishing initial breakpoint setting."));
+    showStatusMessage(tr("Initial breakpoint setting finished."), 1000);
     qq->notifyInferiorRunningRequested();
     m_gdbAdapter->startInferior();
 }
@@ -4238,69 +4264,64 @@ void GdbEngine::handleInitialBreakpointsSet()
 void GdbEngine::handleInferiorStartFailed(const QString &msg)
 {
     debugMessage(_("INFERIOR START FAILED"));
-    QMessageBox::critical(mainWindow(), tr("Error"),
-        tr("Inferior start failed:\n") + msg);
+    showMessageBox(QMessageBox::Critical, tr("Inferior start failed"), msg);
     qq->notifyInferiorExited();
+    m_manager->exitDebugger();
 }
 
 void GdbEngine::handleInferiorStarted()
 {
+    debugMessage(_("INFERIOR STARTED"));
     qq->notifyInferiorRunning();
 }
 
 void GdbEngine::handleInferiorShutDown()
 {
     debugMessage(_("INFERIOR SUCCESSFULLY SHUT DOWN"));
-    qq->notifyInferiorExited();
 }
 
 void GdbEngine::handleInferiorShutdownFailed(const QString &msg)
 {
     debugMessage(_("INFERIOR SHUTDOWN FAILED"));
-    QMessageBox::critical(mainWindow(), tr("Error"),
-        tr("Inferior shutdown failed:\n") + msg);
+    showMessageBox(QMessageBox::Critical,
+        tr("Inferior shutdown failed"), msg);
+    qq->notifyInferiorExited();
+    m_manager->exitDebugger();
 }
 
 void GdbEngine::handleAdapterShutDown()
 {
     debugMessage(_("ADAPTER SUCCESSFULLY SHUT DOWN"));
+    qq->notifyInferiorExited();
 }
 
 void GdbEngine::handleAdapterShutdownFailed(const QString &msg)
 {
     debugMessage(_("ADAPTER SHUTDOWN FAILED"));
-    QMessageBox::critical(mainWindow(), tr("Error"),
-        tr("Inferior shutdown failed:\n") + msg);
+    showMessageBox(QMessageBox::Critical,
+        tr("Inferior shutdown failed"), msg);
+    qq->notifyInferiorExited();
 }
 
-//
-// Factory
-//
-
-IDebuggerEngine *createGdbEngine(DebuggerManager *parent,
-    QList<Core::IOptionsPage*> *opts)
+void GdbEngine::addOptionPages(QList<Core::IOptionsPage*> *opts) const
 {
     opts->push_back(new GdbOptionsPage);
-    GdbEngine *engine = new GdbEngine(parent);
-    PlainGdbAdapter *adapter = new PlainGdbAdapter(engine);
-    engine->setGdbAdapter(adapter);
-    return engine;
+    if (!qgetenv("QTCREATOR_WITH_S60").isEmpty())
+        opts->push_back(new TrkOptionsPage(m_trkAdapter->options()));
 }
 
-IDebuggerEngine *createSymbianEngine(DebuggerManager *parent,
-    QList<Core::IOptionsPage*> *opts)
+void GdbEngine::showMessageBox(int icon, const QString &title, const QString &text)
 {
-    QSharedPointer<TrkOptions> options(new TrkOptions);
-    options->fromSettings(Core::ICore::instance()->settings());
+    m_manager->showMessageBox(icon, title, text);
+}
 
-    if (!qgetenv("QTCREATOR_WITH_S60").isEmpty())
-        opts->push_back(new TrkOptionsPage(options));
-    GdbEngine *engine = new GdbEngine(parent);
-    TrkGdbAdapter *adapter = new TrkGdbAdapter(engine, options);
-    engine->setGdbAdapter(adapter);
-    QObject::connect(adapter, SIGNAL(output(QString)),
-        parent, SLOT(showDebuggerOutput(QString)));
-    return engine;
+//
+// Factory
+//
+
+IDebuggerEngine *createGdbEngine(DebuggerManager *parent)
+{
+    return new GdbEngine(parent);
 }
 
 } // namespace Internal
diff --git a/src/plugins/debugger/gdb/gdbengine.h b/src/plugins/debugger/gdb/gdbengine.h
index 58c7d64a75a1707a31d9d8238d6c8f323c3d9624..a71cede808c03acca75bcf678ffc27ae6816e580 100644
--- a/src/plugins/debugger/gdb/gdbengine.h
+++ b/src/plugins/debugger/gdb/gdbengine.h
@@ -65,6 +65,10 @@ class GdbMi;
 class WatchData;
 class BreakpointData;
 
+class PlainGdbAdapter;
+class TrkGdbAdapter;
+class RemoteGdbAdapter;
+
 enum DebuggingHelperState
 {
     DebuggingHelperUninitialized,
@@ -80,7 +84,6 @@ class GdbEngine : public IDebuggerEngine
 public:
     explicit GdbEngine(DebuggerManager *parent);
     ~GdbEngine();
-    void setGdbAdapter(AbstractGdbAdapter *adapter);
 
 signals:
     void gdbInputAvailable(int channel, const QString &msg);
@@ -92,8 +95,6 @@ private:
     friend class TrkGdbAdapter;
     friend class RemoteGdbAdapter;
 
-    const DebuggerStartParameters &startParameters() const
-        { return *m_startParameters; }
     //
     // IDebuggerEngine implementation
     //
@@ -107,7 +108,6 @@ private:
     void setToolTipExpression(const QPoint &mousePos, TextEditor::ITextEditor *editor, int cursorPos);
     void startDebugger(const DebuggerStartParametersPtr &sp);
     void exitDebugger();
-    void exitDebugger2();
     void detachDebugger();
 
     void continueInferior();
@@ -156,7 +156,8 @@ private:
     bool supportsThreads() const;
     void gotoLocation(const StackFrame &frame, bool setLocationMarker);
 
-    void initializeConnections();
+    void connectAdapter();
+    void disconnectAdapter();
     void initializeVariables();
     QString fullName(const QString &fileName);
     // get one usable name out of these, try full names first
@@ -248,7 +249,7 @@ private:
     int terminationIndex(const QByteArray &buffer, int &length);
     void handleResponse(const QByteArray &buff);
     void handleStart(const GdbResultRecord &response, const QVariant &);
-    void handleAttach(const GdbResultRecord &, const QVariant &);
+    //void handleAttach(const GdbResultRecord &, const QVariant &);
     void handleAqcuiredInferior();
     void handleAsyncOutput(const GdbMi &data);
     void handleStop1(const GdbResultRecord &, const QVariant &cookie);
@@ -268,9 +269,9 @@ private:
     void handleQuerySources(const GdbResultRecord &response, const QVariant &);
     void handleTargetCore(const GdbResultRecord &, const QVariant &);
     void handleExit(const GdbResultRecord &, const QVariant &);
-    void handleExitHelper(const GdbResultRecord &, const QVariant &);
-    void handleSetTargetAsync(const GdbResultRecord &, const QVariant &);
-    void handleTargetRemote(const GdbResultRecord &, const QVariant &);
+    void handleDetach(const GdbResultRecord &, const QVariant &);
+    //void handleSetTargetAsync(const GdbResultRecord &, const QVariant &);
+    //void handleTargetRemote(const GdbResultRecord &, const QVariant &);
     void handleWatchPoint(const GdbResultRecord &, const QVariant &);
     bool showToolTip();
 
@@ -280,7 +281,7 @@ private:
         { m_manager->showStatusMessage(msg, timeout); }
     int status() const { return m_manager->status(); }
     QMainWindow *mainWindow() const { return m_manager->mainWindow(); }
-    DebuggerStartMode startMode() const { return m_startParameters->startMode; }
+    DebuggerStartMode startMode() const;
     qint64 inferiorPid() const { return m_manager->inferiorPid(); }
 
     void handleChildren(const WatchData &parent, const GdbMi &child,
@@ -411,6 +412,7 @@ private:
     void setWatchDataType(WatchData &data, const GdbMi &mi);
     void setWatchDataDisplayedType(WatchData &data, const GdbMi &mi);
     void setLocals(const QList<GdbMi> &locals);
+    void connectDebuggingHelperActions(bool on);
    
     bool startModeAllowsDumpers() const;
     QString parseDisassembler(const GdbMi &lines);
@@ -440,8 +442,18 @@ private:
     DebuggerStartParametersPtr m_startParameters;
     // make sure to re-initialize new members in initializeVariables();
 
+    // only one of those is active at a given time
+    PlainGdbAdapter *m_plainAdapter;
+    TrkGdbAdapter *m_trkAdapter;
+    RemoteGdbAdapter *m_remoteAdapter;
+    
 public:
+    void showMessageBox(int icon, const QString &title, const QString &text);
     void debugMessage(const QString &msg);
+    void addOptionPages(QList<Core::IOptionsPage*> *opts) const;
+    const DebuggerStartParameters &startParameters() const
+        { return *m_startParameters; }
+
     OutputCollector m_outputCollector;
 };
 
diff --git a/src/plugins/debugger/gdb/plaingdbadapter.cpp b/src/plugins/debugger/gdb/plaingdbadapter.cpp
index f29def0afdfa0650ac2efdcba643e44d0df65d41..68630fff7a73afa0b016ff4c065e361cfcba5f62 100644
--- a/src/plugins/debugger/gdb/plaingdbadapter.cpp
+++ b/src/plugins/debugger/gdb/plaingdbadapter.cpp
@@ -83,24 +83,23 @@ PlainGdbAdapter::PlainGdbAdapter(GdbEngine *engine, QObject *parent)
 //        m_manager, SLOT(exitDebugger()));
 }
 
-void PlainGdbAdapter::startAdapter(const DebuggerStartParametersPtr &sp)
+void PlainGdbAdapter::startAdapter()
 {
     QTC_ASSERT(state() == AdapterNotRunning, qDebug() << state());
     setState(AdapterStarting);
     debugMessage(_("TRYING TO START ADAPTER"));
-    m_startParameters = sp;
 
     QStringList gdbArgs;
     gdbArgs.prepend(_("mi"));
     gdbArgs.prepend(_("-i"));
 
-    if (m_startParameters->useTerminal) {
+    if (startParameters().useTerminal) {
         m_stubProc.stop(); // We leave the console open, so recycle it now.
 
-        m_stubProc.setWorkingDirectory(m_startParameters->workingDir);
-        m_stubProc.setEnvironment(m_startParameters->environment);
-        if (!m_stubProc.start(m_startParameters->executable,
-                             m_startParameters->processArgs)) {
+        m_stubProc.setWorkingDirectory(startParameters().workingDir);
+        m_stubProc.setEnvironment(startParameters().environment);
+        if (!m_stubProc.start(startParameters().executable,
+                             startParameters().processArgs)) {
             // Error message for user is delivered via a signal.
             emitAdapterStartFailed(QString());
             return;
@@ -113,10 +112,10 @@ void PlainGdbAdapter::startAdapter(const DebuggerStartParametersPtr &sp)
         }
         gdbArgs.prepend(_("--tty=") + m_engine->m_outputCollector.serverName());
 
-        if (!m_startParameters->workingDir.isEmpty())
-            setWorkingDirectory(m_startParameters->workingDir);
-        if (!m_startParameters->environment.isEmpty())
-            setEnvironment(m_startParameters->environment);
+        if (!startParameters().workingDir.isEmpty())
+            setWorkingDirectory(startParameters().workingDir);
+        if (!startParameters().environment.isEmpty())
+            setEnvironment(startParameters().environment);
     }
 
     QString location = theDebuggerStringSetting(GdbLocation);
@@ -135,9 +134,9 @@ void PlainGdbAdapter::prepareInferior()
 {
     QTC_ASSERT(state() == AdapterStarted, qDebug() << state());
     setState(InferiorPreparing);
-    if (!m_startParameters->processArgs.isEmpty())
+    if (!startParameters().processArgs.isEmpty())
         m_engine->postCommand(_("-exec-arguments ")
-            + m_startParameters->processArgs.join(_(" ")));
+            + startParameters().processArgs.join(_(" ")));
     QFileInfo fi(m_engine->startParameters().executable);
     m_engine->postCommand(_("-file-exec-and-symbols \"%1\"").arg(fi.absoluteFilePath()),
         CB(handleFileExecAndSymbols));
diff --git a/src/plugins/debugger/gdb/plaingdbadapter.h b/src/plugins/debugger/gdb/plaingdbadapter.h
index 78fd23a70a178bf1122817ce4d57148d0d9eeba2..f10d822da7f6dc9b2dc4d1704d26e528ff86aa33 100644
--- a/src/plugins/debugger/gdb/plaingdbadapter.h
+++ b/src/plugins/debugger/gdb/plaingdbadapter.h
@@ -61,7 +61,7 @@ public:
     void setEnvironment(const QStringList &env) { m_gdbProc.setEnvironment(env); }
     bool isTrkAdapter() const { return false; }
 
-    void startAdapter(const DebuggerStartParametersPtr &sp);
+    void startAdapter();
     void prepareInferior();
     void startInferior();
     void interruptInferior();
@@ -83,7 +83,6 @@ private:
     Q_SLOT void stubError(const QString &msg);
 
     QProcess m_gdbProc;
-    DebuggerStartParametersPtr m_startParameters;
     Core::Utils::ConsoleProcess m_stubProc;
 };
 
diff --git a/src/plugins/debugger/gdb/remotegdbadapter.cpp b/src/plugins/debugger/gdb/remotegdbadapter.cpp
index e84eaf9180b6d6dd2091b22d15c613745f268724..85aaaa318223e24aeb1f7ff7164f8c77ebebe5c1 100644
--- a/src/plugins/debugger/gdb/remotegdbadapter.cpp
+++ b/src/plugins/debugger/gdb/remotegdbadapter.cpp
@@ -101,7 +101,24 @@ void RemoteGdbAdapter::startAdapter(const DebuggerStartParametersPtr &sp)
         setEnvironment(m_startParameters->environment);
 
     QString location = theDebuggerStringSetting(GdbLocation);
-    //showStatusMessage(tr("Starting Debugger: ") + loc + _c(' ') + gdbArgs.join(_(" ")));
+
+/*  
+    // FIXME: make asynchroneouis
+    // Start the remote server
+    if (m_startParameters->serverStartScript.isEmpty()) {
+        showStatusMessage(_("No server start script given. "
+            "Assuming server runs already."));
+    } else {
+        if (!m_startParameters->workingDir.isEmpty())
+            m_uploadProc.setWorkingDirectory(m_startParameters->workingDir);
+        if (!m_startParameters->environment.isEmpty())
+            m_uploadProc.setEnvironment(m_startParameters->environment);
+        m_uploadProc.start(_("/bin/sh ") + m_startParameters->serverStartScript);
+        m_uploadProc.waitForStarted();
+    }
+*/
+
+    // Start the debugger
     m_gdbProc.start(location, gdbArgs);
 }
 
diff --git a/src/plugins/debugger/gdb/trkgdbadapter.cpp b/src/plugins/debugger/gdb/trkgdbadapter.cpp
index acb296d50e5ee44303724b193588dae3c27ebc82..05980ba90e59a211ed036fe14124d34d3353ba26 100644
--- a/src/plugins/debugger/gdb/trkgdbadapter.cpp
+++ b/src/plugins/debugger/gdb/trkgdbadapter.cpp
@@ -240,7 +240,7 @@ void TrkGdbAdapter::startInferiorEarly()
     if (!m_trkDevice.open(device, &errorMessage)) {
         logMessage(QString::fromLatin1("Waiting on %1 (%2)").arg(device, errorMessage));
         // Do not loop forever
-        if (m_waitCount++ < (m_options->mode == TrkOptions::BlueTooth ? 60 : 5)) {
+        if (m_waitCount++ < (m_options->mode == TrkOptions::BlueTooth ? 3 : 5)) {
             QTimer::singleShot(1000, this, SLOT(startInferiorEarly()));
         } else {
             QString msg = QString::fromLatin1("Failed to connect to %1 after "
@@ -275,8 +275,13 @@ void TrkGdbAdapter::startInferiorEarly()
 
 void TrkGdbAdapter::logMessage(const QString &msg)
 {
-    if (m_verbose)
+    if (m_verbose) {
+#ifdef STANDALONE_RUNNER
         emit output(msg);
+#else
+        m_engine->debugMessage(msg);
+#endif
+    }
 }
 
 //
@@ -1339,12 +1344,11 @@ void TrkGdbAdapter::handleGdbStateChanged(QProcess::ProcessState newState)
     logMessage(_("GDB: Process State %1").arg(newState));
 }
 
-void TrkGdbAdapter::startAdapter(const DebuggerStartParametersPtr &sp)
+void TrkGdbAdapter::startAdapter()
 {
     QTC_ASSERT(state() == AdapterNotRunning, qDebug() << state());
     setState(AdapterStarting);
     debugMessage(_("TRYING TO START ADAPTER"));
-    m_startParameters = sp;
     logMessage(QLatin1String("### Starting TrkGdbAdapter"));
     if (m_options->mode == TrkOptions::BlueTooth) {
         const QString device = effectiveTrkDevice();
diff --git a/src/plugins/debugger/gdb/trkgdbadapter.h b/src/plugins/debugger/gdb/trkgdbadapter.h
index 55896eb1d085ff3207a309c823c4bb34c92b51b9..7c6ecda322a3dcd84f9b0ced428d7b637fd13888 100644
--- a/src/plugins/debugger/gdb/trkgdbadapter.h
+++ b/src/plugins/debugger/gdb/trkgdbadapter.h
@@ -32,6 +32,7 @@
 
 #include "trkutils.h"
 #include "trkdevice.h"
+#include "trkoptions.h"
 #include "abstractgdbadapter.h"
 
 #include <QtCore/QHash>
@@ -48,8 +49,6 @@
 namespace Debugger {
 namespace Internal {
 
-struct TrkOptions;
-
 struct GdbResult
 {
     QByteArray data;
@@ -85,6 +84,7 @@ public:
     // Set a device (from the project) to override the settings.
     QString overrideTrkDevice() const;
     void setOverrideTrkDevice(const QString &);
+    const TrkOptionsPtr options() const { return m_options; }
 
 signals:
     void output(const QString &msg);
@@ -100,7 +100,6 @@ private:
     QProcess m_gdbProc;
     QProcess m_rfcommProc;
     bool m_running;
-    DebuggerStartParametersPtr m_startParameters;
     void debugMessage(const QString &msg) { m_engine->debugMessage(msg); }
 
 public:
@@ -116,7 +115,7 @@ public:
     void setEnvironment(const QStringList &env);
     bool isTrkAdapter() const { return true; }
 
-    void startAdapter(const DebuggerStartParametersPtr &sp);
+    void startAdapter();
     void prepareInferior();
     void startInferior();
     void interruptInferior();
diff --git a/src/plugins/debugger/idebuggerengine.h b/src/plugins/debugger/idebuggerengine.h
index de2e7c5facc1aa9a25ad8cd195e814fba9cf5e44..6724d0093511865dd59ab1aedba2dd47d357b487 100644
--- a/src/plugins/debugger/idebuggerengine.h
+++ b/src/plugins/debugger/idebuggerengine.h
@@ -43,6 +43,10 @@ namespace TextEditor {
 class ITextEditor;
 }
 
+namespace Core {
+class IOptionsPage;
+}
+
 namespace Debugger {
 namespace Internal {
 
@@ -105,6 +109,8 @@ public:
     virtual void setRegisterValue(int regnr, const QString &value)
         { Q_UNUSED(regnr); Q_UNUSED(value); }
 
+    virtual void addOptionPages(QList<Core::IOptionsPage*> *) const {}
+
 signals:
     void startSuccessful();
     void startFailed();
diff --git a/src/plugins/debugger/script/scriptengine.cpp b/src/plugins/debugger/script/scriptengine.cpp
index d73dc189b62f6e8e845cb93a8c4afab85e5f4241..7f1caec3560b8de532bb950c60af6cf920b5077b 100644
--- a/src/plugins/debugger/script/scriptengine.cpp
+++ b/src/plugins/debugger/script/scriptengine.cpp
@@ -65,10 +65,6 @@
 #include <QtScript/QScriptValue>
 #include <QtScript/QScriptValueIterator>
 
-using namespace Debugger;
-using namespace Debugger::Internal;
-using namespace Debugger::Constants;
-
 //#define DEBUG_SCRIPT 1
 #if DEBUG_SCRIPT
 #   define SDEBUG(s) qDebug() << s
@@ -77,13 +73,17 @@ using namespace Debugger::Constants;
 #endif
 # define XSDEBUG(s) qDebug() << s
 
+
+namespace Debugger {
+namespace Internal {
+
 ///////////////////////////////////////////////////////////////////////
 //
 // ScriptEngine
 //
 ///////////////////////////////////////////////////////////////////////
 
-class Debugger::Internal::ScriptAgent : public QScriptEngineAgent
+class ScriptAgent : public QScriptEngineAgent
 {
 public:
     ScriptAgent(ScriptEngine *debugger, QScriptEngine *script);
@@ -733,8 +733,10 @@ void ScriptEngine::updateSubItem(const WatchData &data0)
     QTC_ASSERT(false, return);
 }
 
-IDebuggerEngine *createScriptEngine(DebuggerManager *parent, QList<Core::IOptionsPage*> *)
+IDebuggerEngine *createScriptEngine(DebuggerManager *parent)
 {
     return new ScriptEngine(parent);
 }
 
+} // namespace Internal
+} // namespace Debugger
diff --git a/src/plugins/debugger/tcf/tcfengine.cpp b/src/plugins/debugger/tcf/tcfengine.cpp
index fe0eebf96a9e6b0bbfdd792addb4625b4b2964d1..cc88654ee2d717083922d4781810a11f9cd07e38 100644
--- a/src/plugins/debugger/tcf/tcfengine.cpp
+++ b/src/plugins/debugger/tcf/tcfengine.cpp
@@ -57,11 +57,6 @@
 
 #include <QtNetwork/QTcpSocket>
 
-
-using namespace Debugger;
-using namespace Debugger::Internal;
-using namespace Debugger::Constants;
-
 #define DEBUG_TCF 1
 #if DEBUG_TCF
 #   define SDEBUG(s) qDebug() << s
@@ -74,7 +69,9 @@ using namespace Debugger::Constants;
 #define STRINGIFY(x) STRINGIFY_INTERNAL(x)
 #define CB(callback) &TcfEngine::callback, STRINGIFY(callback)
 
-QByteArray C(const QByteArray &ba1,
+//#define USE_CONGESTION_CONTROL
+
+static QByteArray C(const QByteArray &ba1,
     const QByteArray &ba2 = QByteArray(),
     const QByteArray &ba3 = QByteArray(),
     const QByteArray &ba4 = QByteArray(),
@@ -88,9 +85,8 @@ QByteArray C(const QByteArray &ba1,
     return result;
 }
 
-
-//#define USE_CONGESTION_CONTROL
-
+namespace Debugger {
+namespace Internal {
 
 ///////////////////////////////////////////////////////////////////////
 //
@@ -571,8 +567,10 @@ void TcfEngine::updateSubItem(const WatchData &data0)
     QTC_ASSERT(false, return);
 }
 
-IDebuggerEngine *createTcfEngine(DebuggerManager *parent, QList<Core::IOptionsPage*> *)
+IDebuggerEngine *createTcfEngine(DebuggerManager *parent)
 {
     return new TcfEngine(parent);
 }
 
+} // namespace Internal
+} // namespace Debugger