diff --git a/src/plugins/projectexplorer/devicesupport/devicetypekitchooser.cpp b/src/plugins/projectexplorer/devicesupport/devicetypekitchooser.cpp new file mode 100644 index 00000000000..e6a5b1a2e2f --- /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 00000000000..997ecd8d438 --- /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 + +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 03daf8b2296..94e6d80b501 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 4af1c12e177..1b7c4dfdf97 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 4d74b7be039..c1f74c7f71c 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 79cbe84d3fd..c5ce9711f5c 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 00000000000..dab5ed4caf1 --- /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 +#include + +#include +#include +#include + +using namespace Qnx; +using namespace Qnx::Internal; + +QnxAttachDebugDialog::QnxAttachDebugDialog(ProjectExplorer::KitChooser *kitChooser, QWidget *parent) + : ProjectExplorer::DeviceProcessesDialog(kitChooser, parent) +{ + QVBoxLayout *mainLayout = dynamic_cast(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 00000000000..09a71331cef --- /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 + +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 00000000000..28fb15d46b3 --- /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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +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(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 00000000000..8cd797399ac --- /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 +#include +#include + +#include + +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 1bb3311b046..478a3267f73 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 a0063e63152..9b80454a84a 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 +#include +#include #include #include +#include #include +#include #include #include +#include #include 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 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 diff --git a/src/plugins/qnx/qnxplugin.h b/src/plugins/qnx/qnxplugin.h index 5d7d1796328..86aa5378488 100644 --- a/src/plugins/qnx/qnxplugin.h +++ b/src/plugins/qnx/qnxplugin.h @@ -34,6 +34,10 @@ #include +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