Commit 8376afd9 authored by hjk's avatar hjk

ProjectExplorer: Remove RunControl::worker<Type>()

It looks like the case where workers need talk to each other by
only knowing the type of the 'partner' does not exist in practice
anymore. With the now-common setup of a 'primary' worker that one
can introduce the 'lesser' workers to each other directly.

That's also conceptually more robust that picking a partner by
type only only from some 'pool' (all the workers in a runcontrol),
scales better (it e.g. is imaginable that a RunControl needs
more than one PortGatherer in complex setups where more than one
device is involved) saves a few cycles, and even removes the need
for workers to be qobject_cast-able.

Change-Id: Ib3d8c942c893d6c198d9813cce7df28ba3260ce8
Reviewed-by: Christian Kandeler's avatarChristian Kandeler <christian.kandeler@qt.io>
Reviewed-by: default avatarhjk <hjk@qt.io>
parent 2cacf24b
......@@ -739,8 +739,8 @@ void GdbServerPortsGatherer::start()
// GdbServerRunner
GdbServerRunner::GdbServerRunner(RunControl *runControl)
: RunWorker(runControl)
GdbServerRunner::GdbServerRunner(RunControl *runControl, GdbServerPortsGatherer *portsGatherer)
: RunWorker(runControl), m_portsGatherer(portsGatherer)
{
setDisplayName("GdbServerRunner");
}
......@@ -751,19 +751,18 @@ GdbServerRunner::~GdbServerRunner()
void GdbServerRunner::start()
{
auto portsGatherer = runControl()->worker<GdbServerPortsGatherer>();
QTC_ASSERT(portsGatherer, reportFailure(); return);
QTC_ASSERT(m_portsGatherer, reportFailure(); return);
StandardRunnable r = runnable().as<StandardRunnable>();
QStringList args = QtcProcess::splitArgs(r.commandLineArguments, OsTypeLinux);
QString command;
const bool isQmlDebugging = portsGatherer->useQmlServer();
const bool isCppDebugging = portsGatherer->useGdbServer();
const bool isQmlDebugging = m_portsGatherer->useQmlServer();
const bool isCppDebugging = m_portsGatherer->useGdbServer();
if (isQmlDebugging) {
args.prepend(QmlDebug::qmlDebugTcpArguments(QmlDebug::QmlDebuggerServices,
portsGatherer->qmlServerPort()));
m_portsGatherer->qmlServerPort()));
}
if (isQmlDebugging && !isCppDebugging) {
......@@ -774,7 +773,7 @@ void GdbServerRunner::start()
command = "gdbserver";
args.clear();
args.append(QString("--multi"));
args.append(QString(":%1").arg(portsGatherer->gdbServerPort().number()));
args.append(QString(":%1").arg(m_portsGatherer->gdbServerPort().number()));
}
r.executable = command;
r.commandLineArguments = QtcProcess::joinArgs(args, OsTypeLinux);
......
......@@ -125,7 +125,8 @@ class DEBUGGER_EXPORT GdbServerRunner : public ProjectExplorer::RunWorker
Q_OBJECT
public:
explicit GdbServerRunner(ProjectExplorer::RunControl *runControl);
explicit GdbServerRunner(ProjectExplorer::RunControl *runControl,
GdbServerPortsGatherer *portsGatherer);
~GdbServerRunner();
private:
......@@ -133,6 +134,7 @@ private:
void stop() override;
ProjectExplorer::ApplicationLauncher m_gdbServer;
GdbServerPortsGatherer *m_portsGatherer;
};
extern DEBUGGER_EXPORT const char GdbServerRunnerWorkerId[];
......
......@@ -771,11 +771,6 @@ void RunControl::registerWorkerCreator(Core::Id id, const WorkerCreator &workerC
Q_UNUSED(keys);
}
QList<QPointer<RunWorker> > RunControl::workers() const
{
return d->m_workers;
}
RunWorker *RunControl::createWorker(Core::Id id)
{
auto keys = theWorkerCreators().keys();
......
......@@ -439,18 +439,6 @@ public:
const QString &cancelButtonText = QString(),
bool *prompt = nullptr);
QList<QPointer<RunWorker>> workers() const;
template <class T> T *worker() const {
for (const QPointer<RunWorker> &worker : workers()) {
if (worker) {
if (auto res = qobject_cast<T *>(worker.data()))
return res;
}
}
return nullptr;
}
RunWorker *createWorker(Core::Id id);
using WorkerCreator = std::function<RunWorker *(RunControl *)>;
......
......@@ -45,11 +45,11 @@ using namespace Utils;
namespace Qnx {
namespace Internal {
class QnxAnalyzeeRunner : public ProjectExplorer::SimpleTargetRunner
class QnxAnalyzeeRunner : public SimpleTargetRunner
{
public:
QnxAnalyzeeRunner(ProjectExplorer::RunControl *runControl)
: SimpleTargetRunner(runControl)
QnxAnalyzeeRunner(RunControl *runControl, PortsGatherer *portsGatherer)
: SimpleTargetRunner(runControl), m_portsGatherer(portsGatherer)
{
setDisplayName("QnxAnalyzeeRunner");
}
......@@ -57,8 +57,7 @@ public:
private:
void start() override
{
auto portsGatherer = runControl()->worker<PortsGatherer>();
Utils::Port port = portsGatherer->findPort();
Utils::Port port = m_portsGatherer->findPort();
auto r = runnable().as<StandardRunnable>();
if (!r.commandLineArguments.isEmpty())
......@@ -70,6 +69,8 @@ private:
SimpleTargetRunner::start();
}
PortsGatherer *m_portsGatherer;
};
......@@ -85,7 +86,7 @@ QnxQmlProfilerSupport::QnxQmlProfilerSupport(RunControl *runControl)
auto portsGatherer = new PortsGatherer(runControl);
auto debuggeeRunner = new QnxAnalyzeeRunner(runControl);
auto debuggeeRunner = new QnxAnalyzeeRunner(runControl, portsGatherer);
debuggeeRunner->addDependency(portsGatherer);
auto slog2InfoRunner = new Slog2InfoRunner(runControl);
......
......@@ -56,8 +56,8 @@ namespace Internal {
class QnxDebuggeeRunner : public ProjectExplorer::SimpleTargetRunner
{
public:
QnxDebuggeeRunner(ProjectExplorer::RunControl *runControl)
: SimpleTargetRunner(runControl)
QnxDebuggeeRunner(RunControl *runControl, GdbServerPortsGatherer *portsGatherer)
: SimpleTargetRunner(runControl), m_portsGatherer(portsGatherer)
{
setDisplayName("QnxDebuggeeRunner");
}
......@@ -65,24 +65,24 @@ public:
private:
void start() override
{
auto portsGatherer = runControl()->worker<GdbServerPortsGatherer>();
StandardRunnable r = runnable().as<StandardRunnable>();
QStringList arguments;
if (portsGatherer->useGdbServer()) {
Utils::Port pdebugPort = portsGatherer->gdbServerPort();
if (m_portsGatherer->useGdbServer()) {
Utils::Port pdebugPort = m_portsGatherer->gdbServerPort();
r.executable = Constants::QNX_DEBUG_EXECUTABLE;
arguments.append(pdebugPort.toString());
}
if (portsGatherer->useQmlServer()) {
if (m_portsGatherer->useQmlServer()) {
arguments.append(QmlDebug::qmlDebugTcpArguments(QmlDebug::QmlDebuggerServices,
portsGatherer->qmlServerPort()));
m_portsGatherer->qmlServerPort()));
}
arguments.append(Utils::QtcProcess::splitArgs(r.commandLineArguments));
r.commandLineArguments = Utils::QtcProcess::joinArgs(arguments);
SimpleTargetRunner::start();
}
GdbServerPortsGatherer *m_portsGatherer;
};
......@@ -94,12 +94,12 @@ QnxDebugSupport::QnxDebugSupport(RunControl *runControl)
setDisplayName("QnxDebugSupport");
appendMessage(tr("Preparing remote side..."), Utils::LogMessageFormat);
auto portsGatherer = new GdbServerPortsGatherer(runControl);
portsGatherer->setUseGdbServer(isCppDebugging());
portsGatherer->setUseQmlServer(isQmlDebugging());
m_portsGatherer = new GdbServerPortsGatherer(runControl);
m_portsGatherer->setUseGdbServer(isCppDebugging());
m_portsGatherer->setUseQmlServer(isQmlDebugging());
auto debuggeeRunner = new QnxDebuggeeRunner(runControl);
debuggeeRunner->addDependency(portsGatherer);
auto debuggeeRunner = new QnxDebuggeeRunner(runControl, m_portsGatherer);
debuggeeRunner->addDependency(m_portsGatherer);
auto slog2InfoRunner = new Slog2InfoRunner(runControl);
slog2InfoRunner->addDependency(debuggeeRunner);
......@@ -109,8 +109,7 @@ QnxDebugSupport::QnxDebugSupport(RunControl *runControl)
void QnxDebugSupport::start()
{
auto portsGatherer = runControl()->worker<GdbServerPortsGatherer>();
Utils::Port pdebugPort = portsGatherer->gdbServerPort();
Utils::Port pdebugPort = m_portsGatherer->gdbServerPort();
auto runConfig = qobject_cast<QnxRunConfiguration *>(runControl()->runConfiguration());
QTC_ASSERT(runConfig, return);
......@@ -128,7 +127,7 @@ void QnxDebugSupport::start()
if (isQmlDebugging()) {
params.qmlServer.host = device()->sshParameters().host;
params.qmlServer.port = portsGatherer->qmlServerPort();
params.qmlServer.port = m_portsGatherer->qmlServerPort();
params.inferior.commandLineArguments.replace("%qml_port%", params.qmlServer.port.toString());
}
......
......@@ -40,6 +40,8 @@ public:
private:
void start() override;
void stop() override;
Debugger::GdbServerPortsGatherer *m_portsGatherer;
};
} // namespace Internal
......
......@@ -52,12 +52,12 @@ LinuxDeviceDebugSupport::LinuxDeviceDebugSupport(RunControl *runControl)
{
setDisplayName("LinuxDeviceDebugSupport");
auto portsGatherer = new GdbServerPortsGatherer(runControl);
portsGatherer->setUseGdbServer(isCppDebugging());
portsGatherer->setUseQmlServer(isQmlDebugging());
m_portsGatherer = new GdbServerPortsGatherer(runControl);
m_portsGatherer->setUseGdbServer(isCppDebugging());
m_portsGatherer->setUseQmlServer(isQmlDebugging());
auto gdbServer = new GdbServerRunner(runControl);
gdbServer->addDependency(portsGatherer);
auto gdbServer = new GdbServerRunner(runControl, m_portsGatherer);
gdbServer->addDependency(m_portsGatherer);
addDependency(gdbServer);
......@@ -75,12 +75,9 @@ void LinuxDeviceDebugSupport::start()
return;
}
auto portsGatherer = runControl()->worker<GdbServerPortsGatherer>();
QTC_ASSERT(portsGatherer, reportFailure(); return);
const QString host = device()->sshParameters().host;
const Port gdbServerPort = portsGatherer->gdbServerPort();
const Port qmlServerPort = portsGatherer->qmlServerPort();
const Port gdbServerPort = m_portsGatherer->gdbServerPort();
const Port qmlServerPort = m_portsGatherer->qmlServerPort();
DebuggerStartParameters params;
params.startMode = AttachToRemoteServer;
......
......@@ -43,6 +43,7 @@ private:
protected:
QString m_symbolFile;
Debugger::GdbServerPortsGatherer *m_portsGatherer = nullptr;
};
} // namespace RemoteLinux
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