ProjectExplorer: Use std::function for SimpleTargetRunner::start()

This spares us the typical r = runnable(); modify(r); setRunnable(r)
roundtrip and the m_runnable storage that might or might not
be the same as runControl->runnable. Similar for m_device.

Change-Id: I8300260dd8dd7cd395e40bcd3d2ae45089085008
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2019-09-02 18:22:35 +02:00
parent 8d85a7c2bc
commit 4028a41d2e
17 changed files with 222 additions and 290 deletions

View File

@@ -54,6 +54,18 @@ namespace Internal {
// BareMetalDebugSupport // BareMetalDebugSupport
class BareMetalGdbServer : public SimpleTargetRunner
{
public:
BareMetalGdbServer(RunControl *runControl, const Runnable &runnable)
: SimpleTargetRunner(runControl)
{
setId("BareMetalGdbServer");
// Baremetal's GDB servers are launched on the host, not on the target.
setStarter([this, runnable] { doStart(runnable, {}); });
}
};
BareMetalDebugSupport::BareMetalDebugSupport(RunControl *runControl) BareMetalDebugSupport::BareMetalDebugSupport(RunControl *runControl)
: Debugger::DebuggerRunTool(runControl) : Debugger::DebuggerRunTool(runControl)
{ {
@@ -75,9 +87,8 @@ BareMetalDebugSupport::BareMetalDebugSupport(RunControl *runControl)
r.setCommandLine(p->command()); r.setCommandLine(p->command());
// Command arguments are in host OS style as the bare metal's GDB servers are launched // Command arguments are in host OS style as the bare metal's GDB servers are launched
// on the host, not on that target. // on the host, not on that target.
m_gdbServer = new SimpleTargetRunner(runControl); auto gdbServer = new BareMetalGdbServer(runControl, r);
m_gdbServer->setRunnable(r); addStartDependency(gdbServer);
addStartDependency(m_gdbServer);
} }
} }

View File

@@ -41,8 +41,6 @@ public:
private: private:
void start() final; void start() final;
ProjectExplorer::SimpleTargetRunner *m_gdbServer = nullptr;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -138,15 +138,13 @@ class QdbDeviceRunSupport : public SimpleTargetRunner
public: public:
QdbDeviceRunSupport(RunControl *runControl) QdbDeviceRunSupport(RunControl *runControl)
: SimpleTargetRunner(runControl) : SimpleTargetRunner(runControl)
{}
void start() final
{ {
Runnable r = runnable(); setStarter([this, runControl] {
r.commandLineArguments = r.executable.toString() + ' ' + r.commandLineArguments; Runnable r = runControl->runnable();
r.executable = Utils::FilePath::fromString(Constants::AppcontrollerFilepath); r.commandLineArguments = r.executable.toString() + ' ' + r.commandLineArguments;
setRunnable(r); r.executable = Utils::FilePath::fromString(Constants::AppcontrollerFilepath);
SimpleTargetRunner::start(); doStart(r, runControl->device());
});
} }
}; };

View File

@@ -1656,7 +1656,6 @@ public:
auto gdbServer = new GdbServerRunner(runControl, portsGatherer()); auto gdbServer = new GdbServerRunner(runControl, portsGatherer());
gdbServer->setUseMulti(false); gdbServer->setUseMulti(false);
gdbServer->setDevice(runControl->device());
gdbServer->setAttachPid(ProcessHandle(pid)); gdbServer->setAttachPid(ProcessHandle(pid));
addStartDependency(gdbServer); addStartDependency(gdbServer);

View File

