Commit 1283233f authored by hjk's avatar hjk Committed by Christian Kandeler

debugger: move startgdbserverdialog from remotelinux plugins

Change-Id: Ic382437bb99fe1b6bda9b1252e286cb3b9476191
Reviewed-by: default avatarChristian Kandeler <christian.kandeler@nokia.com>
parent 59187d18
......@@ -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",
......
......@@ -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()
......
......@@ -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
**
......
......@@ -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
......@@ -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
......@@ -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
/**************************************************************************
/*************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);
......
......@@ -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)
......
......@@ -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;
......
......@@ -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
{
......
......@@ -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 \
......
......@@ -89,8 +89,6 @@ QtcPlugin {
"remotelinuxruncontrol.h",
"remotelinuxutils.cpp",
"remotelinuxutils.h",
"startgdbserverdialog.cpp",
"startgdbserverdialog.h",
"tarpackagecreationstep.h",
"uploadandinstalltarpackagestep.h",
"genericdirectuploadservice.h",
......
......@@ -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
......
......@@ -47,10 +47,6 @@ public:
bool initialize(const QStringList &arguments, QString *errorMessage);
void extensionsInitialized();
private slots:
void startGdbServer();
void attachToRemoteProcess();
};
} // namespace Internal
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment