diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp
index 79f3f9e26e3369d887ee4d1a5a1074a8b11d5eb8..30cc04785e2f6cb1516d733aecba8d9ee57b9768 100644
--- a/src/plugins/debugger/debuggerplugin.cpp
+++ b/src/plugins/debugger/debuggerplugin.cpp
@@ -364,6 +364,7 @@ using namespace Core;
 using namespace Debugger::Constants;
 using namespace ProjectExplorer;
 using namespace TextEditor;
+using namespace ExtensionSystem;
 
 namespace CC = Core::Constants;
 namespace PE = ProjectExplorer::Constants;
@@ -730,10 +731,11 @@ public slots:
     void debugProjectBreakMain();
     void startExternalApplication();
     void startRemoteCdbSession();
-    void startRemoteApplication();
+    void startRemoteProcess();
+    void startRemoteServer();
     bool queryRemoteParameters(DebuggerStartParameters &sp, bool useScript);
     void attachToRemoteServer();
-    //void attachToRemoteProcess();
+    void attachToRemoteProcess();
     void attachToQmlPort();
     void startRemoteEngine();
     void attachExternalApplication();
@@ -1024,6 +1026,8 @@ public slots:
     // FIXME: Remove.
     void maybeEnrichParameters(DebuggerStartParameters *sp);
 
+    void gdbServerStarted(const QString &channel, const QString &sysroot, const QString &localExecutable);
+
 public:
     DebuggerMainWindow *m_mainWindow;
     DebuggerRunControlFactory *m_debuggerRunControlFactory;
@@ -1037,9 +1041,10 @@ public:
     QAction *m_debugWithoutDeployAction;
     QAction *m_startExternalProcessAction;
     QAction *m_startRemoteProcessAction;
+    QAction *m_startRemoteServerAction;
+    QAction *m_attachToRemoteProcessAction;
     QAction *m_attachToQmlPortAction;
     QAction *m_attachToRemoteServerAction;
-    //QAction *m_attachToRemoteProcessAction;
     QAction *m_startRemoteCdbAction;
     QAction *m_startRemoteLldbAction;
     QAction *m_attachExternalAction;
@@ -1510,7 +1515,7 @@ void DebuggerPluginPrivate::attachExternalApplication()
         startDebugger(rc);
 }
 
