From 3059046a489ad60aa41ebf453fb08594242c20a5 Mon Sep 17 00:00:00 2001
From: hjk <qtc-committer@nokia.com>
Date: Mon, 2 Mar 2009 13:08:30 +0100
Subject: [PATCH] Fixes:    debugger: start work on core file loading

---
 src/plugins/debugger/attachcoredialog.ui      |  64 +++++++
 src/plugins/debugger/attachexternaldialog.cpp | 160 ------------------
 src/plugins/debugger/attachexternaldialog.h   |  61 -------
 src/plugins/debugger/attachremotedialog.cpp   | 154 -----------------
 src/plugins/debugger/attachremotedialog.h     |  62 -------
 src/plugins/debugger/debugger.pro             |  11 +-
 src/plugins/debugger/debuggermanager.cpp      |  31 +++-
 src/plugins/debugger/debuggermanager.h        |   4 +-
 src/plugins/debugger/gdbengine.cpp            |   3 +-
 src/plugins/debugger/scriptengine.cpp         |   3 +-
 src/plugins/debugger/startexternaldialog.cpp  | 113 -------------
 src/plugins/debugger/startexternaldialog.h    |  57 -------
 12 files changed, 103 insertions(+), 620 deletions(-)
 create mode 100644 src/plugins/debugger/attachcoredialog.ui
 delete mode 100644 src/plugins/debugger/attachexternaldialog.cpp
 delete mode 100644 src/plugins/debugger/attachexternaldialog.h
 delete mode 100644 src/plugins/debugger/attachremotedialog.cpp
 delete mode 100644 src/plugins/debugger/attachremotedialog.h
 delete mode 100644 src/plugins/debugger/startexternaldialog.cpp
 delete mode 100644 src/plugins/debugger/startexternaldialog.h

