Qnx: Adapt to recent ToolSupport introduction

Change-Id: I5daa28d3fe24f196195396c674e36e0709e77046
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: James McDonnell <jmcdonnell@blackberry.com>
This commit is contained in:
hjk
2017-03-28 17:19:05 +02:00
parent 15867a9518
commit c69b6f0ea9
7 changed files with 72 additions and 90 deletions

View File

@@ -38,9 +38,9 @@ using namespace RemoteLinux;
namespace Qnx { namespace Qnx {
namespace Internal { namespace Internal {
QnxAbstractRunSupport::QnxAbstractRunSupport(QnxRunConfiguration *runConfig, QObject *parent) QnxAbstractRunSupport::QnxAbstractRunSupport(RunControl *runControl)
: QObject(parent) : ToolRunner(runControl)
, m_device(DeviceKitInformation::device(runConfig->target()->kit())) , m_device(DeviceKitInformation::device(runControl->runConfiguration()->target()->kit()))
, m_state(Inactive) , m_state(Inactive)
{ {
m_launcher = new ApplicationLauncher(this); m_launcher = new ApplicationLauncher(this);

View File

@@ -26,6 +26,8 @@
#pragma once #pragma once
#include <projectexplorer/devicesupport/idevice.h> #include <projectexplorer/devicesupport/idevice.h>
#include <projectexplorer/runconfiguration.h>
#include <utils/environment.h> #include <utils/environment.h>
#include <utils/portlist.h> #include <utils/portlist.h>
@@ -40,9 +42,7 @@ class DeviceUsedPortsGatherer;
namespace Qnx { namespace Qnx {
namespace Internal { namespace Internal {
class QnxRunConfiguration; class QnxAbstractRunSupport : public ProjectExplorer::ToolRunner
class QnxAbstractRunSupport : public QObject
{ {
Q_OBJECT Q_OBJECT
protected: protected:
@@ -52,8 +52,9 @@ protected:
StartingRemoteProcess, StartingRemoteProcess,
Running Running
}; };
public: public:
QnxAbstractRunSupport(QnxRunConfiguration *runConfig, QObject *parent = 0); explicit QnxAbstractRunSupport(ProjectExplorer::RunControl *runControl);
protected: protected:
bool setPort(Utils::Port &port); bool setPort(Utils::Port &port);

View File

@@ -43,11 +43,9 @@ using namespace Utils;
namespace Qnx { namespace Qnx {
namespace Internal { namespace Internal {
QnxAnalyzeSupport::QnxAnalyzeSupport(QnxRunConfiguration *runConfig, QnxAnalyzeSupport::QnxAnalyzeSupport(RunControl *runControl)
Debugger::AnalyzerRunControl *runControl) : QnxAbstractRunSupport(runControl)
: QnxAbstractRunSupport(runConfig, runControl) , m_runnable(runControl->runnable().as<StandardRunnable>())
, m_runnable(runConfig->runnable().as<StandardRunnable>())
, m_runControl(runControl)
, m_qmlPort(-1) , m_qmlPort(-1)
{ {
const ApplicationLauncher *runner = appRunner(); const ApplicationLauncher *runner = appRunner();
@@ -64,15 +62,19 @@ QnxAnalyzeSupport::QnxAnalyzeSupport(QnxRunConfiguration *runConfig,
connect(runner, &ApplicationLauncher::remoteStderr, connect(runner, &ApplicationLauncher::remoteStderr,
this, &QnxAnalyzeSupport::handleRemoteOutput); this, &QnxAnalyzeSupport::handleRemoteOutput);
connect(m_runControl, &Debugger::AnalyzerRunControl::starting, connect(runControl, &RunControl::starting,
this, &QnxAnalyzeSupport::handleAdapterSetupRequested); this, &QnxAnalyzeSupport::handleAdapterSetupRequested);
connect(runControl, &RunControl::finished,
this, &QnxAnalyzeSupport::setFinished);
connect(&m_outputParser, &QmlDebug::QmlOutputParser::waitingForConnectionOnPort, connect(&m_outputParser, &QmlDebug::QmlOutputParser::waitingForConnectionOnPort,
this, &QnxAnalyzeSupport::remoteIsRunning); this, &QnxAnalyzeSupport::remoteIsRunning);
IDevice::ConstPtr dev = DeviceKitInformation::device(runConfig->target()->kit()); IDevice::ConstPtr dev = DeviceKitInformation::device(runControl->runConfiguration()->target()->kit());
QnxDevice::ConstPtr qnxDevice = dev.dynamicCast<const QnxDevice>(); QnxDevice::ConstPtr qnxDevice = dev.dynamicCast<const QnxDevice>();
const QString applicationId = FileName::fromString(runConfig->remoteExecutableFilePath()).fileName(); auto qnxRunConfig = qobject_cast<QnxRunConfiguration *>(runControl->runConfiguration());
const QString applicationId = FileName::fromString(qnxRunConfig->remoteExecutableFilePath()).fileName();
m_slog2Info = new Slog2InfoRunner(applicationId, qnxDevice, this); m_slog2Info = new Slog2InfoRunner(applicationId, qnxDevice, this);
connect(m_slog2Info, &Slog2InfoRunner::output, connect(m_slog2Info, &Slog2InfoRunner::output,
this, &QnxAnalyzeSupport::showMessage); this, &QnxAnalyzeSupport::showMessage);
@@ -109,24 +111,21 @@ void QnxAnalyzeSupport::startExecution()
appRunner()->start(r, device()); appRunner()->start(r, device());
} }
Debugger::AnalyzerRunControl *QnxAnalyzeSupport::runControl()
{
return qobject_cast<Debugger::AnalyzerRunControl *>(QnxAbstractRunSupport::runControl());
}
void QnxAnalyzeSupport::handleRemoteProcessFinished(bool success) void QnxAnalyzeSupport::handleRemoteProcessFinished(bool success)
{ {
if (!m_runControl)
return;
if (!success) if (!success)
showMessage(tr("The %1 process closed unexpectedly.").arg(m_runnable.executable), showMessage(tr("The %1 process closed unexpectedly.").arg(m_runnable.executable),
NormalMessageFormat); NormalMessageFormat);
m_runControl->notifyRemoteFinished(); runControl()->notifyRemoteFinished();
m_slog2Info->stop(); m_slog2Info->stop();
} }
void QnxAnalyzeSupport::handleProfilingFinished()
{
setFinished();
}
void QnxAnalyzeSupport::handleProgressReport(const QString &progressOutput) void QnxAnalyzeSupport::handleProgressReport(const QString &progressOutput)
{ {
showMessage(progressOutput + QLatin1Char('\n'), NormalMessageFormat); showMessage(progressOutput + QLatin1Char('\n'), NormalMessageFormat);
@@ -151,14 +150,13 @@ void QnxAnalyzeSupport::handleError(const QString &error)
void QnxAnalyzeSupport::remoteIsRunning() void QnxAnalyzeSupport::remoteIsRunning()
{ {
if (m_runControl) runControl()->notifyRemoteSetupDone(m_qmlPort);
m_runControl->notifyRemoteSetupDone(m_qmlPort);
} }
void QnxAnalyzeSupport::showMessage(const QString &msg, OutputFormat format) void QnxAnalyzeSupport::showMessage(const QString &msg, OutputFormat format)
{ {
if (state() != Inactive && m_runControl) if (state() != Inactive)
m_runControl->appendMessage(msg, format); runControl()->appendMessage(msg, format);
m_outputParser.processOutput(msg); m_outputParser.processOutput(msg);
} }

View File

@@ -36,19 +36,16 @@ namespace Debugger { class AnalyzerRunControl; }
namespace Qnx { namespace Qnx {
namespace Internal { namespace Internal {
class QnxRunConfiguration;
class Slog2InfoRunner; class Slog2InfoRunner;
class QnxAnalyzeSupport : public QnxAbstractRunSupport class QnxAnalyzeSupport : public QnxAbstractRunSupport
{ {
Q_OBJECT Q_OBJECT
public: public:
QnxAnalyzeSupport(QnxRunConfiguration *runConfig, Debugger::AnalyzerRunControl *engine); explicit QnxAnalyzeSupport(ProjectExplorer::RunControl *runControl);
public slots: private:
void handleProfilingFinished();
private slots:
void handleAdapterSetupRequested() override; void handleAdapterSetupRequested() override;
void handleRemoteProcessFinished(bool success) override; void handleRemoteProcessFinished(bool success) override;
@@ -60,12 +57,10 @@ private slots:
void printMissingWarning(); void printMissingWarning();
void remoteIsRunning(); void remoteIsRunning();
private:
void startExecution() override; void startExecution() override;
Debugger::AnalyzerRunControl *runControl();
ProjectExplorer::StandardRunnable m_runnable; ProjectExplorer::StandardRunnable m_runnable;
Debugger::AnalyzerRunControl *m_runControl;
QmlDebug::QmlOutputParser m_outputParser; QmlDebug::QmlOutputParser m_outputParser;
Utils::Port m_qmlPort; Utils::Port m_qmlPort;

View File

@@ -41,20 +41,18 @@
#include <qmldebug/qmldebugcommandlinearguments.h> #include <qmldebug/qmldebugcommandlinearguments.h>
using namespace ProjectExplorer; using namespace ProjectExplorer;
using namespace RemoteLinux;
namespace Qnx { namespace Qnx {
namespace Internal { namespace Internal {
QnxDebugSupport::QnxDebugSupport(QnxRunConfiguration *runConfig, Debugger::DebuggerRunControl *runControl) QnxDebugSupport::QnxDebugSupport(RunControl *runControl)
: QnxAbstractRunSupport(runConfig, runControl) : QnxAbstractRunSupport(runControl)
, m_runnable(runConfig->runnable().as<StandardRunnable>())
, m_runControl(runControl)
, m_pdebugPort(-1)
, m_qmlPort(-1)
, m_useCppDebugger(runConfig->extraAspect<Debugger::DebuggerRunConfigurationAspect>()->useCppDebugger())
, m_useQmlDebugger(runConfig->extraAspect<Debugger::DebuggerRunConfigurationAspect>()->useQmlDebugger())
{ {
auto runConfig = runControl->runConfiguration();
m_useCppDebugger = runConfig->extraAspect<Debugger::DebuggerRunConfigurationAspect>()->useCppDebugger();
m_useQmlDebugger = runConfig->extraAspect<Debugger::DebuggerRunConfigurationAspect>()->useQmlDebugger();
m_runnable = runConfig->runnable().as<StandardRunnable>();
const ApplicationLauncher *runner = appRunner(); const ApplicationLauncher *runner = appRunner();
connect(runner, &ApplicationLauncher::reportError, this, &QnxDebugSupport::handleError); connect(runner, &ApplicationLauncher::reportError, this, &QnxDebugSupport::handleError);
connect(runner, &ApplicationLauncher::remoteProcessStarted, this, &QnxDebugSupport::handleRemoteProcessStarted); connect(runner, &ApplicationLauncher::remoteProcessStarted, this, &QnxDebugSupport::handleRemoteProcessStarted);
@@ -63,10 +61,13 @@ QnxDebugSupport::QnxDebugSupport(QnxRunConfiguration *runConfig, Debugger::Debug
connect(runner, &ApplicationLauncher::remoteStdout, this, &QnxDebugSupport::handleRemoteOutput); connect(runner, &ApplicationLauncher::remoteStdout, this, &QnxDebugSupport::handleRemoteOutput);
connect(runner, &ApplicationLauncher::remoteStderr, this, &QnxDebugSupport::handleRemoteOutput); connect(runner, &ApplicationLauncher::remoteStderr, this, &QnxDebugSupport::handleRemoteOutput);
connect(m_runControl, &Debugger::DebuggerRunControl::requestRemoteSetup, connect(this->runControl(), &Debugger::DebuggerRunControl::requestRemoteSetup,
this, &QnxDebugSupport::handleAdapterSetupRequested); this, &QnxDebugSupport::handleAdapterSetupRequested);
connect(runControl, &RunControl::finished,
this, &QnxDebugSupport::handleDebuggingFinished);
const QString applicationId = Utils::FileName::fromString(runConfig->remoteExecutableFilePath()).fileName(); auto qnxRunConfig = qobject_cast<QnxRunConfiguration *>(runControl->runConfiguration());
const QString applicationId = Utils::FileName::fromString(qnxRunConfig->remoteExecutableFilePath()).fileName();
IDevice::ConstPtr dev = DeviceKitInformation::device(runConfig->target()->kit()); IDevice::ConstPtr dev = DeviceKitInformation::device(runConfig->target()->kit());
QnxDevice::ConstPtr qnxDevice = dev.dynamicCast<const QnxDevice>(); QnxDevice::ConstPtr qnxDevice = dev.dynamicCast<const QnxDevice>();
@@ -81,8 +82,7 @@ void QnxDebugSupport::handleAdapterSetupRequested()
{ {
QTC_ASSERT(state() == Inactive, return); QTC_ASSERT(state() == Inactive, return);
if (m_runControl) runControl()->showMessage(tr("Preparing remote side...") + QLatin1Char('\n'), Debugger::AppStuff);
m_runControl->showMessage(tr("Preparing remote side...") + QLatin1Char('\n'), Debugger::AppStuff);
QnxAbstractRunSupport::handleAdapterSetupRequested(); QnxAbstractRunSupport::handleAdapterSetupRequested();
} }
@@ -120,29 +120,27 @@ void QnxDebugSupport::startExecution()
void QnxDebugSupport::handleRemoteProcessStarted() void QnxDebugSupport::handleRemoteProcessStarted()
{ {
QnxAbstractRunSupport::handleRemoteProcessStarted(); QnxAbstractRunSupport::handleRemoteProcessStarted();
if (m_runControl) { Debugger::RemoteSetupResult result;
Debugger::RemoteSetupResult result; result.success = true;
result.success = true; result.gdbServerPort = m_pdebugPort;
result.gdbServerPort = m_pdebugPort; result.qmlServerPort = m_qmlPort;
result.qmlServerPort = m_qmlPort; runControl()->notifyEngineRemoteSetupFinished(result);
m_runControl->notifyEngineRemoteSetupFinished(result);
}
} }
void QnxDebugSupport::handleRemoteProcessFinished(bool success) void QnxDebugSupport::handleRemoteProcessFinished(bool success)
{ {
if (!m_runControl || state() == Inactive) if (state() == Inactive)
return; return;
if (state() == Running) { if (state() == Running) {
if (!success) if (!success)
m_runControl->notifyInferiorIll(); runControl()->notifyInferiorIll();
} else { } else {
Debugger::RemoteSetupResult result; Debugger::RemoteSetupResult result;
result.success = false; result.success = false;
result.reason = tr("The %1 process closed unexpectedly.").arg(processExecutable()); result.reason = tr("The %1 process closed unexpectedly.").arg(processExecutable());
m_runControl->notifyEngineRemoteSetupFinished(result); runControl()->notifyEngineRemoteSetupFinished(result);
} }
} }
@@ -168,47 +166,43 @@ void QnxDebugSupport::killInferiorProcess()
void QnxDebugSupport::handleProgressReport(const QString &progressOutput) void QnxDebugSupport::handleProgressReport(const QString &progressOutput)
{ {
if (m_runControl) runControl()->showMessage(progressOutput + QLatin1Char('\n'), Debugger::AppStuff);
m_runControl->showMessage(progressOutput + QLatin1Char('\n'), Debugger::AppStuff);
} }
void QnxDebugSupport::handleRemoteOutput(const QByteArray &output) void QnxDebugSupport::handleRemoteOutput(const QByteArray &output)
{ {
QTC_ASSERT(state() == Inactive || state() == Running, return); QTC_ASSERT(state() == Inactive || state() == Running, return);
runControl()->showMessage(QString::fromUtf8(output), Debugger::AppOutput);
if (m_runControl)
m_runControl->showMessage(QString::fromUtf8(output), Debugger::AppOutput);
} }
void QnxDebugSupport::handleError(const QString &error) void QnxDebugSupport::handleError(const QString &error)
{ {
if (state() == Running) { if (state() == Running) {
if (m_runControl) { runControl()->showMessage(error, Debugger::AppError);
m_runControl->showMessage(error, Debugger::AppError); runControl()->notifyInferiorIll();
m_runControl->notifyInferiorIll();
}
} else if (state() != Inactive) { } else if (state() != Inactive) {
setFinished(); setFinished();
if (m_runControl) { Debugger::RemoteSetupResult result;
Debugger::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); runControl()->notifyEngineRemoteSetupFinished(result);
m_runControl->notifyEngineRemoteSetupFinished(result);
}
} }
} }
void QnxDebugSupport::printMissingWarning() void QnxDebugSupport::printMissingWarning()
{ {
if (m_runControl) runControl()->showMessage(tr("Warning: \"slog2info\" is not found on the device, debug output not available."), Debugger::AppError);
m_runControl->showMessage(tr("Warning: \"slog2info\" is not found on the device, debug output not available."), Debugger::AppError);
} }
void QnxDebugSupport::handleApplicationOutput(const QString &msg, Utils::OutputFormat outputFormat) void QnxDebugSupport::handleApplicationOutput(const QString &msg, Utils::OutputFormat outputFormat)
{ {
Q_UNUSED(outputFormat); Q_UNUSED(outputFormat);
if (m_runControl) runControl()->showMessage(msg, Debugger::AppOutput);
m_runControl->showMessage(msg, Debugger::AppOutput); }
Debugger::DebuggerRunControl *QnxDebugSupport::runControl()
{
return qobject_cast<Debugger::DebuggerRunControl *>(QnxAbstractRunSupport::runControl());
} }
} // namespace Internal } // namespace Internal

View File

@@ -36,7 +36,6 @@ namespace Debugger { class DebuggerRunControl; }
namespace Qnx { namespace Qnx {
namespace Internal { namespace Internal {
class QnxRunConfiguration;
class Slog2InfoRunner; class Slog2InfoRunner;
class QnxDebugSupport : public QnxAbstractRunSupport class QnxDebugSupport : public QnxAbstractRunSupport
@@ -44,13 +43,11 @@ class QnxDebugSupport : public QnxAbstractRunSupport
Q_OBJECT Q_OBJECT
public: public:
QnxDebugSupport(QnxRunConfiguration *runConfig, explicit QnxDebugSupport(ProjectExplorer::RunControl *runControl);
Debugger::DebuggerRunControl *runControl);
public slots:
void handleDebuggingFinished(); void handleDebuggingFinished();
private slots: private:
void handleAdapterSetupRequested() override; void handleAdapterSetupRequested() override;
void handleRemoteProcessStarted() override; void handleRemoteProcessStarted() override;
@@ -62,9 +59,9 @@ private slots:
void printMissingWarning(); void printMissingWarning();
void handleApplicationOutput(const QString &msg, Utils::OutputFormat outputFormat); void handleApplicationOutput(const QString &msg, Utils::OutputFormat outputFormat);
private:
void startExecution() override; void startExecution() override;
Debugger::DebuggerRunControl *runControl();
QString processExecutable() const; QString processExecutable() const;
void killInferiorProcess(); void killInferiorProcess();
@@ -72,7 +69,6 @@ private:
ProjectExplorer::StandardRunnable m_runnable; ProjectExplorer::StandardRunnable m_runnable;
Slog2InfoRunner *m_slog2Info; Slog2InfoRunner *m_slog2Info;
Debugger::DebuggerRunControl *m_runControl;
Utils::Port m_pdebugPort; Utils::Port m_pdebugPort;
Utils::Port m_qmlPort; Utils::Port m_qmlPort;

View File

@@ -132,8 +132,7 @@ RunControl *QnxRunControlFactory::create(RunConfiguration *runConfig, Core::Id m
const DebuggerStartParameters params = createDebuggerStartParameters(rc); const DebuggerStartParameters params = createDebuggerStartParameters(rc);
DebuggerRunControl *runControl = createDebuggerRunControl(params, runConfig, errorMessage); DebuggerRunControl *runControl = createDebuggerRunControl(params, runConfig, errorMessage);
QTC_ASSERT(runControl, return 0); QTC_ASSERT(runControl, return 0);
auto debugSupport = new QnxDebugSupport(rc, runControl); (void) new QnxDebugSupport(runControl);
connect(runControl, &RunControl::finished, debugSupport, &QnxDebugSupport::handleDebuggingFinished);
return runControl; return runControl;
} }
@@ -150,8 +149,7 @@ RunControl *QnxRunControlFactory::create(RunConfiguration *runConfig, Core::Id m
connection.analyzerHost = connection.connParams.host; connection.analyzerHost = connection.connParams.host;
connection.analyzerPort = Utils::Port(connection.connParams.port); connection.analyzerPort = Utils::Port(connection.connParams.port);
runControl->setConnection(connection); runControl->setConnection(connection);
auto analyzeSupport = new QnxAnalyzeSupport(rc, runControl); (void) new QnxAnalyzeSupport(runControl);
connect(runControl, &RunControl::finished, analyzeSupport, &QnxAnalyzeSupport::handleProfilingFinished);
return runControl; return runControl;
} }