diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp
index f4fb7e9551890f6d808a171c4ee302d372e6c02d..d75faa03edcb74403e57d199778a3e7a20781ae8 100644
--- a/src/plugins/debugger/debuggerplugin.cpp
+++ b/src/plugins/debugger/debuggerplugin.cpp
@@ -1115,6 +1115,7 @@ public slots:
     void maybeEnrichParameters(DebuggerStartParameters *sp);
 
     void gdbServerStarted(const QString &channel, const QString &sysroot, const QString &localExecutable);
+    void attachedToProcess(const QString &channel, const QString &sysroot, const QString &localExecutable);
 
 public:
     DebuggerMainWindow *m_mainWindow;
@@ -1672,11 +1673,6 @@ void DebuggerPluginPrivate::attachToRemoteServer()
     }
 }
 
-void DebuggerPluginPrivate::attachToRemoteProcess()
-{
-    startRemoteServer();
-}
-
 void DebuggerPluginPrivate::startRemoteServer()
 {
     PluginManager *pm = PluginManager::instance();
@@ -1689,6 +1685,24 @@ void DebuggerPluginPrivate::startRemoteServer()
 
 void DebuggerPluginPrivate::gdbServerStarted(const QString &channel,
     const QString &sysroot, const QString &remoteCommandLine)
+{
+    Q_UNUSED(remoteCommandLine);
+    Q_UNUSED(sysroot);
+    showStatusMessage(tr("gdbserver is now listening at %1").arg(channel));
+}
+
+void DebuggerPluginPrivate::attachToRemoteProcess()
+{
+    PluginManager *pm = PluginManager::instance();
+    QTC_ASSERT(pm, return);
+    QObject *rl = pm->getObjectByName(_("RemoteLinuxPlugin"));
+    QTC_ASSERT(rl, return);
+    QMetaObject::invokeMethod(rl, "attachToRemoteProcess", Qt::QueuedConnection);
+    // This will call back attachedtToProcess() below.
+}
+
+void DebuggerPluginPrivate::attachedToProcess(const QString &channel,
+    const QString &sysroot, const QString &remoteCommandLine)
 {
     QString binary = remoteCommandLine.section(QLatin1Char(' '), 0, 0);
     QString localExecutable;
@@ -3074,7 +3088,7 @@ void DebuggerPluginPrivate::extensionsInitialized()
     connect(act, SIGNAL(triggered()), SLOT(attachToRemoteServer()));
 
     act = m_startRemoteServerAction = new QAction(this);
-    act->setText(tr("Start Remote Debug Server..."));
+    act->setText(tr("Start Remote Debug Server Attached to Process..."));
     connect(act, SIGNAL(triggered()), SLOT(startRemoteServer()));
 
     act = m_attachToRemoteProcessAction = new QAction(this);
diff --git a/src/plugins/remotelinux/remotelinuxplugin.cpp b/src/plugins/remotelinux/remotelinuxplugin.cpp
index 8305e306f02005bb9480abe2971c5aad4c77b045..07035605627e48f687de7903acafc5efa16bc563 100644
--- a/src/plugins/remotelinux/remotelinuxplugin.cpp
+++ b/src/plugins/remotelinux/remotelinuxplugin.cpp
@@ -96,41 +96,20 @@ RemoteLinuxPlugin::~RemoteLinuxPlugin()
 
 void RemoteLinuxPlugin::extensionsInitialized()
 {
-    /*
-    using namespace Core;
-    ICore *core = ICore::instance();
-    ActionManager *am = core->actionManager();
-    ActionContainer *mstart =
-        am->actionContainer(ProjectExplorer::Constants::M_DEBUG_STARTDEBUGGING);
-
-    const Context globalcontext(Core::Constants::C_GLOBAL);
-
-    QAction *act = 0;
-    Command *cmd = 0;
-
-    act = new QAction(tr("Start Remote Debug Server..."), 0);
-    cmd = am->registerAction(act, "StartGdbServer", globalcontext);
-    cmd->setDescription(tr("Start Gdbserver"));
-    mstart->addAction(cmd, Debugger::Constants::G_MANUAL_REMOTE);
-    connect(act, SIGNAL(triggered()), SLOT(startGdbServer()));
-
-    act = new QAction(tr("Attach to Running Remote Process..."), 0);
-    cmd = am->registerAction(act, "AttachRemoteProcess", globalcontext);
-    cmd->setDescription(tr("Attach to Remote Process"));
-    mstart->addAction(cmd, Debugger::Constants::G_AUTOMATIC_REMOTE);
-    connect(act, SIGNAL(triggered()), SLOT(startGdbServer()));
-    */
 }
 
 void RemoteLinuxPlugin::startGdbServer()
 {
     StartGdbServerDialog dlg;
-    int result = dlg.exec();
-    if (result == QDialog::Rejected)
-        return;
     dlg.startGdbServer();
 }
 
+void RemoteLinuxPlugin::attachToRemoteProcess()
+{
+    StartGdbServerDialog dlg;
+    dlg.attachToRemoteProcess();
+}
+
 } // namespace Internal
 } // namespace RemoteLinux
 