diff --git a/src/plugins/debugger/attachcoredialog.ui b/src/plugins/debugger/attachcoredialog.ui
new file mode 100644
index 00000000000..3b16c637a91
--- /dev/null
+++ b/src/plugins/debugger/attachcoredialog.ui
@@ -0,0 +1,64 @@
+<ui version="4.0" >
+ <class>AttachCoreDialog</class>
+ <widget class="QDialog" name="AttachCoreDialog" >
+  <property name="geometry" >
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>561</width>
+    <height>866</height>
+   </rect>
+  </property>
+  <property name="windowTitle" >
+   <string>Start Debugger</string>
+  </property>
+  <layout class="QVBoxLayout" >
+   <property name="spacing" >
+    <number>6</number>
+   </property>
+   <property name="margin" >
+    <number>9</number>
+   </property>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout" >
+     <item>
+      <widget class="QLabel" name="pidLabel" >
+       <property name="text" >
+        <string>Attach to Process ID:</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QLineEdit" name="pidLineEdit" />
+     </item>
+    </layout>
+   </item>
+   <item>
+    <widget class="QTreeView" name="procView" >
+     <property name="editTriggers" >
+      <set>QAbstractItemView::NoEditTriggers</set>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <widget class="Line" name="line" >
+     <property name="orientation" >
+      <enum>Qt::Horizontal</enum>
+     </property>
+    </widget>
+   </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>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/src/plugins/debugger/attachexternaldialog.cpp b/src/plugins/debugger/attachexternaldialog.cpp
deleted file mode 100644
index 37413b7a75c..00000000000
--- a/src/plugins/debugger/attachexternaldialog.cpp
+++ /dev/null
@@ -1,160 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact:  Qt Software Information (qt-info@nokia.com)
-**
-** Commercial Usage
-**
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Nokia.
-**
-** GNU Lesser General Public License Usage
-**
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file.  Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-**
-**************************************************************************/
-
-#include "attachexternaldialog.h"
-
-#include <QDebug>
-#include <QDir>
-#include <QFile>
-#include <QPushButton>
-#include <QStandardItemModel>
-#include <QHeaderView>
-
-#ifdef Q_OS_WINDOWS
-#include <windows.h>
-#include <tlhelp32.h>
-#include <tchar.h>
-#include <stdio.h>
-#endif
-
-using namespace Debugger::Internal;
-
-AttachExternalDialog::AttachExternalDialog(QWidget *parent)
-  : QDialog(parent)
-{
-    setupUi(this);
-    buttonBox->button(QDialogButtonBox::Ok)->setDefault(true);
-    m_model = new QStandardItemModel(this);
-
-    procView->setSortingEnabled(true);
-
-    connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
-    connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
-
-    connect(procView, SIGNAL(activated(const QModelIndex &)),
-        this, SLOT(procSelected(const QModelIndex &)));
-
-    rebuildProcessList();
-}
-
-static bool isProcessName(const QString &procname)
-{
-    for (int i = 0; i != procname.size(); ++i)
-        if (!procname.at(i).isDigit())
-            return false;
-    return true;
-}
-
-struct ProcData
-{
-    QString ppid;
-    QString name;
-    QString state;
-};
-
-static void insertItem(QStandardItem *root, const QString &pid,
-    const QMap<QString, ProcData> &procs, QMap<QString, QStandardItem *> &known)
-{
-    //qDebug() << "HANDLING " << pid;
-    QStandardItem *parent = 0;
-    const ProcData &proc = procs[pid];
-    if (1 || pid == "0") { // FIXME: a real tree is not-so-nice to search
-        parent = root;
-    } else {
-        if (!known.contains(proc.ppid))
-            insertItem(root, proc.ppid, procs, known);
-        parent = known[proc.ppid];
-    }
-    QList<QStandardItem *> row;
-    row.append(new QStandardItem(pid));
-    row.append(new QStandardItem(proc.name));
-    //row.append(new QStandardItem(proc.ppid));
-    row.append(new QStandardItem(proc.state));
-    parent->appendRow(row);
-    known[pid] = row[0];
-}
-
-void AttachExternalDialog::rebuildProcessList()
-{
-    QStringList procnames = QDir("/proc/").entryList();
-    if (procnames.isEmpty()) {
-        procView->hide();
-        return;
-    }
-    
-    typedef QMap<QString, ProcData> Procs;
-    Procs procs;
-
-    foreach (const QString &procname, procnames) {
-        if (!isProcessName(procname))
-            continue;
-        QString filename = "/proc/" + procname + "/stat";
-        QFile file(filename);
-        file.open(QIODevice::ReadOnly);
-        QStringList data = QString::fromLocal8Bit(file.readAll()).split(' ');
-        //qDebug() << filename << data;
-        ProcData proc;
-        proc.name = data.at(1);
-        if (proc.name.startsWith('(') && proc.name.endsWith(')'))
-            proc.name = proc.name.mid(1, proc.name.size() - 2);
-        proc.state = data.at(2);
-        proc.ppid = data.at(3);
-        procs[procname] = proc;
-    }
-
-    m_model->clear();
-    QMap<QString, QStandardItem *> known;
-    for (Procs::const_iterator it = procs.begin(); it != procs.end(); ++it)
-        insertItem(m_model->invisibleRootItem(), it.key(), procs, known);
-    m_model->setHeaderData(0, Qt::Horizontal, "Process ID", Qt::DisplayRole);
-    m_model->setHeaderData(1, Qt::Horizontal, "Name", Qt::DisplayRole);
-    //model->setHeaderData(2, Qt::Horizontal, "Parent", Qt::DisplayRole);
-    m_model->setHeaderData(2, Qt::Horizontal, "State", Qt::DisplayRole);
-
-    procView->setModel(m_model);
-    procView->expandAll();
-    procView->resizeColumnToContents(0);
-    procView->resizeColumnToContents(1);
-    procView->sortByColumn(1, Qt::AscendingOrder);
-}
-
-void AttachExternalDialog::procSelected(const QModelIndex &index0)
-{
-    QModelIndex index = index0.sibling(index0.row(), 0);
-    QStandardItem *item = m_model->itemFromIndex(index);
-    if (!item)
-        return;
-    pidLineEdit->setText(item->text());
-    accept();
-}
-
-int AttachExternalDialog::attachPID() const
-{
-    return pidLineEdit->text().toInt();
-}
diff --git a/src/plugins/debugger/attachexternaldialog.h b/src/plugins/debugger/attachexternaldialog.h
deleted file mode 100644
index 442e00557bf..00000000000
--- a/src/plugins/debugger/attachexternaldialog.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact:  Qt Software Information (qt-info@nokia.com)
-**
-** Commercial Usage
-**
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Nokia.
-**
-** GNU Lesser General Public License Usage
-**
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file.  Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-**
-**************************************************************************/
-
-#ifndef ATTACHEXTERNALDIALOG_H
-#define ATTACHEXTERNALDIALOG_H
-
-#include "ui_attachexternaldialog.h"
-
-QT_BEGIN_NAMESPACE
-class QStandardItemModel;
-QT_END_NAMESPACE
-
-namespace Debugger {
-namespace Internal {
-
-class AttachExternalDialog : public QDialog, Ui::AttachExternalDialog
-{
-    Q_OBJECT
-
-public:
-    explicit AttachExternalDialog(QWidget *parent);
-    int attachPID() const;
-
-private slots:
-    void rebuildProcessList();
-    void procSelected(const QModelIndex &);
-
-private:
-    QStandardItemModel *m_model;
-};
-
-} // namespace Debugger
-} // namespace Internal
-
-#endif // ATTACHEEXTERNALDIALOG_H
diff --git a/src/plugins/debugger/attachremotedialog.cpp b/src/plugins/debugger/attachremotedialog.cpp
deleted file mode 100644
index 9cc90bd179e..00000000000
--- a/src/plugins/debugger/attachremotedialog.cpp
+++ /dev/null
@@ -1,154 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact:  Qt Software Information (qt-info@nokia.com)
-**
-** Commercial Usage
-**
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Nokia.
-**
-** GNU Lesser General Public License Usage
-**
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file.  Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-**
-**************************************************************************/
-
-#include "attachremotedialog.h"
-
-#include <QDebug>
-#include <QDir>
-#include <QFile>
-#include <QPushButton>
-#include <QStandardItemModel>
-#include <QHeaderView>
-
-using namespace Debugger::Internal;
-
-AttachRemoteDialog::AttachRemoteDialog(QWidget *parent, const QString &pid)
-  : QDialog(parent)
-{
-    setupUi(this);
-    buttonBox->button(QDialogButtonBox::Ok)->setDefault(true);
-    m_defaultPID = pid;
-    m_model = new QStandardItemModel(this);
-
-    procView->setSortingEnabled(true);
-
-    connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
-    connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
-
-    connect(procView, SIGNAL(activated(const QModelIndex &)),
-        this, SLOT(procSelected(const QModelIndex &)));
-
-
-    pidLineEdit->setText(m_defaultPID);
-    rebuildProcessList();
-}
-
-static bool isProcessName(const QString &procname)
-{
-    for (int i = 0; i != procname.size(); ++i)
-        if (!procname.at(i).isDigit())
-            return false;
-    return true;
-}
-
-struct ProcData {
-    QString ppid;
-    QString name;
-    QString state;
-};
-
-static void insertItem(QStandardItem *root, const QString &pid,
-    const QMap<QString, ProcData> &procs, QMap<QString, QStandardItem *> &known)
-{
-    //qDebug() << "HANDLING " << pid;
-    QStandardItem *parent = 0;
-    const ProcData &proc = procs[pid];
-    if (1 || pid == "0") {
-        parent = root;
-    } else {
-        if (!known.contains(proc.ppid))
-            insertItem(root, proc.ppid, procs, known);
-        parent = known[proc.ppid];
-    }
-    QList<QStandardItem *> row;
-    row.append(new QStandardItem(pid));
-    row.append(new QStandardItem(proc.name));
-    //row.append(new QStandardItem(proc.ppid));
-    row.append(new QStandardItem(proc.state));
-    parent->appendRow(row);
-    known[pid] = row[0];
-}
-
-void AttachRemoteDialog::rebuildProcessList()
-{
-    QStringList procnames = QDir("/proc/").entryList();
-    if (procnames.isEmpty()) {
-        procView->hide();
-        return;
-    }
-    
-    typedef QMap<QString, ProcData> Procs;
-    Procs procs;
-
-    foreach (const QString &procname, procnames) {
-        if (!isProcessName(procname))
-            continue;
-        QString filename = "/proc/" + procname + "/stat";
-        QFile file(filename);
-        file.open(QIODevice::ReadOnly);
-        QStringList data = QString::fromLocal8Bit(file.readAll()).split(' ');
-        //qDebug() << filename << data;
-        ProcData proc;
-        proc.name = data.at(1);
-        if (proc.name.startsWith('(') && proc.name.endsWith(')'))
-            proc.name = proc.name.mid(1, proc.name.size() - 2);
-        proc.state = data.at(2);
-        proc.ppid = data.at(3);
-        procs[procname] = proc;
-    }
-
-    m_model->clear();
-    QMap<QString, QStandardItem *> known;
-    for (Procs::const_iterator it = procs.begin(); it != procs.end(); ++it)
-        insertItem(m_model->invisibleRootItem(), it.key(), procs, known);
-    m_model->setHeaderData(0, Qt::Horizontal, "Process ID", Qt::DisplayRole);
-    m_model->setHeaderData(1, Qt::Horizontal, "Name", Qt::DisplayRole);
-    //model->setHeaderData(2, Qt::Horizontal, "Parent", Qt::DisplayRole);
-    m_model->setHeaderData(2, Qt::Horizontal, "State", Qt::DisplayRole);
-
-    procView->setModel(m_model);
-    procView->expandAll();
-    procView->resizeColumnToContents(0);
-    procView->resizeColumnToContents(1);
-}
-
-void AttachRemoteDialog::procSelected(const QModelIndex &index0)
-{
-    QModelIndex index = index0.sibling(index0.row(), 0);
-    QStandardItem *item = m_model->itemFromIndex(index);
-    if (!item)
-        return;
-    pidLineEdit->setText(item->text());
-    accept();
-}
-
-int AttachRemoteDialog::attachPID() const
-{
-    return pidLineEdit->text().toInt();
-}
diff --git a/src/plugins/debugger/attachremotedialog.h b/src/plugins/debugger/attachremotedialog.h
deleted file mode 100644
index a3e362647f9..00000000000
--- a/src/plugins/debugger/attachremotedialog.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact:  Qt Software Information (qt-info@nokia.com)
-**
-** Commercial Usage
-**
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Nokia.
-**
-** GNU Lesser General Public License Usage
-**
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file.  Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-**
-**************************************************************************/
-
-#ifndef ATTACHREMOTE_DIALOG_H
-#define ATTACHREMOTE_DIALOG_H
-
-#include "ui_attachremotedialog.h"
-
-QT_BEGIN_NAMESPACE
-class QStandardItemModel;
-QT_END_NAMESPACE
-
-namespace Debugger {
-namespace Internal {
-
-class AttachRemoteDialog : public QDialog, Ui::AttachRemoteDialog
-{
-    Q_OBJECT
-
-public:
-    explicit AttachRemoteDialog(QWidget *parent, const QString &pid);
-    int attachPID() const;
-
-private slots:
-    void rebuildProcessList();
-    void procSelected(const QModelIndex &);
-
-private:
-    QString m_defaultPID;
-    QStandardItemModel *m_model;
-};
-
-} // namespace Debugger
-} // namespace Internal
-
-#endif // ATTACHREMOTEDIALOG_H
diff --git a/src/plugins/debugger/debugger.pro b/src/plugins/debugger/debugger.pro
index b3f98ec41b9..7e302efff62 100644
--- a/src/plugins/debugger/debugger.pro
+++ b/src/plugins/debugger/debugger.pro
@@ -14,11 +14,11 @@ INCLUDEPATH += $$PWD/../../libs/utils
 
 QT += gui network script
 
