debugger: make Attach to Remote... dialogs better accessible

Change-Id: Ic20897a565c37d45d1521c8934ae0c4759fdef01
Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
hjk
2012-03-21 17:54:56 +01:00
committed by hjk
parent b9dfbd8ec3
commit b80e648dbf
4 changed files with 54 additions and 50 deletions

View File

@@ -1115,6 +1115,7 @@ public slots:
void maybeEnrichParameters(DebuggerStartParameters *sp); void maybeEnrichParameters(DebuggerStartParameters *sp);
void gdbServerStarted(const QString &channel, const QString &sysroot, const QString &localExecutable); void gdbServerStarted(const QString &channel, const QString &sysroot, const QString &localExecutable);
void attachedToProcess(const QString &channel, const QString &sysroot, const QString &localExecutable);
public: public:
DebuggerMainWindow *m_mainWindow; DebuggerMainWindow *m_mainWindow;
@@ -1672,11 +1673,6 @@ void DebuggerPluginPrivate::attachToRemoteServer()
} }
} }
void DebuggerPluginPrivate::attachToRemoteProcess()
{
startRemoteServer();
}
void DebuggerPluginPrivate::startRemoteServer() void DebuggerPluginPrivate::startRemoteServer()
{ {
PluginManager *pm = PluginManager::instance(); PluginManager *pm = PluginManager::instance();
@@ -1689,6 +1685,24 @@ void DebuggerPluginPrivate::startRemoteServer()
void DebuggerPluginPrivate::gdbServerStarted(const QString &channel, void DebuggerPluginPrivate::gdbServerStarted(const QString &channel,
const QString &sysroot, const QString &remoteCommandLine) const QString &sysroot, const QString &remoteCommandLine)
{
Q_UNUSED(remoteCommandLine);
Q_UNUSED(sysroot);
showStatusMessage(tr("gdbserver is now listening at %1").arg(channel));
}
void DebuggerPluginPrivate::attachToRemoteProcess()
{
PluginManager *pm = PluginManager::instance();
QTC_ASSERT(pm, return);
QObject *rl = pm->getObjectByName(_("RemoteLinuxPlugin"));
QTC_ASSERT(rl, return);
QMetaObject::invokeMethod(rl, "attachToRemoteProcess", Qt::QueuedConnection);
// This will call back attachedtToProcess() below.
}
void DebuggerPluginPrivate::attachedToProcess(const QString &channel,
const QString &sysroot, const QString &remoteCommandLine)
{ {
QString binary = remoteCommandLine.section(QLatin1Char(' '), 0, 0); QString binary = remoteCommandLine.section(QLatin1Char(' '), 0, 0);
QString localExecutable; QString localExecutable;
@@ -3074,7 +3088,7 @@ void DebuggerPluginPrivate::extensionsInitialized()
connect(act, SIGNAL(triggered()), SLOT(attachToRemoteServer())); connect(act, SIGNAL(triggered()), SLOT(attachToRemoteServer()));
act = m_startRemoteServerAction = new QAction(this); act = m_startRemoteServerAction = new QAction(this);
act->setText(tr("Start Remote Debug Server...")); act->setText(tr("Start Remote Debug Server Attached to Process..."));
connect(act, SIGNAL(triggered()), SLOT(startRemoteServer())); connect(act, SIGNAL(triggered()), SLOT(startRemoteServer()));
act = m_attachToRemoteProcessAction = new QAction(this); act = m_attachToRemoteProcessAction = new QAction(this);

View File

@@ -96,41 +96,20 @@ RemoteLinuxPlugin::~RemoteLinuxPlugin()
void RemoteLinuxPlugin::extensionsInitialized() void RemoteLinuxPlugin::extensionsInitialized()
{ {
/*
using namespace Core;
ICore *core = ICore::instance();
ActionManager *am = core->actionManager();
ActionContainer *mstart =
am->actionContainer(ProjectExplorer::Constants::M_DEBUG_STARTDEBUGGING);
const Context globalcontext(Core::Constants::C_GLOBAL);
QAction *act = 0;
Command *cmd = 0;
act = new QAction(tr("Start Remote Debug Server..."), 0);
cmd = am->registerAction(act, "StartGdbServer", globalcontext);
cmd->setDescription(tr("Start Gdbserver"));
mstart->addAction(cmd, Debugger::Constants::G_MANUAL_REMOTE);
connect(act, SIGNAL(triggered()), SLOT(startGdbServer()));
act = new QAction(tr("Attach to Running Remote Process..."), 0);
cmd = am->registerAction(act, "AttachRemoteProcess", globalcontext);
cmd->setDescription(tr("Attach to Remote Process"));
mstart->addAction(cmd, Debugger::Constants::G_AUTOMATIC_REMOTE);
connect(act, SIGNAL(triggered()), SLOT(startGdbServer()));
*/
} }
void RemoteLinuxPlugin::startGdbServer() void RemoteLinuxPlugin::startGdbServer()
{ {
StartGdbServerDialog dlg; StartGdbServerDialog dlg;
int result = dlg.exec();
if (result == QDialog::Rejected)
return;
dlg.startGdbServer(); dlg.startGdbServer();
} }
void RemoteLinuxPlugin::attachToRemoteProcess()
{
StartGdbServerDialog dlg;
dlg.attachToRemoteProcess();
}
} // namespace Internal } // namespace Internal
} // namespace RemoteLinux } // namespace RemoteLinux

View File

@@ -51,6 +51,7 @@ public:
private slots: private slots:
void startGdbServer(); void startGdbServer();
void attachToRemoteProcess();
}; };
} // namespace Internal } // namespace Internal

