debugger: move startgdbserverdialog from remotelinux plugins

Change-Id: Ic382437bb99fe1b6bda9b1252e286cb3b9476191
Reviewed-by: Christian Kandeler <christian.kandeler@nokia.com>
This commit is contained in:
hjk
2012-07-27 00:17:12 +02:00
committed by Christian Kandeler
parent 59187d18d5
commit 1283233f4b
14 changed files with 102 additions and 141 deletions

View File

@@ -192,6 +192,8 @@ QtcPlugin {
"gdb/gdbengine.h", "gdb/gdbengine.h",
"gdb/gdboptionspage.cpp", "gdb/gdboptionspage.cpp",
"gdb/termgdbadapter.cpp", "gdb/termgdbadapter.cpp",
"gdb/startgdbserverdialog.cpp",
"gdb/startgdbserverdialog.h",
"images/breakpoint_16.png", "images/breakpoint_16.png",
"images/breakpoint_24.png", "images/breakpoint_24.png",
"images/breakpoint_disabled_16.png", "images/breakpoint_disabled_16.png",

View File

@@ -67,6 +67,7 @@
#include "snapshothandler.h" #include "snapshothandler.h"
#include "threadshandler.h" #include "threadshandler.h"
#include "commonoptionspage.h" #include "commonoptionspage.h"
#include "gdb/startgdbserverdialog.h"
#include <coreplugin/actionmanager/actionmanager.h> #include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/actionmanager/actioncontainer.h> #include <coreplugin/actionmanager/actioncontainer.h>
@@ -1093,16 +1094,11 @@ public slots:
unsigned *enabledEngines, QString *errorMessage); unsigned *enabledEngines, QString *errorMessage);
DebuggerToolTipManager *toolTipManager() const { return m_toolTipManager; } DebuggerToolTipManager *toolTipManager() const { return m_toolTipManager; }
virtual QSharedPointer<GlobalDebuggerOptions> globalDebuggerOptions() const { return m_globalDebuggerOptions; } QSharedPointer<GlobalDebuggerOptions> globalDebuggerOptions() const { return m_globalDebuggerOptions; }
// FIXME: Remove. // FIXME: Remove.
void maybeEnrichParameters(DebuggerStartParameters *sp); 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() { void updateQmlActions() {
action(QmlUpdateOnSave)->setEnabled(boolSetting(ShowQmlObjectTree)); action(QmlUpdateOnSave)->setEnabled(boolSetting(ShowQmlObjectTree));
} }
@@ -1671,88 +1667,14 @@ void DebuggerPluginPrivate::attachToRemoteServer()
void DebuggerPluginPrivate::startRemoteServer() void DebuggerPluginPrivate::startRemoteServer()
{ {
QObject *rl = PluginManager::getObjectByName(_("RemoteLinuxPlugin")); StartGdbServerDialog dlg(mainWindow());
QTC_ASSERT(rl, return); dlg.startGdbServer();
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));
} }
void DebuggerPluginPrivate::attachToRemoteProcess() void DebuggerPluginPrivate::attachToRemoteProcess()
{ {
QObject *rl = PluginManager::getObjectByName(_("RemoteLinuxPlugin")); StartGdbServerDialog dlg(mainWindow());
QTC_ASSERT(rl, return); dlg.attachToRemoteProcess();
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);
} }
void DebuggerPluginPrivate::attachToQmlPort() void DebuggerPluginPrivate::attachToQmlPort()

View File

@@ -18,7 +18,7 @@
** **
** In addition, as a special exception, Nokia gives you certain additional ** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception ** 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 ** Other Usage
** **

View File

@@ -13,6 +13,7 @@ HEADERS += \
$$PWD/remotegdbprocess.h \ $$PWD/remotegdbprocess.h \
$$PWD/remoteplaingdbadapter.h \ $$PWD/remoteplaingdbadapter.h \
$$PWD/abstractplaingdbadapter.h \ $$PWD/abstractplaingdbadapter.h \
$$PWD/startgdbserverdialog.h \
$$PWD/symbian.h $$PWD/symbian.h
SOURCES += \ SOURCES += \
@@ -32,6 +33,7 @@ SOURCES += \
$$PWD/remotegdbprocess.cpp \ $$PWD/remotegdbprocess.cpp \
$$PWD/remoteplaingdbadapter.cpp \ $$PWD/remoteplaingdbadapter.cpp \
$$PWD/abstractplaingdbadapter.cpp \ $$PWD/abstractplaingdbadapter.cpp \
$$PWD/startgdbserverdialog.cpp \
$$PWD/symbian.cpp $$PWD/symbian.cpp
RESOURCES += $$PWD/gdb.qrc RESOURCES += $$PWD/gdb.qrc