@@ -1050,20 +1050,53 @@ QUrl GdbServerPortsGatherer::qmlServer() const
// GdbServerRunner // GdbServerRunner
GdbServerRunner::GdbServerRunner(RunControl *runControl, GdbServerPortsGatherer *portsGatherer) GdbServerRunner::GdbServerRunner(RunControl *runControl, GdbServerPortsGatherer *portsGatherer)
: SimpleTargetRunner(runControl), m_portsGatherer(portsGatherer) : SimpleTargetRunner(runControl)
{ {
setId("GdbServerRunner"); setId("GdbServerRunner");
m_runnable = runControl->runnable(); const Runnable mainRunnable = runControl->runnable();
addStartDependency(m_portsGatherer); addStartDependency(portsGatherer);
QTC_ASSERT(portsGatherer, reportFailure(); return);
setStarter([this, runControl, mainRunnable, portsGatherer] {
QTC_ASSERT(portsGatherer, reportFailure(); return);
Runnable gdbserver;
gdbserver.environment = mainRunnable.environment;
gdbserver.workingDirectory = mainRunnable.workingDirectory;
QStringList args = QtcProcess::splitArgs(mainRunnable.commandLineArguments, OsTypeLinux);
const bool isQmlDebugging = portsGatherer->useQmlServer();
const bool isCppDebugging = portsGatherer->useGdbServer();
if (isQmlDebugging) {
args.prepend(QmlDebug::qmlDebugTcpArguments(QmlDebug::QmlDebuggerServices,
portsGatherer->qmlServer()));
}
if (isQmlDebugging && !isCppDebugging) {
gdbserver.executable = mainRunnable.executable; // FIXME: Case should not happen?
} else {
gdbserver.executable = FilePath::fromString(runControl->device()->debugServerPath());
if (gdbserver.executable.isEmpty())
gdbserver.executable = FilePath::fromString("gdbserver");
args.clear();
if (m_useMulti)
args.append("--multi");
if (m_pid.isValid())
args.append("--attach");
args.append(QString(":%1").arg(portsGatherer->gdbServer().port()));
if (m_pid.isValid())
args.append(QString::number(m_pid.pid()));
}
gdbserver.commandLineArguments = QtcProcess::joinArgs(args, OsTypeLinux);
doStart(gdbserver, runControl->device());
});
} }
GdbServerRunner::~GdbServerRunner() = default; GdbServerRunner::~GdbServerRunner() = default;
void GdbServerRunner::setRunnable(const Runnable &runnable)
{
m_runnable = runnable;
}
void GdbServerRunner::setUseMulti(bool on) void GdbServerRunner::setUseMulti(bool on)
{ {
m_useMulti = on; m_useMulti = on;
@@ -1074,42 +1107,4 @@ void GdbServerRunner::setAttachPid(ProcessHandle pid)
m_pid = pid; m_pid = pid;
} }
void GdbServerRunner::start()
{
QTC_ASSERT(m_portsGatherer, reportFailure(); return);
Runnable gdbserver;
gdbserver.environment = m_runnable.environment;
gdbserver.workingDirectory = m_runnable.workingDirectory;
QStringList args = QtcProcess::splitArgs(m_runnable.commandLineArguments, OsTypeLinux);
const bool isQmlDebugging = m_portsGatherer->useQmlServer();
const bool isCppDebugging = m_portsGatherer->useGdbServer();
if (isQmlDebugging) {
args.prepend(QmlDebug::qmlDebugTcpArguments(QmlDebug::QmlDebuggerServices,
m_portsGatherer->qmlServer()));
}
if (isQmlDebugging && !isCppDebugging) {
gdbserver.executable = m_runnable.executable; // FIXME: Case should not happen?
} else {
gdbserver.executable = FilePath::fromString(device()->debugServerPath());
if (gdbserver.executable.isEmpty())
gdbserver.executable = FilePath::fromString("gdbserver");
args.clear();
if (m_useMulti)
args.append("--multi");
if (m_pid.isValid())
args.append("--attach");
args.append(QString(":%1").arg(m_portsGatherer->gdbServer().port()));
if (m_pid.isValid())
args.append(QString::number(m_pid.pid()));
}
gdbserver.commandLineArguments = QtcProcess::joinArgs(args, OsTypeLinux);
SimpleTargetRunner::setRunnable(gdbserver);
SimpleTargetRunner::start();
}
} // namespace Debugger } // namespace Debugger

View File

@@ -166,15 +166,10 @@ public:
~GdbServerRunner() override; ~GdbServerRunner() override;
void setRunnable(const ProjectExplorer::Runnable &runnable);
void setUseMulti(bool on); void setUseMulti(bool on);
void setAttachPid(Utils::ProcessHandle pid); void setAttachPid(Utils::ProcessHandle pid);
private: private:
void start() override;
GdbServerPortsGatherer *m_portsGatherer;
ProjectExplorer::Runnable m_runnable;
Utils::ProcessHandle m_pid; Utils::ProcessHandle m_pid;
bool m_useMulti = true; bool m_useMulti = true;
}; };

View File

@@ -1106,42 +1106,76 @@ SimpleTargetRunner::SimpleTargetRunner(RunControl *runControl)
: RunWorker(runControl) : RunWorker(runControl)
{ {
setId("SimpleTargetRunner"); setId("SimpleTargetRunner");
m_runnable = runControl->runnable(); // Default value. Can be overridden using setRunnable.
m_device = runControl->device(); // Default value. Can be overridden using setDevice.
if (auto terminalAspect = runControl->aspect<TerminalAspect>()) if (auto terminalAspect = runControl->aspect<TerminalAspect>())
m_useTerminal = terminalAspect->useTerminal(); m_useTerminal = terminalAspect->useTerminal();
} }
void SimpleTargetRunner::start() void SimpleTargetRunner::start()
{
if (m_starter)
m_starter();
else
doStart(runControl()->runnable(), runControl()->device());
}
void SimpleTargetRunner::doStart(const Runnable &runnable, const IDevice::ConstPtr &device)
{ {
m_stopReported = false; m_stopReported = false;
m_launcher.disconnect(this); m_launcher.disconnect(this);
m_launcher.setUseTerminal(m_useTerminal); m_launcher.setUseTerminal(m_useTerminal);
const bool isDesktop = m_device.isNull() || m_device.dynamicCast<const DesktopDevice>(); const bool isDesktop = device.isNull() || device.dynamicCast<const DesktopDevice>();
const QString rawDisplayName = m_runnable.displayName(); const QString rawDisplayName = runnable.displayName();
const QString displayName = isDesktop const QString displayName = isDesktop
? QDir::toNativeSeparators(rawDisplayName) ? QDir::toNativeSeparators(rawDisplayName)
: rawDisplayName; : rawDisplayName;
const QString msg = RunControl::tr("Starting %1 %2...") const QString msg = RunControl::tr("Starting %1 %2...")
.arg(displayName).arg(m_runnable.commandLineArguments); .arg(displayName).arg(runnable.commandLineArguments);
appendMessage(msg, Utils::NormalMessageFormat); appendMessage(msg, Utils::NormalMessageFormat);
if (isDesktop) { if (isDesktop) {
connect(&m_launcher, &ApplicationLauncher::appendMessage, connect(&m_launcher, &ApplicationLauncher::appendMessage,
this, &SimpleTargetRunner::appendMessage); this, &SimpleTargetRunner::appendMessage);
connect(&m_launcher, &ApplicationLauncher::processStarted,
this, &SimpleTargetRunner::onProcessStarted);
connect(&m_launcher, &ApplicationLauncher::processExited,
this, &SimpleTargetRunner::onProcessFinished);
connect(&m_launcher, &ApplicationLauncher::error,
this, &SimpleTargetRunner::onProcessError);
if (m_runnable.executable.isEmpty()) { connect(&m_launcher, &ApplicationLauncher::processStarted, this, [this] {
// Console processes only know their pid after being started
ProcessHandle pid = m_launcher.applicationPID();
runControl()->setApplicationProcessHandle(pid);
pid.activate();
reportStarted();
});
connect(&m_launcher, &ApplicationLauncher::processExited,
this, [this, displayName](int exitCode, QProcess::ExitStatus status) {
QString msg;
if (status == QProcess::CrashExit)
msg = tr("%1 crashed.");
else
msg = tr("%2 exited with code %1").arg(exitCode);
appendMessage(msg.arg(displayName), Utils::NormalMessageFormat);
if (!m_stopReported) {
m_stopReported = true;
reportStopped();
}
});
connect(&m_launcher, &ApplicationLauncher::error,
this, [this, runnable](QProcess::ProcessError error) {
if (error == QProcess::Timedout)
return; // No actual change on the process side.
const QString msg = userMessageForProcessError(error, runnable.executable);
appendMessage(msg, Utils::NormalMessageFormat);
if (!m_stopReported) {
m_stopReported = true;
reportStopped();
}
});
if (runnable.executable.isEmpty()) {
reportFailure(RunControl::tr("No executable specified.")); reportFailure(RunControl::tr("No executable specified."));
} else { } else {
m_launcher.start(m_runnable); m_launcher.start(runnable);
} }
} else { } else {
@@ -1189,7 +1223,7 @@ void SimpleTargetRunner::start()
appendMessage(progressString, Utils::NormalMessageFormat); appendMessage(progressString, Utils::NormalMessageFormat);
}); });
m_launcher.start(m_runnable, device()); m_launcher.start(runnable, device);
} }
} }
@@ -1198,55 +1232,11 @@ void SimpleTargetRunner::stop()
m_launcher.stop(); m_launcher.stop();
} }
void SimpleTargetRunner::onProcessStarted() void SimpleTargetRunner::setStarter(const std::function<void ()> &starter)
{ {
// Console processes only know their pid after being started m_starter = starter;
ProcessHandle pid = m_launcher.applicationPID();
runControl()->setApplicationProcessHandle(pid);
pid.activate();
reportStarted();
} }
void SimpleTargetRunner::onProcessFinished(int exitCode, QProcess::ExitStatus status)
{
QString msg;
if (status == QProcess::CrashExit)
msg = tr("%1 crashed.");
else
msg = tr("%2 exited with code %1").arg(exitCode);
appendMessage(msg.arg(m_runnable.displayName()), Utils::NormalMessageFormat);
if (!m_stopReported) {
m_stopReported = true;
reportStopped();
}
}
void SimpleTargetRunner::onProcessError(QProcess::ProcessError error)
{
if (error == QProcess::Timedout)
return; // No actual change on the process side.
const QString msg = userMessageForProcessError(error, m_runnable.executable);
appendMessage(msg, Utils::NormalMessageFormat);
if (!m_stopReported) {
m_stopReported = true;
reportStopped();
}
}
IDevice::ConstPtr SimpleTargetRunner::device() const
{
return m_device;
}
void SimpleTargetRunner::setRunnable(const Runnable &runnable)
{
m_runnable = runnable;
}
void SimpleTargetRunner::setDevice(const IDevice::ConstPtr &device)
{
m_device = device;
}
// RunWorkerPrivate // RunWorkerPrivate

