From 1283233f4b0194d82c57af1e4be9907bb63e2ffb Mon Sep 17 00:00:00 2001 From: hjk <qthjk@ovi.com> Date: Fri, 27 Jul 2012 00:17:12 +0200 Subject: [PATCH] debugger: move startgdbserverdialog from remotelinux plugins Change-Id: Ic382437bb99fe1b6bda9b1252e286cb3b9476191 Reviewed-by: Christian Kandeler <christian.kandeler@nokia.com> --- src/plugins/debugger/debugger.qbs | 2 + src/plugins/debugger/debuggerplugin.cpp | 90 +-------------- .../debugger/debuggerprofileinformation.h | 2 +- src/plugins/debugger/gdb/gdb.pri | 2 + .../gdb}/startgdbserverdialog.cpp | 103 ++++++++++++++---- .../gdb}/startgdbserverdialog.h | 10 +- .../devicesupport/deviceusedportsgatherer.h | 4 +- src/plugins/qnx/qnxdebugsupport.cpp | 1 - .../qnx/qnxdeviceconfigurationwizard.cpp | 1 - src/plugins/remotelinux/linuxdevicetester.h | 5 +- src/plugins/remotelinux/remotelinux.pro | 2 - src/plugins/remotelinux/remotelinux.qbs | 2 - src/plugins/remotelinux/remotelinuxplugin.cpp | 15 --- src/plugins/remotelinux/remotelinuxplugin.h | 4 - 14 files changed, 102 insertions(+), 141 deletions(-) rename src/plugins/{remotelinux => debugger/gdb}/startgdbserverdialog.cpp (77%) rename src/plugins/{remotelinux => debugger/gdb}/startgdbserverdialog.h (91%) diff --git a/src/plugins/debugger/debugger.qbs b/src/plugins/debugger/debugger.qbs index dad378f7612..1ad5ac26e6f 100644 --- a/src/plugins/debugger/debugger.qbs +++ b/src/plugins/debugger/debugger.qbs @@ -192,6 +192,8 @@ QtcPlugin { "gdb/gdbengine.h", "gdb/gdboptionspage.cpp", "gdb/termgdbadapter.cpp", + "gdb/startgdbserverdialog.cpp", + "gdb/startgdbserverdialog.h", "images/breakpoint_16.png", "images/breakpoint_24.png", "images/breakpoint_disabled_16.png", diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 110b6c392b5..fcf367051a0 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -67,6 +67,7 @@ #include "snapshothandler.h" #include "threadshandler.h" #include "commonoptionspage.h" +#include "gdb/startgdbserverdialog.h" #include <coreplugin/actionmanager/actionmanager.h> #include <coreplugin/actionmanager/actioncontainer.h> @@ -1093,16 +1094,11 @@ public slots: unsigned *enabledEngines, QString *errorMessage); DebuggerToolTipManager *toolTipManager() const { return m_toolTipManager; } - virtual QSharedPointer<GlobalDebuggerOptions> globalDebuggerOptions() const { return m_globalDebuggerOptions; } + QSharedPointer<GlobalDebuggerOptions> globalDebuggerOptions() const { return m_globalDebuggerOptions; } // FIXME: Remove. void maybeEnrichParameters(DebuggerStartParameters *sp); - void gdbServerStarted(const QString &channel, const QString &profile, - const QString &remoteCommandLine, const QString &remoteExecutable); - void attachedToProcess(const QString &channel, const QString &profile, - const QString &remoteCommandLine, const QString &remoteExecutable); - void updateQmlActions() { action(QmlUpdateOnSave)->setEnabled(boolSetting(ShowQmlObjectTree)); } @@ -1671,88 +1667,14 @@ void DebuggerPluginPrivate::attachToRemoteServer() void DebuggerPluginPrivate::startRemoteServer() { - QObject *rl = PluginManager::getObjectByName(_("RemoteLinuxPlugin")); - QTC_ASSERT(rl, return); - QMetaObject::invokeMethod(rl, "startGdbServer", Qt::QueuedConnection); - // Will call back gdbServerStarted() below. -} - -void DebuggerPluginPrivate::gdbServerStarted(const QString &channel, - const QString &profileId, - const QString &remoteCommandLine, - const QString &remoteExecutable) -{ - Q_UNUSED(remoteCommandLine); - Q_UNUSED(remoteExecutable); - Q_UNUSED(profileId); - showStatusMessage(tr("gdbserver is now listening at %1").arg(channel)); + StartGdbServerDialog dlg(mainWindow()); + dlg.startGdbServer(); } void DebuggerPluginPrivate::attachToRemoteProcess() { - QObject *rl = PluginManager::getObjectByName(_("RemoteLinuxPlugin")); - QTC_ASSERT(rl, return); - QMetaObject::invokeMethod(rl, "attachToRemoteProcess", Qt::QueuedConnection); - // This will call back attachedToProcess() below. -} - -void DebuggerPluginPrivate::attachedToProcess(const QString &channel, - 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; - if (QFileInfo(candidate).exists()) - localExecutable = candidate; - if (localExecutable.isEmpty()) { - binary = remoteCommandLine.section(QLatin1Char(' '), 0, 0); - candidate = sysroot + QLatin1Char('/') + binary; - if (QFileInfo(candidate).exists()) - localExecutable = candidate; - } - if (localExecutable.isEmpty()) { - candidate = sysroot + QLatin1String("/usr/bin/") + binary; - if (QFileInfo(candidate).exists()) - localExecutable = candidate; - } - if (localExecutable.isEmpty()) { - candidate = sysroot + QLatin1String("/bin/") + binary; - if (QFileInfo(candidate).exists()) - localExecutable = candidate; - } - if (localExecutable.isEmpty()) { - QMessageBox::warning(mainWindow(), tr("Warning"), - tr("Cannot find local executable for remote process \"%1\".") - .arg(remoteCommandLine)); - return; - } - - QList<Abi> abis = Abi::abisOfBinary(Utils::FileName::fromString(localExecutable)); - if (abis.isEmpty()) { - QMessageBox::warning(mainWindow(), tr("Warning"), - tr("Cannot find ABI for remote process \"%1\".") - .arg(remoteCommandLine)); - return; - } - - DebuggerStartParameters sp; - fillParameters(&sp, Id(profileId)); - sp.displayName = tr("Remote: \"%1\"").arg(channel); - sp.remoteChannel = channel; - sp.executable = localExecutable; - sp.startMode = AttachToRemoteServer; - sp.closeMode = KillAtClose; - sp.overrideStartScript.clear(); - sp.useServerStartScript = false; - sp.serverStartScript.clear(); - //sp.debugInfoLocation = dlg.debugInfoLocation(); - if (RunControl *rc = createDebugger(sp)) - startDebugger(rc); + StartGdbServerDialog dlg(mainWindow()); + dlg.attachToRemoteProcess(); } void DebuggerPluginPrivate::attachToQmlPort() diff --git a/src/plugins/debugger/debuggerprofileinformation.h b/src/plugins/debugger/debuggerprofileinformation.h index d632f0b1802..ae409c96f55 100644 --- a/src/plugins/debugger/debuggerprofileinformation.h +++ b/src/plugins/debugger/debuggerprofileinformation.h @@ -18,7 +18,7 @@ ** ** In addition, as a special exception, Nokia gives you certain additional ** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +* version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ** Other Usage ** diff --git a/src/plugins/debugger/gdb/gdb.pri b/src/plugins/debugger/gdb/gdb.pri index 003ba65bd60..3f13fb280b3 100644 --- a/src/plugins/debugger/gdb/gdb.pri +++ b/src/plugins/debugger/gdb/gdb.pri @@ -13,6 +13,7 @@ HEADERS += \ $$PWD/remotegdbprocess.h \ $$PWD/remoteplaingdbadapter.h \ $$PWD/abstractplaingdbadapter.h \ + $$PWD/startgdbserverdialog.h \ $$PWD/symbian.h SOURCES += \ @@ -32,6 +33,7 @@ SOURCES += \ $$PWD/remotegdbprocess.cpp \ $$PWD/remoteplaingdbadapter.cpp \ $$PWD/abstractplaingdbadapter.cpp \ + $$PWD/startgdbserverdialog.cpp \ $$PWD/symbian.cpp RESOURCES += $$PWD/gdb.qrc diff --git a/src/plugins/remotelinux/startgdbserverdialog.cpp b/src/plugins/debugger/gdb/startgdbserverdialog.cpp similarity index 77% rename from src/plugins/remotelinux/startgdbserverdialog.cpp rename to src/plugins/debugger/gdb/startgdbserverdialog.cpp index 5a1ccb3090d..f6a6b0d4a2d 100644 --- a/src/plugins/remotelinux/startgdbserverdialog.cpp +++ b/src/plugins/debugger/gdb/startgdbserverdialog.cpp @@ -30,18 +30,23 @@ #include "startgdbserverdialog.h" +#include "debuggercore.h" +#include "debuggermainwindow.h" +#include "debuggerplugin.h" +#include "debuggerprofileinformation.h" +#include "debuggerrunner.h" +#include "debuggerstartparameters.h" + #include <coreplugin/icore.h> #include <extensionsystem/pluginmanager.h> #include <projectexplorer/profilechooser.h> -#include <projectexplorer/profileinformation.h> #include <projectexplorer/devicesupport/deviceprocesslist.h> #include <projectexplorer/devicesupport/deviceusedportsgatherer.h> - +#include <ssh/sshconnection.h> +#include <ssh/sshremoteprocessrunner.h> #include <utils/pathchooser.h> #include <utils/portlist.h> #include <utils/qtcassert.h> -#include <ssh/sshconnection.h> -#include <ssh/sshremoteprocessrunner.h> #include <QVariant> #include <QSettings> @@ -70,12 +75,12 @@ using namespace ProjectExplorer; using namespace QSsh; using namespace Utils; -const char LastProfile[] = "RemoteLinux/LastProfile"; -const char LastDevice[] = "RemoteLinux/LastDevice"; -const char LastProcessName[] = "RemoteLinux/LastProcessName"; -//const char LastLocalExecutable[] = "RemoteLinux/LastLocalExecutable"; +const char LastProfile[] = "Debugger/LastProfile"; +const char LastDevice[] = "Debugger/LastDevice"; +const char LastProcessName[] = "Debugger/LastProcessName"; +//const char LastLocalExecutable[] = "Debugger/LastLocalExecutable"; -namespace RemoteLinux { +namespace Debugger { namespace Internal { class StartGdbServerDialogPrivate @@ -103,7 +108,6 @@ public: DeviceUsedPortsGatherer gatherer; SshRemoteProcessRunner runner; - QSettings *settings; QString remoteCommandLine; QString remoteExecutable; }; @@ -111,7 +115,7 @@ public: StartGdbServerDialogPrivate::StartGdbServerDialogPrivate(StartGdbServerDialog *q) : q(q), startServerOnly(true), processList(0) { - settings = ICore::settings(); + QSettings *settings = ICore::settings(); profileChooser = new ProfileChooser(q, ProfileChooser::RemoteDebugging); @@ -261,8 +265,9 @@ void StartGdbServerDialog::attachToProcess() return; } - d->settings->setValue(LastProfile, d->profileChooser->currentProfileId().toString()); - d->settings->setValue(LastProcessName, d->processFilterLineEdit->text()); + QSettings *settings = ICore::settings(); + settings->setValue(LastProfile, d->profileChooser->currentProfileId().toString()); + settings->setValue(LastProcessName, d->processFilterLineEdit->text()); startGdbServerOnPort(port, process.pid); } @@ -349,21 +354,73 @@ void StartGdbServerDialog::handleProcessErrorOutput() void StartGdbServerDialog::reportOpenPort(int port) { + close(); logMessage(tr("Port %1 is now accessible.").arg(port)); IDevice::ConstPtr device = d->currentDevice(); QString channel = QString("%1:%2").arg(device->sshParameters().host).arg(port); logMessage(tr("Server started on %1").arg(channel)); - const char *member = d->startServerOnly ? "gdbServerStarted" : "attachedToProcess"; - QObject *ob = ExtensionSystem::PluginManager::getObjectByName("DebuggerCore"); - if (ob) { - QMetaObject::invokeMethod(ob, member, Qt::QueuedConnection, - Q_ARG(QString, channel), - Q_ARG(QString, d->profileChooser->currentProfileId().toString()), - Q_ARG(QString, d->remoteCommandLine), - Q_ARG(QString, d->remoteExecutable)); + const Profile *profile = d->profileChooser->currentProfile(); + QTC_ASSERT(profile, return); + + if (d->startServerOnly) { + //showStatusMessage(tr("gdbserver is now listening at %1").arg(channel)); + } else { + QString sysroot = SysRootProfileInformation::sysRoot(profile).toString(); + QString binary; + QString localExecutable; + QString candidate = sysroot + d->remoteExecutable; + if (QFileInfo(candidate).exists()) + localExecutable = candidate; + if (localExecutable.isEmpty()) { + binary = d->remoteCommandLine.section(QLatin1Char(' '), 0, 0); + candidate = sysroot + QLatin1Char('/') + binary; + if (QFileInfo(candidate).exists()) + localExecutable = candidate; + } + if (localExecutable.isEmpty()) { + candidate = sysroot + QLatin1String("/usr/bin/") + binary; + if (QFileInfo(candidate).exists()) + localExecutable = candidate; + } + if (localExecutable.isEmpty()) { + candidate = sysroot + QLatin1String("/bin/") + binary; + if (QFileInfo(candidate).exists()) + localExecutable = candidate; + } + if (localExecutable.isEmpty()) { + QMessageBox::warning(DebuggerPlugin::mainWindow(), tr("Warning"), + tr("Cannot find local executable for remote process \"%1\".") + .arg(d->remoteCommandLine)); + return; + } + + QList<Abi> abis = Abi::abisOfBinary(Utils::FileName::fromString(localExecutable)); + if (abis.isEmpty()) { + QMessageBox::warning(DebuggerPlugin::mainWindow(), tr("Warning"), + tr("Cannot find ABI for remote process \"%1\".") + .arg(d->remoteCommandLine)); + return; + } + + DebuggerStartParameters sp; + sp.displayName = tr("Remote: \"%1\"").arg(channel); + sp.remoteChannel = channel; + sp.executable = localExecutable; + sp.startMode = AttachToRemoteServer; + sp.closeMode = KillAtClose; + sp.overrideStartScript.clear(); + sp.useServerStartScript = false; + sp.serverStartScript.clear(); + sp.sysRoot = SysRootProfileInformation::sysRoot(profile).toString(); + sp.debuggerCommand = DebuggerProfileInformation::debuggerCommand(profile).toString(); + sp.connParams = device->sshParameters(); + if (ToolChain *tc = ToolChainProfileInformation::toolChain(profile)) + sp.toolChainAbi = tc->targetAbi(); + + if (RunControl *rc = DebuggerPlugin::createDebugger(sp)) + DebuggerPlugin::startDebugger(rc); } - close(); } void StartGdbServerDialog::handleProcessClosed(int status) @@ -386,4 +443,4 @@ void StartGdbServerDialog::startGdbServerOnPort(int port, int pid) d->runner.run(cmd, device->sshParameters()); } -} // namespace RemoteLinux +} // namespace Debugger diff --git a/src/plugins/remotelinux/startgdbserverdialog.h b/src/plugins/debugger/gdb/startgdbserverdialog.h similarity index 91% rename from src/plugins/remotelinux/startgdbserverdialog.h rename to src/plugins/debugger/gdb/startgdbserverdialog.h index 2bd0c367938..74dd0231bce 100644 --- a/src/plugins/remotelinux/startgdbserverdialog.h +++ b/src/plugins/debugger/gdb/startgdbserverdialog.h @@ -31,20 +31,20 @@ #ifndef STARTGDBSERVERDIALOG_H #define STARTGDBSERVERDIALOG_H -#include "remotelinux_export.h" +#include "debugger_global.h" #include <QDialog> -namespace RemoteLinux { +namespace Debugger { namespace Internal { class StartGdbServerDialogPrivate; } -class REMOTELINUX_EXPORT StartGdbServerDialog : public QDialog +class DEBUGGER_EXPORT StartGdbServerDialog : public QDialog { Q_OBJECT public: - explicit StartGdbServerDialog(QWidget *parent = 0); + StartGdbServerDialog(QWidget *parent); ~StartGdbServerDialog(); void startGdbServer(); @@ -78,6 +78,6 @@ private: Internal::StartGdbServerDialogPrivate *d; }; -} // namespace RemoteLinux +} // namespace Debugger #endif // STARTGDBSERVERDIALOG_H diff --git a/src/plugins/projectexplorer/devicesupport/deviceusedportsgatherer.h b/src/plugins/projectexplorer/devicesupport/deviceusedportsgatherer.h index 0d4cb244f11..3f6e49cedc3 100644 --- a/src/plugins/projectexplorer/devicesupport/deviceusedportsgatherer.h +++ b/src/plugins/projectexplorer/devicesupport/deviceusedportsgatherer.h @@ -1,4 +1,4 @@ -/************************************************************************** +/*************DeviceUsedPortsGatherer********************************* ** ** This file is part of Qt Creator ** @@ -42,7 +42,7 @@ class PROJECTEXPLORER_EXPORT DeviceUsedPortsGatherer : public QObject Q_OBJECT public: - explicit DeviceUsedPortsGatherer(QObject *parent = 0); + DeviceUsedPortsGatherer(QObject *parent = 0); ~DeviceUsedPortsGatherer(); void start(const ProjectExplorer::IDevice::ConstPtr &devConf); diff --git a/src/plugins/qnx/qnxdebugsupport.cpp b/src/plugins/qnx/qnxdebugsupport.cpp index 039d5f7cd5c..afda2edac5b 100644 --- a/src/plugins/qnx/qnxdebugsupport.cpp +++ b/src/plugins/qnx/qnxdebugsupport.cpp @@ -38,7 +38,6 @@ #include <debugger/debuggerengine.h> #include <utils/qtcassert.h> -using namespace Qnx; using namespace Qnx::Internal; QnxDebugSupport::QnxDebugSupport(QnxRunConfiguration *runConfig, Debugger::DebuggerEngine *engine) diff --git a/src/plugins/qnx/qnxdeviceconfigurationwizard.cpp b/src/plugins/qnx/qnxdeviceconfigurationwizard.cpp index 6b736407ac1..793e9adc08c 100644 --- a/src/plugins/qnx/qnxdeviceconfigurationwizard.cpp +++ b/src/plugins/qnx/qnxdeviceconfigurationwizard.cpp @@ -42,7 +42,6 @@ #include <remotelinux/linuxdevicetestdialog.h> #include <remotelinux/linuxdevicetester.h> #include <utils/portlist.h> -#include <ssh/sshconnection.h> using namespace ProjectExplorer; using namespace Qnx; diff --git a/src/plugins/remotelinux/linuxdevicetester.h b/src/plugins/remotelinux/linuxdevicetester.h index d4b1467596a..9eaeb6cf9ad 100644 --- a/src/plugins/remotelinux/linuxdevicetester.h +++ b/src/plugins/remotelinux/linuxdevicetester.h @@ -37,10 +37,13 @@ namespace ProjectExplorer { class DeviceUsedPortsGatherer; } namespace QSsh { class SshConnection; } +namespace ProjectExplorer { class DeviceUsedPortsGatherer; } namespace RemoteLinux { -namespace Internal { class GenericLinuxDeviceTesterPrivate; } +namespace Internal { +class GenericLinuxDeviceTesterPrivate; +} class REMOTELINUX_EXPORT AbstractLinuxDeviceTester : public QObject { diff --git a/src/plugins/remotelinux/remotelinux.pro b/src/plugins/remotelinux/remotelinux.pro index 263d3ae0fdd..898f7cdf456 100644 --- a/src/plugins/remotelinux/remotelinux.pro +++ b/src/plugins/remotelinux/remotelinux.pro @@ -48,7 +48,6 @@ HEADERS += \ deploymentsettingsassistant.h \ remotelinuxdeployconfigurationwidget.h \ profilesupdatedialog.h \ - startgdbserverdialog.h \ remotelinuxcustomcommanddeployservice.h \ remotelinuxcustomcommanddeploymentstep.h \ genericlinuxdeviceconfigurationwidget.h \ @@ -95,7 +94,6 @@ SOURCES += \ deploymentsettingsassistant.cpp \ remotelinuxdeployconfigurationwidget.cpp \ profilesupdatedialog.cpp \ - startgdbserverdialog.cpp \ remotelinuxcustomcommanddeployservice.cpp \ remotelinuxcustomcommanddeploymentstep.cpp \ genericlinuxdeviceconfigurationwidget.cpp \ diff --git a/src/plugins/remotelinux/remotelinux.qbs b/src/plugins/remotelinux/remotelinux.qbs index 1b0afe7d225..2236fe1511b 100644 --- a/src/plugins/remotelinux/remotelinux.qbs +++ b/src/plugins/remotelinux/remotelinux.qbs @@ -89,8 +89,6 @@ QtcPlugin { "remotelinuxruncontrol.h", "remotelinuxutils.cpp", "remotelinuxutils.h", - "startgdbserverdialog.cpp", - "startgdbserverdialog.h", "tarpackagecreationstep.h", "uploadandinstalltarpackagestep.h", "genericdirectuploadservice.h", diff --git a/src/plugins/remotelinux/remotelinuxplugin.cpp b/src/plugins/remotelinux/remotelinuxplugin.cpp index de1763e0165..42e291aaa33 100644 --- a/src/plugins/remotelinux/remotelinuxplugin.cpp +++ b/src/plugins/remotelinux/remotelinuxplugin.cpp @@ -38,15 +38,12 @@ #include "remotelinuxdeployconfigurationfactory.h" #include "remotelinuxrunconfigurationfactory.h" #include "remotelinuxruncontrolfactory.h" -#include "startgdbserverdialog.h" #include <coreplugin/icore.h> #include <coreplugin/coreconstants.h> #include <coreplugin/actionmanager/actionmanager.h> #include <coreplugin/actionmanager/actioncontainer.h> -#include <debugger/debuggerconstants.h> - #include <projectexplorer/projectexplorerconstants.h> #include <QtPlugin> @@ -89,18 +86,6 @@ void RemoteLinuxPlugin::extensionsInitialized() { } -void RemoteLinuxPlugin::startGdbServer() -{ - StartGdbServerDialog dlg; - dlg.startGdbServer(); -} - -void RemoteLinuxPlugin::attachToRemoteProcess() -{ - StartGdbServerDialog dlg; - dlg.attachToRemoteProcess(); -} - } // namespace Internal } // namespace RemoteLinux diff --git a/src/plugins/remotelinux/remotelinuxplugin.h b/src/plugins/remotelinux/remotelinuxplugin.h index 6a9454c87d8..bac83c687a7 100644 --- a/src/plugins/remotelinux/remotelinuxplugin.h +++ b/src/plugins/remotelinux/remotelinuxplugin.h @@ -47,10 +47,6 @@ public: bool initialize(const QStringList &arguments, QString *errorMessage); void extensionsInitialized(); - -private slots: - void startGdbServer(); - void attachToRemoteProcess(); }; } // namespace Internal -- GitLab