View File

@@ -30,18 +30,23 @@
#include "startgdbserverdialog.h" #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 <coreplugin/icore.h>
#include <extensionsystem/pluginmanager.h> #include <extensionsystem/pluginmanager.h>
#include <projectexplorer/profilechooser.h> #include <projectexplorer/profilechooser.h>
#include <projectexplorer/profileinformation.h>
#include <projectexplorer/devicesupport/deviceprocesslist.h> #include <projectexplorer/devicesupport/deviceprocesslist.h>
#include <projectexplorer/devicesupport/deviceusedportsgatherer.h> #include <projectexplorer/devicesupport/deviceusedportsgatherer.h>
#include <ssh/sshconnection.h>
#include <ssh/sshremoteprocessrunner.h>
#include <utils/pathchooser.h> #include <utils/pathchooser.h>
#include <utils/portlist.h> #include <utils/portlist.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <ssh/sshconnection.h>
#include <ssh/sshremoteprocessrunner.h>
#include <QVariant> #include <QVariant>
#include <QSettings> #include <QSettings>
@@ -70,12 +75,12 @@ using namespace ProjectExplorer;
using namespace QSsh; using namespace QSsh;
using namespace Utils; using namespace Utils;
const char LastProfile[] = "RemoteLinux/LastProfile"; const char LastProfile[] = "Debugger/LastProfile";
const char LastDevice[] = "RemoteLinux/LastDevice"; const char LastDevice[] = "Debugger/LastDevice";
const char LastProcessName[] = "RemoteLinux/LastProcessName"; const char LastProcessName[] = "Debugger/LastProcessName";
//const char LastLocalExecutable[] = "RemoteLinux/LastLocalExecutable"; //const char LastLocalExecutable[] = "Debugger/LastLocalExecutable";
namespace RemoteLinux { namespace Debugger {
namespace Internal { namespace Internal {
class StartGdbServerDialogPrivate class StartGdbServerDialogPrivate
@@ -103,7 +108,6 @@ public:
DeviceUsedPortsGatherer gatherer; DeviceUsedPortsGatherer gatherer;
SshRemoteProcessRunner runner; SshRemoteProcessRunner runner;
QSettings *settings;
QString remoteCommandLine; QString remoteCommandLine;
QString remoteExecutable; QString remoteExecutable;
}; };
@@ -111,7 +115,7 @@ public:
StartGdbServerDialogPrivate::StartGdbServerDialogPrivate(StartGdbServerDialog *q) StartGdbServerDialogPrivate::StartGdbServerDialogPrivate(StartGdbServerDialog *q)
: q(q), startServerOnly(true), processList(0) : q(q), startServerOnly(true), processList(0)
{ {
settings = ICore::settings(); QSettings *settings = ICore::settings();
profileChooser = new ProfileChooser(q, ProfileChooser::RemoteDebugging); profileChooser = new ProfileChooser(q, ProfileChooser::RemoteDebugging);
@@ -261,8 +265,9 @@ void StartGdbServerDialog::attachToProcess()
return; return;
} }
d->settings->setValue(LastProfile, d->profileChooser->currentProfileId().toString()); QSettings *settings = ICore::settings();
d->settings->setValue(LastProcessName, d->processFilterLineEdit->text()); settings->setValue(LastProfile, d->profileChooser->currentProfileId().toString());
settings->setValue(LastProcessName, d->processFilterLineEdit->text());
startGdbServerOnPort(port, process.pid); startGdbServerOnPort(port, process.pid);
} }
@@ -349,21 +354,73 @@ void StartGdbServerDialog::handleProcessErrorOutput()
void StartGdbServerDialog::reportOpenPort(int port) void StartGdbServerDialog::reportOpenPort(int port)
{ {
close();
logMessage(tr("Port %1 is now accessible.").arg(port)); logMessage(tr("Port %1 is now accessible.").arg(port));
IDevice::ConstPtr device = d->currentDevice(); IDevice::ConstPtr device = d->currentDevice();
QString channel = QString("%1:%2").arg(device->sshParameters().host).arg(port); QString channel = QString("%1:%2").arg(device->sshParameters().host).arg(port);
logMessage(tr("Server started on %1").arg(channel)); logMessage(tr("Server started on %1").arg(channel));
const char *member = d->startServerOnly ? "gdbServerStarted" : "attachedToProcess"; const Profile *profile = d->profileChooser->currentProfile();
QObject *ob = ExtensionSystem::PluginManager::getObjectByName("DebuggerCore"); QTC_ASSERT(profile, return);
if (ob) {
QMetaObject::invokeMethod(ob, member, Qt::QueuedConnection, if (d->startServerOnly) {
Q_ARG(QString, channel), //showStatusMessage(tr("gdbserver is now listening at %1").arg(channel));
Q_ARG(QString, d->profileChooser->currentProfileId().toString()), } else {
Q_ARG(QString, d->remoteCommandLine), QString sysroot = SysRootProfileInformation::sysRoot(profile).toString();
Q_ARG(QString, d->remoteExecutable)); 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) void StartGdbServerDialog::handleProcessClosed(int status)
@@ -386,4 +443,4 @@ void StartGdbServerDialog::startGdbServerOnPort(int port, int pid)
d->runner.run(cmd, device->sshParameters()); d->runner.run(cmd, device->sshParameters());
} }
} // namespace RemoteLinux } // namespace Debugger