View File

@@ -279,23 +279,19 @@ class PROJECTEXPLORER_EXPORT SimpleTargetRunner : public RunWorker
public: public:
explicit SimpleTargetRunner(RunControl *runControl); explicit SimpleTargetRunner(RunControl *runControl);
void setRunnable(const Runnable &runnable);
void setDevice(const IDevice::ConstPtr &device);
IDevice::ConstPtr device() const;
protected: protected:
void start() override; void setStarter(const std::function<void()> &starter);
void stop() override; void doStart(const Runnable &runnable, const IDevice::ConstPtr &device);
private: private:
void onProcessStarted(); void start() final;
void onProcessFinished(int exitCode, QProcess::ExitStatus status); void stop() final;
void onProcessError(QProcess::ProcessError error);
const Runnable &runnable() const = delete;
ApplicationLauncher m_launcher; ApplicationLauncher m_launcher;
Runnable m_runnable; std::function<void()> m_starter;
IDevice::ConstPtr m_device;
bool m_stopReported = false; bool m_stopReported = false;
bool m_useTerminal = false; bool m_useTerminal = false;
}; };

View File

@@ -123,12 +123,14 @@ LocalQmlPreviewSupport::LocalQmlPreviewSupport(ProjectExplorer::RunControl *runC
addStopDependency(preview); addStopDependency(preview);
addStartDependency(preview); addStartDependency(preview);
ProjectExplorer::Runnable run = runnable(); setStarter([this, runControl, serverUrl] {
ProjectExplorer::Runnable run = runControl->runnable();
Utils::QtcProcess::addArg(&run.commandLineArguments, Utils::QtcProcess::addArg(&run.commandLineArguments,
QmlDebug::qmlDebugLocalArguments(QmlDebug::QmlPreviewServices, QmlDebug::qmlDebugLocalArguments(QmlDebug::QmlPreviewServices,
serverUrl.path())); serverUrl.path()));
setRunnable(run); doStart(run, {});
});
} }
} // namespace QmlPreview } // namespace QmlPreview

