summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Nätterlund <tobias.naetterlund.qnx@kdab.com>2014-02-12 05:58:56 +0100
committerhjk <hjk121@nokiamail.com>2014-02-12 10:40:00 +0100
commit8d319ce8993fa767c58e8d92da78a3d5c58d8f45 (patch)
treef151ac1c00a8f79970102dd73a9c45d75c8094f5
parent7ed1576083ceb7a6587796c63510d0fe027a9aac (diff)
downloadqt-creator-8d319ce8993fa767c58e8d92da78a3d5c58d8f45.tar.gz
QNX: Add support for attaching to a running application
This adds a new menu item to the Debug -> Start Debugging menu, which shows a processes dialog for the user, listing the processes on the selected device. Clicking Attach to Application launches pdebug on the device and then starts the gdb engine to attach to the selected process. This adds a DeviceTypeKitChooser class to ProjectExplorer, to only have the KitChooser show kits configured for a specific device type. Change-Id: I1572dc76a6bdc4774dbf2e8cc96ca6bcf0f79a0a Reviewed-by: hjk <hjk121@nokiamail.com>
-rw-r--r--src/plugins/projectexplorer/devicesupport/devicetypekitchooser.cpp48
-rw-r--r--src/plugins/projectexplorer/devicesupport/devicetypekitchooser.h55
-rw-r--r--src/plugins/projectexplorer/projectexplorer.pro2
-rw-r--r--src/plugins/projectexplorer/projectexplorer.qbs1
-rw-r--r--src/plugins/qnx/qnx.pro9
-rw-r--r--src/plugins/qnx/qnx.qbs4
-rw-r--r--src/plugins/qnx/qnxattachdebugdialog.cpp71
-rw-r--r--src/plugins/qnx/qnxattachdebugdialog.h59
-rw-r--r--src/plugins/qnx/qnxattachdebugsupport.cpp174
-rw-r--r--src/plugins/qnx/qnxattachdebugsupport.h89
-rw-r--r--src/plugins/qnx/qnxconstants.h2
-rw-r--r--src/plugins/qnx/qnxplugin.cpp45
-rw-r--r--src/plugins/qnx/qnxplugin.h11
13 files changed, 565 insertions, 5 deletions
diff --git a/src/plugins/projectexplorer/devicesupport/devicetypekitchooser.cpp b/src/plugins/projectexplorer/devicesupport/devicetypekitchooser.cpp
new file mode 100644
index 0000000000..e6a5b1a2e2
--- /dev/null
+++ b/src/plugins/projectexplorer/devicesupport/devicetypekitchooser.cpp
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klarälvdalens Datakonsult AB, a KDAB Group company
+** Contact: info@kdab.com
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "devicetypekitchooser.h"
+
+#include "kitinformation.h"
+
+using namespace ProjectExplorer;
+
+DeviceTypeKitChooser::DeviceTypeKitChooser(Core::Id deviceType, QWidget *parent)
+ : KitChooser(parent)
+ , m_deviceType(deviceType)
+{
+}
+
+bool DeviceTypeKitChooser::kitMatches(const Kit *k) const
+{
+ if (!KitChooser::kitMatches(k))
+ return false;
+
+ return DeviceTypeKitInformation::deviceTypeId(k) == m_deviceType;
+}
diff --git a/src/plugins/projectexplorer/devicesupport/devicetypekitchooser.h b/src/plugins/projectexplorer/devicesupport/devicetypekitchooser.h
new file mode 100644
index 0000000000..997ecd8d43
--- /dev/null
+++ b/src/plugins/projectexplorer/devicesupport/devicetypekitchooser.h
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klarälvdalens Datakonsult AB, a KDAB Group company
+** Contact: info@kdab.com
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef PROJECTEXPLORER_DEVICETYPEKITCHOOSER_H
+#define PROJECTEXPLORER_DEVICETYPEKITCHOOSER_H
+
+#include "../kitchooser.h"
+#include "../projectexplorer_export.h"
+
+#include <coreplugin/id.h>
+
+namespace ProjectExplorer {
+
+class PROJECTEXPLORER_EXPORT DeviceTypeKitChooser : public KitChooser
+{
+ Q_OBJECT
+public:
+ explicit DeviceTypeKitChooser(Core::Id deviceType, QWidget *parent = 0);
+
+protected:
+ bool kitMatches(const Kit *k) const;
+
+private:
+ Core::Id m_deviceType;
+};
+
+} // namespace ProjectExplorer
+
+#endif // PROJECTEXPLORER_DEVICETYPEKITCHOOSER_H
diff --git a/src/plugins/projectexplorer/projectexplorer.pro b/src/plugins/projectexplorer/projectexplorer.pro
index 03daf8b229..94e6d80b50 100644
--- a/src/plugins/projectexplorer/projectexplorer.pro
+++ b/src/plugins/projectexplorer/projectexplorer.pro
@@ -128,6 +128,7 @@ HEADERS += projectexplorer.h \
devicesupport/devicesettingswidget.h \
devicesupport/devicesettingspage.h \
devicesupport/devicetestdialog.h \
+ devicesupport/devicetypekitchooser.h \
devicesupport/deviceusedportsgatherer.h \
devicesupport/deviceapplicationrunner.h \
devicesupport/localprocesslist.h \
@@ -258,6 +259,7 @@ SOURCES += projectexplorer.cpp \
devicesupport/devicesettingswidget.cpp \
devicesupport/devicesettingspage.cpp \
devicesupport/devicetestdialog.cpp \
+ devicesupport/devicetypekitchooser.cpp \
devicesupport/deviceusedportsgatherer.cpp \
devicesupport/deviceapplicationrunner.cpp \
devicesupport/localprocesslist.cpp \
diff --git a/src/plugins/projectexplorer/projectexplorer.qbs b/src/plugins/projectexplorer/projectexplorer.qbs
index 4af1c12e17..1b7c4dfdf9 100644
--- a/src/plugins/projectexplorer/projectexplorer.qbs
+++ b/src/plugins/projectexplorer/projectexplorer.qbs
@@ -185,6 +185,7 @@ QtcPlugin {
"devicesettingspage.cpp", "devicesettingspage.h",
"devicesettingswidget.cpp", "devicesettingswidget.h", "devicesettingswidget.ui",
"devicetestdialog.cpp", "devicetestdialog.h", "devicetestdialog.ui",
+ "devicetypekitchooser.cpp", "devicetypekitchooser.h",
"deviceusedportsgatherer.cpp", "deviceusedportsgatherer.h",
"idevice.cpp", "idevice.h",
"idevicefactory.cpp", "idevicefactory.h",
diff --git a/src/plugins/qnx/qnx.pro b/src/plugins/qnx/qnx.pro
index 4d74b7be03..c1f74c7f71 100644
--- a/src/plugins/qnx/qnx.pro
+++ b/src/plugins/qnx/qnx.pro
@@ -99,7 +99,9 @@ SOURCES += qnxplugin.cpp \
blackberrydebugtokenpinsdialog.cpp \
blackberrycheckdevicestatusstepfactory.cpp \
blackberrycheckdevicestatusstepconfigwidget.cpp \
- blackberrycheckdevicestatusstep.cpp
+ blackberrycheckdevicestatusstep.cpp \
+ qnxattachdebugsupport.cpp \
+ qnxattachdebugdialog.cpp
HEADERS += qnxplugin.h\
qnxconstants.h \
@@ -198,8 +200,9 @@ HEADERS += qnxplugin.h\
blackberrydebugtokenpinsdialog.h \
blackberrycheckdevicestatusstep.h \
blackberrycheckdevicestatusstepfactory.h \
- blackberrycheckdevicestatusstepconfigwidget.h
-
+ blackberrycheckdevicestatusstepconfigwidget.h \
+ qnxattachdebugsupport.h \
+ qnxattachdebugdialog.h
FORMS += \
blackberrydeviceconfigurationwizardsetuppage.ui \
diff --git a/src/plugins/qnx/qnx.qbs b/src/plugins/qnx/qnx.qbs
index 79cbe84d3f..c5ce9711f5 100644
--- a/src/plugins/qnx/qnx.qbs
+++ b/src/plugins/qnx/qnx.qbs
@@ -200,6 +200,10 @@ QtcPlugin {
"qnx.qrc",
"qnxabstractqtversion.cpp",
"qnxabstractqtversion.h",
+ "qnxattachdebugsupport.cpp",
+ "qnxattachdebugsupport.h",
+ "qnxattachdebugdialog.cpp",
+ "qnxattachdebugdialog.h",
"qnxbaseqtconfigwidget.cpp",
"qnxbaseqtconfigwidget.h",
"qnxbaseqtconfigwidget.ui",
diff --git a/src/plugins/qnx/qnxattachdebugdialog.cpp b/src/plugins/qnx/qnxattachdebugdialog.cpp
new file mode 100644
index 0000000000..dab5ed4caf
--- /dev/null
+++ b/src/plugins/qnx/qnxattachdebugdialog.cpp
@@ -0,0 +1,71 @@
+/**************************************************************************
+**
+** Copyright (C) 2014 Klarälvdalens Datakonsult AB, a KDAB Group company
+** Contact: info@kdab.com
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "qnxattachdebugdialog.h"
+
+#include <utils/pathchooser.h>
+#include <utils/qtcassert.h>
+
+#include <QFormLayout>
+#include <QLabel>
+#include <QVBoxLayout>
+
+using namespace Qnx;
+using namespace Qnx::Internal;
+
+QnxAttachDebugDialog::QnxAttachDebugDialog(ProjectExplorer::KitChooser *kitChooser, QWidget *parent)
+ : ProjectExplorer::DeviceProcessesDialog(kitChooser, parent)
+{
+ QVBoxLayout *mainLayout = dynamic_cast<QVBoxLayout*>(layout());
+ QTC_ASSERT(mainLayout, return);
+
+ QFormLayout *formLayout = new QFormLayout;
+
+ QLabel *sourceLabel = new QLabel(tr("Project source directory:"), this);
+ m_projectSource = new Utils::PathChooser(this);
+ m_projectSource->setExpectedKind(Utils::PathChooser::ExistingDirectory);
+ formLayout->addRow(sourceLabel, m_projectSource);
+
+ QLabel *binaryLabel = new QLabel(tr("Local executable:"), this);
+ m_localExecutable = new Utils::PathChooser(this);
+ m_localExecutable->setExpectedKind(Utils::PathChooser::File);
+ formLayout->addRow(binaryLabel, m_localExecutable);
+
+ mainLayout->insertLayout(mainLayout->count() - 2, formLayout);
+}
+
+QString QnxAttachDebugDialog::projectSource() const
+{
+ return m_projectSource->path();
+}
+
+QString QnxAttachDebugDialog::localExecutable() const
+{
+ return m_localExecutable->path();
+}
diff --git a/src/plugins/qnx/qnxattachdebugdialog.h b/src/plugins/qnx/qnxattachdebugdialog.h
new file mode 100644
index 0000000000..09a71331ce
--- /dev/null
+++ b/src/plugins/qnx/qnxattachdebugdialog.h
@@ -0,0 +1,59 @@
+/**************************************************************************
+**
+** Copyright (C) 2014 Klarälvdalens Datakonsult AB, a KDAB Group company
+** Contact: info@kdab.com
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef QNX_INTERNAL_QNXATTACHDEBUGDIALOG_H
+#define QNX_INTERNAL_QNXATTACHDEBUGDIALOG_H
+
+#include <projectexplorer/devicesupport/deviceprocessesdialog.h>
+
+namespace Utils {
+class PathChooser;
+}
+
+namespace Qnx {
+namespace Internal {
+
+class QnxAttachDebugDialog : public ProjectExplorer::DeviceProcessesDialog
+{
+ Q_OBJECT
+
+public:
+ explicit QnxAttachDebugDialog(ProjectExplorer::KitChooser *kitChooser, QWidget *parent = 0);
+
+ QString projectSource() const;
+ QString localExecutable() const;
+
+private:
+ Utils::PathChooser *m_projectSource;
+ Utils::PathChooser *m_localExecutable;
+};
+
+} // namespace Internal
+} // namespace Qnx
+#endif // QNX_INTERNAL_QNXATTACHDEBUGDIALOG_H
diff --git a/src/plugins/qnx/qnxattachdebugsupport.cpp b/src/plugins/qnx/qnxattachdebugsupport.cpp
new file mode 100644
index 0000000000..28fb15d46b
--- /dev/null
+++ b/src/plugins/qnx/qnxattachdebugsupport.cpp
@@ -0,0 +1,174 @@
+/**************************************************************************
+**
+** Copyright (C) 2014 Klarälvdalens Datakonsult AB, a KDAB Group company
+** Contact: info@kdab.com
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "qnxattachdebugsupport.h"
+
+#include "qnxattachdebugdialog.h"
+#include "qnxconstants.h"
+#include "qnxqtversion.h"
+#include "qnxutils.h"
+
+#include <debugger/debuggerengine.h>
+#include <debugger/debuggerkitinformation.h>
+#include <debugger/debuggerplugin.h>
+#include <debugger/debuggerrunner.h>
+#include <debugger/debuggerstartparameters.h>
+#include <projectexplorer/devicesupport/deviceapplicationrunner.h>
+#include <projectexplorer/devicesupport/deviceusedportsgatherer.h>
+#include <projectexplorer/devicesupport/devicetypekitchooser.h>
+#include <projectexplorer/devicesupport/deviceprocessesdialog.h>
+#include <projectexplorer/devicesupport/deviceprocesslist.h>
+#include <projectexplorer/kit.h>
+#include <projectexplorer/kitinformation.h>
+#include <projectexplorer/projectexplorer.h>
+#include <projectexplorer/toolchain.h>
+#include <qtsupport/qtkitinformation.h>
+#include <utils/portlist.h>
+#include <utils/qtcassert.h>
+
+using namespace Qnx;
+using namespace Qnx::Internal;
+
+QnxAttachDebugSupport::QnxAttachDebugSupport(QObject *parent)
+ : QObject(parent)
+ , m_kit(0)
+ , m_engine(0)
+ , m_pdebugPort(-1)
+{
+ m_runner = new ProjectExplorer::DeviceApplicationRunner(this);
+ m_portsGatherer = new ProjectExplorer::DeviceUsedPortsGatherer(this);
+
+ connect(m_portsGatherer, SIGNAL(portListReady()), this, SLOT(launchPDebug()));
+ connect(m_portsGatherer, SIGNAL(error(QString)), this, SLOT(handleError(QString)));
+ connect(m_runner, SIGNAL(remoteProcessStarted()), this, SLOT(attachToProcess()));
+ connect(m_runner, SIGNAL(reportError(QString)), this, SLOT(handleError(QString)));
+ connect(m_runner, SIGNAL(reportProgress(QString)), this, SLOT(handleProgressReport(QString)));
+ connect(m_runner, SIGNAL(remoteStdout(QByteArray)), this, SLOT(handleRemoteOutput(QByteArray)));
+ connect(m_runner, SIGNAL(remoteStderr(QByteArray)), this, SLOT(handleRemoteOutput(QByteArray)));
+}
+
+void QnxAttachDebugSupport::showProcessesDialog()
+{
+ ProjectExplorer::DeviceTypeKitChooser *kitChooser = new ProjectExplorer::DeviceTypeKitChooser(Core::Id(Constants::QNX_QNX_OS_TYPE));
+ QnxAttachDebugDialog dlg(kitChooser, 0);
+ dlg.addAcceptButton(ProjectExplorer::DeviceProcessesDialog::tr("&Attach to Process"));
+ dlg.showAllDevices();
+ if (dlg.exec() == QDialog::Rejected)
+ return;
+
+ m_kit = kitChooser->currentKit();
+ if (!m_kit)
+ return;
+
+ m_device = ProjectExplorer::DeviceKitInformation::device(m_kit);
+ QTC_ASSERT(m_device, return);
+ m_process = dlg.currentProcess();
+
+ m_projectSourceDirectory = dlg.projectSource();
+ m_localExecutablePath = dlg.localExecutable();
+
+ m_portsGatherer->start(m_device);
+}
+
+void QnxAttachDebugSupport::launchPDebug()
+{
+ Utils::PortList portList = m_device->freePorts();
+ m_pdebugPort = m_portsGatherer->getNextFreePort(&portList);
+ if (m_pdebugPort == -1) {
+ handleError(tr("No free ports for debugging."));
+ return;
+ }
+
+ const QString remoteCommand = QLatin1String("pdebug");
+ QStringList arguments;
+ arguments << QString::number(m_pdebugPort);
+ m_runner->start(m_device, remoteCommand, arguments);
+}
+
+void QnxAttachDebugSupport::attachToProcess()
+{
+ Debugger::DebuggerStartParameters sp;
+ sp.attachPID = m_process.pid;
+ sp.startMode = Debugger::AttachToRemoteServer;
+ sp.closeMode = Debugger::DetachAtClose;
+ sp.masterEngineType = Debugger::GdbEngineType;
+ sp.connParams.port = m_pdebugPort;
+ sp.remoteChannel = m_device->sshParameters().host + QLatin1Char(':') + QString::number(m_pdebugPort);
+ sp.displayName = tr("Remote: \"%1:%2\" - Process %3").arg(sp.connParams.host).arg(m_pdebugPort).arg(m_process.pid);
+ sp.debuggerCommand = Debugger::DebuggerKitInformation::debuggerCommand(m_kit).toString();
+ sp.projectSourceDirectory = m_projectSourceDirectory;
+ sp.executable = m_localExecutablePath;
+ if (ProjectExplorer::ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain(m_kit))
+ sp.toolChainAbi = tc->targetAbi();
+ sp.useCtrlCStub = true;
+
+ QnxQtVersion *qtVersion = dynamic_cast<QnxQtVersion *>(QtSupport::QtKitInformation::qtVersion(m_kit));
+ if (qtVersion)
+ sp.solibSearchPath = QnxUtils::searchPaths(qtVersion);
+
+ QString errorMessage;
+ Debugger::DebuggerRunControl * const runControl = Debugger::DebuggerPlugin::createDebugger(sp, 0, &errorMessage);
+ if (!errorMessage.isEmpty()) {
+ handleError(errorMessage);
+ stopPDebug();
+ return;
+ }
+ m_engine = runControl->engine();
+ connect(m_engine, SIGNAL(stateChanged(Debugger::DebuggerState)), this, SLOT(handleDebuggerStateChanged(Debugger::DebuggerState)));
+ ProjectExplorer::ProjectExplorerPlugin::instance()->startRunControl(runControl, ProjectExplorer::DebugRunMode);
+}
+
+void QnxAttachDebugSupport::handleDebuggerStateChanged(Debugger::DebuggerState state)
+{
+ if (state == Debugger::DebuggerFinished)
+ stopPDebug();
+}
+
+void QnxAttachDebugSupport::handleError(const QString &message)
+{
+ if (m_engine)
+ m_engine->showMessage(message, Debugger::AppError);
+}
+
+void QnxAttachDebugSupport::handleProgressReport(const QString &message)
+{
+ if (m_engine)
+ m_engine->showMessage(message + QLatin1Char('\n'), Debugger::AppStuff);
+}
+
+void QnxAttachDebugSupport::handleRemoteOutput(const QByteArray &output)
+{
+ if (m_engine)
+ m_engine->showMessage(QString::fromUtf8(output), Debugger::AppOutput);
+}
+
+void QnxAttachDebugSupport::stopPDebug()
+{
+ m_runner->stop();
+}
diff --git a/src/plugins/qnx/qnxattachdebugsupport.h b/src/plugins/qnx/qnxattachdebugsupport.h
new file mode 100644
index 0000000000..8cd797399a
--- /dev/null
+++ b/src/plugins/qnx/qnxattachdebugsupport.h
@@ -0,0 +1,89 @@
+/**************************************************************************
+**
+** Copyright (C) 2014 Klarälvdalens Datakonsult AB, a KDAB Group company
+** Contact: info@kdab.com
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef QNX_INTERNAL_QNXATTACHDEBUGSUPPORT_H
+#define QNX_INTERNAL_QNXATTACHDEBUGSUPPORT_H
+
+#include <debugger/debuggerconstants.h>
+#include <projectexplorer/devicesupport/deviceprocesslist.h>
+#include <projectexplorer/devicesupport/idevice.h>
+
+#include <QObject>
+
+namespace Debugger {
+class DebuggerEngine;
+}
+
+namespace ProjectExplorer {
+class DeviceApplicationRunner;
+class DeviceUsedPortsGatherer;
+class Kit;
+}
+
+namespace Qnx {
+namespace Internal {
+
+class QnxAttachDebugSupport : public QObject
+{
+ Q_OBJECT
+public:
+ explicit QnxAttachDebugSupport(QObject *parent = 0);
+
+public slots:
+ void showProcessesDialog();
+
+private slots:
+ void launchPDebug();
+ void attachToProcess();
+
+ void handleDebuggerStateChanged(Debugger::DebuggerState state);
+ void handleError(const QString &message);
+ void handleProgressReport(const QString &message);
+ void handleRemoteOutput(const QByteArray &output);
+
+private:
+ void stopPDebug();
+
+ ProjectExplorer::Kit *m_kit;
+ ProjectExplorer::IDevice::ConstPtr m_device;
+ ProjectExplorer::DeviceProcessItem m_process;
+
+ ProjectExplorer::DeviceApplicationRunner *m_runner;
+ ProjectExplorer::DeviceUsedPortsGatherer *m_portsGatherer;
+ Debugger::DebuggerEngine *m_engine;
+
+ int m_pdebugPort;
+ QString m_projectSourceDirectory;
+ QString m_localExecutablePath;
+};
+
+} // namespace Internal
+} // namespace Qnx
+
+#endif // QNX_INTERNAL_QNXATTACHDEBUGSUPPORT_H
diff --git a/src/plugins/qnx/qnxconstants.h b/src/plugins/qnx/qnxconstants.h
index 1bb3311b04..478a3267f7 100644
--- a/src/plugins/qnx/qnxconstants.h
+++ b/src/plugins/qnx/qnxconstants.h
@@ -115,6 +115,8 @@ const char QNX_BLACKBERRY_CASCADESIMPORTER_VERSION[] = "0.0.1";
const char QNX_BLACKBERRY_CONFIGS_FILENAME[] = "bbndkconfigurations.xml";
+const char QNX_DEBUGGING_GROUP[] = "Debugger.Group.Qnx";
+
} // namespace Constants
} // namespace Qnx
diff --git a/src/plugins/qnx/qnxplugin.cpp b/src/plugins/qnx/qnxplugin.cpp
index a0063e6315..9b80454a84 100644
--- a/src/plugins/qnx/qnxplugin.cpp
+++ b/src/plugins/qnx/qnxplugin.cpp
@@ -39,6 +39,7 @@
#include "blackberrydeploystepfactory.h"
#include "blackberryrunconfigurationfactory.h"
#include "blackberryruncontrolfactory.h"
+#include "qnxattachdebugsupport.h"
#include "qnxdeviceconfigurationfactory.h"
#include "qnxruncontrolfactory.h"
#include "qnxdeploystepfactory.h"
@@ -55,19 +56,27 @@
#include "blackberryconfiguration.h"
#include "cascadesimport/cascadesimportwizard.h"
#include "qnxtoolchain.h"
+#include "qnxattachdebugsupport.h"
-
+#include <coreplugin/actionmanager/actioncontainer.h>
+#include <coreplugin/actionmanager/actionmanager.h>
+#include <coreplugin/coreconstants.h>
#include <coreplugin/icore.h>
#include <coreplugin/mimedatabase.h>
+#include <projectexplorer/kitinformation.h>
#include <projectexplorer/projectexplorer.h>
+#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/taskhub.h>
#include <projectexplorer/kitmanager.h>
+#include <QAction>
#include <QtPlugin>
using namespace Qnx::Internal;
QNXPlugin::QNXPlugin()
+ : m_debugSeparator(0)
+ , m_attachToQnxApplication(0)
{
}
@@ -130,6 +139,23 @@ void QNXPlugin::extensionsInitialized()
{
ProjectExplorer::TaskHub::addCategory(Constants::QNX_TASK_CATEGORY_BARDESCRIPTOR,
tr("Bar Descriptor"));
+
+ // Debug support
+ QnxAttachDebugSupport *debugSupport = new QnxAttachDebugSupport(this);
+
+ m_attachToQnxApplication = new QAction(this);
+ m_attachToQnxApplication->setText(tr("Attach to Remote QNX Application..."));
+ connect(m_attachToQnxApplication, SIGNAL(triggered()), debugSupport, SLOT(showProcessesDialog()));
+
+ const Core::Context globalcontext(Core::Constants::C_GLOBAL);
+ Core::ActionContainer *mstart = Core::ActionManager::actionContainer(ProjectExplorer::Constants::M_DEBUG_STARTDEBUGGING);
+ mstart->appendGroup(Constants::QNX_DEBUGGING_GROUP);
+ mstart->addSeparator(globalcontext, Constants::QNX_DEBUGGING_GROUP, &m_debugSeparator);
+
+ Core::Command *cmd = Core::ActionManager::registerAction(m_attachToQnxApplication, "Debugger.AttachToQnxApplication", globalcontext);
+ mstart->addAction(cmd, Constants::QNX_DEBUGGING_GROUP);
+
+ connect(ProjectExplorer::KitManager::instance(), SIGNAL(kitsChanged()), this, SLOT(updateDebuggerActions()));
}
ExtensionSystem::IPlugin::ShutdownFlag QNXPlugin::aboutToShutdown()
@@ -137,6 +163,23 @@ ExtensionSystem::IPlugin::ShutdownFlag QNXPlugin::aboutToShutdown()
return SynchronousShutdown;
}
+void QNXPlugin::updateDebuggerActions()
+{
+ bool hasValidQnxKit = false;
+ ProjectExplorer::DeviceTypeMatcher qnxTypeMatcher(Constants::QNX_QNX_OS_TYPE);
+ const QList<ProjectExplorer::Kit *> qnxKits = ProjectExplorer::KitManager::matchingKits(qnxTypeMatcher);
+
+ foreach (ProjectExplorer::Kit *qnxKit, qnxKits) {
+ if (qnxKit->isValid() && !ProjectExplorer::DeviceKitInformation::device(qnxKit).isNull()) {
+ hasValidQnxKit = true;
+ break;
+ }
+ }
+
+ m_attachToQnxApplication->setVisible(hasValidQnxKit);
+ m_debugSeparator->setVisible(hasValidQnxKit);
+}
+
#ifdef WITH_TESTS
#include <QTest>
diff --git a/src/plugins/qnx/qnxplugin.h b/src/plugins/qnx/qnxplugin.h
index 5d7d179632..86aa537848 100644
--- a/src/plugins/qnx/qnxplugin.h
+++ b/src/plugins/qnx/qnxplugin.h
@@ -34,6 +34,10 @@
#include <extensionsystem/iplugin.h>
+QT_BEGIN_NAMESPACE
+class QAction;
+QT_END_NAMESPACE
+
namespace Qnx {
namespace Internal {
@@ -50,8 +54,9 @@ public:
void extensionsInitialized();
ShutdownFlag aboutToShutdown();
-#ifdef WITH_TESTS
private slots:
+ void updateDebuggerActions();
+#ifdef WITH_TESTS
void testBarDescriptorDocumentSetValue_data();
void testBarDescriptorDocumentSetValue();
@@ -61,6 +66,10 @@ private slots:
void testConfigurationManager_data();
void testConfigurationManager();
#endif
+
+private:
+ QAction *m_debugSeparator;
+ QAction *m_attachToQnxApplication;
};
} // namespace Internal