diff --git a/src/plugins/remotelinux/remotelinuxplugin.h b/src/plugins/remotelinux/remotelinuxplugin.h
index 4ea667c84484d5365f632d6cfd4d47c8f81e7060..b65e6da10daf93b5326f866b0d32535715227eec 100644
--- a/src/plugins/remotelinux/remotelinuxplugin.h
+++ b/src/plugins/remotelinux/remotelinuxplugin.h
@@ -51,6 +51,7 @@ public:
 
 private slots:
     void startGdbServer();
+    void attachToRemoteProcess();
 };
 
 } // namespace Internal
diff --git a/src/plugins/remotelinux/startgdbserverdialog.cpp b/src/plugins/remotelinux/startgdbserverdialog.cpp
index 3fe2035bcb858ca63bf414959c46d0a8d96f97a9..ca7526c0fb036a69d811c1990e7b8400c1eb1436 100644
--- a/src/plugins/remotelinux/startgdbserverdialog.cpp
+++ b/src/plugins/remotelinux/startgdbserverdialog.cpp
@@ -92,6 +92,7 @@ public:
     }
 
     StartGdbServerDialog *q;
+    bool startServerOnly;
     AbstractRemoteLinuxProcessList *processList;
     QSortFilterProxyModel proxyModel;
 
@@ -110,7 +111,7 @@ public:
 };
 
 StartGdbServerDialogPrivate::StartGdbServerDialogPrivate(StartGdbServerDialog *q)
-    : q(q), processList(0)
+    : q(q), startServerOnly(true), processList(0)
 {
     settings = ICore::settings();
 
@@ -313,13 +314,20 @@ void StartGdbServerDialog::portListReady()
 
 void StartGdbServerDialog::startGdbServer()
 {
+    d->startServerOnly = true;
+    if (exec() == QDialog::Rejected)
+        return;
     LinuxDeviceConfiguration::ConstPtr device = d->currentDevice();
     d->gatherer.start(SshConnection::create(device->sshParameters()), device);
 }
 
 void StartGdbServerDialog::attachToRemoteProcess()
 {
-    startGdbServer();
+    d->startServerOnly = false;
+    if (exec() == QDialog::Rejected)
+        return;
+    LinuxDeviceConfiguration::ConstPtr device = d->currentDevice();
+    d->gatherer.start(SshConnection::create(device->sshParameters()), device);
 }
 
 void StartGdbServerDialog::handleConnectionError()
@@ -343,21 +351,17 @@ void StartGdbServerDialog::handleProcessErrorOutput(const QByteArray &ba)
     logMessage(QString::fromUtf8(ba.trimmed()));
     // "Attached; pid = 16740"
     // "Listening on port 10000"
-    int pos = ba.indexOf("Listening on port");
-    if (pos == -1)
-        return;
-    const int port = ba.mid(pos + 18).trimmed().toInt();
-    logMessage(tr("Port %1 is now accessible.").arg(port));
-    reportOpenPort(port);
+    foreach (const QByteArray &line, ba.split('\n')) {
+        if (line.startsWith("Listening on port")) {
+            const int port = line.mid(18).trimmed().toInt();
+            reportOpenPort(port);
+        }
+    }
 }
 
 void StartGdbServerDialog::reportOpenPort(int port)
 {
-    ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
-    QObject *ob = pm->getObjectByName("DebuggerCore");
-    if (!ob)
-        return;
-
+    logMessage(tr("Port %1 is now accessible.").arg(port));
     LinuxDeviceConfiguration::ConstPtr device = d->currentDevice();
     QString host = device->sshParameters().host;
     QString channel;
@@ -367,10 +371,16 @@ void StartGdbServerDialog::reportOpenPort(int port)
         channel = QString::fromLatin1("%1:%2").arg(host).arg(port);
     logMessage(tr("Server started on %1").arg(channel));
 
-    QMetaObject::invokeMethod(ob, "gdbServerStarted", Qt::QueuedConnection,
-        Q_ARG(QString, channel),
-        Q_ARG(QString, d->sysrootPathChooser->path()),
-        Q_ARG(QString, d->remoteCommandLine));
+    const char *member = d->startServerOnly ? "gdbServerStarted" : "attachedToProcess";
+    ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
+    QObject *ob = pm->getObjectByName("DebuggerCore");
+    if (ob) {
+        QMetaObject::invokeMethod(ob, member, Qt::QueuedConnection,
+            Q_ARG(QString, channel),
+            Q_ARG(QString, d->sysrootPathChooser->path()),
+            Q_ARG(QString, d->remoteCommandLine));
+    }
+    close();
 }
 
 void StartGdbServerDialog::handleProcessClosed(int status)