-HEADERS += attachexternaldialog.h \
-    attachremotedialog.h \
+HEADERS += \
     breakhandler.h \
     breakwindow.h \
     debuggerconstants.h \
+    debuggerdialogs.h \
     debuggermanager.h \
     debuggeroutputwindow.h \
     debuggerplugin.h \
@@ -39,16 +39,15 @@ HEADERS += attachexternaldialog.h \
     stackhandler.h \
     stackwindow.h \
     sourcefileswindow.h \
-    startexternaldialog.h \
     threadswindow.h \
     watchhandler.h \
     watchwindow.h
 
-SOURCES += attachexternaldialog.cpp \
-    attachremotedialog.cpp \
+SOURCES += \
     breakhandler.cpp \
     breakwindow.cpp \
     breakwindow.h \
+    debuggerdialogs.cpp \
     debuggermanager.cpp \
     debuggeroutputwindow.cpp \
     debuggerplugin.cpp \
@@ -67,13 +66,13 @@ SOURCES += attachexternaldialog.cpp \
     stackhandler.cpp \
     stackwindow.cpp \
     sourcefileswindow.cpp \
-    startexternaldialog.cpp \
     threadswindow.cpp \
     watchhandler.cpp \
     watchwindow.cpp
 
 FORMS += attachexternaldialog.ui \
     attachremotedialog.ui \
