forked from qt-creator/qt-creator
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:
@@ -54,6 +54,18 @@ namespace Internal {
|
||||
|
||||
// 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)
|
||||
: Debugger::DebuggerRunTool(runControl)
|
||||
{
|
||||
@@ -75,9 +87,8 @@ BareMetalDebugSupport::BareMetalDebugSupport(RunControl *runControl)
|
||||
r.setCommandLine(p->command());
|
||||
// Command arguments are in host OS style as the bare metal's GDB servers are launched
|
||||
// on the host, not on that target.
|
||||
m_gdbServer = new SimpleTargetRunner(runControl);
|
||||
m_gdbServer->setRunnable(r);
|
||||
addStartDependency(m_gdbServer);
|
||||
auto gdbServer = new BareMetalGdbServer(runControl, r);
|
||||
addStartDependency(gdbServer);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -41,8 +41,6 @@ public:
|
||||
|
||||
private:
|
||||
void start() final;
|
||||
|
||||
ProjectExplorer::SimpleTargetRunner *m_gdbServer = nullptr;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -138,15 +138,13 @@ class QdbDeviceRunSupport : public SimpleTargetRunner
|
||||
public:
|
||||
QdbDeviceRunSupport(RunControl *runControl)
|
||||
: SimpleTargetRunner(runControl)
|
||||
{}
|
||||
|
||||
void start() final
|
||||
{
|
||||
Runnable r = runnable();
|
||||
setStarter([this, runControl] {
|
||||
Runnable r = runControl->runnable();
|
||||
r.commandLineArguments = r.executable.toString() + ' ' + r.commandLineArguments;
|
||||
r.executable = Utils::FilePath::fromString(Constants::AppcontrollerFilepath);
|
||||
setRunnable(r);
|
||||
SimpleTargetRunner::start();
|
||||
doStart(r, runControl->device());
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -1656,7 +1656,6 @@ public:
|
||||
|
||||
auto gdbServer = new GdbServerRunner(runControl, portsGatherer());
|
||||
gdbServer->setUseMulti(false);
|
||||
gdbServer->setDevice(runControl->device());
|
||||
gdbServer->setAttachPid(ProcessHandle(pid));
|
||||
|
||||
addStartDependency(gdbServer);
|
||||
|
@@ -1050,20 +1050,53 @@ QUrl GdbServerPortsGatherer::qmlServer() const
|
||||
// GdbServerRunner
|
||||
|
||||
GdbServerRunner::GdbServerRunner(RunControl *runControl, GdbServerPortsGatherer *portsGatherer)
|
||||
: SimpleTargetRunner(runControl), m_portsGatherer(portsGatherer)
|
||||
: SimpleTargetRunner(runControl)
|
||||
{
|
||||
setId("GdbServerRunner");
|
||||
m_runnable = runControl->runnable();
|
||||
addStartDependency(m_portsGatherer);
|
||||
const Runnable mainRunnable = runControl->runnable();
|
||||
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;
|
||||
|
||||
void GdbServerRunner::setRunnable(const Runnable &runnable)
|
||||
{
|
||||
m_runnable = runnable;
|
||||
}
|
||||
|
||||
void GdbServerRunner::setUseMulti(bool on)
|
||||
{
|
||||
m_useMulti = on;
|
||||
@@ -1074,42 +1107,4 @@ void GdbServerRunner::setAttachPid(ProcessHandle 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
|
||||
|
@@ -166,15 +166,10 @@ public:
|
||||
|
||||
~GdbServerRunner() override;
|
||||
|
||||
void setRunnable(const ProjectExplorer::Runnable &runnable);
|
||||
void setUseMulti(bool on);
|
||||
void setAttachPid(Utils::ProcessHandle pid);
|
||||
|
||||
private:
|
||||
void start() override;
|
||||
|
||||
GdbServerPortsGatherer *m_portsGatherer;
|
||||
ProjectExplorer::Runnable m_runnable;
|
||||
Utils::ProcessHandle m_pid;
|
||||
bool m_useMulti = true;
|
||||
};
|
||||
|
@@ -1106,42 +1106,76 @@ SimpleTargetRunner::SimpleTargetRunner(RunControl *runControl)
|
||||
: RunWorker(runControl)
|
||||
{
|
||||
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>())
|
||||
m_useTerminal = terminalAspect->useTerminal();
|
||||
}
|
||||
|
||||
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_launcher.disconnect(this);
|
||||
m_launcher.setUseTerminal(m_useTerminal);
|
||||
|
||||
const bool isDesktop = m_device.isNull() || m_device.dynamicCast<const DesktopDevice>();
|
||||
const QString rawDisplayName = m_runnable.displayName();
|
||||
const bool isDesktop = device.isNull() || device.dynamicCast<const DesktopDevice>();
|
||||
const QString rawDisplayName = runnable.displayName();
|
||||
const QString displayName = isDesktop
|
||||
? QDir::toNativeSeparators(rawDisplayName)
|
||||
: rawDisplayName;
|
||||
const QString msg = RunControl::tr("Starting %1 %2...")
|
||||
.arg(displayName).arg(m_runnable.commandLineArguments);
|
||||
.arg(displayName).arg(runnable.commandLineArguments);
|
||||
appendMessage(msg, Utils::NormalMessageFormat);
|
||||
|
||||
if (isDesktop) {
|
||||
|
||||
connect(&m_launcher, &ApplicationLauncher::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."));
|
||||
} else {
|
||||
m_launcher.start(m_runnable);
|
||||
m_launcher.start(runnable);
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -1189,7 +1223,7 @@ void SimpleTargetRunner::start()
|
||||
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();
|
||||
}
|
||||
|
||||
void SimpleTargetRunner::onProcessStarted()
|
||||
void SimpleTargetRunner::setStarter(const std::function<void ()> &starter)
|
||||
{
|
||||
// Console processes only know their pid after being started
|
||||
ProcessHandle pid = m_launcher.applicationPID();
|
||||
runControl()->setApplicationProcessHandle(pid);
|
||||
pid.activate();
|
||||
reportStarted();
|
||||
m_starter = starter;
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
|
@@ -279,23 +279,19 @@ class PROJECTEXPLORER_EXPORT SimpleTargetRunner : public RunWorker
|
||||
public:
|
||||
explicit SimpleTargetRunner(RunControl *runControl);
|
||||
|
||||
void setRunnable(const Runnable &runnable);
|
||||
|
||||
void setDevice(const IDevice::ConstPtr &device);
|
||||
IDevice::ConstPtr device() const;
|
||||
|
||||
protected:
|
||||
void start() override;
|
||||
void stop() override;
|
||||
void setStarter(const std::function<void()> &starter);
|
||||
void doStart(const Runnable &runnable, const IDevice::ConstPtr &device);
|
||||
|
||||
private:
|
||||
void onProcessStarted();
|
||||
void onProcessFinished(int exitCode, QProcess::ExitStatus status);
|
||||
void onProcessError(QProcess::ProcessError error);
|
||||
void start() final;
|
||||
void stop() final;
|
||||
|
||||
const Runnable &runnable() const = delete;
|
||||
|
||||
ApplicationLauncher m_launcher;
|
||||
Runnable m_runnable;
|
||||
IDevice::ConstPtr m_device;
|
||||
std::function<void()> m_starter;
|
||||
|
||||
bool m_stopReported = false;
|
||||
bool m_useTerminal = false;
|
||||
};
|
||||
|
@@ -123,12 +123,14 @@ LocalQmlPreviewSupport::LocalQmlPreviewSupport(ProjectExplorer::RunControl *runC
|
||||
addStopDependency(preview);
|
||||
addStartDependency(preview);
|
||||
|
||||
ProjectExplorer::Runnable run = runnable();
|
||||
setStarter([this, runControl, serverUrl] {
|
||||
ProjectExplorer::Runnable run = runControl->runnable();
|
||||
|
||||
Utils::QtcProcess::addArg(&run.commandLineArguments,
|
||||
QmlDebug::qmlDebugLocalArguments(QmlDebug::QmlPreviewServices,
|
||||
serverUrl.path()));
|
||||
setRunnable(run);
|
||||
doStart(run, {});
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace QmlPreview
|
||||
|
@@ -229,20 +229,18 @@ LocalQmlProfilerSupport::LocalQmlProfilerSupport(RunControl *runControl, const Q
|
||||
{
|
||||
setId("LocalQmlProfilerSupport");
|
||||
|
||||
m_profiler = new QmlProfilerRunner(runControl);
|
||||
m_profiler->setServerUrl(serverUrl);
|
||||
auto profiler = new QmlProfilerRunner(runControl);
|
||||
profiler->setServerUrl(serverUrl);
|
||||
|
||||
addStopDependency(m_profiler);
|
||||
addStopDependency(profiler);
|
||||
// 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.
|
||||
addStartDependency(m_profiler);
|
||||
}
|
||||
addStartDependency(profiler);
|
||||
|
||||
void LocalQmlProfilerSupport::start()
|
||||
{
|
||||
Runnable debuggee = runnable();
|
||||
setStarter([this, runControl, profiler, serverUrl] {
|
||||
Runnable debuggee = runControl->runnable();
|
||||
|
||||
QUrl serverUrl = m_profiler->serverUrl();
|
||||
QUrl serverUrl = profiler->serverUrl();
|
||||
QString code;
|
||||
if (serverUrl.scheme() == Utils::urlSocketScheme())
|
||||
code = QString("file:%1").arg(serverUrl.path());
|
||||
@@ -259,8 +257,8 @@ void LocalQmlProfilerSupport::start()
|
||||
|
||||
debuggee.commandLineArguments = arguments;
|
||||
|
||||
setRunnable(debuggee);
|
||||
SimpleTargetRunner::start();
|
||||
doStart(debuggee, {});
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -71,11 +71,6 @@ public:
|
||||
LocalQmlProfilerSupport(ProjectExplorer::RunControl *runControl);
|
||||
LocalQmlProfilerSupport(ProjectExplorer::RunControl *runControl,
|
||||
const QUrl &serverUrl);
|
||||
|
||||
private:
|
||||
void start() override;
|
||||
|
||||
QmlProfilerRunner *m_profiler;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -25,21 +25,14 @@
|
||||
|
||||
#include "qnxanalyzesupport.h"
|
||||
|
||||
#include "qnxdevice.h"
|
||||
#include "qnxrunconfiguration.h"
|
||||
#include "slog2inforunner.h"
|
||||
|
||||
#include <projectexplorer/devicesupport/deviceusedportsgatherer.h>
|
||||
#include <projectexplorer/kitinformation.h>
|
||||
#include <projectexplorer/target.h>
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/qtcprocess.h>
|
||||
|
||||
#include <qmldebug/qmldebugcommandlinearguments.h>
|
||||
#include <qmldebug/qmloutputparser.h>
|
||||
|
||||
#include <ssh/sshconnection.h>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
using namespace Utils;
|
||||
@@ -53,30 +46,27 @@ QnxQmlProfilerSupport::QnxQmlProfilerSupport(RunControl *runControl)
|
||||
setId("QnxQmlProfilerSupport");
|
||||
appendMessage(tr("Preparing remote side..."), Utils::LogMessageFormat);
|
||||
|
||||
m_portsGatherer = new PortsGatherer(runControl);
|
||||
addStartDependency(m_portsGatherer);
|
||||
auto portsGatherer = new PortsGatherer(runControl);
|
||||
addStartDependency(portsGatherer);
|
||||
|
||||
auto slog2InfoRunner = new Slog2InfoRunner(runControl);
|
||||
addStartDependency(slog2InfoRunner);
|
||||
|
||||
m_profiler = runControl->createWorker(ProjectExplorer::Constants::QML_PROFILER_RUNNER);
|
||||
m_profiler->addStartDependency(this);
|
||||
addStopDependency(m_profiler);
|
||||
}
|
||||
auto profiler = runControl->createWorker(ProjectExplorer::Constants::QML_PROFILER_RUNNER);
|
||||
profiler->addStartDependency(this);
|
||||
addStopDependency(profiler);
|
||||
|
||||
void QnxQmlProfilerSupport::start()
|
||||
{
|
||||
const QUrl serverUrl = m_portsGatherer->findEndPoint();
|
||||
m_profiler->recordData("QmlServerUrl", serverUrl);
|
||||
setStarter([this, runControl, portsGatherer, profiler] {
|
||||
const QUrl serverUrl = portsGatherer->findEndPoint();
|
||||
profiler->recordData("QmlServerUrl", serverUrl);
|
||||
|
||||
Runnable r = runnable();
|
||||
Runnable r = runControl->runnable();
|
||||
QtcProcess::addArg(&r.commandLineArguments,
|
||||
QmlDebug::qmlDebugTcpArguments(QmlDebug::QmlProfilerServices, serverUrl),
|
||||
device()->osType());
|
||||
Utils::OsTypeOtherUnix);
|
||||
|
||||
setRunnable(r);
|
||||
|
||||
SimpleTargetRunner::start();
|
||||
doStart(r, runControl->device());
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -25,24 +25,15 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <projectexplorer/devicesupport/deviceusedportsgatherer.h>
|
||||
#include <projectexplorer/runconfiguration.h>
|
||||
#include <projectexplorer/runcontrol.h>
|
||||
|
||||
namespace Qnx {
|
||||
namespace Internal {
|
||||
|
||||
class QnxQmlProfilerSupport : public ProjectExplorer::SimpleTargetRunner
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit QnxQmlProfilerSupport(ProjectExplorer::RunControl *runControl);
|
||||
|
||||
private:
|
||||
void start() override;
|
||||
|
||||
ProjectExplorer::PortsGatherer *m_portsGatherer;
|
||||
ProjectExplorer::RunWorker *m_profiler;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -97,34 +97,28 @@ class QnxDebuggeeRunner : public ProjectExplorer::SimpleTargetRunner
|
||||
{
|
||||
public:
|
||||
QnxDebuggeeRunner(RunControl *runControl, GdbServerPortsGatherer *portsGatherer)
|
||||
: SimpleTargetRunner(runControl), m_portsGatherer(portsGatherer)
|
||||
: SimpleTargetRunner(runControl)
|
||||
{
|
||||
setId("QnxDebuggeeRunner");
|
||||
}
|
||||
|
||||
private:
|
||||
void start() final
|
||||
{
|
||||
Runnable r = runnable();
|
||||
setStarter([this, runControl, portsGatherer] {
|
||||
Runnable r = runControl->runnable();
|
||||
QStringList arguments;
|
||||
if (m_portsGatherer->useGdbServer()) {
|
||||
int pdebugPort = m_portsGatherer->gdbServer().port();
|
||||
if (portsGatherer->useGdbServer()) {
|
||||
int pdebugPort = portsGatherer->gdbServer().port();
|
||||
r.executable = FilePath::fromString(Constants::QNX_DEBUG_EXECUTABLE);
|
||||
arguments.append(QString::number(pdebugPort));
|
||||
}
|
||||
if (m_portsGatherer->useQmlServer()) {
|
||||
if (portsGatherer->useQmlServer()) {
|
||||
arguments.append(QmlDebug::qmlDebugTcpArguments(QmlDebug::QmlDebuggerServices,
|
||||
m_portsGatherer->qmlServer()));
|
||||
portsGatherer->qmlServer()));
|
||||
}
|
||||
arguments.append(QtcProcess::splitArgs(r.commandLineArguments));
|
||||
r.commandLineArguments = QtcProcess::joinArgs(arguments);
|
||||
|
||||
setRunnable(r);
|
||||
|
||||
SimpleTargetRunner::start();
|
||||
doStart(r, runControl->device());
|
||||
});
|
||||
}
|
||||
|
||||
GdbServerPortsGatherer *m_portsGatherer;
|
||||
};
|
||||
|
||||
|
||||
@@ -197,26 +191,20 @@ class PDebugRunner : public ProjectExplorer::SimpleTargetRunner
|
||||
{
|
||||
public:
|
||||
PDebugRunner(RunControl *runControl, GdbServerPortsGatherer *portsGatherer)
|
||||
: SimpleTargetRunner(runControl), m_portsGatherer(portsGatherer)
|
||||
: SimpleTargetRunner(runControl)
|
||||
{
|
||||
setId("PDebugRunner");
|
||||
addStartDependency(m_portsGatherer);
|
||||
}
|
||||
addStartDependency(portsGatherer);
|
||||
|
||||
private:
|
||||
void start() final
|
||||
{
|
||||
const int pdebugPort = m_portsGatherer->gdbServer().port();
|
||||
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);
|
||||
setRunnable(r);
|
||||
|
||||
SimpleTargetRunner::start();
|
||||
doStart(r, runControl->device());
|
||||
});
|
||||
}
|
||||
|
||||
GdbServerPortsGatherer *m_portsGatherer;
|
||||
};
|
||||
|
||||
QnxAttachDebugSupport::QnxAttachDebugSupport(RunControl *runControl)
|
||||
|
@@ -25,6 +25,8 @@
|
||||
|
||||
#include "remotelinuxqmltoolingsupport.h"
|
||||
|
||||
#include <projectexplorer/devicesupport/deviceusedportsgatherer.h>
|
||||
|
||||
#include <qmldebug/qmldebugcommandlinearguments.h>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
@@ -38,34 +40,30 @@ RemoteLinuxQmlToolingSupport::RemoteLinuxQmlToolingSupport(RunControl *runContro
|
||||
{
|
||||
setId("RemoteLinuxQmlToolingSupport");
|
||||
|
||||
m_portsGatherer = new PortsGatherer(runControl);
|
||||
addStartDependency(m_portsGatherer);
|
||||
auto portsGatherer = new PortsGatherer(runControl);
|
||||
addStartDependency(portsGatherer);
|
||||
|
||||
// The ports gatherer can safely be stopped once the process is running, even though it has to
|
||||
// be started before.
|
||||
addStopDependency(m_portsGatherer);
|
||||
addStopDependency(portsGatherer);
|
||||
|
||||
m_runworker = runControl->createWorker(QmlDebug::runnerIdForRunMode(runControl->runMode()));
|
||||
m_runworker->addStartDependency(this);
|
||||
addStopDependency(m_runworker);
|
||||
}
|
||||
auto runworker = runControl->createWorker(QmlDebug::runnerIdForRunMode(runControl->runMode()));
|
||||
runworker->addStartDependency(this);
|
||||
addStopDependency(runworker);
|
||||
|
||||
void RemoteLinuxQmlToolingSupport::start()
|
||||
{
|
||||
const QUrl serverUrl = m_portsGatherer->findEndPoint();
|
||||
setStarter([this, runControl, portsGatherer, runworker] {
|
||||
const QUrl serverUrl = 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 = runnable();
|
||||
Runnable r = runControl->runnable();
|
||||
QtcProcess::addArg(&r.commandLineArguments,
|
||||
QmlDebug::qmlDebugTcpArguments(services, serverUrl),
|
||||
device()->osType());
|
||||
OsTypeLinux);
|
||||
|
||||
setRunnable(r);
|
||||
|
||||
SimpleTargetRunner::start();
|
||||
doStart(r, runControl->device());
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -25,8 +25,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <projectexplorer/devicesupport/deviceusedportsgatherer.h>
|
||||
#include <projectexplorer/runconfiguration.h>
|
||||
#include <projectexplorer/runcontrol.h>
|
||||
|
||||
namespace RemoteLinux {
|
||||
namespace Internal {
|
||||
@@ -35,12 +34,6 @@ class RemoteLinuxQmlToolingSupport : public ProjectExplorer::SimpleTargetRunner
|
||||
{
|
||||
public:
|
||||
explicit RemoteLinuxQmlToolingSupport(ProjectExplorer::RunControl *runControl);
|
||||
|
||||
private:
|
||||
void start() override;
|
||||
|
||||
ProjectExplorer::PortsGatherer *m_portsGatherer;
|
||||
ProjectExplorer::RunWorker *m_runworker;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -91,23 +91,18 @@ public:
|
||||
EmrunRunWorker(RunControl *runControl)
|
||||
: SimpleTargetRunner(runControl)
|
||||
{
|
||||
m_portsGatherer = new PortsGatherer(runControl);
|
||||
addStartDependency(m_portsGatherer);
|
||||
}
|
||||
auto portsGatherer = new PortsGatherer(runControl);
|
||||
addStartDependency(portsGatherer);
|
||||
|
||||
void start() final
|
||||
{
|
||||
CommandLine cmd = emrunCommand(runControl()->target(),
|
||||
runControl()->aspect<WebBrowserSelectionAspect>()->currentBrowser(),
|
||||
QString::number(m_portsGatherer->findEndPoint().port()));
|
||||
setStarter([this, runControl, portsGatherer] {
|
||||
CommandLine cmd = emrunCommand(runControl->target(),
|
||||
runControl->aspect<WebBrowserSelectionAspect>()->currentBrowser(),
|
||||
QString::number(portsGatherer->findEndPoint().port()));
|
||||
Runnable r;
|
||||
r.setCommandLine(cmd);
|
||||
setRunnable(r);
|
||||
|
||||
SimpleTargetRunner::start();
|
||||
SimpleTargetRunner::doStart(r, {});
|
||||
});
|
||||
}
|
||||
|
||||
PortsGatherer *m_portsGatherer;
|
||||
};
|
||||
|
||||
RunWorkerFactory::WorkerCreator makeEmrunWorker()
|
||||
|
Reference in New Issue
Block a user