RemoteLinux: Base AbstractLinuxRunSupport on PE::ToolSupport

This continues the quest started with eb0b0f944.

This also moves the AnalyzerRunControl::starting signal to the
base, similar to the already present started and finished
signals. Moving emission of the signal to the base is left
to a follow-up patch to keep this here small.

Change-Id: I12e04823df22e7667a4d0a9ee7412153180c60cc
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
hjk
2017-03-28 09:07:29 +02:00
parent a5574bc802
commit 2a1e7cb9f5
10 changed files with 56 additions and 56 deletions

View File

@@ -49,9 +49,6 @@ public:
virtual void notifyRemoteSetupDone(Utils::Port) {} virtual void notifyRemoteSetupDone(Utils::Port) {}
virtual void notifyRemoteSetupFailed(const QString &) {} virtual void notifyRemoteSetupFailed(const QString &) {}
virtual void notifyRemoteFinished() {} virtual void notifyRemoteFinished() {}
signals:
void starting();
}; };
} // namespace Debugger } // namespace Debugger

View File

@@ -989,4 +989,9 @@ RunControl *ToolRunner::runControl() const
return m_runControl; return m_runControl;
} }
void ToolRunner::appendMessage(const QString &msg, OutputFormat format)
{
m_runControl->appendMessage(msg, format);
}
} // namespace ProjectExplorer } // namespace ProjectExplorer

View File

@@ -407,6 +407,7 @@ public:
signals: signals:
void appendMessageRequested(ProjectExplorer::RunControl *runControl, void appendMessageRequested(ProjectExplorer::RunControl *runControl,
const QString &msg, Utils::OutputFormat format); const QString &msg, Utils::OutputFormat format);
void starting();
void started(QPrivateSignal); // Use reportApplicationStart! void started(QPrivateSignal); // Use reportApplicationStart!
void finished(QPrivateSignal); // Use reportApplicationStop! void finished(QPrivateSignal); // Use reportApplicationStop!
void applicationProcessHandleChanged(QPrivateSignal); // Use setApplicationProcessHandle void applicationProcessHandleChanged(QPrivateSignal); // Use setApplicationProcessHandle
@@ -458,6 +459,7 @@ public:
explicit ToolRunner(RunControl *runControl); explicit ToolRunner(RunControl *runControl);
RunControl *runControl() const; RunControl *runControl() const;
void appendMessage(const QString &msg, Utils::OutputFormat format);
private: private:
QPointer<RunControl> m_runControl; QPointer<RunControl> m_runControl;

View File

@@ -62,9 +62,9 @@ public:
using namespace Internal; using namespace Internal;
AbstractRemoteLinuxRunSupport::AbstractRemoteLinuxRunSupport(RunConfiguration *runConfig, QObject *parent) AbstractRemoteLinuxRunSupport::AbstractRemoteLinuxRunSupport(RunControl *runControl)
: QObject(parent), : ToolRunner(runControl),
d(new AbstractRemoteLinuxRunSupportPrivate(runConfig)) d(new AbstractRemoteLinuxRunSupportPrivate(runControl->runConfiguration()))
{ {
} }

View File