View File

@@ -229,38 +229,36 @@ LocalQmlProfilerSupport::LocalQmlProfilerSupport(RunControl *runControl, const Q
{ {
setId("LocalQmlProfilerSupport"); setId("LocalQmlProfilerSupport");
m_profiler = new QmlProfilerRunner(runControl); auto profiler = new QmlProfilerRunner(runControl);
m_profiler->setServerUrl(serverUrl); profiler->setServerUrl(serverUrl);
addStopDependency(m_profiler); addStopDependency(profiler);
// We need to open the local server before the application tries to connect. // We need to open the local server before the application tries to connect.
// In the TCP case, it doesn't hurt either to start the profiler before. // In the TCP case, it doesn't hurt either to start the profiler before.
addStartDependency(m_profiler); addStartDependency(profiler);
}
void LocalQmlProfilerSupport::start() setStarter([this, runControl, profiler, serverUrl] {
{ Runnable debuggee = runControl->runnable();
Runnable debuggee = runnable();
QUrl serverUrl = m_profiler->serverUrl(); QUrl serverUrl = profiler->serverUrl();
QString code; QString code;
if (serverUrl.scheme() == Utils::urlSocketScheme()) if (serverUrl.scheme() == Utils::urlSocketScheme())
code = QString("file:%1").arg(serverUrl.path()); code = QString("file:%1").arg(serverUrl.path());
else if (serverUrl.scheme() == Utils::urlTcpScheme()) else if (serverUrl.scheme() == Utils::urlTcpScheme())
code = QString("port:%1").arg(serverUrl.port()); code = QString("port:%1").arg(serverUrl.port());
else else
QTC_CHECK(false); QTC_CHECK(false);
QString arguments = Utils::QtcProcess::quoteArg( QString arguments = Utils::QtcProcess::quoteArg(
QmlDebug::qmlDebugCommandLineArguments(QmlDebug::QmlProfilerServices, code, true)); QmlDebug::qmlDebugCommandLineArguments(QmlDebug::QmlProfilerServices, code, true));
if (!debuggee.commandLineArguments.isEmpty()) if (!debuggee.commandLineArguments.isEmpty())
arguments += ' ' + debuggee.commandLineArguments; arguments += ' ' + debuggee.commandLineArguments;
debuggee.commandLineArguments = arguments; debuggee.commandLineArguments = arguments;
setRunnable(debuggee); doStart(debuggee, {});
SimpleTargetRunner::start(); });
} }
} // namespace Internal } // namespace Internal

View File