+    attachcoredialog.ui \
     breakbyfunction.ui \
     breakcondition.ui \
     gdboptionpage.ui \
diff --git a/src/plugins/debugger/debuggermanager.cpp b/src/plugins/debugger/debuggermanager.cpp
index 3b49153d9cd..19f9826f61f 100644
--- a/src/plugins/debugger/debuggermanager.cpp
+++ b/src/plugins/debugger/debuggermanager.cpp
@@ -51,8 +51,7 @@
 #include "stackhandler.h"
 #include "watchhandler.h"
 
-#include "startexternaldialog.h"
-#include "attachexternaldialog.h"
+#include "debuggerdialogs.h"
 
 #include <utils/qtcassert.h>
 
@@ -294,6 +293,9 @@ void DebuggerManager::init()
     m_attachExternalAction = new QAction(this);
     m_attachExternalAction->setText(tr("Attach to Running External Application..."));
 
+    m_attachCoreAction = new QAction(this);
+    m_attachCoreAction->setText(tr("Attach to Core..."));
+
     m_continueAction = new QAction(this);
     m_continueAction->setText(tr("Continue"));
     m_continueAction->setIcon(QIcon(":/gdbdebugger/images/debugger_continue_small.png"));
@@ -362,6 +364,8 @@ void DebuggerManager::init()
         this, SLOT(startExternalApplication()));
     connect(m_attachExternalAction, SIGNAL(triggered()),
         this, SLOT(attachExternalApplication()));