View File

@@ -92,6 +92,7 @@ public:
} }
StartGdbServerDialog *q; StartGdbServerDialog *q;
bool startServerOnly;
AbstractRemoteLinuxProcessList *processList; AbstractRemoteLinuxProcessList *processList;
QSortFilterProxyModel proxyModel; QSortFilterProxyModel proxyModel;
@@ -110,7 +111,7 @@ public:
}; };
StartGdbServerDialogPrivate::StartGdbServerDialogPrivate(StartGdbServerDialog *q) StartGdbServerDialogPrivate::StartGdbServerDialogPrivate(StartGdbServerDialog *q)
: q(q), processList(0) : q(q), startServerOnly(true), processList(0)
{ {
settings = ICore::settings(); settings = ICore::settings();
@@ -313,13 +314,20 @@ void StartGdbServerDialog::portListReady()
void StartGdbServerDialog::startGdbServer() void StartGdbServerDialog::startGdbServer()
{ {
d->startServerOnly = true;
if (exec() == QDialog::Rejected)
return;
LinuxDeviceConfiguration::ConstPtr device = d->currentDevice(); LinuxDeviceConfiguration::ConstPtr device = d->currentDevice();
d->gatherer.start(SshConnection::create(device->sshParameters()), device); d->gatherer.start(SshConnection::create(device->sshParameters()), device);
} }
void StartGdbServerDialog::attachToRemoteProcess() void StartGdbServerDialog::attachToRemoteProcess()
{ {
startGdbServer(); d->startServerOnly = false;
if (exec() == QDialog::Rejected)
return;
LinuxDeviceConfiguration::ConstPtr device = d->currentDevice();
d->gatherer.start(SshConnection::create(device->sshParameters()), device);
} }
void StartGdbServerDialog::handleConnectionError() void StartGdbServerDialog::handleConnectionError()
@@ -343,21 +351,17 @@ void StartGdbServerDialog::handleProcessErrorOutput(const QByteArray &ba)
logMessage(QString::fromUtf8(ba.trimmed())); logMessage(QString::fromUtf8(ba.trimmed()));
// "Attached; pid = 16740" // "Attached; pid = 16740"
// "Listening on port 10000" // "Listening on port 10000"
int pos = ba.indexOf("Listening on port"); foreach (const QByteArray &line, ba.split('\n')) {
if (pos == -1) if (line.startsWith("Listening on port")) {
return; const int port = line.mid(18).trimmed().toInt();
const int port = ba.mid(pos + 18).trimmed().toInt();
logMessage(tr("Port %1 is now accessible.").arg(port));
reportOpenPort(port); reportOpenPort(port);
}
}
} }
void StartGdbServerDialog::reportOpenPort(int port) void StartGdbServerDialog::reportOpenPort(int port)
{ {
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); logMessage(tr("Port %1 is now accessible.").arg(port));
QObject *ob = pm->getObjectByName("DebuggerCore");
if (!ob)
return;
LinuxDeviceConfiguration::ConstPtr device = d->currentDevice(); LinuxDeviceConfiguration::ConstPtr device = d->currentDevice();
QString host = device->sshParameters().host; QString host = device->sshParameters().host;
QString channel; QString channel;
@@ -367,10 +371,16 @@ void StartGdbServerDialog::reportOpenPort(int port)
channel = QString::fromLatin1("%1:%2").arg(host).arg(port); channel = QString::fromLatin1("%1:%2").arg(host).arg(port);
logMessage(tr("Server started on %1").arg(channel)); logMessage(tr("Server started on %1").arg(channel));
QMetaObject::invokeMethod(ob, "gdbServerStarted", Qt::QueuedConnection, const char *member = d->startServerOnly ? "gdbServerStarted" : "attachedToProcess";
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
QObject *ob = pm->getObjectByName("DebuggerCore");
if (ob) {
QMetaObject::invokeMethod(ob, member, Qt::QueuedConnection,
Q_ARG(QString, channel), Q_ARG(QString, channel),
Q_ARG(QString, d->sysrootPathChooser->path()), Q_ARG(QString, d->sysrootPathChooser->path()),
Q_ARG(QString, d->remoteCommandLine)); Q_ARG(QString, d->remoteCommandLine));
}
close();
} }
void StartGdbServerDialog::handleProcessClosed(int status) void StartGdbServerDialog::handleProcessClosed(int status)