diff --git a/src/plugins/android/androiddebugsupport.cpp b/src/plugins/android/androiddebugsupport.cpp
index 5eb5150f347a3a78962a55417c1bda7f88c39911..bc058216c53600341d177196f1851d8d1ecea849 100644
--- a/src/plugins/android/androiddebugsupport.cpp
+++ b/src/plugins/android/androiddebugsupport.cpp
@@ -37,9 +37,10 @@
 #include "androidrunner.h"
 #include "androidmanager.h"
 
+#include <debugger/debuggerengine.h>
 #include <debugger/debuggerplugin.h>
+#include <debugger/debuggerprofileinformation.h>
 #include <debugger/debuggerrunner.h>
-#include <debugger/debuggerengine.h>
 #include <debugger/debuggerstartparameters.h>
 
 #include <projectexplorer/target.h>
@@ -69,11 +70,14 @@ static Qt4Project *project(AndroidRunConfiguration *rc)
 RunControl *AndroidDebugSupport::createDebugRunControl(AndroidRunConfiguration *runConfig)
 {
     DebuggerStartParameters params;
-    params.toolChainAbi = runConfig->abi();
+    Profile *profile = runConfig->target()->profile();
+    params.sysRoot = SysRootProfileInformation::sysRoot(profile).toString();
+    params.debuggerCommand = DebuggerProfileInformation::debuggerCommand(profile).toString();
+    if (ToolChain *tc = ToolChainProfileInformation::toolChain(profile))
+        params.toolChainAbi = tc->targetAbi();
     params.dumperLibrary = runConfig->dumperLib();
     params.startMode = AttachToRemoteServer;
     params.executable = project(runConfig)->rootQt4ProjectNode()->buildDir() + QLatin1String("/app_process");
-    params.debuggerCommand = runConfig->gdbCmd().toString();
     params.remoteChannel = runConfig->remoteChannel();
     params.displayName = AndroidManager::packageName(runConfig->target());
 
diff --git a/src/plugins/debugger/attachcoredialog.ui b/src/plugins/debugger/attachcoredialog.ui
index 1eab1b5dea61d781c803db2851520979208a481c..5502c7ea022be3060b59135edf3743b73c59ed76 100644
--- a/src/plugins/debugger/attachcoredialog.ui
+++ b/src/plugins/debugger/attachcoredialog.ui
@@ -60,7 +60,7 @@
      <item row="2" column="0">
       <widget class="QLabel" name="toolchainLabel">
        <property name="text">
-        <string>&amp;Tool chain:</string>
+        <string>&amp;Target:</string>
        </property>
        <property name="buddy">
         <cstring>toolchainComboBox</cstring>
@@ -68,7 +68,7 @@
       </widget>
      </item>
      <item row="2" column="1">
-      <widget class="Debugger::Internal::DebuggerToolChainComboBox" name="toolchainComboBox"/>
+      <widget class="Debugger::ProfileChooser" name="toolchainComboBox"/>
      </item>
      <item row="3" column="1">
       <widget class="Utils::PathChooser" name="overrideStartScriptFileName" native="true"/>
@@ -129,7 +129,7 @@
    </slots>
   </customwidget>
   <customwidget>
-   <class>Debugger::Internal::DebuggerToolChainComboBox</class>
+   <class>Debugger::ProfileChooser</class>
    <extends>QComboBox</extends>
    <header>debuggertoolchaincombobox.h</header>
   </customwidget>
diff --git a/src/plugins/debugger/attachexternaldialog.ui b/src/plugins/debugger/attachexternaldialog.ui
index c2f945a4ccb789c701b4be07205edf7b608364a2..c1126543104dfc21b51c5c4078ae8317389ebfa8 100644
--- a/src/plugins/debugger/attachexternaldialog.ui
+++ b/src/plugins/debugger/attachexternaldialog.ui
@@ -44,7 +44,7 @@
      <item row="1" column="0">
       <widget class="QLabel" name="toolchainLabel">
        <property name="text">
-        <string>&amp;Tool chain:</string>
+        <string>&amp;Target:</string>
        </property>
        <property name="buddy">
         <cstring>toolchainComboBox</cstring>
@@ -52,7 +52,7 @@
       </widget>
      </item>
      <item row="1" column="1">
-      <widget class="Debugger::Internal::DebuggerToolChainComboBox" name="toolchainComboBox"/>
+      <widget class="Debugger::ProfileChooser" name="toolchainComboBox"/>
      </item>
     </layout>
    </item>
@@ -94,7 +94,7 @@
    <header location="global">utils/filterlineedit.h</header>
   </customwidget>
   <customwidget>
-   <class>Debugger::Internal::DebuggerToolChainComboBox</class>
+   <class>Debugger::ProfileChooser</class>
    <extends>QComboBox</extends>
    <header>debuggertoolchaincombobox.h</header>
   </customwidget>
diff --git a/src/plugins/debugger/attachtoqmlportdialog.ui b/src/plugins/debugger/attachtoqmlportdialog.ui
deleted file mode 100644
index caf141f5df877cdc4ac7c0a3403358cec7067bb1..0000000000000000000000000000000000000000
--- a/src/plugins/debugger/attachtoqmlportdialog.ui
+++ /dev/null
@@ -1,97 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>Debugger::Internal::AttachToQmlPortDialog</class>
- <widget class="QDialog" name="Debugger::Internal::AttachToQmlPortDialog">
-  <property name="geometry">
-   <rect>
-    <x>0</x>
-    <y>0</y>
-    <width>212</width>
-    <height>136</height>
-   </rect>
-  </property>
-  <property name="windowTitle">
-   <string>Start Debugger</string>
-  </property>
-  <layout class="QVBoxLayout" name="verticalLayout">
-   <item>
-    <layout class="QFormLayout" name="formLayout">
-     <item row="0" column="0">
-      <widget class="QLabel" name="hostLabel">
-       <property name="text">
-        <string>&amp;Host:</string>
-       </property>
-       <property name="buddy">
-        <cstring>hostLineEdit</cstring>
-       </property>
-      </widget>
-     </item>
-     <item row="0" column="1">
-      <widget class="QLineEdit" name="hostLineEdit">
-       <property name="text">
-        <string notr="true">localhost</string>
-       </property>
-      </widget>
-     </item>
-     <item row="1" column="0">
-      <widget class="QLabel" name="portLabel">
-       <property name="text">
-        <string>&amp;Port:</string>
-       </property>
-       <property name="buddy">
-        <cstring>portSpinBox</cstring>
-       </property>
-      </widget>
-     </item>
-     <item row="1" column="1">
-      <widget class="QSpinBox" name="portSpinBox">
-       <property name="maximum">
-        <number>65535</number>
-       </property>
-       <property name="value">
-        <number>3768</number>
-       </property>
-      </widget>
-     </item>
-     <item row="2" column="0">
-      <widget class="QLabel" name="sysrootLabel">
-       <property name="text">
-        <string>Sys&amp;root:</string>
-       </property>
-       <property name="buddy">
-        <cstring>sysRootChooser</cstring>
-       </property>
-      </widget>
-     </item>
-     <item row="2" column="1">
-      <widget class="Utils::PathChooser" name="sysRootChooser" native="true"/>
-     </item>
-    </layout>
-   </item>
-   <item>
-    <widget class="QDialogButtonBox" name="buttonBox">
-     <property name="orientation">
-      <enum>Qt::Horizontal</enum>
-     </property>
-     <property name="standardButtons">
-      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
-     </property>
-    </widget>
-   </item>
-  </layout>
- </widget>
- <customwidgets>
-  <customwidget>
-   <class>Utils::PathChooser</class>
-   <extends>QWidget</extends>
-   <header location="global">utils/pathchooser.h</header>
-   <container>1</container>
-   <slots>
-    <signal>editingFinished()</signal>
-    <signal>browsingFinished()</signal>
-   </slots>
-  </customwidget>
- </customwidgets>
- <resources/>
- <connections/>
-</ui>
diff --git a/src/plugins/debugger/cdb/cdbengine.cpp b/src/plugins/debugger/cdb/cdbengine.cpp
index 112ed2524c2bc3e0015b86646b8414d79fc6b6dc..fb8e260531430008c61d2e882b9778cd86fe5b0d 100644
--- a/src/plugins/debugger/cdb/cdbengine.cpp
+++ b/src/plugins/debugger/cdb/cdbengine.cpp
@@ -368,24 +368,13 @@ static inline bool isMsvcFlavor(Abi::OSFlavor osf)
       || osf == Abi::WindowsMsvc2010Flavor;
 }
 