+    connect(m_attachCoreAction, SIGNAL(triggered()),
+        this, SLOT(attachCore()));
 
     connect(m_stopAction, SIGNAL(triggered()),
         this, SLOT(interruptDebuggingRequest()));
@@ -769,6 +773,12 @@ void DebuggerManager::attachExternalApplication()
         emit debuggingFinished();
 }
 
+void DebuggerManager::attachCore()
+{
+    if (!startNewDebugger(AttachCore))
+        emit debuggingFinished();
+}
+
 bool DebuggerManager::startNewDebugger(StartMode mode)
 {
     m_startMode = mode;
@@ -827,6 +837,22 @@ bool DebuggerManager::startNewDebugger(StartMode mode)
             //m_processArgs = sd.processArgs.join(QLatin1String(" "));
             m_attachedPID = 0;
         }
+    } else if (startMode() == AttachCore) {
+        StartExternalDialog dlg(mainWindow());
+        dlg.setExecutableFile(
+            configValue(QLatin1String("LastExternalExecutableFile")).toString());
+        dlg.setExecutableArguments(
+            configValue(QLatin1String("LastExternalExecutableArguments")).toString());
+        if (dlg.exec() != QDialog::Accepted)
+            return false;
+        setConfigValue(QLatin1String("LastExternalExecutableFile"),
+            dlg.executableFile());
+        setConfigValue(QLatin1String("LastExternalExecutableArguments"),
+            dlg.executableArguments());
+        m_executable = dlg.executableFile();
+        m_processArgs = dlg.executableArguments().split(' ');
+        m_workingDir = QString();
+        m_attachedPID = -1;
     }
 
     emit debugModeRequested();
@@ -1053,6 +1079,7 @@ void DebuggerManager::setStatus(int status)
 
     m_startExternalAction->setEnabled(!started && !starting);
     m_attachExternalAction->setEnabled(!started && !starting);
+    m_attachCoreAction->setEnabled(!started && !starting);
     m_watchAction->setEnabled(ready);
     m_breakAction->setEnabled(true);
 
diff --git a/src/plugins/debugger/debuggermanager.h b/src/plugins/debugger/debuggermanager.h
index 04f8c6c8e23..4964d7b87e0 100644
--- a/src/plugins/debugger/debuggermanager.h
+++ b/src/plugins/debugger/debuggermanager.h
@@ -215,7 +215,7 @@ public:
     QLabel *statusLabel() const { return m_statusLabel; }
     DebuggerSettings *settings() { return &m_settings; }
 
-    enum StartMode { StartInternal, StartExternal, AttachExternal };
+    enum StartMode { StartInternal, StartExternal, AttachExternal, AttachCore };
     enum DebuggerType { GdbDebugger, ScriptDebugger, WinDebugger };
 
 public slots:
@@ -241,6 +241,7 @@ public slots:
     void interruptDebuggingRequest();
     void startExternalApplication();
     void attachExternalApplication();
+    void attachCore();
 
     void jumpToLineExec();
     void runToLineExec();
@@ -423,6 +424,7 @@ private:
     friend class DebuggerPlugin;
     QAction *m_startExternalAction;
     QAction *m_attachExternalAction;
+    QAction *m_attachCoreAction;
     QAction *m_continueAction;
     QAction *m_stopAction;
     QAction *m_resetAction; // FIXME: Should not be needed in a stable release
diff --git a/src/plugins/debugger/gdbengine.cpp b/src/plugins/debugger/gdbengine.cpp
index 311608709ba..1628de7155d 100644
--- a/src/plugins/debugger/gdbengine.cpp
+++ b/src/plugins/debugger/gdbengine.cpp
@@ -42,8 +42,7 @@
 #include "watchhandler.h"
 #include "sourcefileswindow.h"
 
-#include "startexternaldialog.h"
-#include "attachexternaldialog.h"
+#include "debuggerdialogs.h"
 
 #include <utils/qtcassert.h>
 
diff --git a/src/plugins/debugger/scriptengine.cpp b/src/plugins/debugger/scriptengine.cpp
index ea13e44c3a4..03d8bd8f4ba 100644
--- a/src/plugins/debugger/scriptengine.cpp
+++ b/src/plugins/debugger/scriptengine.cpp
@@ -29,7 +29,7 @@
 
 #include "scriptengine.h"
 
-#include "attachexternaldialog.h"
+#include "debuggerdialogs.h"
 #include "breakhandler.h"
 #include "debuggerconstants.h"
 #include "debuggermanager.h"
@@ -37,7 +37,6 @@
 #include "moduleshandler.h"
 #include "registerhandler.h"
 #include "stackhandler.h"
-#include "startexternaldialog.h"
 #include "watchhandler.h"
 
 #include <utils/qtcassert.h>