@@ -28,6 +28,8 @@
#include "remotelinux_export.h" #include "remotelinux_export.h"
#include <projectexplorer/devicesupport/idevice.h> #include <projectexplorer/devicesupport/idevice.h>
#include <projectexplorer/runconfiguration.h>
#include <utils/port.h> #include <utils/port.h>
#include <QObject> #include <QObject>
@@ -43,7 +45,7 @@ namespace RemoteLinux {
namespace Internal { class AbstractRemoteLinuxRunSupportPrivate; } namespace Internal { class AbstractRemoteLinuxRunSupportPrivate; }
class REMOTELINUX_EXPORT AbstractRemoteLinuxRunSupport : public QObject class REMOTELINUX_EXPORT AbstractRemoteLinuxRunSupport : public ProjectExplorer::ToolRunner
{ {
Q_OBJECT Q_OBJECT
protected: protected:
@@ -55,8 +57,7 @@ protected:
Running Running
}; };
public: public:
AbstractRemoteLinuxRunSupport(ProjectExplorer::RunConfiguration *runConfig, explicit AbstractRemoteLinuxRunSupport(ProjectExplorer::RunControl *runControl);
QObject *parent = 0);
~AbstractRemoteLinuxRunSupport(); ~AbstractRemoteLinuxRunSupport();
protected: protected:

View File

@@ -54,9 +54,8 @@ namespace Internal {
class RemoteLinuxAnalyzeSupportPrivate class RemoteLinuxAnalyzeSupportPrivate
{ {
public: public:
RemoteLinuxAnalyzeSupportPrivate(AnalyzerRunControl *rc, Core::Id runMode) RemoteLinuxAnalyzeSupportPrivate(RunControl *runControl, Core::Id runMode)
: runControl(rc), : runMode(runMode)
runMode(runMode)
{ {
if (runMode != ProjectExplorer::Constants::PERFPROFILER_RUN_MODE) if (runMode != ProjectExplorer::Constants::PERFPROFILER_RUN_MODE)
return; return;
@@ -70,7 +69,6 @@ public:
.join(' '); .join(' ');
} }
const QPointer<AnalyzerRunControl> runControl;
Core::Id runMode; Core::Id runMode;
Utils::Port qmlPort; Utils::Port qmlPort;
QString remoteFifo; QString remoteFifo;
@@ -84,16 +82,15 @@ public:
using namespace Internal; using namespace Internal;
RemoteLinuxAnalyzeSupport::RemoteLinuxAnalyzeSupport(RunConfiguration *runConfig, RemoteLinuxAnalyzeSupport::RemoteLinuxAnalyzeSupport(RunControl *runControl, Core::Id runMode)
AnalyzerRunControl *engine, Core::Id runMode) : AbstractRemoteLinuxRunSupport(runControl),
: AbstractRemoteLinuxRunSupport(runConfig, engine), d(new RemoteLinuxAnalyzeSupportPrivate(runControl, runMode))
d(new RemoteLinuxAnalyzeSupportPrivate(engine, runMode))
{ {
connect(d->runControl.data(), &AnalyzerRunControl::starting, connect(runControl, &RunControl::starting,
this, &RemoteLinuxAnalyzeSupport::handleRemoteSetupRequested); this, &RemoteLinuxAnalyzeSupport::handleRemoteSetupRequested);
connect(&d->outputParser, &QmlDebug::QmlOutputParser::waitingForConnectionOnPort, connect(&d->outputParser, &QmlDebug::QmlOutputParser::waitingForConnectionOnPort,
this, &RemoteLinuxAnalyzeSupport::remoteIsRunning); this, &RemoteLinuxAnalyzeSupport::remoteIsRunning);
connect(engine, &RunControl::finished, connect(runControl, &RunControl::finished,
this, &RemoteLinuxAnalyzeSupport::handleProfilingFinished); this, &RemoteLinuxAnalyzeSupport::handleProfilingFinished);
} }
@@ -104,8 +101,8 @@ RemoteLinuxAnalyzeSupport::~RemoteLinuxAnalyzeSupport()
void RemoteLinuxAnalyzeSupport::showMessage(const QString &msg, Utils::OutputFormat format) void RemoteLinuxAnalyzeSupport::showMessage(const QString &msg, Utils::OutputFormat format)
{ {
if (state() != Inactive && d->runControl) if (state() != Inactive)
d->runControl->appendMessage(msg, format); appendMessage(msg, format);
d->outputParser.processOutput(msg); d->outputParser.processOutput(msg);
} }
@@ -173,9 +170,9 @@ void RemoteLinuxAnalyzeSupport::startExecution()
r.executable = QLatin1String("sh"); r.executable = QLatin1String("sh");
connect(&d->outputGatherer, SIGNAL(remoteStdout(QByteArray)), connect(&d->outputGatherer, SIGNAL(remoteStdout(QByteArray)),
d->runControl, SIGNAL(analyzePerfOutput(QByteArray))); runControl(), SIGNAL(analyzePerfOutput(QByteArray)));
connect(&d->outputGatherer, SIGNAL(finished(bool)), connect(&d->outputGatherer, SIGNAL(finished(bool)),
d->runControl, SIGNAL(perfFinished())); runControl(), SIGNAL(perfFinished()));
StandardRunnable outputRunner; StandardRunnable outputRunner;
outputRunner.executable = QLatin1String("sh"); outputRunner.executable = QLatin1String("sh");
@@ -201,7 +198,9 @@ void RemoteLinuxAnalyzeSupport::handleAppRunnerFinished(bool success)
reset(); reset();
if (!success) if (!success)
showMessage(tr("Failure running remote process."), Utils::NormalMessageFormat); showMessage(tr("Failure running remote process."), Utils::NormalMessageFormat);
d->runControl->notifyRemoteFinished(); auto rc = qobject_cast<AnalyzerRunControl *>(runControl());
QTC_ASSERT(rc, return);
rc->notifyRemoteFinished();
} }
void RemoteLinuxAnalyzeSupport::handleProfilingFinished() void RemoteLinuxAnalyzeSupport::handleProfilingFinished()
@@ -211,7 +210,9 @@ void RemoteLinuxAnalyzeSupport::handleProfilingFinished()
void RemoteLinuxAnalyzeSupport::remoteIsRunning() void RemoteLinuxAnalyzeSupport::remoteIsRunning()
{ {
d->runControl->notifyRemoteSetupDone(d->qmlPort); auto rc = qobject_cast<AnalyzerRunControl *>(runControl());
QTC_ASSERT(rc, return);
rc->notifyRemoteSetupDone(d->qmlPort);
} }
void RemoteLinuxAnalyzeSupport::handleRemoteOutput(const QByteArray &output) void RemoteLinuxAnalyzeSupport::handleRemoteOutput(const QByteArray &output)
@@ -225,9 +226,6 @@ void RemoteLinuxAnalyzeSupport::handleRemoteErrorOutput(const QByteArray &output
{ {
QTC_ASSERT(state() != GatheringResources, return); QTC_ASSERT(state() != GatheringResources, return);
if (!d->runControl)
return;
showMessage(QString::fromUtf8(output), Utils::StdErrFormat); showMessage(QString::fromUtf8(output), Utils::StdErrFormat);
} }

View File

@@ -42,8 +42,7 @@ class REMOTELINUX_EXPORT RemoteLinuxAnalyzeSupport : public AbstractRemoteLinuxR
{ {
Q_OBJECT Q_OBJECT
public: public:
RemoteLinuxAnalyzeSupport(ProjectExplorer::RunConfiguration *runConfig, RemoteLinuxAnalyzeSupport(ProjectExplorer::RunControl *runConfig, Core::Id runMode);
Debugger::AnalyzerRunControl *engine, Core::Id runMode);
~RemoteLinuxAnalyzeSupport() override; ~RemoteLinuxAnalyzeSupport() override;
protected: protected:

View File

@@ -56,14 +56,12 @@ namespace Internal {
class LinuxDeviceDebugSupportPrivate class LinuxDeviceDebugSupportPrivate
{ {
public: public:
LinuxDeviceDebugSupportPrivate(const RunConfiguration *runConfig, DebuggerRunControl *runControl) LinuxDeviceDebugSupportPrivate(const RunConfiguration *runConfig)
: runControl(runControl), : qmlDebugging(runConfig->extraAspect<DebuggerRunConfigurationAspect>()->useQmlDebugger()),
qmlDebugging(runConfig->extraAspect<DebuggerRunConfigurationAspect>()->useQmlDebugger()),
cppDebugging(runConfig->extraAspect<DebuggerRunConfigurationAspect>()->useCppDebugger()) cppDebugging(runConfig->extraAspect<DebuggerRunConfigurationAspect>()->useCppDebugger())
{ {
} }
const QPointer<DebuggerRunControl> runControl;
bool qmlDebugging; bool qmlDebugging;
bool cppDebugging; bool cppDebugging;
QByteArray gdbserverOutput; QByteArray gdbserverOutput;
@@ -75,12 +73,11 @@ public:
using namespace Internal; using namespace Internal;
LinuxDeviceDebugSupport::LinuxDeviceDebugSupport(RunConfiguration *runConfig, LinuxDeviceDebugSupport::LinuxDeviceDebugSupport(RunControl *runControl)
DebuggerRunControl *runControl) : AbstractRemoteLinuxRunSupport(runControl),
: AbstractRemoteLinuxRunSupport(runConfig, runControl), d(new LinuxDeviceDebugSupportPrivate(runControl->runConfiguration()))
d(new LinuxDeviceDebugSupportPrivate(runConfig, runControl))
{ {
connect(runControl, &DebuggerRunControl::requestRemoteSetup, connect(this->runControl(), &DebuggerRunControl::requestRemoteSetup,
this, &LinuxDeviceDebugSupport::handleRemoteSetupRequested); this, &LinuxDeviceDebugSupport::handleRemoteSetupRequested);
connect(runControl, &RunControl::finished, connect(runControl, &RunControl::finished,
this, &LinuxDeviceDebugSupport::handleDebuggingFinished); this, &LinuxDeviceDebugSupport::handleDebuggingFinished);
@@ -103,8 +100,13 @@ bool LinuxDeviceDebugSupport::isQmlDebugging() const
void LinuxDeviceDebugSupport::showMessage(const QString &msg, int channel) void LinuxDeviceDebugSupport::showMessage(const QString &msg, int channel)
{ {
if (state() != Inactive && d->runControl) if (state() != Inactive)
d->runControl->showMessage(msg, channel); runControl()->showMessage(msg, channel);
}
DebuggerRunControl *LinuxDeviceDebugSupport::runControl() const
{
return qobject_cast<DebuggerRunControl *>(AbstractRemoteLinuxRunSupport::runControl());
} }
void LinuxDeviceDebugSupport::handleRemoteSetupRequested() void LinuxDeviceDebugSupport::handleRemoteSetupRequested()
@@ -183,8 +185,7 @@ void LinuxDeviceDebugSupport::handleAppRunnerError(const QString &error)
{ {
if (state() == Running) { if (state() == Running) {
showMessage(error, AppError); showMessage(error, AppError);
if (d->runControl) runControl()->notifyInferiorIll();
d->runControl->notifyInferiorIll();
} else if (state() != Inactive) { } else if (state() != Inactive) {
handleAdapterSetupFailed(error); handleAdapterSetupFailed(error);
} }
@@ -192,21 +193,21 @@ void LinuxDeviceDebugSupport::handleAppRunnerError(const QString &error)
void LinuxDeviceDebugSupport::handleAppRunnerFinished(bool success) void LinuxDeviceDebugSupport::handleAppRunnerFinished(bool success)
{ {
if (!d->runControl || state() == Inactive) if (state() == Inactive)
return; return;
if (state() == Running) { if (state() == Running) {
// The QML engine does not realize on its own that the application has finished. // The QML engine does not realize on its own that the application has finished.
if (d->qmlDebugging && !d->cppDebugging) if (d->qmlDebugging && !d->cppDebugging)
d->runControl->quitDebugger(); runControl()->quitDebugger();
else if (!success) else if (!success)
d->runControl->notifyInferiorIll(); runControl()->notifyInferiorIll();
} else if (state() == StartingRunner) { } else if (state() == StartingRunner) {
RemoteSetupResult result; RemoteSetupResult result;
result.success = false; result.success = false;
result.reason = tr("Debugging failed."); result.reason = tr("Debugging failed.");
d->runControl->notifyEngineRemoteSetupFinished(result); runControl()->notifyEngineRemoteSetupFinished(result);
} }
reset(); reset();
} }
@@ -228,9 +229,6 @@ void LinuxDeviceDebugSupport::handleRemoteErrorOutput(const QByteArray &output)
{ {
QTC_ASSERT(state() != GatheringResources, return); QTC_ASSERT(state() != GatheringResources, return);
if (!d->runControl)
return;
showMessage(QString::fromUtf8(output), AppError); showMessage(QString::fromUtf8(output), AppError);
if (state() == StartingRunner && d->cppDebugging) { if (state() == StartingRunner && d->cppDebugging) {
d->gdbserverOutput += output; d->gdbserverOutput += output;
@@ -253,7 +251,7 @@ void LinuxDeviceDebugSupport::handleAdapterSetupFailed(const QString &error)
RemoteSetupResult result; RemoteSetupResult result;
result.success = false; result.success = false;
result.reason = tr("Initial setup failed: %1").arg(error); result.reason = tr("Initial setup failed: %1").arg(error);
d->runControl->notifyEngineRemoteSetupFinished(result); runControl()->notifyEngineRemoteSetupFinished(result);
} }
void LinuxDeviceDebugSupport::handleAdapterSetupDone() void LinuxDeviceDebugSupport::handleAdapterSetupDone()
@@ -264,7 +262,7 @@ void LinuxDeviceDebugSupport::handleAdapterSetupDone()
result.success = true; result.success = true;
result.gdbServerPort = d->gdbServerPort; result.gdbServerPort = d->gdbServerPort;
result.qmlServerPort = d->qmlPort; result.qmlServerPort = d->qmlPort;
d->runControl->notifyEngineRemoteSetupFinished(result); runControl()->notifyEngineRemoteSetupFinished(result);
} }
void LinuxDeviceDebugSupport::handleRemoteProcessStarted() void LinuxDeviceDebugSupport::handleRemoteProcessStarted()

View File

@@ -38,8 +38,7 @@ class REMOTELINUX_EXPORT LinuxDeviceDebugSupport : public AbstractRemoteLinuxRun
Q_OBJECT Q_OBJECT
public: public:
LinuxDeviceDebugSupport(ProjectExplorer::RunConfiguration *runConfig, LinuxDeviceDebugSupport(ProjectExplorer::RunControl *runControl);
Debugger::DebuggerRunControl *runControl);
~LinuxDeviceDebugSupport() override; ~LinuxDeviceDebugSupport() override;
protected: protected:
@@ -63,6 +62,7 @@ private:
void handleDebuggingFinished(); void handleDebuggingFinished();
void showMessage(const QString &msg, int channel); void showMessage(const QString &msg, int channel);
Debugger::DebuggerRunControl *runControl() const;
Internal::LinuxDeviceDebugSupportPrivate * const d; Internal::LinuxDeviceDebugSupportPrivate * const d;
}; };

View File

@@ -138,7 +138,7 @@ RunControl *RemoteLinuxRunControlFactory::create(RunConfiguration *runConfig, Co
DebuggerRunControl * const runControl = createDebuggerRunControl(params, runConfig, errorMessage, mode); DebuggerRunControl * const runControl = createDebuggerRunControl(params, runConfig, errorMessage, mode);
if (!runControl) if (!runControl)
return 0; return 0;
(void) new LinuxDeviceDebugSupport(runConfig, runControl); (void) new LinuxDeviceDebugSupport(runControl);
return runControl; return runControl;
} }
@@ -150,7 +150,7 @@ RunControl *RemoteLinuxRunControlFactory::create(RunConfiguration *runConfig, Co
DeviceKitInformation::device(runConfig->target()->kit())->sshParameters(); DeviceKitInformation::device(runConfig->target()->kit())->sshParameters();
connection.analyzerHost = connection.connParams.host; connection.analyzerHost = connection.connParams.host;
runControl->setConnection(connection); runControl->setConnection(connection);
(void) new RemoteLinuxAnalyzeSupport(runConfig, runControl, mode); (void) new RemoteLinuxAnalyzeSupport(runControl, mode);
return runControl; return runControl;
} }