-static QString cdbBinary(const DebuggerStartParameters &sp)
-{
-    if (!sp.debuggerCommand.isEmpty()) {
-        // Do not use a GDB binary if we got started for a project with MinGW runtime.
-        const bool abiMatch = sp.toolChainAbi.os() == Abi::WindowsOS
-                   && isMsvcFlavor(sp.toolChainAbi.osFlavor());
-        if (abiMatch)
-            return sp.debuggerCommand;
-    }
-    return debuggerCore()->debuggerForAbi(sp.toolChainAbi, CdbEngineType);
-}
-
 bool checkCdbConfiguration(const DebuggerStartParameters &sp, ConfigurationCheck *check)
 {
 #ifdef Q_OS_WIN
+    const Abi abi = toolChainAbi(sp);
     if (!isCdbEngineEnabled()) {
         check->errorDetails.push_back(CdbEngine::tr("The CDB debug engine required for %1 is currently disabled.").
-                           arg(sp.toolChainAbi.toString()));
+                           arg(abi.toString()));
         check->settingsCategory = QLatin1String(Debugger::Constants::DEBUGGER_SETTINGS_CATEGORY);
         check->settingsPage = CdbOptionsPage::settingsId();
         return false;
@@ -396,19 +385,19 @@ bool checkCdbConfiguration(const DebuggerStartParameters &sp, ConfigurationCheck
         return false;
     }
 
-    if (sp.toolChainAbi.binaryFormat() != Abi::PEFormat || sp.toolChainAbi.os() != Abi::WindowsOS) {
+    if (abi.binaryFormat() != Abi::PEFormat || abi.os() != Abi::WindowsOS) {
         check->errorDetails.push_back(CdbEngine::tr("The CDB debug engine does not support the %1 ABI.").
-                                      arg(sp.toolChainAbi.toString()));
+                                      arg(abi.toString()));
         return false;
     }
 
-    if (sp.startMode == AttachCore && !isMsvcFlavor(sp.toolChainAbi.osFlavor())) {
+    if (sp.startMode == AttachCore && !isMsvcFlavor(abi.osFlavor())) {
         check->errorDetails.push_back(CdbEngine::tr("The CDB debug engine cannot debug gdb core files."));
         return false;
     }
 
-    if (cdbBinary(sp).isEmpty()) {
-        check->errorDetails.push_back(msgNoCdbBinaryForToolChain(sp.toolChainAbi));
+    if (debuggerCommand(sp).isEmpty()) {
+        check->errorDetails.push_back(msgNoCdbBinaryForToolChain(abi));
         check->settingsCategory = QLatin1String(ProjectExplorer::Constants::PROJECTEXPLORER_SETTINGS_CATEGORY);
         check->settingsPage = QLatin1String(ProjectExplorer::Constants::PROJECTEXPLORER_SETTINGS_CATEGORY);
         return false;
@@ -722,7 +711,7 @@ bool CdbEngine::launchCDB(const DebuggerStartParameters &sp, QString *errorMessa
     // Determine binary (force MSVC), extension lib name and path to use
     // The extension is passed as relative name with the path variable set
     //(does not work with absolute path names)
-    const QString executable = cdbBinary(sp);
+    const QString executable = sp.debuggerCommand;
     if (executable.isEmpty()) {
         *errorMessage = tr("There is no CDB executable specified.");
         return false;
diff --git a/src/plugins/debugger/debugger.pro b/src/plugins/debugger/debugger.pro
index e633c50ab46d8beb8893067e2feb479d85231375..edc8fa1bb62ec03f14a6abd562158ea63162959f 100644
--- a/src/plugins/debugger/debugger.pro
+++ b/src/plugins/debugger/debugger.pro
@@ -143,8 +143,7 @@ FORMS += attachexternaldialog.ui \
     commonoptionspage.ui \
     startexternaldialog.ui \
     startremotedialog.ui \
-    startremoteenginedialog.ui \
-    attachtoqmlportdialog.ui
+    startremoteenginedialog.ui
 
 RESOURCES += debugger.qrc
 
diff --git a/src/plugins/debugger/debugger.qbs b/src/plugins/debugger/debugger.qbs
index a2de81509e8ad7ea2623daedb371144734671c38..ef9e1456a48b650e5ec2d907e50e939e47dbbe7b 100644
--- a/src/plugins/debugger/debugger.qbs
+++ b/src/plugins/debugger/debugger.qbs
@@ -42,7 +42,6 @@ QtcPlugin {
         "debuggerprofileinformation.h",
         "attachcoredialog.ui",
         "attachexternaldialog.ui",
-        "attachtoqmlportdialog.ui",
         "basewindow.cpp",
         "breakhandler.cpp",
         "breakhandler.h",
diff --git a/src/plugins/debugger/debuggercore.h b/src/plugins/debugger/debuggercore.h
index 57d18dcd403a009c73df564e303c71ef521e7f17..8761ffc095e8ad5715e4766288a057737fc2d101 100644
--- a/src/plugins/debugger/debuggercore.h
+++ b/src/plugins/debugger/debuggercore.h
@@ -110,8 +110,8 @@ public:
     virtual bool initialize(const QStringList &arguments, QString *errorMessage) = 0;
     virtual QWidget *mainWindow() const = 0;
     virtual bool isDockVisible(const QString &objectName) const = 0;
-    virtual QString debuggerForAbi(const ProjectExplorer::Abi &abi,
-        DebuggerEngineType et = NoEngineType) const = 0;
+//    virtual QString debuggerForAbi(const ProjectExplorer::Abi &abi,
+//        DebuggerEngineType et = NoEngineType) const = 0;
     virtual void showModuleSymbols(const QString &moduleName,
         const QVector<Symbol> &symbols) = 0;
     virtual void openMemoryEditor() = 0;
diff --git a/src/plugins/debugger/debuggerdialogs.cpp b/src/plugins/debugger/debuggerdialogs.cpp
index aca2e8edfd8f6ea41c28364dbf01866ff5b56707..502e54ccad02bb71788478e51fdf9751d0f1880d 100644
--- a/src/plugins/debugger/debuggerdialogs.cpp
+++ b/src/plugins/debugger/debuggerdialogs.cpp
@@ -36,6 +36,7 @@
 #include "debuggerconstants.h"
 #include "debuggerprofileinformation.h"
 #include "debuggerstringutils.h"
+#include "debuggertoolchaincombobox.h"
 #include "cdb/cdbengine.h"
 #include "shared/hostutils.h"
 
@@ -44,31 +45,40 @@
 #include "ui_startexternaldialog.h"
 #include "ui_startremotedialog.h"
 #include "ui_startremoteenginedialog.h"
-#include "ui_attachtoqmlportdialog.h"
 
 #include <coreplugin/icore.h>
 #include <projectexplorer/abi.h>
 #include <projectexplorer/profileinformation.h>
 #include <utils/historycompleter.h>
+#include <utils/pathchooser.h>
 #include <utils/qtcassert.h>
 #include <utils/synchronousprocess.h>
 
+#include <QAction>
+#include <QApplication>
+#include <QButtonGroup>
 #include <QCoreApplication>
 #include <QDebug>
+#include <QDialog>
+#include <QDialogButtonBox>
 #include <QDir>
-#include <QRegExp>
-
-#include <QButtonGroup>
 #include <QFileDialog>
+#include <QFormLayout>
+#include <QGridLayout>
 #include <QGroupBox>
 #include <QHeaderView>
+#include <QLabel>
+#include <QLineEdit>
 #include <QMessageBox>
 #include <QPushButton>
 #include <QRadioButton>
+#include <QRegExp>
 #include <QScrollArea>
 #include <QSortFilterProxyModel>
+#include <QSpinBox>
 #include <QStandardItemModel>
-#include <QGridLayout>
+#include <QVariant>
+#include <QVBoxLayout>
 
 using namespace ProjectExplorer;
 using namespace Utils;
@@ -232,9 +242,9 @@ void AttachCoreDialog::setCoreFile(const QString &fileName)
     changed();
 }
 
-Profile *AttachCoreDialog::profile() const
+Core::Id AttachCoreDialog::profileId() const
 {
-    return m_ui->toolchainComboBox->currentProfile();
+    return m_ui->toolchainComboBox->currentProfileId();
 }
 
 void AttachCoreDialog::setProfileIndex(int i)
@@ -379,9 +389,9 @@ QString AttachExternalDialog::executable() const
     return m_model->executableForPid(attachPIDText());
 }
 
-Profile *AttachExternalDialog::profile() const
+Core::Id AttachExternalDialog::profileId() const
 {
-    return m_ui->toolchainComboBox->currentProfile();
+    return m_ui->toolchainComboBox->currentProfileId();
 }
 
 void AttachExternalDialog::setProfileIndex(int i)
@@ -587,9 +597,9 @@ QString StartExternalDialog::executableFile() const
     return m_ui->execFile->path();
 }
 
-Profile *StartExternalDialog::profile() const
+Core::Id StartExternalDialog::profileId() const
 {
-    return m_ui->toolChainComboBox->currentProfile();
+    return m_ui->toolChainComboBox->currentProfileId();
 }
 
 bool StartExternalDialog::isValid() const
@@ -670,28 +680,14 @@ bool StartExternalDialog::run(QWidget *parent,
         writeParameterHistory(history, settings, settingsGroup, arrayName);
     }
 
-    Profile *profile = dialog.profile();
-    QTC_ASSERT(profile, return false);
-    ToolChain *tc = ToolChainProfileInformation::toolChain(profile);
-    QTC_ASSERT(tc, return false);
-
+    fillParameters(sp, dialog.profileId());
     sp->executable = newParameters.executableFile;
     sp->startMode = StartExternal;
-    sp->toolChainAbi = tc->targetAbi();
-    sp->debuggerCommand = DebuggerProfileInformation::debuggerCommand(profile).toString();
     sp->workingDirectory = newParameters.workingDirectory;
     sp->displayName = sp->executable;
     sp->useTerminal = newParameters.runInTerminal;
     if (!newParameters.arguments.isEmpty())
         sp->processArgs = newParameters.arguments;
-    // Fixme: 1 of 3 testing hacks.
-    if (sp->processArgs.startsWith(QLatin1String("@tcf@ ")) || sp->processArgs.startsWith(QLatin1String("@sym@ ")))
-        // Set up an ARM Symbian Abi
-        sp->toolChainAbi = Abi(Abi::ArmArchitecture,
-                               Abi::SymbianOS,
-                               Abi::SymbianDeviceFlavor,
-                               Abi::ElfFormat, false);
-
     sp->breakOnMain = newParameters.breakAtMain;
     return true;
 }
@@ -847,17 +843,11 @@ bool StartRemoteDialog::run(QWidget *parent,
         writeParameterHistory(history, settings, settingsGroup, arrayName);
     }
 
-    Profile *profile = dialog.profile();
-    QTC_ASSERT(profile, return false);
-    ToolChain *tc = ToolChainProfileInformation::toolChain(profile);
-    QTC_ASSERT(tc, return false);
-
+    fillParameters(sp, dialog.profileId());
     sp->remoteChannel = newParameters.remoteChannel;
     sp->remoteArchitecture = newParameters.remoteArchitecture;
     sp->executable = newParameters.localExecutable;
     sp->displayName = tr("Remote: \"%1\"").arg(sp->remoteChannel);
-    sp->debuggerCommand = DebuggerProfileInformation::debuggerCommand(profile).toString();
-    sp->toolChainAbi = tc->targetAbi();
     sp->overrideStartScript = newParameters.overrideStartScript;
     sp->useServerStartScript = newParameters.useServerStartScript;
     sp->serverStartScript = newParameters.serverStartScript;
@@ -911,9 +901,9 @@ void StartRemoteDialog::historyIndexChanged(int index)
     setParameters(v.value<StartRemoteParameters>());
 }
 
-Profile *StartRemoteDialog::profile() const
+Core::Id StartRemoteDialog::profileId() const
 {
-    return m_ui->toolchainComboBox->currentProfile();
+    return m_ui->toolchainComboBox->currentProfileId();
 }
 
 void StartRemoteDialog::setRemoteArchitectures(const QStringList &list)
@@ -938,51 +928,97 @@ void StartRemoteDialog::updateState()
 //
 ///////////////////////////////////////////////////////////////////////
 
+class AttachToQmlPortDialogPrivate
+{
+public:
+    QLabel *hostLabel;
+    QLineEdit *hostLineEdit;
+    QLabel *portLabel;
+    QSpinBox *portSpinBox;
+    QLabel *profileLabel;
+    Debugger::ProfileChooser *profileChooser;
+};
+
 AttachToQmlPortDialog::AttachToQmlPortDialog(QWidget *parent)
   : QDialog(parent),
-    m_ui(new Ui::AttachToQmlPortDialog)
+    d(new AttachToQmlPortDialogPrivate)
 {
     setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
-    m_ui->setupUi(this);
-    m_ui->buttonBox->button(QDialogButtonBox::Ok)->setDefault(true);
+    setWindowTitle(tr("Start Debugger"));
 
-    connect(m_ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
-    connect(m_ui->buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
+    d->hostLineEdit = new QLineEdit(this);
+    d->hostLineEdit->setText(QString::fromUtf8("localhost"));
+
+    d->hostLabel = new QLabel(this);
+    d->hostLabel->setText(tr("&Host:"));
+    d->hostLabel->setBuddy(d->hostLineEdit);
+
+    d->portSpinBox = new QSpinBox(this);
+    d->portSpinBox->setMaximum(65535);
+    d->portSpinBox->setValue(3768);
+
+    d->portLabel = new QLabel(this);
+    d->portLabel->setText(tr("&Port:"));
+    d->portLabel->setBuddy(d->portSpinBox);
+
+    d->profileChooser = new Debugger::ProfileChooser(this);
+
+    d->profileLabel = new QLabel(this);
+    d->profileLabel->setText(tr("Target:"));
+
+    QDialogButtonBox *buttonBox = new QDialogButtonBox(this);
+    buttonBox->setOrientation(Qt::Horizontal);
+    buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
+
+    QVBoxLayout *verticalLayout = new QVBoxLayout(this);
+    QFormLayout *formLayout = new QFormLayout();
+
+    formLayout->addRow(d->hostLabel, d->hostLineEdit);
+    formLayout->addRow(d->portLabel, d->portSpinBox);
+    formLayout->addRow(d->profileLabel, d->profileChooser);
+
+    verticalLayout->addLayout(formLayout);
+    verticalLayout->addWidget(buttonBox);
+
+    buttonBox->button(QDialogButtonBox::Ok)->setDefault(true);
+
+    connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
+    connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
 }
 
 AttachToQmlPortDialog::~AttachToQmlPortDialog()
 {
-    delete m_ui;
+    delete d;
 }
 
 void AttachToQmlPortDialog::setHost(const QString &host)
 {
-    m_ui->hostLineEdit->setText(host);
+    d->hostLineEdit->setText(host);
 }
 
 QString AttachToQmlPortDialog::host() const
 {
-    return m_ui->hostLineEdit->text();
+    return d->hostLineEdit->text();
 }
 
 void AttachToQmlPortDialog::setPort(const int port)
 {
-    m_ui->portSpinBox->setValue(port);
+    d->portSpinBox->setValue(port);
 }
 
 int AttachToQmlPortDialog::port() const
 {
-    return m_ui->portSpinBox->value();
+    return d->portSpinBox->value();
 }
 
-QString AttachToQmlPortDialog::sysroot() const
+Core::Id AttachToQmlPortDialog::profileId() const
 {
-    return m_ui->sysRootChooser->path();
+    return d->profileChooser->currentProfileId();
 }
 
-void AttachToQmlPortDialog::setSysroot(const QString &sysroot)
+void AttachToQmlPortDialog::setProfileId(const Core::Id &id)
 {
-    m_ui->sysRootChooser->setPath(sysroot);
+    d->profileChooser->setCurrentProfileId(id);
 }
 
 // --------- StartRemoteCdbDialog
diff --git a/src/plugins/debugger/debuggerdialogs.h b/src/plugins/debugger/debuggerdialogs.h
index 69b20832aa6bf1fbf8edd2a5652ec42ccf4a1568..1b9578bfb75a1b818043b9405f4e1024d1b26591 100644
--- a/src/plugins/debugger/debuggerdialogs.h
+++ b/src/plugins/debugger/debuggerdialogs.h
@@ -45,6 +45,7 @@ class QDialogButtonBox;
 class QSettings;
 QT_END_NAMESPACE
 
+namespace Core { class Id; }
 namespace ProjectExplorer { class Profile; }
 
 namespace Debugger {
@@ -57,13 +58,13 @@ class AttachCoreDialog;
 class AttachExternalDialog;
 class StartExternalDialog;
 class StartRemoteDialog;
-class AttachToQmlPortDialog;
 class StartRemoteEngineDialog;
 } // namespace Ui
 
 class ProcessListFilterModel;
 class StartExternalParameters;
 class StartRemoteParameters;
+class AttachToQmlPortDialogPrivate;
 
 class AttachCoreDialog : public QDialog
 {
@@ -81,7 +82,7 @@ public:
 
     int profileIndex() const;
     void setProfileIndex(int);
-    ProjectExplorer::Profile *profile() const;
+    Core::Id profileId() const;
 
     QString overrideStartScript() const;
     void setOverrideStartScript(const QString &scriptName);
@@ -108,7 +109,7 @@ public:
 
     int profileIndex() const;
     void setProfileIndex(int);
-    ProjectExplorer::Profile *profile() const;
+    Core::Id profileId() const;
 
     void accept();
 
@@ -150,7 +151,7 @@ private:
     QString executableFile() const;
     void setExecutableFile(const QString &executable);
 
-    ProjectExplorer::Profile *profile() const;
+    Core::Id profileId() const;
     bool isValid() const;
 
     Ui::StartExternalDialog *m_ui;
@@ -178,7 +179,7 @@ private:
 
     void setRemoteArchitectures(const QStringList &list);
 
-    ProjectExplorer::Profile *profile() const;
+    Core::Id profileId() const;
 
     Ui::StartRemoteDialog *m_ui;
 };
@@ -197,11 +198,11 @@ public:
     int port() const;
     void setPort(const int port);
 
-    QString sysroot() const;
-    void setSysroot(const QString &sysroot);
+    Core::Id profileId() const;
+    void setProfileId(const Core::Id &id);
 
 private:
-    Ui::AttachToQmlPortDialog *m_ui;
+    AttachToQmlPortDialogPrivate *d;
 };
 
 class StartRemoteCdbDialog : public QDialog
diff --git a/src/plugins/debugger/debuggerengine.cpp b/src/plugins/debugger/debuggerengine.cpp
index e7d1cb78585025fae6a2c62f7217295e951028fa..df038d71f9ae18a870194698119a6ae12bea060f 100644
--- a/src/plugins/debugger/debuggerengine.cpp
+++ b/src/plugins/debugger/debuggerengine.cpp
@@ -185,8 +185,6 @@ public:
         m_taskHub(0)
     {
         connect(&m_locationTimer, SIGNAL(timeout()), SLOT(resetLocation()));
-        if (sp.toolChainAbi.os() == Abi::MacOS)
-            m_disassemblerAgent.setTryMixed(false);
     }
 
     ~DebuggerEnginePrivate() {}
@@ -1321,9 +1319,10 @@ DebuggerLanguages DebuggerEngine::languages() const
 QString DebuggerEngine::toFileInProject(const QUrl &fileUrl)
 {
     // make sure file finder is properly initialized
-    d->m_fileFinder.setProjectDirectory(startParameters().projectSourceDirectory);
-    d->m_fileFinder.setProjectFiles(startParameters().projectSourceFiles);
-    d->m_fileFinder.setSysroot(startParameters().sysroot);
+    const DebuggerStartParameters &sp = startParameters();
+    d->m_fileFinder.setProjectDirectory(sp.projectSourceDirectory);
+    d->m_fileFinder.setProjectFiles(sp.projectSourceFiles);
+    d->m_fileFinder.setSysroot(sp.sysRoot);
 
     return d->m_fileFinder.findFile(fileUrl);
 }
diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp
index c4ce7405a5b7c32920b8a62e040685d7ca60e026..cabab778e9c27a2d965bf7c73c7da43c6da8f243 100644
--- a/src/plugins/debugger/debuggerplugin.cpp
+++ b/src/plugins/debugger/debuggerplugin.cpp
@@ -466,14 +466,6 @@ static QToolButton *toolButton(const char *id)
     return toolButton(Core::ActionManager::command(id)->action());
 }
 
-static Abi anyAbiOfBinary(const QString &fileName)
-{
-    QList<Abi> abis = Abi::abisOfBinary(Utils::FileName::fromString(fileName));
-    if (abis.isEmpty())
-        return Abi();
-    return abis.at(0);
-}
-
 ///////////////////////////////////////////////////////////////////////
 //
 // DummyEngine
@@ -554,6 +546,17 @@ public:
 //
 ///////////////////////////////////////////////////////////////////////
 
+void fillParameters(DebuggerStartParameters *sp, Core::Id id)
+{
+    Profile *profile = ProfileManager::instance()->find(id);
+    QTC_ASSERT(profile, return);
+    sp->sysRoot = SysRootProfileInformation::sysRoot(profile).toString();
+    sp->debuggerCommand = DebuggerProfileInformation::debuggerCommand(profile).toString();
+    ToolChain *tc = ToolChainProfileInformation::toolChain(profile);
+    if (tc)
+        sp->toolChainAbi = tc->targetAbi();
+}
+
 static TextEditor::ITextEditor *currentTextEditor()
 {
     return qobject_cast<TextEditor::ITextEditor *>(Core::EditorManager::currentEditor());
@@ -768,7 +771,7 @@ public slots:
     void startRemoteProcess();
     void startRemoteServer();
     void loadRemoteCoreFile();
-    bool queryRemoteParameters(DebuggerStartParameters &sp, bool useScript);
+    //bool queryRemoteParameters(DebuggerStartParameters &sp, bool useScript);
     void attachToRemoteServer();
     void attachToRemoteProcess();
     void attachToQmlPort();
@@ -798,7 +801,7 @@ public slots:
     void runControlFinished(DebuggerEngine *engine);
     DebuggerLanguages activeLanguages() const;
     unsigned enabledEngines() const { return m_cmdLineEnabledEngines; }
-    QString debuggerForAbi(const Abi &abi, DebuggerEngineType et = NoEngineType) const;
+//    QString debuggerForAbi(const Abi &abi, DebuggerEngineType et = NoEngineType) const;
     void remoteCommand(const QStringList &options, const QStringList &);
 
     bool isReverseDebugging() const;
@@ -1092,9 +1095,9 @@ public slots:
     // FIXME: Remove.
     void maybeEnrichParameters(DebuggerStartParameters *sp);
 
-    void gdbServerStarted(const QString &channel, const QString &sysroot,
+    void gdbServerStarted(const QString &channel, const QString &profile,
         const QString &remoteCommandLine, const QString &remoteExecutable);
-    void attachedToProcess(const QString &channel, const QString &sysroot,
+    void attachedToProcess(const QString &channel, const QString &profile,
         const QString &remoteCommandLine, const QString &remoteExecutable);
 
     void updateQmlActions() {
@@ -1289,21 +1292,12 @@ void DebuggerPluginPrivate::maybeEnrichParameters(DebuggerStartParameters *sp)
 {
     if (!boolSetting(AutoEnrichParameters))
         return;
-    if (sp->sysroot.isEmpty() &&
-              (sp->startMode == AttachToRemoteServer
-            || sp->startMode == StartRemoteProcess
-            || sp->startMode == AttachToRemoteProcess
-            || sp->startMode == LoadRemoteCore)) {
-        // FIXME: Get from BaseQtVersion.
-        sp->sysroot = QString::fromLocal8Bit(qgetenv("QTC_DEBUGGER_SYSROOT"));
-        showMessage(QString::fromLatin1("USING QTC_DEBUGGER_SYSROOT %1")
-            .arg(sp->sysroot), LogWarning);
-    }
+    const QString sysroot = sp->sysRoot;
     if (sp->debugInfoLocation.isEmpty()) {
-        sp->debugInfoLocation = sp->sysroot + QLatin1String("/usr/lib/debug");
+        sp->debugInfoLocation = sysroot + QLatin1String("/usr/lib/debug");
     }
     if (sp->debugSourceLocation.isEmpty()) {
-        QString base = sp->sysroot + QLatin1String("/usr/src/debug/");
+        QString base = sysroot + QLatin1String("/usr/src/debug/");
         sp->debugSourceLocation.append(base + QLatin1String("qt5base/src/corelib"));
         sp->debugSourceLocation.append(base + QLatin1String("qt5base/src/gui"));
         sp->debugSourceLocation.append(base + QLatin1String("qt5base/src/network"));
@@ -1318,7 +1312,7 @@ bool DebuggerPluginPrivate::parseArgument(QStringList::const_iterator &it,
 {
     const QString &option = *it;
     // '-debug <pid>'
-    // '-debug <exe>[,server=<server:port>|,core=<core>][,arch=<arch>][,sysroot=<sysroot>]'
+    // '-debug <exe>[,server=<server:port>|,core=<core>][,arch=<arch>][,profile=<profile>]'
     if (*it == _("-debug")) {
         ++it;
         if (it == cend) {
@@ -1326,6 +1320,7 @@ bool DebuggerPluginPrivate::parseArgument(QStringList::const_iterator &it,
             return false;
         }
         DebuggerStartParameters sp;
+        fillParameters(&sp, ProfileManager::instance()->defaultProfile()->id());
         qulonglong pid = it->toULongLong();
         if (pid) {
             sp.startMode = AttachExternal;
@@ -1333,10 +1328,9 @@ bool DebuggerPluginPrivate::parseArgument(QStringList::const_iterator &it,
             sp.attachPID = pid;
             sp.displayName = tr("Process %1").arg(sp.attachPID);
             sp.startMessage = tr("Attaching to local process %1.").arg(sp.attachPID);
-            sp.toolChainAbi = Abi::hostAbi();
         } else {
-            QStringList args = it->split(QLatin1Char(','));
             sp.startMode = StartExternal;
+            QStringList args = it->split(QLatin1Char(','));
             foreach (const QString &arg, args) {
                 QString key = arg.section(QLatin1Char('='), 0, 0);
                 QString val = arg.section(QLatin1Char('='), 1, 1);
@@ -1365,10 +1359,9 @@ bool DebuggerPluginPrivate::parseArgument(QStringList::const_iterator &it,
                     sp.displayName = tr("Core file \"%1\"").arg(sp.coreFile);
                     sp.startMessage = tr("Attaching to core file %1.").arg(sp.coreFile);
                 }
-                else if (key == QLatin1String("sysroot"))
-                    sp.sysroot = val;
+                else if (key == QLatin1String("profile"))
+                    fillParameters(&sp, Id(val));
             }
-            sp.toolChainAbi = anyAbiOfBinary(sp.executable);
         }
         if (sp.startMode == StartExternal) {
             sp.displayName = tr("Executable file \"%1\"").arg(sp.executable);
@@ -1389,12 +1382,12 @@ bool DebuggerPluginPrivate::parseArgument(QStringList::const_iterator &it,
             return false;
         }
         DebuggerStartParameters sp;
+        fillParameters(&sp, ProfileManager::instance()->defaultProfile()->id());
         sp.startMode = AttachCrashedExternal;
         sp.crashParameter = it->section(QLatin1Char(':'), 0, 0);
         sp.attachPID = it->section(QLatin1Char(':'), 1, 1).toULongLong();
         sp.displayName = tr("Crashed process %1").arg(sp.attachPID);
         sp.startMessage = tr("Attaching to crashed process %1").arg(sp.attachPID);
-        sp.toolChainAbi = Abi::hostAbi();
         if (!sp.attachPID) {
             *errorMessage = DebuggerPlugin::tr("The parameter '%1' of option '%2' "
                 "does not match the pattern <handle>:<pid>.").arg(*it, option);
@@ -1547,19 +1540,13 @@ void DebuggerPluginPrivate::attachExternalApplication()
 
     setConfigValue(_("LastAttachExternalProfileIndex"), QVariant(dlg.profileIndex()));
 
-    Profile *profile = dlg.profile();
-    QTC_ASSERT(profile, return);
-    ToolChain *tc = ToolChainProfileInformation::toolChain(profile);
-    QTC_ASSERT(tc, return);
-
     DebuggerStartParameters sp;
+    fillParameters(&sp, dlg.profileId());
     sp.attachPID = dlg.attachPID();
     sp.displayName = tr("Process %1").arg(dlg.attachPID());
     sp.executable = dlg.executable();
     sp.startMode = AttachExternal;
     sp.closeMode = DetachAtClose;
-    sp.toolChainAbi = tc->targetAbi();
-    sp.debuggerCommand = DebuggerProfileInformation::debuggerCommand(profile).toString();
     if (DebuggerRunControl *rc = createDebugger(sp))
         startDebugger(rc);
 }
@@ -1567,11 +1554,11 @@ void DebuggerPluginPrivate::attachExternalApplication()
 void DebuggerPluginPrivate::attachExternalApplication(RunControl *rc)
 {
     DebuggerStartParameters sp;
+    fillParameters(&sp, ProfileManager::instance()->defaultProfile()->id()); // FIXME: Extract from rc.
     sp.attachPID = rc->applicationProcessHandle().pid();
     sp.displayName = tr("Debugger attached to %1").arg(rc->displayName());
     sp.startMode = AttachExternal;
     sp.closeMode = DetachAtClose;
-    sp.toolChainAbi = rc->abi();
     if (DebuggerRunControl *rc = createDebugger(sp))
         startDebugger(rc);
 }
@@ -1592,20 +1579,13 @@ void DebuggerPluginPrivate::attachCore()
     setConfigValue(_("LastExternalProfileIndex"), QVariant(dlg.profileIndex()));
     setConfigValue(_("LastExternalStartScript"), dlg.overrideStartScript());
 
-    Profile *profile = dlg.profile();
-    QTC_ASSERT(profile, return);
-    ToolChain *tc = ToolChainProfileInformation::toolChain(profile);
-    QTC_ASSERT(tc, return);
-
     DebuggerStartParameters sp;
+    fillParameters(&sp, dlg.profileId());
     sp.executable = dlg.executableFile();
     sp.coreFile = dlg.coreFile();
     sp.displayName = tr("Core file \"%1\"").arg(dlg.coreFile());
     sp.startMode = AttachCore;
     sp.closeMode = DetachAtClose;
-    sp.debuggerCommand = DebuggerProfileInformation::debuggerCommand(profile).toString();
-    sp.toolChainAbi = tc->targetAbi();
-    sp.sysroot = SysRootProfileInformation::sysRoot(profile).toString();
     sp.overrideStartScript = dlg.overrideStartScript();
     if (DebuggerRunControl *rc = createDebugger(sp))
         startDebugger(rc);
@@ -1613,26 +1593,47 @@ void DebuggerPluginPrivate::attachCore()
 
 void DebuggerPluginPrivate::attachToRemoteServer(const QString &spec)
 {
-    // spec is: server:port@executable@architecture
+    // spec is: profile@server:port@executable@architecture
+    const QChar delim(QLatin1Char('@'));
     DebuggerStartParameters sp;
-    sp.remoteChannel = spec.section(QLatin1Char('@'), 0, 0);
-    sp.executable = spec.section(QLatin1Char('@'), 1, 1);
-    sp.remoteArchitecture = spec.section(QLatin1Char('@'), 2, 2);
+    fillParameters(&sp, Id(spec.section(delim, 0, 0)));
+    sp.remoteChannel = spec.section(delim, 1, 1);
+    sp.executable = spec.section(delim, 2, 2);
+    sp.remoteArchitecture = spec.section(delim, 3, 3);
     sp.displayName = tr("Remote: \"%1\"").arg(sp.remoteChannel);
     sp.startMode = AttachToRemoteServer;
     sp.closeMode = KillAtClose;
-    sp.toolChainAbi = anyAbiOfBinary(sp.executable);
     if (DebuggerRunControl *rc = createDebugger(sp))
         startDebugger(rc);
 }
 
+struct RemoteCdbMatcher : ProfileMatcher
+{
+    RemoteCdbMatcher() : m_hostAbi(Abi::hostAbi()) {}
+
+    bool matches(const Profile *profile) const
+    {
+        ToolChain *tc = ToolChainProfileInformation::toolChain(profile);
+        QTC_ASSERT(tc, return false);
+        Abi abi = tc->targetAbi();
+        return abi.architecture() == m_hostAbi.architecture()
+                && abi.os() == Abi::WindowsOS
+                && abi.osFlavor() == Abi::WindowsMsvc2010Flavor
+                && abi.binaryFormat() == Abi::PEFormat
+                && abi.wordWidth() == m_hostAbi.wordWidth();
+    }
+
+    Abi m_hostAbi;
+};
+
 void DebuggerPluginPrivate::startRemoteCdbSession()
 {
     const QString connectionKey = _("CdbRemoteConnection");
     DebuggerStartParameters sp;
-    Abi hostAbi = Abi::hostAbi();
-    sp.toolChainAbi = Abi(hostAbi.architecture(), Abi::WindowsOS,
-        Abi::WindowsMsvc2010Flavor, Abi::PEFormat, hostAbi.wordWidth());
+    RemoteCdbMatcher matcher;
+    Profile *profile = ProfileManager::instance()->find(&matcher);
+    QTC_ASSERT(profile, return);
+    fillParameters(&sp, profile->id());
     sp.startMode = AttachToRemoteServer;
     sp.closeMode = KillAtClose;
     StartRemoteCdbDialog dlg(mainWindow());
@@ -1648,13 +1649,10 @@ void DebuggerPluginPrivate::startRemoteCdbSession()
         startDebugger(rc);
 }
 
-bool DebuggerPluginPrivate::queryRemoteParameters(DebuggerStartParameters &sp, bool useScript)
-{
-    return StartRemoteDialog::run(mainWindow(),
-                                  m_coreSettings,
-                                  useScript,
-                                  &sp);
-}
+//bool DebuggerPluginPrivate::queryRemoteParameters(DebuggerStartParameters &sp, bool useScript)
+//{
+//    return StartRemoteDialog::run(mainWindow(), m_coreSettings, useScript, &sp);
+//}
 
 void DebuggerPluginPrivate::startRemoteProcess()
 {
@@ -1688,13 +1686,13 @@ void DebuggerPluginPrivate::startRemoteServer()
 }
 
 void DebuggerPluginPrivate::gdbServerStarted(const QString &channel,
-    const QString &sysroot,
+    const QString &profileId,
     const QString &remoteCommandLine,
     const QString &remoteExecutable)
 {
     Q_UNUSED(remoteCommandLine);
     Q_UNUSED(remoteExecutable);
-    Q_UNUSED(sysroot);
+    Q_UNUSED(profileId);
     showStatusMessage(tr("gdbserver is now listening at %1").arg(channel));
 }
 
@@ -1710,12 +1708,10 @@ void DebuggerPluginPrivate::loadRemoteCoreFile()
     dlg.setLocalCoreFileName(sp.coreFile);
     if (!dlg.exec())
         return;
+    fillParameters(&sp, dlg.profileId());
     sp.displayName = tr("Core file \"%1\"").arg(sp.coreFile);
     sp.startMode = AttachCore;
     sp.closeMode = DetachAtClose;
-    //sp.debuggerCommand = dlg.debuggerCommand();
-    //sp.toolChainAbi = dlg.abi();
-    sp.sysroot = dlg.sysroot();
     //sp.overrideStartScript = dlg.overrideStartScript();
     if (DebuggerRunControl *rc = createDebugger(sp))
         startDebugger(rc);
@@ -1730,10 +1726,13 @@ void DebuggerPluginPrivate::attachToRemoteProcess()
 }
 
 void DebuggerPluginPrivate::attachedToProcess(const QString &channel,
-    const QString &sysroot,
+    const QString &profileId,
     const QString &remoteCommandLine,
     const QString &remoteExecutable)
 {
+    Profile *profile = ProfileManager::instance()->find(Id(profileId));
+    QTC_ASSERT(profile, return);
+    QString sysroot = SysRootProfileInformation::sysRoot(profile).toString();
     QString binary;
     QString localExecutable;
     QString candidate = sysroot + remoteExecutable;
@@ -1771,11 +1770,9 @@ void DebuggerPluginPrivate::attachedToProcess(const QString &channel,
     }
 
     DebuggerStartParameters sp;
-    sp.toolChainAbi = abis.at(0);
-    //sp.remoteArchitecture = abis.at(0).toString();
+    fillParameters(&sp, Id(profileId));
     sp.displayName = tr("Remote: \"%1\"").arg(channel);
     sp.remoteChannel = channel;
-    sp.sysroot = sysroot;
     sp.executable = localExecutable;
     sp.startMode = AttachToRemoteServer;
     sp.closeMode = KillAtClose;
@@ -1806,20 +1803,20 @@ void DebuggerPluginPrivate::attachToQmlPort()
         dlg.setPort(sp.qmlServerPort);
     }
 
-    const QVariant sysrootPath = configValue(_("LastSysroot"));
-    if (sysrootPath.isValid())
-        dlg.setSysroot(sysrootPath.toString());
+    const QVariant profileId = configValue(_("LastProfile"));
+    if (profileId.isValid())
+        dlg.setProfileId(Id(profileId.toString()));
 
     if (dlg.exec() != QDialog::Accepted)
         return;
 
     setConfigValue(_("LastQmlServerAddress"), dlg.host());
     setConfigValue(_("LastQmlServerPort"), dlg.port());
-    setConfigValue(_("LastSysroot"), dlg.sysroot());
+    setConfigValue(_("LastProfile"), dlg.profileId().toString());
 
+    fillParameters(&sp, dlg.profileId());
     sp.qmlServerAddress = dlg.host();
     sp.qmlServerPort = dlg.port();
-    sp.sysroot = dlg.sysroot();
 
     sp.startMode = AttachToRemoteProcess;
     sp.closeMode = KillAtClose;
@@ -2731,8 +2728,9 @@ static QString formatStartParameters(DebuggerStartParameters &sp)
             str.setIntegerBase(10);
         }
     }
-    if (!sp.debuggerCommand.isEmpty())
-        str << "Debugger: " << QDir::toNativeSeparators(sp.debuggerCommand) << '\n';
+    QString cmd = sp.debuggerCommand;
+    if (!cmd.isEmpty())
+        str << "Debugger: " << QDir::toNativeSeparators(cmd) << '\n';
     if (!sp.coreFile.isEmpty())
         str << "Core: " << QDir::toNativeSeparators(sp.coreFile) << '\n';
     if (sp.attachPID > 0)
@@ -2762,7 +2760,7 @@ static QString formatStartParameters(DebuggerStartParameters &sp)
     }
     if (!sp.gnuTarget.isEmpty())
         str << "Gnu target: " << sp.gnuTarget << '\n';
-    str << "Sysroot: " << sp.sysroot << '\n';
+    str << "Sysroot: " << sp.sysRoot << '\n';
     str << "Debug Source Location: " << sp.debugSourceLocation.join(QLatin1String(":")) << '\n';
     str << "Symbol file: " << sp.symbolFileName << '\n';
     if (sp.useServerStartScript)
@@ -2819,61 +2817,6 @@ void DebuggerPluginPrivate::remoteCommand(const QStringList &options,
     runScheduled();
 }
 
-QString DebuggerPluginPrivate::debuggerForAbi(const Abi &abi, DebuggerEngineType et) const
-{
-    enum { debug = 0 };
-    QList<Abi> searchAbis;
-    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() == Abi::WindowsOS) {
-        switch (et) {
-        case CdbEngineType:
-            searchAbis.clear();
-            searchAbis.push_back(Abi(abi.architecture(), abi.os(),
-                Abi::WindowsMsvc2010Flavor, abi.binaryFormat(), abi.wordWidth()));
-            searchAbis.push_back(Abi(abi.architecture(), abi.os(),
-                Abi::WindowsMsvc2008Flavor, abi.binaryFormat(), abi.wordWidth()));
-            searchAbis.push_back(Abi(abi.architecture(), abi.os(),
-                Abi::WindowsMsvc2005Flavor, abi.binaryFormat(), abi.wordWidth()));
-            break;
-        case GdbEngineType:
-            searchAbis.clear();
-            searchAbis.push_back(Abi(abi.architecture(), abi.os(),
-                Abi::WindowsMSysFlavor, abi.binaryFormat(), abi.wordWidth()));
-            break;
-        default:
-            break;
-        }
-    }
-    if (debug)
-        qDebug() << "debuggerForAbi" << abi.toString() << searchAbis.size()
-                 << searchAbis.front().toString() << et;
-
-    QList<Profile *> profileList = ProfileManager::instance()->profiles();
-    // Note: stList is not sorted with autodected first!
-    QStringList debuggerList;
-    foreach (Profile *p, profileList) {
-        if (!p->isValid())
-            continue;
-        ToolChain *tc = ProjectExplorer::ToolChainProfileInformation::toolChain(p);
-        if (!tc)
-            continue;
-        if (searchAbis.contains(tc->targetAbi())) {
-            const QString debugger = DebuggerProfileInformation::debuggerCommand(p).toString();
-            if (!debugger.isEmpty()) {
-                if (p->isAutoDetected())
-                    debuggerList.append(debugger);
-                else
-                    debuggerList.prepend(debugger);
-            }
-        }
-    }
-    if (!debuggerList.isEmpty())
-        return debuggerList.at(0);
-    return QString();
-}
-
 DebuggerLanguages DebuggerPluginPrivate::activeLanguages() const
 {
     QTC_ASSERT(m_mainWindow, return AnyLanguage);
@@ -3738,12 +3681,12 @@ static Target *activeTarget()
     return project->activeTarget();
 }
 
-static ToolChain *currentToolChain()
+static Id currentProfileId()
 {
     Target *t = activeTarget();
     if (!t || !t->isEnabled())
         return 0;
-    return ToolChainProfileInformation::toolChain(activeTarget()->profile());
+    return activeTarget()->profile()->id();
 }
 
 static LocalApplicationRunConfiguration *activeLocalRunConfiguration()
@@ -3793,7 +3736,7 @@ void DebuggerPluginPrivate::testPythonDumpers1()
 void DebuggerPluginPrivate::testPythonDumpers2()
 {
     DebuggerStartParameters sp;
-    sp.toolChainAbi = currentToolChain()->targetAbi();
+    fillParameters(&sp, currentProfileId());
     sp.executable = activeLocalRunConfiguration()->executable();
     testRunProject(sp, TestCallBack(this, "testPythonDumpers3"));
 }
@@ -3825,7 +3768,7 @@ void DebuggerPluginPrivate::testStateMachine1()
 void DebuggerPluginPrivate::testStateMachine2()
 {
     DebuggerStartParameters sp;
-    sp.toolChainAbi = currentToolChain()->targetAbi();
+    fillParameters(&sp, currentProfileId());
     sp.executable = activeLocalRunConfiguration()->executable();
     sp.testCase = TestNoBoundsOfCurrentFunction;
     testRunProject(sp, TestCallBack(this, "testStateMachine3"));
diff --git a/src/plugins/debugger/debuggerrunner.cpp b/src/plugins/debugger/debuggerrunner.cpp
index 4f9f7a1ac846e4a41d7573a3f8ca5bd03d992765..5852a641a3d521739feed54b2208813ad2d5bb53 100644
--- a/src/plugins/debugger/debuggerrunner.cpp
+++ b/src/plugins/debugger/debuggerrunner.cpp
@@ -158,7 +158,7 @@ static inline QString msgEngineNotAvailable(DebuggerEngineType et)
 //
 ////////////////////////////////////////////////////////////////////////
 
-class DebuggerRunConfigWidget : public ProjectExplorer::RunConfigWidget
+class DebuggerRunConfigWidget : public RunConfigWidget
 {
     Q_OBJECT
 
@@ -323,7 +323,7 @@ DebuggerRunControlPrivate::DebuggerRunControlPrivate(DebuggerRunControl *parent,
 DebuggerRunControl::DebuggerRunControl(RunConfiguration *runConfiguration,
                                        const DebuggerStartParameters &sp,
                                        const QPair<DebuggerEngineType, DebuggerEngineType> &masterSlaveEngineTypes)
-    : RunControl(runConfiguration, ProjectExplorer::DebugRunMode),
+    : RunControl(runConfiguration, DebugRunMode),
       d(new DebuggerRunControlPrivate(this, runConfiguration))
 {
     connect(this, SIGNAL(finished()), SLOT(handleFinished()));
@@ -671,12 +671,6 @@ static QList<DebuggerEngineType> engineTypes(const DebuggerStartParameters &sp)
             return result;
     }
 
-    // FIXME: 1 of 3 testing hacks.
-    if (sp.processArgs.startsWith(QLatin1String("@tcf@ "))) {
-        result.push_back(GdbEngineType);
-        return result;
-    }
-
     if (sp.startMode != AttachToRemoteServer
             && sp.startMode != AttachToRemoteProcess
             && sp.startMode != LoadRemoteCore
@@ -743,8 +737,9 @@ static inline bool canUseEngine(DebuggerEngineType et,
 DEBUGGER_EXPORT ConfigurationCheck checkDebugConfiguration(const DebuggerStartParameters &sp)
 {
     ConfigurationCheck result;
+    QString abi = sp.toolChainAbi.toString();
     if (debug)
-        qDebug().nospace() << "checkDebugConfiguration " << sp.toolChainAbi.toString()
+        qDebug().nospace() << "checkDebugConfiguration " << abi
                            << " Start mode=" << sp.startMode << " Executable=" << sp.executable
                            << " Debugger command=" << sp.debuggerCommand;
     // Get all applicable types.
@@ -780,12 +775,12 @@ DEBUGGER_EXPORT ConfigurationCheck checkDebugConfiguration(const DebuggerStartPa
             result.errorMessage = DebuggerPlugin::tr(
                 "The debugger engine '%1' required for debugging binaries of the type '%2'"
                 " is not configured correctly.").
-                arg(QLatin1String(engineTypeName(requiredTypes.front())), sp.toolChainAbi.toString());
+                arg(QLatin1String(engineTypeName(requiredTypes.front())), abi);
         } else {
             result.errorMessage = DebuggerPlugin::tr(
                 "None of the debugger engines '%1' capable of debugging binaries of the type '%2'"
                 " is configured correctly.").
-                arg(engineTypeNames(requiredTypes), sp.toolChainAbi.toString());
+                arg(engineTypeNames(requiredTypes), abi);
         }
         return result;
     }
@@ -796,7 +791,7 @@ DEBUGGER_EXPORT ConfigurationCheck checkDebugConfiguration(const DebuggerStartPa
         const QString msg = DebuggerPlugin::tr(
             "The preferred debugger engine for debugging binaries of type '%1' is not available.\n"
             "The debugger engine '%2' will be used as a fallback.\nDetails: %3").
-                arg(sp.toolChainAbi.toString(), QLatin1String(engineTypeName(usableType)),
+                arg(abi, QLatin1String(engineTypeName(usableType)),
                     result.errorDetails.join(QString(QLatin1Char('\n'))));
         debuggerCore()->showMessage(msg, LogWarning);
         showMessageBox(QMessageBox::Warning, DebuggerPlugin::tr("Warning"), msg);
@@ -880,6 +875,9 @@ static DebuggerStartParameters localStartParameters(RunConfiguration *runConfigu
             qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration);
     QTC_ASSERT(rc, return sp);
 
+    Target *target = runConfiguration->target();
+    Profile *profile = target ? target->profile() : ProfileManager::instance()->defaultProfile();
+    fillParameters(&sp, profile->id());
     sp.environment = rc->environment();
     sp.workingDirectory = rc->workingDirectory();
 
@@ -893,17 +891,11 @@ static DebuggerStartParameters localStartParameters(RunConfiguration *runConfigu
         return sp;
     sp.startMode = StartInternal;
     sp.processArgs = rc->commandLineArguments();
-    sp.toolChainAbi = rc->abi();
-    if (!sp.toolChainAbi.isValid()) {
-        QList<Abi> abis = Abi::abisOfBinary(Utils::FileName::fromString(sp.executable));
-        if (!abis.isEmpty())
-            sp.toolChainAbi = abis.at(0);
-    }
     sp.useTerminal = rc->runMode() == LocalApplicationRunConfiguration::Console;
     sp.dumperLibrary = rc->dumperLibrary();
     sp.dumperLibraryLocations = rc->dumperLibraryLocations();
 
-    if (const ProjectExplorer::Target *target = runConfiguration->target()) {
+    if (target) {
         if (QByteArray(target->metaObject()->className()).contains("Qt4")) {
             // FIXME: Get this from the profile?
             //        We could query the QtVersion for this information directly, but then we
@@ -915,13 +907,10 @@ static DebuggerStartParameters localStartParameters(RunConfiguration *runConfigu
             if (!qmake.isEmpty())
                 sp.qtInstallPath = findQtInstallPath(qmake);
         }
-        if (const ProjectExplorer::Project *project = target->project()) {
+        if (const Project *project = target->project()) {
             sp.projectSourceDirectory = project->projectDirectory();
-            if (const ProjectExplorer::BuildConfiguration *buildConfig = target->activeBuildConfiguration()) {
+            if (const BuildConfiguration *buildConfig = target->activeBuildConfiguration())
                 sp.projectBuildDirectory = buildConfig->buildDirectory();
-                const ProjectExplorer::Profile *p = runConfiguration->target()->profile();
-                sp.debuggerCommand = DebuggerProfileInformation::debuggerCommand(p).toString();
-            }
             sp.projectSourceFiles = project->files(Project::ExcludeGeneratedFiles);
         }
     }
diff --git a/src/plugins/debugger/debuggerstartparameters.h b/src/plugins/debugger/debuggerstartparameters.h
index ff5f51ec1d76a23c13af17adaa17318cc6c75b87..51a5bd51b4aa7ea91ebc8f57456a375a5d0a1ad9 100644
--- a/src/plugins/debugger/debuggerstartparameters.h
+++ b/src/plugins/debugger/debuggerstartparameters.h
@@ -36,6 +36,7 @@
 #include "debugger_global.h"
 #include "debuggerconstants.h"
 
+#include <coreplugin/id.h>
 #include <ssh/sshconnection.h>
 #include <utils/environment.h>
 #include <projectexplorer/abi.h>
@@ -77,6 +78,12 @@ public:
         testCase(0)
     {}
 
+    //Core::Id profileId;
+
+    QString sysRoot;
+    QString debuggerCommand;
+    ProjectExplorer::Abi toolChainAbi;
+
     QString executable;
     QString displayName; // Used in the Snapshots view.
     QString startMessage; // First status message shown.
@@ -111,7 +118,7 @@ public:
     QString symbolFileName;
     bool useServerStartScript;
     QString serverStartScript;
-    QString sysroot;
+    //QString sysroot;
     QString searchPath; // Gdb "set solib-search-path"
     QString debugInfoLocation; // Gdb "set-debug-file-directory".
     QStringList debugSourceLocation; // Gdb "directory"
@@ -122,8 +129,8 @@ public:
     QSsh::SshConnectionParameters connParams;
     bool remoteSetupNeeded;
 
-    QString debuggerCommand;
-    ProjectExplorer::Abi toolChainAbi;
+    //QString debuggerCommand;
+    //ProjectExplorer::Abi toolChainAbi;
 
     QString dumperLibrary;
     QStringList solibSearchPath;
@@ -143,6 +150,11 @@ public:
     int testCase;
 };
 
+namespace Internal {
+
+void fillParameters(DebuggerStartParameters *sp, Core::Id id);
+
+} // namespace Internal
 } // namespace Debugger
 
 Q_DECLARE_METATYPE(Debugger::DebuggerStartParameters)
diff --git a/src/plugins/debugger/debuggertoolchaincombobox.cpp b/src/plugins/debugger/debuggertoolchaincombobox.cpp
index 96a079fdfc79208ba2338737cb650075cbb27845..169a817d2200756096781d6ad92dc237d8f8c999 100644
--- a/src/plugins/debugger/debuggertoolchaincombobox.cpp
+++ b/src/plugins/debugger/debuggertoolchaincombobox.cpp
@@ -47,14 +47,13 @@
 using namespace ProjectExplorer;
 
 namespace Debugger {
-namespace Internal {
 
-DebuggerToolChainComboBox::DebuggerToolChainComboBox(QWidget *parent) :
+ProfileChooser::ProfileChooser(QWidget *parent) :
     QComboBox(parent)
 {
 }
 
-void DebuggerToolChainComboBox::init(bool hostAbiOnly)
+void ProfileChooser::init(bool hostAbiOnly)
 {
     const Abi hostAbi = Abi::hostAbi();
     foreach (const Profile *st, ProfileManager::instance()->profiles()) {
@@ -85,23 +84,12 @@ void DebuggerToolChainComboBox::init(bool hostAbiOnly)
     setEnabled(count() > 1);
 }
 
-void DebuggerToolChainComboBox::setCurrentProfile(const Profile *profile)
-{
-    QTC_ASSERT(profile->isValid(), return);
-    for (int i = 0, n = count(); i != n; ++i) {
-        if (profileAt(i) == profile) {
-            setCurrentIndex(i);
-            break;
-        }
-    }
-}
-
-Profile *DebuggerToolChainComboBox::currentProfile() const
+Profile *ProfileChooser::currentProfile() const
 {
     return profileAt(currentIndex());
 }
 
-void DebuggerToolChainComboBox::setCurrentProfileId(Core::Id id)
+void ProfileChooser::setCurrentProfileId(Core::Id id)
 {
     for (int i = 0, n = count(); i != n; ++i) {
         if (profileAt(i)->id() == id) {
@@ -111,16 +99,15 @@ void DebuggerToolChainComboBox::setCurrentProfileId(Core::Id id)
     }
 }
 
-Core::Id DebuggerToolChainComboBox::currentProfileId() const
+Core::Id ProfileChooser::currentProfileId() const
 {
     return profileAt(currentIndex())->id();
 }
 
-Profile *DebuggerToolChainComboBox::profileAt(int index) const
+Profile *ProfileChooser::profileAt(int index) const
 {
     Core::Id id = qvariant_cast<Core::Id>(itemData(index));
     return ProfileManager::instance()->find(id);
 }
 
 } // namespace Debugger
-} // namespace Internal
diff --git a/src/plugins/debugger/debuggertoolchaincombobox.h b/src/plugins/debugger/debuggertoolchaincombobox.h
index d4dcf16bbd2c9d5684cebb6bf2fa84c053822a83..164f5b11aee1615765e65a8204182d7ca7b0d27a 100644
--- a/src/plugins/debugger/debuggertoolchaincombobox.h
+++ b/src/plugins/debugger/debuggertoolchaincombobox.h
@@ -33,28 +33,28 @@
 #ifndef DEBUGGERTOOLCHAINCOMBOBOX_H
 #define DEBUGGERTOOLCHAINCOMBOBOX_H
 
+#include "debugger_global.h"
+
 #include <QComboBox>
 
 namespace Core { class Id; }
 namespace ProjectExplorer { class Profile; }
 
 namespace Debugger {
-namespace Internal {
 
-// Let the user pick a profile associated with a debugger.
-class DebuggerToolChainComboBox : public QComboBox
+// Let the user pick a profile.
+class DEBUGGER_EXPORT ProfileChooser : public QComboBox
 {
     Q_OBJECT
 
 public:
-    explicit DebuggerToolChainComboBox(QWidget *parent);
+    explicit ProfileChooser(QWidget *parent);
 
     void init(bool hostAbiOnly);
 
     void setCurrentProfileId(Core::Id id);
     Core::Id currentProfileId() const;
 
-    void setCurrentProfile(const ProjectExplorer::Profile *profile);
     ProjectExplorer::Profile *currentProfile() const;
 
 private:
@@ -62,6 +62,5 @@ private:
 };
 
 } // namespace Debugger
-} // namespace Internal
 
 #endif // DEBUGGERTOOLCHAINCOMBOBOX_H
diff --git a/src/plugins/debugger/disassembleragent.cpp b/src/plugins/debugger/disassembleragent.cpp
index ed141a11a54f52c2104bb3d5c71d71df7faba9cc..9e0c7fbcb905b1f0b881e1340cfad4fb9ed847ef 100644
--- a/src/plugins/debugger/disassembleragent.cpp
+++ b/src/plugins/debugger/disassembleragent.cpp
@@ -32,12 +32,13 @@
 
 #include "disassembleragent.h"
 
-#include "disassemblerlines.h"
 #include "breakhandler.h"
+#include "debuggercore.h"
 #include "debuggerengine.h"
 #include "debuggerinternalconstants.h"
-#include "debuggercore.h"
+#include "debuggerstartparameters.h"
 #include "debuggerstringutils.h"
+#include "disassemblerlines.h"
 #include "stackframe.h"
 
 #include <coreplugin/coreconstants.h>
@@ -45,6 +46,8 @@
 #include <coreplugin/icore.h>
 #include <coreplugin/mimedatabase.h>
 
+#include <projectexplorer/abi.h>
+
 #include <texteditor/basetextdocument.h>
 #include <texteditor/basetexteditor.h>
 #include <texteditor/basetextmark.h>
@@ -116,6 +119,7 @@ public:
     QList<ITextMark *> breakpointMarks;
     QList<CacheEntry> cache;
     QString mimeType;
+    bool tryMixedInitialized;
     bool tryMixed;
     bool resetLocationScheduled;
 };
@@ -124,6 +128,7 @@ DisassemblerAgentPrivate::DisassemblerAgentPrivate()
   : editor(0),
     locationMark(0),
     mimeType(_("text/x-qtcreator-generic-asm")),
+    tryMixedInitialized(false),
     tryMixed(true),
     resetLocationScheduled(false)
 {
@@ -214,6 +219,12 @@ const Location &DisassemblerAgent::location() const
 
 bool DisassemblerAgent::isMixed() const
 {
+    if (!d->tryMixedInitialized) {
+        if (d->engine->startParameters().toolChainAbi.os() == ProjectExplorer::Abi::MacOS)
+           d->tryMixed = false;
+        d->tryMixedInitialized = true;
+    }
+
     return d->tryMixed
         && d->location.lineNumber() > 0
         && !d->location.functionName().isEmpty()
@@ -406,10 +417,5 @@ quint64 DisassemblerAgent::address() const
     return d->location.address();
 }
 
-void DisassemblerAgent::setTryMixed(bool on)
-{
-    d->tryMixed = on;
-}
-
 } // namespace Internal
 } // namespace Debugger
diff --git a/src/plugins/debugger/disassembleragent.h b/src/plugins/debugger/disassembleragent.h
index 88365f5b84f8afc8b856f18d13e8962cffef2d79..013a1d18743cbb231e01ac3bf82e820119acc01e 100644
--- a/src/plugins/debugger/disassembleragent.h
+++ b/src/plugins/debugger/disassembleragent.h
@@ -53,7 +53,6 @@ public:
     explicit DisassemblerAgent(DebuggerEngine *engine);
     ~DisassemblerAgent();
 
-    void setTryMixed(bool on);
     void setLocation(const Location &location);
     const Location &location() const;
     void scheduleResetLocation();
diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp
index f25f381eaa8da296a362fcb49c1fc0e0d24a4d16..1b981c9414f64eb1122c03cd3dd484b4ce6e8558 100644
--- a/src/plugins/debugger/gdb/gdbengine.cpp
+++ b/src/plugins/debugger/gdb/gdbengine.cpp
@@ -1182,7 +1182,8 @@ void GdbEngine::handleResultRecord(GdbResponse *response)
 
     if (!isExpectedResult) {
         const DebuggerStartParameters &sp = startParameters();
-        if (sp.toolChainAbi.os() == Abi::WindowsOS
+        Abi abi = sp.toolChainAbi;
+        if (abi.os() == Abi::WindowsOS
             && cmd.command.startsWith("attach")
             && (sp.startMode == AttachExternal || sp.useTerminal))
         {
@@ -1628,7 +1629,6 @@ void GdbEngine::handleStop2(const GdbMi &data)
     const QByteArray reason = data.findChild("reason").data();
     const QByteArray func = data.findChild("frame").findChild("from").data();
     const DebuggerStartParameters &sp = startParameters();
-    const Abi abi = sp.toolChainAbi;
 
     bool isStopperThread = false;
 
@@ -1644,7 +1644,7 @@ void GdbEngine::handleStop2(const GdbMi &data)
         return;
     }
 
-    if (abi.os() == Abi::WindowsOS
+    if (sp.toolChainAbi.os() == Abi::WindowsOS
             && sp.useTerminal
             && reason == "signal-received"
             && data.findChild("signal-name").data() == "SIGTRAP")
@@ -1934,7 +1934,7 @@ QString GdbEngine::cleanupFullName(const QString &fileName)
     if (!debuggerCore()->boolSetting(AutoEnrichParameters))
         return cleanFilePath;
 
-    const QString sysroot = startParameters().sysroot;
+    const QString sysroot = startParameters().sysRoot;
     if (QFileInfo(cleanFilePath).isReadable())
         return cleanFilePath;
     if (!sysroot.isEmpty() && fileName.startsWith(QLatin1Char('/'))) {
@@ -2068,6 +2068,7 @@ void GdbEngine::handleThreadGroupCreated(const GdbMi &result)
 {
     QByteArray id = result.findChild("id").data();
     QByteArray pid = result.findChild("pid").data();
+    Q_UNUSED(id);
     Q_UNUSED(pid);
 }
 
@@ -2081,7 +2082,7 @@ int GdbEngine::currentFrame() const
     return stackHandler()->currentIndex();
 }
 
-QString msgNoGdbBinaryForToolChain(const Abi &tc)
+static QString msgNoGdbBinaryForToolChain(const Abi &tc)
 {
     return GdbEngine::tr("There is no gdb binary available for binaries in format '%1'")
         .arg(tc.toString());
@@ -4634,27 +4635,21 @@ static QString gdbBinary(const DebuggerStartParameters &sp)
     const QByteArray envBinary = qgetenv("QTC_DEBUGGER_PATH");
     if (!envBinary.isEmpty())
         return QString::fromLocal8Bit(envBinary);
-    // 2) Command explicitly specified.
-    if (!sp.debuggerCommand.isEmpty()) {
-        // Do not use a CDB binary if we got started for a project with MSVC runtime.
-        const Abi abi = sp.toolChainAbi;
-        if (abi.os() != Abi::WindowsOS || abi.osFlavor() == Abi::WindowsMSysFlavor)
-            return sp.debuggerCommand;
-    }
-    // 3) Find one from tool chains.
-    return debuggerCore()->debuggerForAbi(sp.toolChainAbi, GdbEngineType);
+    // 2) Command from profile.
+    return sp.debuggerCommand;
 }
 
 bool checkGdbConfiguration(const DebuggerStartParameters &sp, ConfigurationCheck *check)
 {
     const QString binary = gdbBinary(sp);
-    if (gdbBinary(sp).isEmpty()) {
-        check->errorDetails.push_back(msgNoGdbBinaryForToolChain(sp.toolChainAbi));
+    const Abi abi = sp.toolChainAbi;
+    if (binary.isEmpty()) {
+        check->errorDetails.push_back(msgNoGdbBinaryForToolChain(abi));
         check->settingsCategory = _(ProjectExplorer::Constants::PROJECTEXPLORER_SETTINGS_CATEGORY);
         check->settingsPage = _(ProjectExplorer::Constants::PROJECTEXPLORER_SETTINGS_CATEGORY);
         return false;
     }
-    if (sp.toolChainAbi.os() == Abi::WindowsOS &&  !QFileInfo(binary).isAbsolute()) {
+    if (abi.os() == Abi::WindowsOS &&  !QFileInfo(binary).isAbsolute()) {
     // See initialization below, we need an absolute path to be able to locate Python on Windows.
         check->errorDetails.push_back(GdbEngine::tr("The gdb location must be given as an "
                 "absolute path in the debugger settings (%1).").arg(binary));
@@ -4818,7 +4813,7 @@ void GdbEngine::startGdb(const QStringList &args)
     foreach (const QString &src, sp.debugSourceLocation)
         postCommand("directory " + src.toLocal8Bit());
 
-    const QByteArray sysroot = sp.sysroot.toLocal8Bit();
+    const QByteArray sysroot = sp.sysRoot.toLocal8Bit();
     if (!sysroot.isEmpty()) {
         postCommand("set sysroot " + sysroot);
         // sysroot is not enough to correctly locate the sources, so explicitly
diff --git a/src/plugins/debugger/gdb/remoteplaingdbadapter.cpp b/src/plugins/debugger/gdb/remoteplaingdbadapter.cpp
index fb92ee51cb0e666939e9b04d16ab140b380880a9..01aaefa07f222719ec41b1e848b874f913b69428 100644
--- a/src/plugins/debugger/gdb/remoteplaingdbadapter.cpp
+++ b/src/plugins/debugger/gdb/remoteplaingdbadapter.cpp
@@ -105,11 +105,12 @@ void GdbRemotePlainEngine::notifyEngineRemoteSetupDone(int gdbServerPort, int qm
     Q_UNUSED(gdbServerPort);
     QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state());
 
+    DebuggerStartParameters &sp = startParameters();
     if (qmlPort != -1)
-        startParameters().qmlServerPort = qmlPort;
-    m_gdbProc.realStart(startParameters().debuggerCommand,
+        sp.qmlServerPort = qmlPort;
+    m_gdbProc.realStart(sp.debuggerCommand,
         QStringList() << QLatin1String("-i") << QLatin1String("mi"),
-        startParameters().executable);
+        sp.executable);
 }
 
 void GdbRemotePlainEngine::handleGdbStarted()
diff --git a/src/plugins/debugger/loadremotecoredialog.cpp b/src/plugins/debugger/loadremotecoredialog.cpp
index ab6ef56680ea844af93448f39e6feaba8f197f59..259d286747e796fcb5cb4580bd6a72a31ba63694 100644
--- a/src/plugins/debugger/loadremotecoredialog.cpp
+++ b/src/plugins/debugger/loadremotecoredialog.cpp
@@ -31,9 +31,11 @@
 **************************************************************************/
 
 #include "loadremotecoredialog.h"
-#include "debuggerstartparameters.h"
+
 #include "debuggerconstants.h"
 #include "debuggercore.h"
+#include "debuggerstartparameters.h"
+#include "debuggertoolchaincombobox.h"
 
 #include <coreplugin/icore.h>
 #include <projectexplorer/abi.h>
@@ -93,7 +95,8 @@ public:
     QPushButton *loadCoreFileButton;
     QTextBrowser *textBrowser;
     QPushButton *closeButton;
-    PathChooser *sysrootPathChooser;
+    //PathChooser *sysrootPathChooser;
+    ProfileChooser *toolchainComboBox;
 
     QSettings *settings;
     QString remoteCommandLine;
@@ -113,11 +116,7 @@ LoadRemoteCoreFileDialog::LoadRemoteCoreFileDialog(QWidget *parent)
 
     d->deviceComboBox = new QComboBox(this);
 
-    d->sysrootPathChooser = new PathChooser(this);
-    d->sysrootPathChooser->setExpectedKind(PathChooser::Directory);
-    d->sysrootPathChooser->setPromptDialogTitle(tr("Select Sysroot"));
-    d->sysrootPathChooser->setPath(d->settings->value(QLatin1String("LastSysroot")).toString());
-
+    d->toolchainComboBox = new ProfileChooser(this);
     d->fileSystemModel = new SftpFileSystemModel(this);
 
     //executablePathChooser = new PathChooser(q);
@@ -143,7 +142,7 @@ LoadRemoteCoreFileDialog::LoadRemoteCoreFileDialog(QWidget *parent)
 
     QFormLayout *formLayout = new QFormLayout();
     formLayout->addRow(tr("Device:"), d->deviceComboBox);
-    formLayout->addRow(tr("Sysroot:"), d->sysrootPathChooser);
+    formLayout->addRow(tr("Profile:"), d->toolchainComboBox);
 
     QHBoxLayout *horizontalLayout2 = new QHBoxLayout();
     horizontalLayout2->addStretch(1);
@@ -169,8 +168,7 @@ LoadRemoteCoreFileDialog::LoadRemoteCoreFileDialog(QWidget *parent)
         connect(d->fileSystemView->selectionModel(),
             SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
             SLOT(updateButtons()));
-        connect(d->sysrootPathChooser, SIGNAL(changed(QString)),
-                SLOT(updateButtons()));
+        connect(d->toolchainComboBox, SIGNAL(activated(int)), SLOT(updateButtons()));
         connect(d->loadCoreFileButton, SIGNAL(clicked()), SLOT(selectCoreFile()));
         connect(d->deviceComboBox, SIGNAL(currentIndexChanged(int)),
             SLOT(attachToDevice(int)));
@@ -194,9 +192,9 @@ QString LoadRemoteCoreFileDialog::localCoreFileName() const
     return d->localCoreFile;
 }
 
-QString LoadRemoteCoreFileDialog::sysroot() const
+Id LoadRemoteCoreFileDialog::profileId() const
 {
-    return d->sysrootPathChooser->path();
+    return d->toolchainComboBox->currentProfileId();
 }
 
 void LoadRemoteCoreFileDialog::attachToDevice(int modelIndex)
@@ -251,7 +249,8 @@ void LoadRemoteCoreFileDialog::selectCoreFile()
     d->loadCoreFileButton->setEnabled(false);
     d->fileSystemView->setEnabled(false);
 
-    d->settings->setValue(QLatin1String("LastSysroot"), d->sysrootPathChooser->path());
+    d->settings->setValue(QLatin1String("LastProfile"),
+        d->toolchainComboBox->currentProfileId().toString());
     d->settings->setValue(QLatin1String("LastDevice"), d->deviceComboBox->currentIndex());
     d->settings->setValue(QLatin1String("LastSftpRoot"), d->fileSystemModel->rootDirectory());
 
diff --git a/src/plugins/debugger/loadremotecoredialog.h b/src/plugins/debugger/loadremotecoredialog.h
index 272b1a3e22325555bb3b46b94c2a14cd0335965d..54ac361aa685eb64ee1ef3881f5bfaa4cdb3f687 100644
--- a/src/plugins/debugger/loadremotecoredialog.h
+++ b/src/plugins/debugger/loadremotecoredialog.h
@@ -37,6 +37,8 @@
 
 #include <QDialog>
 
+namespace Core { class Id; }
+
 namespace Debugger {
 namespace Internal {
 
@@ -52,7 +54,7 @@ public:
 
     void setLocalCoreFileName(const QString &fileName);
     QString localCoreFileName() const;
-    QString sysroot() const;
+    Core::Id profileId() const;
 
 private slots:
     void handleSftpOperationFinished(QSsh::SftpJobId, const QString &error);
diff --git a/src/plugins/debugger/startexternaldialog.ui b/src/plugins/debugger/startexternaldialog.ui
index 9e1807dafe807a8da1784546b05ae6f18a1da553..2a32e88cf8a1b6bc045936ddbdc1f461ff959562 100644
--- a/src/plugins/debugger/startexternaldialog.ui
+++ b/src/plugins/debugger/startexternaldialog.ui
@@ -80,7 +80,7 @@
      <item row="4" column="0">
       <widget class="QLabel" name="toolChainLabel">
        <property name="text">
-        <string>&amp;Tool chain:</string>
+        <string>&amp;Target:</string>
        </property>
        <property name="buddy">
         <cstring>toolChainComboBox</cstring>
@@ -88,7 +88,7 @@
       </widget>
      </item>
      <item row="4" column="1">
-      <widget class="Debugger::Internal::DebuggerToolChainComboBox" name="toolChainComboBox"/>
+      <widget class="Debugger::ProfileChooser" name="toolChainComboBox"/>
      </item>
      <item row="5" column="0">
       <widget class="QLabel" name="labelBreakAtMain">
@@ -173,7 +173,7 @@
    </slots>
   </customwidget>
   <customwidget>
-   <class>Debugger::Internal::DebuggerToolChainComboBox</class>
+   <class>Debugger::ProfileChooser</class>
    <extends>QComboBox</extends>
    <header>debuggertoolchaincombobox.h</header>
   </customwidget>
diff --git a/src/plugins/debugger/startremotedialog.ui b/src/plugins/debugger/startremotedialog.ui
index bfa3faba10cf4b8192a4bbbc3c8589ca3fa4a410..ad695152d2f6a85f5541e69fd8182a5e261e3415 100644
--- a/src/plugins/debugger/startremotedialog.ui
+++ b/src/plugins/debugger/startremotedialog.ui
@@ -30,7 +30,7 @@
       </widget>
      </item>
      <item row="0" column="1">
-      <widget class="Debugger::Internal::DebuggerToolChainComboBox" name="toolchainComboBox"/>
+      <widget class="Debugger::ProfileChooser" name="toolchainComboBox"/>
      </item>
      <item row="1" column="0">
       <widget class="QLabel" name="executableLabel">
@@ -210,7 +210,7 @@
    </slots>
   </customwidget>
   <customwidget>
-   <class>Debugger::Internal::DebuggerToolChainComboBox</class>
+   <class>Debugger::ProfileChooser</class>
    <extends>QComboBox</extends>
    <header>debuggertoolchaincombobox.h</header>
   </customwidget>
diff --git a/src/plugins/qmlprojectmanager/qmlprojectruncontrol.cpp b/src/plugins/qmlprojectmanager/qmlprojectruncontrol.cpp
index bd0f1405dbe03771fc766ccc4837234a06d9f8d5..afafc2d037b0434810ae2d7f4f999602fa36a40b 100644
--- a/src/plugins/qmlprojectmanager/qmlprojectruncontrol.cpp
+++ b/src/plugins/qmlprojectmanager/qmlprojectruncontrol.cpp
@@ -35,6 +35,7 @@
 #include <coreplugin/icore.h>
 #include <projectexplorer/projectexplorerconstants.h>
 #include <projectexplorer/target.h>
+#include <projectexplorer/profile.h>
 #include <projectexplorer/project.h>
 #include <projectexplorer/projectexplorer.h>
 #include <utils/qtcassert.h>
@@ -215,9 +216,6 @@ RunControl *QmlProjectRunControlFactory::createDebugRunControl(QmlProjectRunConf
     if (runConfig->debuggerAspect()->useCppDebugger())
         params.languages |= Debugger::CppLanguage;
 
-    if (!runConfig->qtVersion()->qtAbis().isEmpty())
-        params.toolChainAbi = runConfig->qtVersion()->qtAbis().first();
-
     // Makes sure that all bindings go through the JavaScript engine, so that
     // breakpoints are actually hit!
     const QString optimizerKey = QLatin1String("QML_DISABLE_OPTIMIZER");
diff --git a/src/plugins/qt4projectmanager/qt-s60/s60devicedebugruncontrol.cpp b/src/plugins/qt4projectmanager/qt-s60/s60devicedebugruncontrol.cpp
index 041fa573b543a9b44193fb113da23655c0bf4833..bfdfd2aa3c4d1f0df1bc064e2cc4e1f8e93140b1 100644
--- a/src/plugins/qt4projectmanager/qt-s60/s60devicedebugruncontrol.cpp
+++ b/src/plugins/qt4projectmanager/qt-s60/s60devicedebugruncontrol.cpp
@@ -39,8 +39,11 @@
 
 #include <coreplugin/icore.h>
 #include <debugger/debuggerengine.h>
+#include <debugger/debuggerprofileinformation.h>
 #include <debugger/debuggerstartparameters.h>
 #include <projectexplorer/buildconfiguration.h>
+#include <projectexplorer/profile.h>
+#include <projectexplorer/profileinformation.h>
 #include <projectexplorer/project.h>
 #include <projectexplorer/target.h>
 #include <utils/qtcassert.h>
@@ -80,35 +83,41 @@ static Debugger::DebuggerStartParameters s60DebuggerStartParams(const S60DeviceR
         qobject_cast<S60DeployConfiguration *>(rc->target()->activeDeployConfiguration());
     QTC_ASSERT(activeDeployConf, return sp);
 
+    DebuggerRunConfigurationAspect *debuggerAspect = rc->debuggerAspect();
+
     const QString debugFileName = QString::fromLatin1("%1:\\sys\\bin\\%2.exe")
             .arg(activeDeployConf->installationDrive()).arg(rc->targetName());
 
+    Profile *profile = rc->target()->profile();
+    sp.sysRoot = SysRootProfileInformation::sysRoot(profile).toString();
+    sp.debuggerCommand = Debugger::DebuggerProfileInformation::debuggerCommand(profile).toString();
+    if (ToolChain *tc = ToolChainProfileInformation::toolChain(profile))
+        sp.toolChainAbi = tc->targetAbi();
     SymbianIDevice::ConstPtr dev = activeDeployConf->device();
     sp.remoteChannel = dev->serialPortName();
     sp.processArgs = rc->commandLineArguments();
-    if (rc->debuggerAspect()->useQmlDebugger() && !rc->debuggerAspect()->useCppDebugger()) {
+    if (debuggerAspect->useQmlDebugger() && !debuggerAspect->useCppDebugger()) {
         sp.remoteSetupNeeded = true;
         sp.startMode = Debugger::AttachToRemoteServer;
     } else {
         sp.startMode = Debugger::StartInternal;
     }
 
-    sp.toolChainAbi = rc->abi();
     sp.executable = debugFileName;
     sp.executableUid = rc->executableUid();
     sp.serverAddress = dev->address();
     sp.serverPort = dev->port().toInt();
     sp.displayName = rc->displayName();
     sp.qmlServerAddress = dev->address();
-    sp.qmlServerPort = rc->debuggerAspect()->qmlDebugServerPort();
-    if (rc->debuggerAspect()->useQmlDebugger()) {
+    sp.qmlServerPort = debuggerAspect->qmlDebugServerPort();
+    if (debuggerAspect->useQmlDebugger()) {
         sp.languages |= Debugger::QmlLanguage;
         QString qmlArgs = rc->qmlCommandLineArguments();
         if (sp.processArgs.length())
             sp.processArgs.prepend(QLatin1Char(' '));
         sp.processArgs.prepend(qmlArgs);
     }
-    if (rc->debuggerAspect()->useCppDebugger())
+    if (debuggerAspect->useCppDebugger())
         sp.languages |= Debugger::CppLanguage;
 
     sp.communicationChannel = dev->communicationChannel() == SymbianIDevice::CommunicationCodaTcpConnection?
diff --git a/src/plugins/remotelinux/remotelinuxdebugsupport.cpp b/src/plugins/remotelinux/remotelinuxdebugsupport.cpp
index 86adfdf554c5dac3168c3e744ca7665f5ff8e7c3..6184b94f22a183cf37b79ccff28f53d8fe90f529 100644
--- a/src/plugins/remotelinux/remotelinuxdebugsupport.cpp
+++ b/src/plugins/remotelinux/remotelinuxdebugsupport.cpp
@@ -97,9 +97,17 @@ using namespace Internal;
 DebuggerStartParameters AbstractRemoteLinuxDebugSupport::startParameters(const RemoteLinuxRunConfiguration *runConfig)
 {
     DebuggerStartParameters params;
+    Target *target = runConfig->target();
+    Profile *profile = target->profile();
     const LinuxDeviceConfiguration::ConstPtr devConf
-            = DeviceProfileInformation::device(runConfig->target()->profile())
+            = DeviceProfileInformation::device(profile)
               .dynamicCast<const RemoteLinux::LinuxDeviceConfiguration>();
+
+    params.sysRoot = SysRootProfileInformation::sysRoot(profile).toString();
+    params.debuggerCommand = DebuggerProfileInformation::debuggerCommand(profile).toString();
+    if (ToolChain *tc = ToolChainProfileInformation::toolChain(profile))
+        params.toolChainAbi = tc->targetAbi();
+
     if (runConfig->debuggerAspect()->useQmlDebugger()) {
         params.languages |= QmlLanguage;
         params.qmlServerAddress = devConf->sshParameters().host;
@@ -108,18 +116,12 @@ DebuggerStartParameters AbstractRemoteLinuxDebugSupport::startParameters(const R
     if (runConfig->debuggerAspect()->useCppDebugger()) {
         params.languages |= CppLanguage;
         params.processArgs = runConfig->arguments();
-        QString systemRoot;
-        if (SysRootProfileInformation::hasSysRoot(runConfig->target()->profile()))
-            systemRoot = SysRootProfileInformation::sysRoot(runConfig->target()->profile()).toString();
-        params.sysroot = systemRoot;
-        params.toolChainAbi = runConfig->abi();
         params.startMode = AttachToRemoteServer;
         params.executable = runConfig->localExecutableFilePath();
-        params.debuggerCommand = DebuggerProfileInformation::debuggerCommand(runConfig->target()->profile()).toString();
         params.remoteChannel = devConf->sshParameters().host + QLatin1String(":-1");
 
         // TODO: This functionality should be inside the debugger.
-        ToolChain *tc = ToolChainProfileInformation::toolChain(runConfig->target()->profile());
+        ToolChain *tc = ToolChainProfileInformation::toolChain(profile);
         if (tc) {
             const Abi &abi = tc->targetAbi();
             params.remoteArchitecture = abi.toString();
@@ -132,9 +134,9 @@ DebuggerStartParameters AbstractRemoteLinuxDebugSupport::startParameters(const R
     params.remoteSetupNeeded = true;
     params.displayName = runConfig->displayName();
 
-    if (const Project *project = runConfig->target()->project()) {
+    if (const Project *project = target->project()) {
         params.projectSourceDirectory = project->projectDirectory();
-        if (const BuildConfiguration *buildConfig = runConfig->target()->activeBuildConfiguration())
+        if (const BuildConfiguration *buildConfig = target->activeBuildConfiguration())
             params.projectBuildDirectory = buildConfig->buildDirectory();
         params.projectSourceFiles = project->files(Project::ExcludeGeneratedFiles);
     }
diff --git a/src/plugins/remotelinux/startgdbserverdialog.cpp b/src/plugins/remotelinux/startgdbserverdialog.cpp
index a487a4b9c7beabe27c05d093d004d9bd9a350531..41b1a307ea2b577fc78dc815f18bd72f480a3893 100644
--- a/src/plugins/remotelinux/startgdbserverdialog.cpp
+++ b/src/plugins/remotelinux/startgdbserverdialog.cpp
@@ -37,6 +37,7 @@
 #include "remotelinuxusedportsgatherer.h"
 
 #include <coreplugin/icore.h>
+#include <debugger/debuggertoolchaincombobox.h>
 #include <extensionsystem/pluginmanager.h>
 #include <projectexplorer/devicesupport/devicemanager.h>
 #include <projectexplorer/devicesupport/devicemanagermodel.h>
@@ -73,7 +74,7 @@ using namespace ProjectExplorer;
 using namespace QSsh;
 using namespace Utils;
 
-const char LastSysroot[] = "RemoteLinux/LastSysroot";
+const char LastProfile[] = "RemoteLinux/LastProfile";
 const char LastDevice[] = "RemoteLinux/LastDevice";
 const char LastProcessName[] = "RemoteLinux/LastProcessName";
 //const char LastLocalExecutable[] = "RemoteLinux/LastLocalExecutable";
@@ -104,7 +105,7 @@ public:
     QPushButton *attachProcessButton;
     QTextBrowser *textBrowser;
     QPushButton *closeButton;
-    PathChooser *sysrootPathChooser;
+    Debugger::ProfileChooser *profileChooser;
 
     RemoteLinuxUsedPortsGatherer gatherer;
     SshRemoteProcessRunner runner;
@@ -120,10 +121,11 @@ StartGdbServerDialogPrivate::StartGdbServerDialogPrivate(StartGdbServerDialog *q
 
     deviceComboBox = new QComboBox(q);
 
-    sysrootPathChooser = new PathChooser(q);
-    sysrootPathChooser->setExpectedKind(PathChooser::Directory);
-    sysrootPathChooser->setPromptDialogTitle(StartGdbServerDialog::tr("Select Sysroot"));
-    sysrootPathChooser->setPath(settings->value(LastSysroot).toString());
+    profileChooser = new Debugger::ProfileChooser(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);
@@ -153,7 +155,7 @@ StartGdbServerDialogPrivate::StartGdbServerDialogPrivate(StartGdbServerDialog *q
 
     QFormLayout *formLayout = new QFormLayout();
     formLayout->addRow(StartGdbServerDialog::tr("Device:"), deviceComboBox);
-    formLayout->addRow(StartGdbServerDialog::tr("Sysroot:"), sysrootPathChooser);
+    formLayout->addRow(StartGdbServerDialog::tr("Profile:"), profileChooser);
     formLayout->addRow(StartGdbServerDialog::tr("&Filter entries:"), processFilterLineEdit);
 
     QHBoxLayout *horizontalLayout2 = new QHBoxLayout();
@@ -197,7 +199,7 @@ StartGdbServerDialog::StartGdbServerDialog(QWidget *parent) :
         connect(d->tableView->selectionModel(),
             SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
             SLOT(updateButtons()));
-        connect(d->sysrootPathChooser, SIGNAL(changed(QString)),
+        connect(d->profileChooser, SIGNAL(activated(int)),
                 SLOT(updateButtons()));
         //connect(d->updateListButton, SIGNAL(clicked()),
         //    SLOT(updateProcessList()));
@@ -281,7 +283,7 @@ void StartGdbServerDialog::attachToProcess()
         return;
     }
 
-    d->settings->setValue(LastSysroot, d->sysrootPathChooser->path());
+    d->settings->setValue(LastProfile, d->profileChooser->currentProfileId().toString());
     d->settings->setValue(LastDevice, d->deviceComboBox->currentIndex());
     d->settings->setValue(LastProcessName, d->processFilterLineEdit->text());
 
@@ -380,7 +382,7 @@ void StartGdbServerDialog::reportOpenPort(int port)
     if (ob) {
         QMetaObject::invokeMethod(ob, member, Qt::QueuedConnection,
             Q_ARG(QString, channel),
-            Q_ARG(QString, d->sysrootPathChooser->path()),
+            Q_ARG(QString, d->profileChooser->currentProfileId().toString()),
             Q_ARG(QString, d->remoteCommandLine),
             Q_ARG(QString, d->remoteExecutable));
     }