-void DebuggerPluginPrivate::attachExternalApplication(ProjectExplorer::RunControl *rc)
+void DebuggerPluginPrivate::attachExternalApplication(RunControl *rc)
 {
     DebuggerStartParameters sp;
     sp.attachPID = rc->applicationProcessHandle().pid();
@@ -1571,11 +1576,8 @@ void DebuggerPluginPrivate::startRemoteCdbSession()
     const QString connectionKey = _("CdbRemoteConnection");
     DebuggerStartParameters sp;
     Abi hostAbi = Abi::hostAbi();
-    sp.toolChainAbi = ProjectExplorer::Abi(hostAbi.architecture(),
-                                           ProjectExplorer::Abi::WindowsOS,
-                                           ProjectExplorer::Abi::WindowsMsvc2010Flavor,
-                                           ProjectExplorer::Abi::PEFormat,
-                                           hostAbi.wordWidth());
+    sp.toolChainAbi = Abi(hostAbi.architecture(), Abi::WindowsOS,
+        Abi::WindowsMsvc2010Flavor, Abi::PEFormat, hostAbi.wordWidth());
     sp.startMode = AttachToRemoteServer;
     StartRemoteCdbDialog dlg(mainWindow());
     QString previousConnection = configValue(connectionKey).toString();
@@ -1644,7 +1646,7 @@ bool DebuggerPluginPrivate::queryRemoteParameters(DebuggerStartParameters &sp, b
     sp.displayName = tr("Remote: \"%1\"").arg(sp.remoteChannel);
     sp.debuggerCommand = dlg.debugger(); // Override toolchain-detection.
     if (!sp.debuggerCommand.isEmpty())
-        sp.toolChainAbi = ProjectExplorer::Abi();
+        sp.toolChainAbi = Abi();
     sp.overrideStartScript = dlg.overrideStartScript();
     sp.useServerStartScript = dlg.useServerStartScript();
     sp.serverStartScript = dlg.serverStartScript();
@@ -1653,7 +1655,7 @@ bool DebuggerPluginPrivate::queryRemoteParameters(DebuggerStartParameters &sp, b
     return true;
 }
 
-void DebuggerPluginPrivate::startRemoteApplication()
+void DebuggerPluginPrivate::startRemoteProcess()
 {
     DebuggerStartParameters sp;
     sp.startMode = StartRemoteProcess;
@@ -1675,21 +1677,71 @@ void DebuggerPluginPrivate::attachToRemoteServer()
         startDebugger(rc);
 }
 
-/*
 void DebuggerPluginPrivate::attachToRemoteProcess()
 {
+    startRemoteServer();
+}
 
-    DebuggerStartParameters sp;
-    if (!queryRemoteParameters(sp, false))
+void DebuggerPluginPrivate::startRemoteServer()
+{
+    PluginManager *pm = PluginManager::instance();
+    QTC_ASSERT(pm, return);
+    QObject *rl = pm->getObjectByName(_("RemoteLinuxPlugin"));
+    QTC_ASSERT(rl, return);
+    QMetaObject::invokeMethod(rl, "startGdbServer", Qt::QueuedConnection);
+    // Will call back gdbServerStarted() below.
+}
+
+void DebuggerPluginPrivate::gdbServerStarted(const QString &channel,
+    const QString &sysroot, const QString &remoteCommandLine)
+{
+    QString binary = remoteCommandLine.section(QLatin1Char(' '), 0, 0);
+    QString localExecutable;
+    QString candidate = sysroot + QLatin1Char('/') + binary;
+    if (QFileInfo(candidate).exists())
+        localExecutable = candidate;
+    if (localExecutable.isEmpty()) {
+        candidate = sysroot + QLatin1String("/usr/bin/") + binary;
+        if (QFileInfo(candidate).exists())
+            localExecutable = candidate;
+    }
+    if (localExecutable.isEmpty()) {
+        candidate = sysroot + QLatin1String("/bin/") + binary;
+        if (QFileInfo(candidate).exists())
+            localExecutable = candidate;
+    }
+    if (localExecutable.isEmpty()) {
+        QMessageBox::warning(mainWindow(), tr("Warning"),
+            tr("Cannot find local executable for remote process \"%1\".")
+                .arg(remoteCommandLine));
+        return;
+    }
+
+    QList<Abi> abis = Abi::abisOfBinary(localExecutable);
+    if (abis.isEmpty()) {
+        QMessageBox::warning(mainWindow(), tr("Warning"),
+            tr("Cannot find abi for remote process \"%1\".")
+                .arg(remoteCommandLine));
         return;
+    }
 
-    sp.startMode = AttachToRemoteProcess;
+    DebuggerStartParameters sp;
+    sp.toolChainAbi = abis.at(0);
+    //sp.remoteArchitecture = abis.at(0).toString();
+    sp.displayName = tr("Remote: \"%1\"").arg(channel);
+    sp.remoteChannel = channel;
+    sp.sysroot = sysroot;
+    sp.executable = localExecutable;
+    sp.startMode = AttachToRemoteServer;
+    sp.useServerStartScript = false;
+    sp.serverStartScript.clear();
+    sp.overrideStartScript.clear();
     sp.useServerStartScript = false;
     sp.serverStartScript.clear();
+    //sp.debugInfoLocation = dlg.debugInfoLocation();
     if (RunControl *rc = createDebugger(sp))
         startDebugger(rc);
 }
-*/
 
 void DebuggerPluginPrivate::attachToQmlPort()
 {
@@ -1730,11 +1782,11 @@ void DebuggerPluginPrivate::attachToQmlPort()
     //
     // get files from all the projects in the session
     //
-    ProjectExplorer::SessionManager *sessionManager = ProjectExplorer::ProjectExplorerPlugin::instance()->session();
+    SessionManager *sessionManager = ProjectExplorerPlugin::instance()->session();
     QList<Project *> projects = sessionManager->projects();
-    if (Project *startupProject = ProjectExplorer::ProjectExplorerPlugin::instance()->startupProject()) {
+    if (Project *startupProject = ProjectExplorerPlugin::instance()->startupProject()) {
         // startup project first
-        projects.removeOne(ProjectExplorer::ProjectExplorerPlugin::instance()->startupProject());
+        projects.removeOne(ProjectExplorerPlugin::instance()->startupProject());
         projects.insert(0, startupProject);
     }
     QStringList sourceFiles;
@@ -2260,7 +2312,7 @@ void DebuggerPluginPrivate::updateState(DebuggerEngine *engine)
     m_attachToCoreAction->setEnabled(true);
     m_startRemoteProcessAction->setEnabled(true);
     m_attachToRemoteServerAction->setEnabled(true);
-    //m_attachToRemoteProcessAction->setEnabled(true);
+    m_attachToRemoteProcessAction->setEnabled(true);
 
     const bool isCore = engine->startParameters().startMode == AttachCore;
     const bool stopped = state == InferiorStopOk;
@@ -2728,7 +2780,7 @@ QString DebuggerPluginPrivate::debuggerForAbi(const Abi &abi, DebuggerEngineType
     searchAbis.push_back(abi);
     // Pick the right tool chain in case cdb/gdb were started with other tool chains.
     // Also, lldb should be preferred over gdb.
-    if (abi.os() == ProjectExplorer::Abi::WindowsOS) {
+    if (abi.os() == Abi::WindowsOS) {
         switch (et) {
         case CdbEngineType:
             searchAbis.clear();
@@ -2800,7 +2852,7 @@ void DebuggerPluginPrivate::extensionsInitialized()
 
     connect(core, SIGNAL(coreAboutToClose()), this, SLOT(coreShutdown()));
 
-    Core::ActionManager *am = core->actionManager();
+    ActionManager *am = core->actionManager();
     QTC_ASSERT(am, return);
 
     m_plugin->addObject(this);
@@ -2972,7 +3024,7 @@ void DebuggerPluginPrivate::extensionsInitialized()
     m_mainWindow->createDockWidget(CppLanguage, m_threadsWindow);
     m_mainWindow->createDockWidget(QmlLanguage, m_scriptConsoleWindow);
 
-    QSplitter *localsAndWatchers = new Core::MiniSplitter(Qt::Vertical);
+    QSplitter *localsAndWatchers = new MiniSplitter(Qt::Vertical);
     localsAndWatchers->setObjectName(DOCKWIDGET_WATCHERS);
     localsAndWatchers->setWindowTitle(m_localsWindow->windowTitle());
     localsAndWatchers->addWidget(m_localsWindow);
@@ -3034,15 +3086,19 @@ void DebuggerPluginPrivate::extensionsInitialized()
 
     act = m_startRemoteProcessAction = new QAction(this);
     act->setText(tr("Start and Debug Remote Application..."));
-    connect(act, SIGNAL(triggered()), SLOT(startRemoteApplication()));
+    connect(act, SIGNAL(triggered()), SLOT(startRemoteProcess()));
 
     act = m_attachToRemoteServerAction = new QAction(this);
     act->setText(tr("Attach to Remote Debug Server..."));
     connect(act, SIGNAL(triggered()), SLOT(attachToRemoteServer()));
 
-    //act = m_attachToRemoteProcessAction = new QAction(this);
-    //act->setText(tr("Attach to Running Remote Process..."));
-    //connect(act, SIGNAL(triggered()), SLOT(attachToRemoteProcess()));
+    act = m_startRemoteServerAction = new QAction(this);
+    act->setText(tr("Start Remote Debug Server..."));
+    connect(act, SIGNAL(triggered()), SLOT(startRemoteServer()));
+
+    act = m_attachToRemoteProcessAction = new QAction(this);
+    act->setText(tr("Attach to Running Remote Process..."));
+    connect(act, SIGNAL(triggered()), SLOT(attachToRemoteProcess()));
 
     act = m_attachToQmlPortAction = new QAction(this);
     act->setText(tr("Attach to QML Port..."));
@@ -3108,16 +3164,20 @@ void DebuggerPluginPrivate::extensionsInitialized()
     cmd->setAttribute(Command::CA_Hide);
     mstart->addAction(cmd, Constants::G_MANUAL_REMOTE);
 
-    //cmd = am->registerAction(m_attachToRemoteProcessAction,
-    //    "Debugger.AttachToRemoteProcess", globalcontext);
-    //cmd->setAttribute(Command::CA_Hide);
-    //mstart->addAction(cmd, Constants::G_AUTOMATIC_REMOTE);
-
     cmd = am->registerAction(m_startRemoteProcessAction,
         "Debugger.StartRemoteProcess", globalcontext);
     cmd->setAttribute(Command::CA_Hide);
     mstart->addAction(cmd, Constants::G_AUTOMATIC_REMOTE);
 
+    cmd = am->registerAction(m_startRemoteServerAction,
+         "Debugger.StartRemoteServer", globalcontext);
+    cmd->setDefaultText(tr("Start Gdbserver"));
+    mstart->addAction(cmd, Debugger::Constants::G_MANUAL_REMOTE);
+
+    cmd = am->registerAction(m_attachToRemoteProcessAction,
+         "Debugger.AttachToRemoteProcess", globalcontext);
+    cmd->setDefaultText(tr("Attach to Remote Process"));
+    mstart->addAction(cmd, Debugger::Constants::G_AUTOMATIC_REMOTE);
 
 #ifdef WITH_LLDB
     cmd = am->registerAction(m_startRemoteLldbAction,
@@ -3292,7 +3352,7 @@ void DebuggerPluginPrivate::extensionsInitialized()
         // Debugger.AddToWatch is enough.
     }
 
-    QList<Core::IOptionsPage *> engineOptionPages;
+    QList<IOptionsPage *> engineOptionPages;
     if (m_cmdLineEnabledEngines & GdbEngineType)
         addGdbOptionPages(&engineOptionPages);
    addCdbOptionPages(&engineOptionPages);
@@ -3305,7 +3365,8 @@ void DebuggerPluginPrivate::extensionsInitialized()
     //    addScriptOptionPages(&engineOptionPages);
     //if (m_cmdLineEnabledEngines & TcfEngineType)
     //    addTcfOptionPages(&engineOptionPages);
-    foreach (Core::IOptionsPage *op, engineOptionPages)
+
+    foreach (IOptionsPage *op, engineOptionPages)
         m_plugin->addAutoReleasedObject(op);
     m_plugin->addAutoReleasedObject(new DebuggingHelperOptionPage);
 
@@ -3313,7 +3374,7 @@ void DebuggerPluginPrivate::extensionsInitialized()
         SLOT(onModeChanged(Core::IMode*)));
     connect(ICore::instance(), SIGNAL(coreAboutToOpen()),
         SLOT(onCoreAboutToOpen()));
-    connect(ProjectExplorer::ProjectExplorerPlugin::instance(), SIGNAL(settingsChanged()),
+    connect(ProjectExplorerPlugin::instance(), SIGNAL(settingsChanged()),
             this, SLOT(updateDebugWithoutDeployMenu()));
 
     // Debug mode setup
@@ -3399,6 +3460,9 @@ void DebuggerPluginPrivate::extensionsInitialized()
         SIGNAL(startupProjectChanged(ProjectExplorer::Project*)),
         SLOT(onCurrentProjectChanged(ProjectExplorer::Project*)));
 
+    m_commonOptionsPage = new CommonOptionsPage(m_globalDebuggerOptions);
+    m_plugin->addAutoReleasedObject(m_commonOptionsPage);
+
     QTC_CHECK(m_coreSettings);
     m_globalDebuggerOptions->fromSettings(m_coreSettings);
     m_watchersWindow->setVisible(false);
@@ -3494,12 +3558,12 @@ DebuggerPlugin::~DebuggerPlugin()
 bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMessage)
 {
     ICore *core = ICore::instance();
-    QTC_ASSERT(core, return true);
+    QTC_ASSERT(core, return false);
 
     // Menu groups
     const Context globalcontext(CC::C_GLOBAL);
 
-    Core::ActionManager *am = core->actionManager();
+    ActionManager *am = core->actionManager();
     ActionContainer *mstart = am->actionContainer(PE::M_DEBUG_STARTDEBUGGING);
 
     mstart->appendGroup(Constants::G_START_LOCAL);
@@ -3526,7 +3590,7 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess
     return theDebuggerCore->initialize(arguments, errorMessage);
 }
 
-ExtensionSystem::IPlugin::ShutdownFlag DebuggerPlugin::aboutToShutdown()
+IPlugin::ShutdownFlag DebuggerPlugin::aboutToShutdown()
 {
     theDebuggerCore->aboutToShutdown();
     return SynchronousShutdown;
diff --git a/src/plugins/debugger/debuggerrunner.cpp b/src/plugins/debugger/debuggerrunner.cpp
index 60fc25695a36a812f3805a8f6aaeaf16e7747baa..aae1346567010c5e9742a75f2629d3de69f2b8b1 100644
--- a/src/plugins/debugger/debuggerrunner.cpp
+++ b/src/plugins/debugger/debuggerrunner.cpp
@@ -512,7 +512,9 @@ static QList<DebuggerEngineType> engineTypes(const DebuggerStartParameters &sp)
         return result;
     }
 
-    if (sp.startMode != AttachToRemoteServer && !sp.executable.isEmpty())
+    if (sp.startMode != AttachToRemoteServer
+            && sp.startMode != AttachToRemoteProcess
+            && !sp.executable.isEmpty())
         result = enginesForExecutable(sp.executable);
     if (!result.isEmpty())
         return result;
diff --git a/src/plugins/remotelinux/linuxdeviceconfiguration.cpp b/src/plugins/remotelinux/linuxdeviceconfiguration.cpp
index ee86d4422d01c4e54ef6226e95972f80aaaa274f..61ab79ebbf562d52d0daa161e7a3f5019eeca428 100644
--- a/src/plugins/remotelinux/linuxdeviceconfiguration.cpp
+++ b/src/plugins/remotelinux/linuxdeviceconfiguration.cpp
@@ -213,6 +213,7 @@ SshConnectionParameters LinuxDeviceConfiguration::sshParameters() const
 }
 
 LinuxDeviceConfiguration::DeviceType LinuxDeviceConfiguration::deviceType() const
+
 {
     return d->deviceType;
 }
diff --git a/src/plugins/remotelinux/remotelinux.pro b/src/plugins/remotelinux/remotelinux.pro
index b219077217e556e8193c1bbaabcbf159d3c96d27..00990e0252060ae20e711e81f440262a383bbf5c 100644
--- a/src/plugins/remotelinux/remotelinux.pro
+++ b/src/plugins/remotelinux/remotelinux.pro
@@ -127,8 +127,7 @@ FORMS += \
     linuxdeviceconfigurationssettingswidget.ui \
     sshkeycreationdialog.ui \
     remotelinuxdeployconfigurationwidget.ui \
-    profilesupdatedialog.ui \
-    startgdbserverdialog.ui
+    profilesupdatedialog.ui
 
 RESOURCES += remotelinux.qrc
 
diff --git a/src/plugins/remotelinux/remotelinuxplugin.cpp b/src/plugins/remotelinux/remotelinuxplugin.cpp
index e60d12d30c71445c7b37dbcbfcd7715af68d22d5..325170ce9791128b3ba3778dbd6860880d15849e 100644
--- a/src/plugins/remotelinux/remotelinuxplugin.cpp
+++ b/src/plugins/remotelinux/remotelinuxplugin.cpp
@@ -62,6 +62,7 @@ namespace Internal {
 
 RemoteLinuxPlugin::RemoteLinuxPlugin()
 {
+    setObjectName(QLatin1String("RemoteLinuxPlugin"));
 }
 
 bool RemoteLinuxPlugin::initialize(const QStringList &arguments,
@@ -72,6 +73,7 @@ bool RemoteLinuxPlugin::initialize(const QStringList &arguments,
 
     LinuxDeviceConfigurations::instance(this);
 
+    addObject(this);
     addAutoReleasedObject(new LinuxDeviceConfigurationsSettingsPage);
     addAutoReleasedObject(new GenericLinuxDeviceConfigurationFactory);
     addAutoReleasedObject(new RemoteLinuxRunConfigurationFactory);
@@ -89,6 +91,7 @@ bool RemoteLinuxPlugin::initialize(const QStringList &arguments,
 
 void RemoteLinuxPlugin::extensionsInitialized()
 {
+    /*
     using namespace Core;
     ICore *core = ICore::instance();
     ActionManager *am = core->actionManager();
@@ -111,6 +114,7 @@ void RemoteLinuxPlugin::extensionsInitialized()
     cmd->setDefaultText(tr("Attach to Remote Process"));
     mstart->addAction(cmd, Debugger::Constants::G_AUTOMATIC_REMOTE);
     connect(act, SIGNAL(triggered()), SLOT(startGdbServer()));
+    */
 }
 
 void RemoteLinuxPlugin::startGdbServer()
diff --git a/src/plugins/remotelinux/remotelinuxprocesslist.cpp b/src/plugins/remotelinux/remotelinuxprocesslist.cpp
index c9fecb5ed17b9d219958b026e3093c4f551fd316..9b936232f5ac46d0367a2da9efc1ce97d8741a98 100644
--- a/src/plugins/remotelinux/remotelinuxprocesslist.cpp
+++ b/src/plugins/remotelinux/remotelinuxprocesslist.cpp
@@ -110,6 +110,11 @@ int AbstractRemoteLinuxProcessList::pidAt(int row) const
     return d->remoteProcesses.at(row).pid;
 }
 
+QString AbstractRemoteLinuxProcessList::commandLineAt(int row) const
+{
+    return d->remoteProcesses.at(row).cmdLine;
+}
+
 int AbstractRemoteLinuxProcessList::rowCount(const QModelIndex &parent) const
 {
     return parent.isValid() ? 0 : d->remoteProcesses.count();
diff --git a/src/plugins/remotelinux/remotelinuxprocesslist.h b/src/plugins/remotelinux/remotelinuxprocesslist.h
index d5bb0d43cf8ee37f2935a8e94105fc03dce859b5..33d34cd263835b3e32e88a91756da209fffacc04 100644
--- a/src/plugins/remotelinux/remotelinuxprocesslist.h
+++ b/src/plugins/remotelinux/remotelinuxprocesslist.h
@@ -54,6 +54,7 @@ public:
     void update();
     void killProcess(int row);
     int pidAt(int row) const;
+    QString commandLineAt(int row) const;
 
 signals:
     void error(const QString &errorMsg);
diff --git a/src/plugins/remotelinux/startgdbserverdialog.cpp b/src/plugins/remotelinux/startgdbserverdialog.cpp
index 377268e15982f10ea8bd83328e182550011f97b6..794fb6135f9fff863d972ad55970b6df337ce7b8 100644
--- a/src/plugins/remotelinux/startgdbserverdialog.cpp
+++ b/src/plugins/remotelinux/startgdbserverdialog.cpp
@@ -31,7 +31,6 @@
 **************************************************************************/
 
 #include "startgdbserverdialog.h"
-#include "ui_startgdbserverdialog.h"
 
 #include "remotelinuxprocesslist.h"
 #include "linuxdeviceconfiguration.h"
@@ -39,15 +38,44 @@
 #include "remotelinuxusedportsgatherer.h"
 #include "portlist.h"
 
+#include <coreplugin/icore.h>
+
 #include <extensionsystem/pluginmanager.h>
 
+#include <utils/pathchooser.h>
+#include <utils/qtcassert.h>
 #include <utils/ssh/sshconnection.h>
 #include <utils/ssh/sshremoteprocessrunner.h>
-#include <utils/qtcassert.h>
 
+#include <QtCore/QVariant>
+#include <QtCore/QSettings>
+
+#include <QtGui/QAction>
+#include <QtGui/QApplication>
+#include <QtGui/QComboBox>
+#include <QtGui/QDialog>
+#include <QtGui/QDialogButtonBox>
+#include <QtGui/QFormLayout>
+#include <QtGui/QGridLayout>
+#include <QtGui/QHBoxLayout>
+#include <QtGui/QHeaderView>
+#include <QtGui/QLabel>
+#include <QtGui/QLineEdit>
 #include <QtGui/QMessageBox>
+#include <QtGui/QPushButton>
 #include <QtGui/QSortFilterProxyModel>
-#include <QtGui/QComboBox>
+#include <QtGui/QSpacerItem>
+#include <QtGui/QTableView>
+#include <QtGui/QTextBrowser>
+#include <QtGui/QVBoxLayout>
+
+using namespace Core;
+using namespace Utils;
+
+const char LastSysroot[] = "RemoteLinux/LastSysroot";
+const char LastDevice[] = "RemoteLinux/LastDevice";
+const char LastProcessName[] = "RemoteLinux/LastProcessName";
+//const char LastLocalExecutable[] = "RemoteLinux/LastLocalExecutable";
 
 namespace RemoteLinux {
 namespace Internal {
@@ -55,54 +83,126 @@ namespace Internal {
 class StartGdbServerDialogPrivate
 {
 public:
-    StartGdbServerDialogPrivate() : processList(0) {}
+    StartGdbServerDialogPrivate(StartGdbServerDialog *q);
 
     LinuxDeviceConfiguration::ConstPtr currentDevice() const
     {
         LinuxDeviceConfigurations *devices = LinuxDeviceConfigurations::instance();
-        return devices->deviceAt(ui.deviceComboBox->currentIndex());
+        return devices->deviceAt(deviceComboBox->currentIndex());
     }
 
+    StartGdbServerDialog *q;
     AbstractRemoteLinuxProcessList *processList;
     QSortFilterProxyModel proxyModel;
-    Ui::StartGdbServerDialog ui;
+
+    QComboBox *deviceComboBox;
+    QLineEdit *processFilterLineEdit;
+    QTableView *tableView;
+    QPushButton *attachProcessButton;
+    QTextBrowser *textBrowser;
+    QPushButton *closeButton;
+    PathChooser *sysrootPathChooser;
+
     RemoteLinuxUsedPortsGatherer gatherer;
-    Utils::SshRemoteProcessRunner runner;
+    SshRemoteProcessRunner runner;
+    QSettings *settings;
+    QString remoteCommandLine;
 };
 
+StartGdbServerDialogPrivate::StartGdbServerDialogPrivate(StartGdbServerDialog *q)
+    : q(q), processList(0)
+{
+    settings = ICore::instance()->settings();
+
+    deviceComboBox = new QComboBox(q);
+
+    sysrootPathChooser = new PathChooser(q);
+    sysrootPathChooser->setExpectedKind(PathChooser::Directory);
+    sysrootPathChooser->setPromptDialogTitle(StartGdbServerDialog::tr("Select Sysroot"));
+    sysrootPathChooser->setPath(settings->value(LastSysroot).toString());
+
+    //executablePathChooser = new PathChooser(q);
+    //executablePathChooser->setExpectedKind(PathChooser::File);
+    //executablePathChooser->setPromptDialogTitle(StartGdbServerDialog::tr("Select Executable"));
+    //executablePathChooser->setPath(settings->value(LastLocalExecutable).toString());
+
+    processFilterLineEdit = new QLineEdit(q);
+    processFilterLineEdit->setText(settings->value(LastProcessName).toString());
+    processFilterLineEdit->selectAll();
+
+    tableView = new QTableView(q);
+    tableView->setShowGrid(false);
+    tableView->setSortingEnabled(true);
+    tableView->horizontalHeader()->setDefaultSectionSize(100);
+    tableView->horizontalHeader()->setStretchLastSection(true);
+    tableView->verticalHeader()->setVisible(false);
+    tableView->setSelectionMode(QAbstractItemView::SingleSelection);
+
+    attachProcessButton = new QPushButton(q);
+    attachProcessButton->setText(StartGdbServerDialog::tr("&Attach to Selected Process"));
+
+    closeButton = new QPushButton(q);
+    closeButton->setText(StartGdbServerDialog::tr("Close"));
+
+    textBrowser = new QTextBrowser(q);
+    textBrowser->setEnabled(false);
+
+    QFormLayout *formLayout = new QFormLayout();
+    formLayout->addRow(StartGdbServerDialog::tr("Device:"), deviceComboBox);
+    formLayout->addRow(StartGdbServerDialog::tr("Sysroot:"), sysrootPathChooser);
+    formLayout->addRow(StartGdbServerDialog::tr("&Filter by process name:"),
+                           processFilterLineEdit);
+
+    QHBoxLayout *horizontalLayout2 = new QHBoxLayout();
+    horizontalLayout2->addStretch(1);
+    horizontalLayout2->addWidget(attachProcessButton);
+    horizontalLayout2->addWidget(closeButton);
+
+    formLayout->addRow(tableView);
+    formLayout->addRow(textBrowser);
+    formLayout->addRow(horizontalLayout2);
+    q->setLayout(formLayout);
+}
+
 } // namespace Internal
 
+
 StartGdbServerDialog::StartGdbServerDialog(QWidget *parent) :
     QDialog(parent),
-    d(new Internal::StartGdbServerDialogPrivate)
+    d(new Internal::StartGdbServerDialogPrivate(this))
 {
+    setWindowTitle(tr("List of Remote Processes"));
+
     LinuxDeviceConfigurations *devices = LinuxDeviceConfigurations::instance();
-    d->ui.setupUi(this);
-    d->ui.deviceComboBox->setModel(devices);
+
+    QObject::connect(d->closeButton, SIGNAL(clicked()), this, SLOT(reject()));
+
+    d->deviceComboBox->setModel(devices);
+    d->deviceComboBox->setCurrentIndex(d->settings->value(LastDevice).toInt());
     connect(&d->gatherer, SIGNAL(error(QString)), SLOT(portGathererError(QString)));
     connect(&d->gatherer, SIGNAL(portListReady()), SLOT(portListReady()));
     if (devices->rowCount() == 0) {
-        d->ui.tableView->setEnabled(false);
+        d->tableView->setEnabled(false);
     } else {
-        d->ui.tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
+        d->tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
         d->proxyModel.setDynamicSortFilter(true);
         d->proxyModel.setFilterKeyColumn(1);
-        d->ui.tableView->setModel(&d->proxyModel);
-        connect(d->ui.processFilterLineEdit, SIGNAL(textChanged(QString)),
+        d->tableView->setModel(&d->proxyModel);
+        connect(d->processFilterLineEdit, SIGNAL(textChanged(QString)),
             &d->proxyModel, SLOT(setFilterRegExp(QString)));
 
-        connect(d->ui.tableView->selectionModel(),
+        connect(d->tableView->selectionModel(),
             SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
-            SLOT(handleSelectionChanged()));
-        connect(d->ui.updateListButton, SIGNAL(clicked()),
-            SLOT(updateProcessList()));
-        connect(d->ui.attachProcessButton, SIGNAL(clicked()), SLOT(attachToProcess()));
+            SLOT(updateButtons()));
+        //connect(d->updateListButton, SIGNAL(clicked()),
+        //    SLOT(updateProcessList()));
+        connect(d->attachProcessButton, SIGNAL(clicked()), SLOT(attachToProcess()));
         connect(&d->proxyModel, SIGNAL(layoutChanged()),
             SLOT(handleProcessListUpdated()));
-        connect(d->ui.deviceComboBox, SIGNAL(currentIndexChanged(int)),
+        connect(d->deviceComboBox, SIGNAL(currentIndexChanged(int)),
             SLOT(attachToDevice(int)));
-        handleSelectionChanged();
-        attachToDevice(0);
+        updateButtons();
+        attachToDevice(d->deviceComboBox->currentIndex());
     }
 }
 
@@ -112,7 +212,6 @@ StartGdbServerDialog::~StartGdbServerDialog()
     delete d;
 }
 
-
 void StartGdbServerDialog::attachToDevice(int index)
 {
     LinuxDeviceConfigurations *devices = LinuxDeviceConfigurations::instance();
@@ -131,46 +230,60 @@ void StartGdbServerDialog::attachToDevice(int index)
 void StartGdbServerDialog::handleRemoteError(const QString &errorMsg)
 {
     QMessageBox::critical(this, tr("Remote Error"), errorMsg);
-    d->ui.updateListButton->setEnabled(true);
-    handleSelectionChanged();
+    updateButtons();
 }
 
 void StartGdbServerDialog::handleProcessListUpdated()
 {
-    d->ui.updateListButton->setEnabled(true);
-    d->ui.tableView->resizeRowsToContents();
-    handleSelectionChanged();
+    d->tableView->resizeRowsToContents();
+    updateButtons();
 }
 
 void StartGdbServerDialog::updateProcessList()
 {
-    d->ui.updateListButton->setEnabled(false);
-    d->ui.attachProcessButton->setEnabled(false);
+    d->attachProcessButton->setEnabled(false);
     d->processList->update();
+    d->proxyModel.setFilterRegExp(QString());
+    d->proxyModel.setFilterRegExp(d->processFilterLineEdit->text());
+    updateButtons();
 }
 
 void StartGdbServerDialog::attachToProcess()
 {
     const QModelIndexList &indexes =
-            d->ui.tableView->selectionModel()->selectedIndexes();
+            d->tableView->selectionModel()->selectedIndexes();
     if (indexes.empty())
         return;
-    d->ui.updateListButton->setEnabled(false);
-    d->ui.attachProcessButton->setEnabled(false);
+    d->attachProcessButton->setEnabled(false);
 
     LinuxDeviceConfiguration::ConstPtr device = d->currentDevice();
     PortList ports = device->freePorts();
     const int port = d->gatherer.getNextFreePort(&ports);
     const int row = d->proxyModel.mapToSource(indexes.first()).row();
-    QTC_ASSERT(row >= 0, processAborted(); return);
+    QTC_ASSERT(row >= 0, return);
     const int pid = d->processList->pidAt(row);
+    d->remoteCommandLine = d->processList->commandLineAt(row);
     if (port == -1) {
-        emit processAborted();
-    } else {
-        emit pidSelected(pid);
-        emit portSelected(pid);
-        startGdbServerOnPort(port, pid);
+        reportFailure();
+        return;
     }
+
+    d->settings->setValue(LastSysroot, d->sysrootPathChooser->path());
+    d->settings->setValue(LastDevice, d->deviceComboBox->currentIndex());
+    d->settings->setValue(LastProcessName, d->processFilterLineEdit->text());
+
+    startGdbServerOnPort(port, pid);
+}
+
+void StartGdbServerDialog::reportFailure()
+{
+    QTC_ASSERT(false, /**/);
+    logMessage(tr("Process aborted"));
+}
+
+void StartGdbServerDialog::logMessage(const QString &line)
+{
+    d->textBrowser->append(line);
 }
 
 void StartGdbServerDialog::handleProcessKilled()
@@ -178,76 +291,84 @@ void StartGdbServerDialog::handleProcessKilled()
     updateProcessList();
 }
 
-void StartGdbServerDialog::handleSelectionChanged()
+void StartGdbServerDialog::updateButtons()
 {
-    d->ui.attachProcessButton->setEnabled(d->ui.tableView->selectionModel()->hasSelection());
+    d->attachProcessButton->setEnabled(d->tableView->selectionModel()->hasSelection()
+        || d->proxyModel.rowCount() == 1);
 }
 
 void StartGdbServerDialog::portGathererError(const QString &text)
 {
-    d->ui.textBrowser->append(tr("Could not retrieve list of free ports:"));
-    d->ui.textBrowser->append(text);
-    emit processAborted();
+    logMessage(tr("Could not retrieve list of free ports:"));
+    logMessage(text);
+    reportFailure();
 }
 
 void StartGdbServerDialog::portListReady()
 {
-    d->ui.updateListButton->setEnabled(true);
-    d->ui.attachProcessButton->setEnabled(true);
+    updateButtons();
 }
 
 void StartGdbServerDialog::startGdbServer()
 {
     LinuxDeviceConfiguration::ConstPtr device = d->currentDevice();
-    d->gatherer.start(Utils::SshConnection::create(device->sshParameters()), device);
+    d->gatherer.start(SshConnection::create(device->sshParameters()), device);
 }
 
 void StartGdbServerDialog::attachToRemoteProcess()
 {
-    LinuxDeviceConfiguration::ConstPtr device = d->currentDevice();
-    d->gatherer.start(Utils::SshConnection::create(device->sshParameters()), device);
+    startGdbServer();
 }
 
 void StartGdbServerDialog::handleConnectionError()
 {
-    d->ui.textBrowser->append(tr("Connection error: %1")
-        .arg(d->runner.lastConnectionErrorString()));
+    logMessage(tr("Connection error: %1").arg(d->runner.lastConnectionErrorString()));
     emit processAborted();
 }
 
 void StartGdbServerDialog::handleProcessStarted()
 {
-    d->ui.textBrowser->append(tr("Starting gdbserver..."));
+    logMessage(tr("Starting gdbserver..."));
 }
 
 void StartGdbServerDialog::handleProcessOutputAvailable(const QByteArray &ba)
 {
-    d->ui.textBrowser->append(QString::fromUtf8(ba.trimmed()));
+    logMessage(QString::fromUtf8(ba.trimmed()));
 }
 
 void StartGdbServerDialog::handleProcessErrorOutput(const QByteArray &ba)
 {
-    d->ui.textBrowser->append(QString::fromUtf8(ba.trimmed()));
+    logMessage(QString::fromUtf8(ba.trimmed()));
     // "Attached; pid = 16740"
     // "Listening on port 10000"
     int pos = ba.indexOf("Listening on port");
-    if (pos != -1) {
-        int port = ba.mid(pos + 18).trimmed().toInt();
-        d->ui.textBrowser->append(tr("Port %1 is now accessible.").arg(port));
-        emit portOpened(port);
-        ExtensionSystem::PluginManager *pm =
-            ExtensionSystem::PluginManager::instance();
-        QObject *ob = pm->getObjectByName("DebuggerCore");
-        qDebug() << "FOUND DEBUGGER CORE: " << ob;
-        if (ob)
-           QMetaObject::invokeMethod(ob, "gdbServerStarted", Qt::QueuedConnection,
-                                  Q_ARG(int, 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);
+}
+
+void StartGdbServerDialog::reportOpenPort(int port)
+{
+    ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
+    QObject *ob = pm->getObjectByName("DebuggerCore");
+    if (!ob)
+        return;
+
+    LinuxDeviceConfiguration::ConstPtr device = d->currentDevice();
+    QString channel = QString("%1:%2").arg(device->sshParameters().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));
 }
 
 void StartGdbServerDialog::handleProcessClosed(int status)
 {
-    d->ui.textBrowser->append(tr("Process gdbserver finished. Status: %1").arg(status));
+    logMessage(tr("Process gdbserver finished. Status: %1").arg(status));
 }
 
 void StartGdbServerDialog::startGdbServerOnPort(int port, int pid)
@@ -263,6 +384,7 @@ void StartGdbServerDialog::startGdbServerOnPort(int port, int pid)
 
     QByteArray cmd = "/usr/bin/gdbserver --attach localhost:"
         + QByteArray::number(port) + " " + QByteArray::number(pid);
+    logMessage(tr("Running command: %1").arg(QString::fromLatin1(cmd)));
     d->runner.run(cmd, device->sshParameters());
 }
 
diff --git a/src/plugins/remotelinux/startgdbserverdialog.h b/src/plugins/remotelinux/startgdbserverdialog.h
index ce176dec2f420238b9c97365fb981bd73e712497..eda5baf8f0779880fc42a7827555d99a54f87c7b 100644
--- a/src/plugins/remotelinux/startgdbserverdialog.h
+++ b/src/plugins/remotelinux/startgdbserverdialog.h
@@ -39,9 +39,7 @@
 
 namespace RemoteLinux {
 
-namespace Internal {
-class StartGdbServerDialogPrivate;
-} // namespace Internal
+namespace Internal { class StartGdbServerDialogPrivate; }
 
 class REMOTELINUX_EXPORT StartGdbServerDialog : public QDialog
 {
@@ -55,9 +53,6 @@ public:
     void attachToRemoteProcess();
 
 signals:
-    void pidSelected(int pid);
-    void portSelected(int port);
-    void portOpened(int port);
     void processAborted();
 
 private slots:
@@ -67,7 +62,7 @@ private slots:
     void updateProcessList();
     void attachToProcess();
     void handleProcessKilled();
-    void handleSelectionChanged();
+    void updateButtons();
     void portGathererError(const QString &errorMessage);
     void portListReady();
 
@@ -79,6 +74,9 @@ private slots:
 
 private:
     void startGdbServerOnPort(int port, int pid);
+    void reportOpenPort(int port);
+    void reportFailure();
+    void logMessage(const QString &line);
     Internal::StartGdbServerDialogPrivate *d;
 };
 
diff --git a/src/plugins/remotelinux/startgdbserverdialog.ui b/src/plugins/remotelinux/startgdbserverdialog.ui
deleted file mode 100644
index faa74d9cc4326af6b885d340aa4b4a8f9151a1a8..0000000000000000000000000000000000000000
--- a/src/plugins/remotelinux/startgdbserverdialog.ui
+++ /dev/null
@@ -1,182 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>RemoteLinux::Internal::StartGdbServerDialog</class>
- <widget class="QDialog" name="RemoteLinux::Internal::StartGdbServerDialog">
-  <property name="geometry">
-   <rect>
-    <x>0</x>
-    <y>0</y>
-    <width>420</width>
-    <height>564</height>
-   </rect>
-  </property>
-  <property name="windowTitle">
-   <string>List of Remote Processes</string>
-  </property>
-  <layout class="QVBoxLayout" name="verticalLayout_2" stretch="0,1,0,0,0">
-   <item>
-    <layout class="QGridLayout" name="gridLayout">
-     <item row="0" column="0">
-      <widget class="QLabel" name="label">
-       <property name="text">
-        <string>Device:</string>
-       </property>
-      </widget>
-     </item>
-     <item row="0" column="1">
-      <widget class="QComboBox" name="deviceComboBox"/>
-     </item>
-     <item row="1" column="0">
-      <widget class="QLabel" name="filterLabel">
-       <property name="text">
-        <string>&amp;Filter by process name:</string>
-       </property>
-       <property name="buddy">
-        <cstring>processFilterLineEdit</cstring>
-       </property>
-      </widget>
-     </item>
-     <item row="1" column="1">
-      <widget class="QLineEdit" name="processFilterLineEdit"/>
-     </item>
-     <item row="1" column="2">
-      <spacer name="horizontalSpacer_3">
-       <property name="orientation">
-        <enum>Qt::Horizontal</enum>
-       </property>
-       <property name="sizeHint" stdset="0">
-        <size>
-         <width>40</width>
-         <height>20</height>
-        </size>
-       </property>
-      </spacer>
-     </item>
-    </layout>
-   </item>
-   <item>
-    <layout class="QHBoxLayout" name="horizontalLayout">
-     <item>
-      <widget class="QTableView" name="tableView">
-       <property name="showGrid">
-        <bool>false</bool>
-       </property>
-       <property name="sortingEnabled">
-        <bool>true</bool>
-       </property>
-       <attribute name="horizontalHeaderDefaultSectionSize">
-        <number>100</number>
-       </attribute>
-       <attribute name="horizontalHeaderStretchLastSection">
-        <bool>true</bool>
-       </attribute>
-       <attribute name="verticalHeaderVisible">
-        <bool>false</bool>
-       </attribute>
-      </widget>
-     </item>
-     <item>
-      <layout class="QVBoxLayout" name="verticalLayout">
-       <item>
-        <spacer name="verticalSpacer">
-         <property name="orientation">
-          <enum>Qt::Vertical</enum>
-         </property>
-         <property name="sizeHint" stdset="0">
-          <size>
-           <width>20</width>
-           <height>40</height>
-          </size>
-         </property>
-        </spacer>
-       </item>
-      </layout>
-     </item>
-    </layout>
-   </item>
-   <item>
-    <layout class="QHBoxLayout" name="horizontalLayout_2">
-     <item>
-      <widget class="QPushButton" name="attachProcessButton">
-       <property name="text">
-        <string>&amp;Attach to Selected Process</string>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <widget class="QPushButton" name="updateListButton">
-       <property name="text">
-        <string>&amp;Update List</string>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <spacer name="horizontalSpacer">
-       <property name="orientation">
-        <enum>Qt::Horizontal</enum>
-       </property>
-       <property name="sizeHint" stdset="0">
-        <size>
-         <width>242</width>
-         <height>20</height>
-        </size>
-       </property>
-      </spacer>
-     </item>
-    </layout>
-   </item>
-   <item>
-    <widget class="QTextBrowser" name="textBrowser"/>
-   </item>
-   <item>
-    <layout class="QHBoxLayout" name="horizontalLayout_3">
-     <item>
-      <widget class="QDialogButtonBox" name="buttonBox">
-       <property name="orientation">
-        <enum>Qt::Horizontal</enum>
-       </property>
-       <property name="standardButtons">
-        <set>QDialogButtonBox::Close</set>
-       </property>
-      </widget>
-     </item>
-    </layout>
-   </item>
-  </layout>
- </widget>
- <resources/>
- <connections>
-  <connection>
-   <sender>buttonBox</sender>
-   <signal>accepted()</signal>
-   <receiver>RemoteLinux::Internal::StartGdbServerDialog</receiver>
-   <slot>accept()</slot>
-   <hints>
-    <hint type="sourcelabel">
-     <x>257</x>
-     <y>290</y>
-    </hint>
-    <hint type="destinationlabel">
-     <x>157</x>
-     <y>274</y>
-    </hint>
-   </hints>
-  </connection>
-  <connection>
-   <sender>buttonBox</sender>
-   <signal>rejected()</signal>
-   <receiver>RemoteLinux::Internal::StartGdbServerDialog</receiver>
-   <slot>reject()</slot>
-   <hints>
-    <hint type="sourcelabel">
-     <x>316</x>
-     <y>260</y>
-    </hint>
-    <hint type="destinationlabel">
-     <x>286</x>
-     <y>274</y>
-    </hint>
-   </hints>
-  </connection>
- </connections>
-</ui>