View File

@@ -31,20 +31,20 @@
#ifndef STARTGDBSERVERDIALOG_H #ifndef STARTGDBSERVERDIALOG_H
#define STARTGDBSERVERDIALOG_H #define STARTGDBSERVERDIALOG_H
#include "remotelinux_export.h" #include "debugger_global.h"
#include <QDialog> #include <QDialog>
namespace RemoteLinux { namespace Debugger {
namespace Internal { class StartGdbServerDialogPrivate; } namespace Internal { class StartGdbServerDialogPrivate; }
class REMOTELINUX_EXPORT StartGdbServerDialog : public QDialog class DEBUGGER_EXPORT StartGdbServerDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit StartGdbServerDialog(QWidget *parent = 0); StartGdbServerDialog(QWidget *parent);
~StartGdbServerDialog(); ~StartGdbServerDialog();
void startGdbServer(); void startGdbServer();
@@ -78,6 +78,6 @@ private:
Internal::StartGdbServerDialogPrivate *d; Internal::StartGdbServerDialogPrivate *d;
}; };
} // namespace RemoteLinux } // namespace Debugger
#endif // STARTGDBSERVERDIALOG_H #endif // STARTGDBSERVERDIALOG_H

View File

@@ -1,4 +1,4 @@
/************************************************************************** /*************DeviceUsedPortsGatherer*********************************
** **
** This file is part of Qt Creator ** This file is part of Qt Creator
** **
@@ -42,7 +42,7 @@ class PROJECTEXPLORER_EXPORT DeviceUsedPortsGatherer : public QObject
Q_OBJECT Q_OBJECT
public: public:
explicit DeviceUsedPortsGatherer(QObject *parent = 0); DeviceUsedPortsGatherer(QObject *parent = 0);
~DeviceUsedPortsGatherer(); ~DeviceUsedPortsGatherer();
void start(const ProjectExplorer::IDevice::ConstPtr &devConf); void start(const ProjectExplorer::IDevice::ConstPtr &devConf);

View File

@@ -38,7 +38,6 @@
#include <debugger/debuggerengine.h> #include <debugger/debuggerengine.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
using namespace Qnx;
using namespace Qnx::Internal; using namespace Qnx::Internal;
QnxDebugSupport::QnxDebugSupport(QnxRunConfiguration *runConfig, Debugger::DebuggerEngine *engine) QnxDebugSupport::QnxDebugSupport(QnxRunConfiguration *runConfig, Debugger::DebuggerEngine *engine)

View File

@@ -42,7 +42,6 @@
#include <remotelinux/linuxdevicetestdialog.h> #include <remotelinux/linuxdevicetestdialog.h>
#include <remotelinux/linuxdevicetester.h> #include <remotelinux/linuxdevicetester.h>
#include <utils/portlist.h> #include <utils/portlist.h>
#include <ssh/sshconnection.h>
using namespace ProjectExplorer; using namespace ProjectExplorer;
using namespace Qnx; using namespace Qnx;

View File

@@ -37,10 +37,13 @@
namespace ProjectExplorer { class DeviceUsedPortsGatherer; } namespace ProjectExplorer { class DeviceUsedPortsGatherer; }
namespace QSsh { class SshConnection; } namespace QSsh { class SshConnection; }
namespace ProjectExplorer { class DeviceUsedPortsGatherer; }
namespace RemoteLinux { namespace RemoteLinux {
namespace Internal { class GenericLinuxDeviceTesterPrivate; } namespace Internal {
class GenericLinuxDeviceTesterPrivate;
}
class REMOTELINUX_EXPORT AbstractLinuxDeviceTester : public QObject class REMOTELINUX_EXPORT AbstractLinuxDeviceTester : public QObject
{ {

View File

@@ -48,7 +48,6 @@ HEADERS += \
deploymentsettingsassistant.h \ deploymentsettingsassistant.h \
remotelinuxdeployconfigurationwidget.h \ remotelinuxdeployconfigurationwidget.h \
profilesupdatedialog.h \ profilesupdatedialog.h \
startgdbserverdialog.h \
remotelinuxcustomcommanddeployservice.h \ remotelinuxcustomcommanddeployservice.h \
remotelinuxcustomcommanddeploymentstep.h \ remotelinuxcustomcommanddeploymentstep.h \
genericlinuxdeviceconfigurationwidget.h \ genericlinuxdeviceconfigurationwidget.h \
@@ -95,7 +94,6 @@ SOURCES += \
deploymentsettingsassistant.cpp \ deploymentsettingsassistant.cpp \
remotelinuxdeployconfigurationwidget.cpp \ remotelinuxdeployconfigurationwidget.cpp \
profilesupdatedialog.cpp \ profilesupdatedialog.cpp \
startgdbserverdialog.cpp \
remotelinuxcustomcommanddeployservice.cpp \ remotelinuxcustomcommanddeployservice.cpp \
remotelinuxcustomcommanddeploymentstep.cpp \ remotelinuxcustomcommanddeploymentstep.cpp \
genericlinuxdeviceconfigurationwidget.cpp \ genericlinuxdeviceconfigurationwidget.cpp \

View File

@@ -89,8 +89,6 @@ QtcPlugin {
"remotelinuxruncontrol.h", "remotelinuxruncontrol.h",
"remotelinuxutils.cpp", "remotelinuxutils.cpp",
"remotelinuxutils.h", "remotelinuxutils.h",
"startgdbserverdialog.cpp",
"startgdbserverdialog.h",
"tarpackagecreationstep.h", "tarpackagecreationstep.h",
"uploadandinstalltarpackagestep.h", "uploadandinstalltarpackagestep.h",
"genericdirectuploadservice.h", "genericdirectuploadservice.h",

View File

@@ -38,15 +38,12 @@
#include "remotelinuxdeployconfigurationfactory.h" #include "remotelinuxdeployconfigurationfactory.h"
#include "remotelinuxrunconfigurationfactory.h" #include "remotelinuxrunconfigurationfactory.h"
#include "remotelinuxruncontrolfactory.h" #include "remotelinuxruncontrolfactory.h"
#include "startgdbserverdialog.h"
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <coreplugin/coreconstants.h> #include <coreplugin/coreconstants.h>
#include <coreplugin/actionmanager/actionmanager.h> #include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/actionmanager/actioncontainer.h> #include <coreplugin/actionmanager/actioncontainer.h>
#include <debugger/debuggerconstants.h>
#include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/projectexplorerconstants.h>
#include <QtPlugin> #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 Internal
} // namespace RemoteLinux } // namespace RemoteLinux

View File

@@ -47,10 +47,6 @@ public:
bool initialize(const QStringList &arguments, QString *errorMessage); bool initialize(const QStringList &arguments, QString *errorMessage);
void extensionsInitialized(); void extensionsInitialized();
private slots:
void startGdbServer();
void attachToRemoteProcess();
}; };
} // namespace Internal } // namespace Internal