forked from qt-creator/qt-creator
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:
@@ -49,9 +49,6 @@ public:
|
||||
virtual void notifyRemoteSetupDone(Utils::Port) {}
|
||||
virtual void notifyRemoteSetupFailed(const QString &) {}
|
||||
virtual void notifyRemoteFinished() {}
|
||||
|
||||
signals:
|
||||
void starting();
|
||||
};
|
||||
|
||||
} // namespace Debugger
|
||||
|
@@ -989,4 +989,9 @@ RunControl *ToolRunner::runControl() const
|
||||
return m_runControl;
|
||||
}
|
||||
|
||||
void ToolRunner::appendMessage(const QString &msg, OutputFormat format)
|
||||
{
|
||||
m_runControl->appendMessage(msg, format);
|
||||
}
|
||||
|
||||
} // namespace ProjectExplorer
|
||||
|
@@ -407,6 +407,7 @@ public:
|
||||
signals:
|
||||
void appendMessageRequested(ProjectExplorer::RunControl *runControl,
|
||||
const QString &msg, Utils::OutputFormat format);
|
||||
void starting();
|
||||
void started(QPrivateSignal); // Use reportApplicationStart!
|
||||
void finished(QPrivateSignal); // Use reportApplicationStop!
|
||||
void applicationProcessHandleChanged(QPrivateSignal); // Use setApplicationProcessHandle
|
||||
@@ -458,6 +459,7 @@ public:
|
||||
explicit ToolRunner(RunControl *runControl);
|
||||
|
||||
RunControl *runControl() const;
|
||||
void appendMessage(const QString &msg, Utils::OutputFormat format);
|
||||
|
||||
private:
|
||||
QPointer<RunControl> m_runControl;
|
||||
|
@@ -62,9 +62,9 @@ public:
|
||||
|
||||
using namespace Internal;
|
||||
|
||||
AbstractRemoteLinuxRunSupport::AbstractRemoteLinuxRunSupport(RunConfiguration *runConfig, QObject *parent)
|
||||
: QObject(parent),
|
||||
d(new AbstractRemoteLinuxRunSupportPrivate(runConfig))
|
||||
AbstractRemoteLinuxRunSupport::AbstractRemoteLinuxRunSupport(RunControl *runControl)
|
||||
: ToolRunner(runControl),
|
||||
d(new AbstractRemoteLinuxRunSupportPrivate(runControl->runConfiguration()))
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -28,6 +28,8 @@
|
||||
#include "remotelinux_export.h"
|
||||
|
||||
#include <projectexplorer/devicesupport/idevice.h>
|
||||
#include <projectexplorer/runconfiguration.h>
|
||||
|
||||
#include <utils/port.h>
|
||||
|
||||
#include <QObject>
|
||||
@@ -43,7 +45,7 @@ namespace RemoteLinux {
|
||||
|
||||
namespace Internal { class AbstractRemoteLinuxRunSupportPrivate; }
|
||||
|
||||
class REMOTELINUX_EXPORT AbstractRemoteLinuxRunSupport : public QObject
|
||||
class REMOTELINUX_EXPORT AbstractRemoteLinuxRunSupport : public ProjectExplorer::ToolRunner
|
||||
{
|
||||
Q_OBJECT
|
||||
protected:
|
||||
@@ -55,8 +57,7 @@ protected:
|
||||
Running
|
||||
};
|
||||
public:
|
||||
AbstractRemoteLinuxRunSupport(ProjectExplorer::RunConfiguration *runConfig,
|
||||
QObject *parent = 0);
|
||||
explicit AbstractRemoteLinuxRunSupport(ProjectExplorer::RunControl *runControl);
|
||||
~AbstractRemoteLinuxRunSupport();
|
||||
|
||||
protected:
|
||||
|
@@ -54,9 +54,8 @@ namespace Internal {
|
||||
class RemoteLinuxAnalyzeSupportPrivate
|
||||
{
|
||||
public:
|
||||
RemoteLinuxAnalyzeSupportPrivate(AnalyzerRunControl *rc, Core::Id runMode)
|
||||
: runControl(rc),
|
||||
runMode(runMode)
|
||||
RemoteLinuxAnalyzeSupportPrivate(RunControl *runControl, Core::Id runMode)
|
||||
: runMode(runMode)
|
||||
{
|
||||
if (runMode != ProjectExplorer::Constants::PERFPROFILER_RUN_MODE)
|
||||
return;
|
||||
@@ -70,7 +69,6 @@ public:
|
||||
.join(' ');
|
||||
}
|
||||
|
||||
const QPointer<AnalyzerRunControl> runControl;
|
||||
Core::Id runMode;
|
||||
Utils::Port qmlPort;
|
||||
QString remoteFifo;
|
||||
@@ -84,16 +82,15 @@ public:
|
||||
|
||||
using namespace Internal;
|
||||
|
||||
RemoteLinuxAnalyzeSupport::RemoteLinuxAnalyzeSupport(RunConfiguration *runConfig,
|
||||
AnalyzerRunControl *engine, Core::Id runMode)
|
||||
: AbstractRemoteLinuxRunSupport(runConfig, engine),
|
||||
d(new RemoteLinuxAnalyzeSupportPrivate(engine, runMode))
|
||||
RemoteLinuxAnalyzeSupport::RemoteLinuxAnalyzeSupport(RunControl *runControl, Core::Id runMode)
|
||||
: AbstractRemoteLinuxRunSupport(runControl),
|
||||
d(new RemoteLinuxAnalyzeSupportPrivate(runControl, runMode))
|
||||
{
|
||||
connect(d->runControl.data(), &AnalyzerRunControl::starting,
|
||||
connect(runControl, &RunControl::starting,
|
||||
this, &RemoteLinuxAnalyzeSupport::handleRemoteSetupRequested);
|
||||
connect(&d->outputParser, &QmlDebug::QmlOutputParser::waitingForConnectionOnPort,
|
||||
this, &RemoteLinuxAnalyzeSupport::remoteIsRunning);
|
||||
connect(engine, &RunControl::finished,
|
||||
connect(runControl, &RunControl::finished,
|
||||
this, &RemoteLinuxAnalyzeSupport::handleProfilingFinished);
|
||||
}
|
||||
|
||||
@@ -104,8 +101,8 @@ RemoteLinuxAnalyzeSupport::~RemoteLinuxAnalyzeSupport()
|
||||
|
||||
void RemoteLinuxAnalyzeSupport::showMessage(const QString &msg, Utils::OutputFormat format)
|
||||
{
|
||||
if (state() != Inactive && d->runControl)
|
||||
d->runControl->appendMessage(msg, format);
|
||||
if (state() != Inactive)
|
||||
appendMessage(msg, format);
|
||||
d->outputParser.processOutput(msg);
|
||||
}
|
||||
|
||||
@@ -173,9 +170,9 @@ void RemoteLinuxAnalyzeSupport::startExecution()
|
||||
r.executable = QLatin1String("sh");
|
||||
|
||||
connect(&d->outputGatherer, SIGNAL(remoteStdout(QByteArray)),
|
||||
d->runControl, SIGNAL(analyzePerfOutput(QByteArray)));
|
||||
runControl(), SIGNAL(analyzePerfOutput(QByteArray)));
|
||||
connect(&d->outputGatherer, SIGNAL(finished(bool)),
|
||||
d->runControl, SIGNAL(perfFinished()));
|
||||
runControl(), SIGNAL(perfFinished()));
|
||||
|
||||
StandardRunnable outputRunner;
|
||||
outputRunner.executable = QLatin1String("sh");
|
||||
@@ -201,7 +198,9 @@ void RemoteLinuxAnalyzeSupport::handleAppRunnerFinished(bool success)
|
||||
reset();
|
||||
if (!success)
|
||||
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()
|
||||
@@ -211,7 +210,9 @@ void RemoteLinuxAnalyzeSupport::handleProfilingFinished()
|
||||
|
||||
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)
|
||||
@@ -225,9 +226,6 @@ void RemoteLinuxAnalyzeSupport::handleRemoteErrorOutput(const QByteArray &output
|
||||
{
|
||||
QTC_ASSERT(state() != GatheringResources, return);
|
||||
|
||||
if (!d->runControl)
|
||||
return;
|
||||
|
||||
showMessage(QString::fromUtf8(output), Utils::StdErrFormat);
|
||||
}
|
||||
|
||||
|
@@ -42,8 +42,7 @@ class REMOTELINUX_EXPORT RemoteLinuxAnalyzeSupport : public AbstractRemoteLinuxR
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
RemoteLinuxAnalyzeSupport(ProjectExplorer::RunConfiguration *runConfig,
|
||||
Debugger::AnalyzerRunControl *engine, Core::Id runMode);
|
||||
RemoteLinuxAnalyzeSupport(ProjectExplorer::RunControl *runConfig, Core::Id runMode);
|
||||
~RemoteLinuxAnalyzeSupport() override;
|
||||
|
||||
protected:
|
||||
|
@@ -56,14 +56,12 @@ namespace Internal {
|
||||
class LinuxDeviceDebugSupportPrivate
|
||||
{
|
||||
public:
|
||||
LinuxDeviceDebugSupportPrivate(const RunConfiguration *runConfig, DebuggerRunControl *runControl)
|
||||
: runControl(runControl),
|
||||
qmlDebugging(runConfig->extraAspect<DebuggerRunConfigurationAspect>()->useQmlDebugger()),
|
||||
LinuxDeviceDebugSupportPrivate(const RunConfiguration *runConfig)
|
||||
: qmlDebugging(runConfig->extraAspect<DebuggerRunConfigurationAspect>()->useQmlDebugger()),
|
||||
cppDebugging(runConfig->extraAspect<DebuggerRunConfigurationAspect>()->useCppDebugger())
|
||||
{
|
||||
}
|
||||
|
||||
const QPointer<DebuggerRunControl> runControl;
|
||||
bool qmlDebugging;
|
||||
bool cppDebugging;
|
||||
QByteArray gdbserverOutput;
|
||||
@@ -75,12 +73,11 @@ public:
|
||||
|
||||
using namespace Internal;
|
||||
|
||||
LinuxDeviceDebugSupport::LinuxDeviceDebugSupport(RunConfiguration *runConfig,
|
||||
DebuggerRunControl *runControl)
|
||||
: AbstractRemoteLinuxRunSupport(runConfig, runControl),
|
||||
d(new LinuxDeviceDebugSupportPrivate(runConfig, runControl))
|
||||
LinuxDeviceDebugSupport::LinuxDeviceDebugSupport(RunControl *runControl)
|
||||
: AbstractRemoteLinuxRunSupport(runControl),
|
||||
d(new LinuxDeviceDebugSupportPrivate(runControl->runConfiguration()))
|
||||
{
|
||||
connect(runControl, &DebuggerRunControl::requestRemoteSetup,
|
||||
connect(this->runControl(), &DebuggerRunControl::requestRemoteSetup,
|
||||
this, &LinuxDeviceDebugSupport::handleRemoteSetupRequested);
|
||||
connect(runControl, &RunControl::finished,
|
||||
this, &LinuxDeviceDebugSupport::handleDebuggingFinished);
|
||||
@@ -103,8 +100,13 @@ bool LinuxDeviceDebugSupport::isQmlDebugging() const
|
||||
|
||||
void LinuxDeviceDebugSupport::showMessage(const QString &msg, int channel)
|
||||
{
|
||||
if (state() != Inactive && d->runControl)
|
||||
d->runControl->showMessage(msg, channel);
|
||||
if (state() != Inactive)
|
||||
runControl()->showMessage(msg, channel);
|
||||
}
|
||||
|
||||
DebuggerRunControl *LinuxDeviceDebugSupport::runControl() const
|
||||
{
|
||||
return qobject_cast<DebuggerRunControl *>(AbstractRemoteLinuxRunSupport::runControl());
|
||||
}
|
||||
|
||||
void LinuxDeviceDebugSupport::handleRemoteSetupRequested()
|
||||
@@ -183,8 +185,7 @@ void LinuxDeviceDebugSupport::handleAppRunnerError(const QString &error)
|
||||
{
|
||||
if (state() == Running) {
|
||||
showMessage(error, AppError);
|
||||
if (d->runControl)
|
||||
d->runControl->notifyInferiorIll();
|
||||
runControl()->notifyInferiorIll();
|
||||
} else if (state() != Inactive) {
|
||||
handleAdapterSetupFailed(error);
|
||||
}
|
||||
@@ -192,21 +193,21 @@ void LinuxDeviceDebugSupport::handleAppRunnerError(const QString &error)
|
||||
|
||||
void LinuxDeviceDebugSupport::handleAppRunnerFinished(bool success)
|
||||
{
|
||||
if (!d->runControl || state() == Inactive)
|
||||
if (state() == Inactive)
|
||||
return;
|
||||
|
||||
if (state() == Running) {
|
||||
// The QML engine does not realize on its own that the application has finished.
|
||||
if (d->qmlDebugging && !d->cppDebugging)
|
||||
d->runControl->quitDebugger();
|
||||
runControl()->quitDebugger();
|
||||
else if (!success)
|
||||
d->runControl->notifyInferiorIll();
|
||||
runControl()->notifyInferiorIll();
|
||||
|
||||
} else if (state() == StartingRunner) {
|
||||
RemoteSetupResult result;
|
||||
result.success = false;
|
||||
result.reason = tr("Debugging failed.");
|
||||
d->runControl->notifyEngineRemoteSetupFinished(result);
|
||||
runControl()->notifyEngineRemoteSetupFinished(result);
|
||||
}
|
||||
reset();
|
||||
}
|
||||
@@ -228,9 +229,6 @@ void LinuxDeviceDebugSupport::handleRemoteErrorOutput(const QByteArray &output)
|
||||
{
|
||||
QTC_ASSERT(state() != GatheringResources, return);
|
||||
|
||||
if (!d->runControl)
|
||||
return;
|
||||
|
||||
showMessage(QString::fromUtf8(output), AppError);
|
||||
if (state() == StartingRunner && d->cppDebugging) {
|
||||
d->gdbserverOutput += output;
|
||||
@@ -253,7 +251,7 @@ void LinuxDeviceDebugSupport::handleAdapterSetupFailed(const QString &error)
|
||||
RemoteSetupResult result;
|
||||
result.success = false;
|
||||
result.reason = tr("Initial setup failed: %1").arg(error);
|
||||
d->runControl->notifyEngineRemoteSetupFinished(result);
|
||||
runControl()->notifyEngineRemoteSetupFinished(result);
|
||||
}
|
||||
|
||||
void LinuxDeviceDebugSupport::handleAdapterSetupDone()
|
||||
@@ -264,7 +262,7 @@ void LinuxDeviceDebugSupport::handleAdapterSetupDone()
|
||||
result.success = true;
|
||||
result.gdbServerPort = d->gdbServerPort;
|
||||
result.qmlServerPort = d->qmlPort;
|
||||
d->runControl->notifyEngineRemoteSetupFinished(result);
|
||||
runControl()->notifyEngineRemoteSetupFinished(result);
|
||||
}
|
||||
|
||||
void LinuxDeviceDebugSupport::handleRemoteProcessStarted()
|
||||
|
@@ -38,8 +38,7 @@ class REMOTELINUX_EXPORT LinuxDeviceDebugSupport : public AbstractRemoteLinuxRun
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
LinuxDeviceDebugSupport(ProjectExplorer::RunConfiguration *runConfig,
|
||||
Debugger::DebuggerRunControl *runControl);
|
||||
LinuxDeviceDebugSupport(ProjectExplorer::RunControl *runControl);
|
||||
~LinuxDeviceDebugSupport() override;
|
||||
|
||||
protected:
|
||||
@@ -63,6 +62,7 @@ private:
|
||||
void handleDebuggingFinished();
|
||||
|
||||
void showMessage(const QString &msg, int channel);
|
||||
Debugger::DebuggerRunControl *runControl() const;
|
||||
|
||||
Internal::LinuxDeviceDebugSupportPrivate * const d;
|
||||
};
|
||||
|
@@ -138,7 +138,7 @@ RunControl *RemoteLinuxRunControlFactory::create(RunConfiguration *runConfig, Co
|
||||
DebuggerRunControl * const runControl = createDebuggerRunControl(params, runConfig, errorMessage, mode);
|
||||
if (!runControl)
|
||||
return 0;
|
||||
(void) new LinuxDeviceDebugSupport(runConfig, runControl);
|
||||
(void) new LinuxDeviceDebugSupport(runControl);
|
||||
return runControl;
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ RunControl *RemoteLinuxRunControlFactory::create(RunConfiguration *runConfig, Co
|
||||
DeviceKitInformation::device(runConfig->target()->kit())->sshParameters();
|
||||
connection.analyzerHost = connection.connParams.host;
|
||||
runControl->setConnection(connection);
|
||||
(void) new RemoteLinuxAnalyzeSupport(runConfig, runControl, mode);
|
||||
(void) new RemoteLinuxAnalyzeSupport(runControl, mode);
|
||||
return runControl;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user