@@ -71,11 +71,6 @@ public:
LocalQmlProfilerSupport(ProjectExplorer::RunControl *runControl); LocalQmlProfilerSupport(ProjectExplorer::RunControl *runControl);
LocalQmlProfilerSupport(ProjectExplorer::RunControl *runControl, LocalQmlProfilerSupport(ProjectExplorer::RunControl *runControl,
const QUrl &serverUrl); const QUrl &serverUrl);
private:
void start() override;
QmlProfilerRunner *m_profiler;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -25,21 +25,14 @@
#include "qnxanalyzesupport.h" #include "qnxanalyzesupport.h"
#include "qnxdevice.h"
#include "qnxrunconfiguration.h"
#include "slog2inforunner.h" #include "slog2inforunner.h"
#include <projectexplorer/devicesupport/deviceusedportsgatherer.h> #include <projectexplorer/devicesupport/deviceusedportsgatherer.h>
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/target.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <utils/qtcprocess.h> #include <utils/qtcprocess.h>
#include <qmldebug/qmldebugcommandlinearguments.h> #include <qmldebug/qmldebugcommandlinearguments.h>
#include <qmldebug/qmloutputparser.h>
#include <ssh/sshconnection.h>
using namespace ProjectExplorer; using namespace ProjectExplorer;
using namespace Utils; using namespace Utils;
@@ -53,30 +46,27 @@ QnxQmlProfilerSupport::QnxQmlProfilerSupport(RunControl *runControl)
setId("QnxQmlProfilerSupport"); setId("QnxQmlProfilerSupport");
appendMessage(tr("Preparing remote side..."), Utils::LogMessageFormat); appendMessage(tr("Preparing remote side..."), Utils::LogMessageFormat);
m_portsGatherer = new PortsGatherer(runControl); auto portsGatherer = new PortsGatherer(runControl);
addStartDependency(m_portsGatherer); addStartDependency(portsGatherer);
auto slog2InfoRunner = new Slog2InfoRunner(runControl); auto slog2InfoRunner = new Slog2InfoRunner(runControl);
addStartDependency(slog2InfoRunner); addStartDependency(slog2InfoRunner);
m_profiler = runControl->createWorker(ProjectExplorer::Constants::QML_PROFILER_RUNNER); auto profiler = runControl->createWorker(ProjectExplorer::Constants::QML_PROFILER_RUNNER);
m_profiler->addStartDependency(this); profiler->addStartDependency(this);
addStopDependency(m_profiler); addStopDependency(profiler);
}
void QnxQmlProfilerSupport::start() setStarter([this, runControl, portsGatherer, profiler] {
{ const QUrl serverUrl = portsGatherer->findEndPoint();
const QUrl serverUrl = m_portsGatherer->findEndPoint(); profiler->recordData("QmlServerUrl", serverUrl);
m_profiler->recordData("QmlServerUrl", serverUrl);
Runnable r = runnable(); Runnable r = runControl->runnable();
QtcProcess::addArg(&r.commandLineArguments, QtcProcess::addArg(&r.commandLineArguments,
QmlDebug::qmlDebugTcpArguments(QmlDebug::QmlProfilerServices, serverUrl), QmlDebug::qmlDebugTcpArguments(QmlDebug::QmlProfilerServices, serverUrl),
device()->osType()); Utils::OsTypeOtherUnix);
setRunnable(r); doStart(r, runControl->device());
});
SimpleTargetRunner::start();
} }
} // namespace Internal } // namespace Internal

View File