diff --git a/src/plugins/debugger/startexternaldialog.cpp b/src/plugins/debugger/startexternaldialog.cpp
deleted file mode 100644
index 1ac633fa197..00000000000
--- a/src/plugins/debugger/startexternaldialog.cpp
+++ /dev/null
@@ -1,113 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact:  Qt Software Information (qt-info@nokia.com)
-**
-** Commercial Usage
-**
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Nokia.
-**
-** GNU Lesser General Public License Usage
-**
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file.  Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-**
-**************************************************************************/
-
-#include "startexternaldialog.h"
-
-#include <QtGui/QFileDialog>
-#include <QtGui/QPushButton>
-
-using namespace Debugger::Internal;
-
-StartExternalDialog::StartExternalDialog(QWidget *parent)
-  : QDialog(parent)
-{
-    setupUi(this);
-    execFile->setExpectedKind(Core::Utils::PathChooser::File);
-    execFile->setPromptDialogTitle(tr("Select Executable"));
-    buttonBox->button(QDialogButtonBox::Ok)->setDefault(true);
-
-    //execLabel->setHidden(false);
-    //execEdit->setHidden(false);
-    //browseButton->setHidden(false);
-
-    execLabel->setText(tr("Executable:"));
-    argLabel->setText(tr("Arguments:"));
-
-    connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
-    connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
-}
-
-void StartExternalDialog::setExecutableFile(const QString &str)
-{
-    execFile->setPath(str);
-}
-
-void StartExternalDialog::setExecutableArguments(const QString &str)
-{
-    argsEdit->setText(str);
-}
-
-QString StartExternalDialog::executableFile() const
-{
-    return execFile->path();
-}
-
-QString StartExternalDialog::executableArguments() const
-{
-    return argsEdit->text();
-    /*
-    bool inQuotes = false;
-    QString args = argsEdit->text();
-    QChar current;
-    QChar last;
-    QString arg;
-
-    QStringList result;
-    if (!args.isEmpty())
-        result << QLatin1String("--args");
-    result << execEdit->text();
-
-    for (int i = 0; i < args.length(); ++i) {
-        current = args.at(i);
-
-        if (current == QLatin1Char('\"') && last != QLatin1Char('\\')) {
-            if (inQuotes && !arg.isEmpty()) {
-                result << arg;
-                arg.clear();
-            }
-            inQuotes = !inQuotes;
-        } else if (!inQuotes && current == QLatin1Char(' ')) {
-            arg = arg.trimmed();
-            if (!arg.isEmpty()) {
-                result << arg;
-                arg.clear();
-            }
-        } else {
-            arg += current;
-        }
-
-        last = current;
-    }
-
-    if (!arg.isEmpty())
-        result << arg;
-
-    return result;
-    */
-}
diff --git a/src/plugins/debugger/startexternaldialog.h b/src/plugins/debugger/startexternaldialog.h
deleted file mode 100644
index 3f135a71286..00000000000
--- a/src/plugins/debugger/startexternaldialog.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact:  Qt Software Information (qt-info@nokia.com)
-**
-** Commercial Usage
-**
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Nokia.
-**
-** GNU Lesser General Public License Usage
-**
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file.  Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-**
-**************************************************************************/
-
-#ifndef DEBUGGER_STARTEXTERNALDIALOG_H
-#define DEBUGGER_STARTEXTERNALDIALOG_H
-
-#include <QtGui/QDialog>
-
-#include "ui_startexternaldialog.h"
-
-namespace Debugger {
-namespace Internal {
-
-class StartExternalDialog : public QDialog, Ui::StartExternalDialog
-{
-    Q_OBJECT
-
-public:
-    StartExternalDialog(QWidget *parent);
-
-    void setExecutableFile(const QString &executable);
-    void setExecutableArguments(const QString &args);
-
-    QString executableFile() const;
-    QString executableArguments() const;
-};
-
-} // namespace Debugger
-} // namespace Internal
-
-#endif // DEBUGGER_STARTEXTERNALDIALOG_H
-- 
GitLab