@@ -25,24 +25,15 @@
#pragma once #pragma once
#include <projectexplorer/devicesupport/deviceusedportsgatherer.h> #include <projectexplorer/runcontrol.h>
#include <projectexplorer/runconfiguration.h>
namespace Qnx { namespace Qnx {
namespace Internal { namespace Internal {
class QnxQmlProfilerSupport : public ProjectExplorer::SimpleTargetRunner class QnxQmlProfilerSupport : public ProjectExplorer::SimpleTargetRunner
{ {
Q_OBJECT
public: public:
explicit QnxQmlProfilerSupport(ProjectExplorer::RunControl *runControl); explicit QnxQmlProfilerSupport(ProjectExplorer::RunControl *runControl);
private:
void start() override;
ProjectExplorer::PortsGatherer *m_portsGatherer;
ProjectExplorer::RunWorker *m_profiler;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -97,34 +97,28 @@ class QnxDebuggeeRunner : public ProjectExplorer::SimpleTargetRunner
{ {
public: public:
QnxDebuggeeRunner(RunControl *runControl, GdbServerPortsGatherer *portsGatherer) QnxDebuggeeRunner(RunControl *runControl, GdbServerPortsGatherer *portsGatherer)
: SimpleTargetRunner(runControl), m_portsGatherer(portsGatherer) : SimpleTargetRunner(runControl)
{ {
setId("QnxDebuggeeRunner"); setId("QnxDebuggeeRunner");
setStarter([this, runControl, portsGatherer] {
Runnable r = runControl->runnable();
QStringList arguments;
if (portsGatherer->useGdbServer()) {
int pdebugPort = portsGatherer->gdbServer().port();
r.executable = FilePath::fromString(Constants::QNX_DEBUG_EXECUTABLE);
arguments.append(QString::number(pdebugPort));
}
if (portsGatherer->useQmlServer()) {
arguments.append(QmlDebug::qmlDebugTcpArguments(QmlDebug::QmlDebuggerServices,
portsGatherer->qmlServer()));
}
arguments.append(QtcProcess::splitArgs(r.commandLineArguments));
r.commandLineArguments = QtcProcess::joinArgs(arguments);
doStart(r, runControl->device());
});
} }
private:
void start() final
{
Runnable r = runnable();
QStringList arguments;
if (m_portsGatherer->useGdbServer()) {
int pdebugPort = m_portsGatherer->gdbServer().port();
r.executable = FilePath::fromString(Constants::QNX_DEBUG_EXECUTABLE);
arguments.append(QString::number(pdebugPort));
}
if (m_portsGatherer->useQmlServer()) {
arguments.append(QmlDebug::qmlDebugTcpArguments(QmlDebug::QmlDebuggerServices,
m_portsGatherer->qmlServer()));
}
arguments.append(QtcProcess::splitArgs(r.commandLineArguments));
r.commandLineArguments = QtcProcess::joinArgs(arguments);
setRunnable(r);
SimpleTargetRunner::start();
}
GdbServerPortsGatherer *m_portsGatherer;
}; };
@@ -197,26 +191,20 @@ class PDebugRunner : public ProjectExplorer::SimpleTargetRunner
{ {
public: public:
PDebugRunner(RunControl *runControl, GdbServerPortsGatherer *portsGatherer) PDebugRunner(RunControl *runControl, GdbServerPortsGatherer *portsGatherer)
: SimpleTargetRunner(runControl), m_portsGatherer(portsGatherer) : SimpleTargetRunner(runControl)
{ {
setId("PDebugRunner"); setId("PDebugRunner");
addStartDependency(m_portsGatherer); addStartDependency(portsGatherer);
setStarter([this, runControl, portsGatherer] {
const int pdebugPort = portsGatherer->gdbServer().port();
Runnable r;
r.executable = FilePath::fromString(Constants::QNX_DEBUG_EXECUTABLE);
r.commandLineArguments = QString::number(pdebugPort);
doStart(r, runControl->device());
});
} }
private:
void start() final
{
const int pdebugPort = m_portsGatherer->gdbServer().port();
Runnable r;
r.executable = FilePath::fromString(Constants::QNX_DEBUG_EXECUTABLE);
r.commandLineArguments = QString::number(pdebugPort);
setRunnable(r);
SimpleTargetRunner::start();
}
GdbServerPortsGatherer *m_portsGatherer;
}; };
QnxAttachDebugSupport::QnxAttachDebugSupport(RunControl *runControl) QnxAttachDebugSupport::QnxAttachDebugSupport(RunControl *runControl)

View File

@@ -25,6 +25,8 @@
#include "remotelinuxqmltoolingsupport.h" #include "remotelinuxqmltoolingsupport.h"
#include <projectexplorer/devicesupport/deviceusedportsgatherer.h>
#include <qmldebug/qmldebugcommandlinearguments.h> #include <qmldebug/qmldebugcommandlinearguments.h>
using namespace ProjectExplorer; using namespace ProjectExplorer;
@@ -38,34 +40,30 @@ RemoteLinuxQmlToolingSupport::RemoteLinuxQmlToolingSupport(RunControl *runContro
{ {
setId("RemoteLinuxQmlToolingSupport"); setId("RemoteLinuxQmlToolingSupport");
m_portsGatherer = new PortsGatherer(runControl); auto portsGatherer = new PortsGatherer(runControl);
addStartDependency(m_portsGatherer); addStartDependency(portsGatherer);
// The ports gatherer can safely be stopped once the process is running, even though it has to // The ports gatherer can safely be stopped once the process is running, even though it has to
// be started before. // be started before.
addStopDependency(m_portsGatherer); addStopDependency(portsGatherer);
m_runworker = runControl->createWorker(QmlDebug::runnerIdForRunMode(runControl->runMode())); auto runworker = runControl->createWorker(QmlDebug::runnerIdForRunMode(runControl->runMode()));
m_runworker->addStartDependency(this); runworker->addStartDependency(this);
addStopDependency(m_runworker); addStopDependency(runworker);
}
void RemoteLinuxQmlToolingSupport::start() setStarter([this, runControl, portsGatherer, runworker] {
{ const QUrl serverUrl = portsGatherer->findEndPoint();
const QUrl serverUrl = m_portsGatherer->findEndPoint(); runworker->recordData("QmlServerUrl", serverUrl);
m_runworker->recordData("QmlServerUrl", serverUrl); QmlDebug::QmlDebugServicesPreset services = QmlDebug::servicesForRunMode(runControl->runMode());
QmlDebug::QmlDebugServicesPreset services = QmlDebug::servicesForRunMode(runControl()->runMode()); Runnable r = runControl->runnable();
QtcProcess::addArg(&r.commandLineArguments,
QmlDebug::qmlDebugTcpArguments(services, serverUrl),
OsTypeLinux);
Runnable r = runnable(); doStart(r, runControl->device());
QtcProcess::addArg(&r.commandLineArguments, });
QmlDebug::qmlDebugTcpArguments(services, serverUrl),
device()->osType());
setRunnable(r);
SimpleTargetRunner::start();
} }
} // namespace Internal } // namespace Internal

View File

@@ -25,8 +25,7 @@
#pragma once #pragma once
#include <projectexplorer/devicesupport/deviceusedportsgatherer.h> #include <projectexplorer/runcontrol.h>
#include <projectexplorer/runconfiguration.h>
namespace RemoteLinux { namespace RemoteLinux {
namespace Internal { namespace Internal {
@@ -35,12 +34,6 @@ class RemoteLinuxQmlToolingSupport : public ProjectExplorer::SimpleTargetRunner
{ {
public: public:
explicit RemoteLinuxQmlToolingSupport(ProjectExplorer::RunControl *runControl); explicit RemoteLinuxQmlToolingSupport(ProjectExplorer::RunControl *runControl);
private:
void start() override;
ProjectExplorer::PortsGatherer *m_portsGatherer;
ProjectExplorer::RunWorker *m_runworker;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -91,23 +91,18 @@ public:
EmrunRunWorker(RunControl *runControl) EmrunRunWorker(RunControl *runControl)
: SimpleTargetRunner(runControl) : SimpleTargetRunner(runControl)
{ {
m_portsGatherer = new PortsGatherer(runControl); auto portsGatherer = new PortsGatherer(runControl);
addStartDependency(m_portsGatherer); addStartDependency(portsGatherer);
setStarter([this, runControl, portsGatherer] {
CommandLine cmd = emrunCommand(runControl->target(),
runControl->aspect<WebBrowserSelectionAspect>()->currentBrowser(),
QString::number(portsGatherer->findEndPoint().port()));
Runnable r;
r.setCommandLine(cmd);
SimpleTargetRunner::doStart(r, {});
});
} }
void start() final
{
CommandLine cmd = emrunCommand(runControl()->target(),
runControl()->aspect<WebBrowserSelectionAspect>()->currentBrowser(),
QString::number(m_portsGatherer->findEndPoint().port()));
Runnable r;
r.setCommandLine(cmd);
setRunnable(r);
SimpleTargetRunner::start();
}
PortsGatherer *m_portsGatherer;
}; };
RunWorkerFactory::WorkerCreator makeEmrunWorker() RunWorkerFactory::WorkerCreator makeEmrunWorker()