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 Internal {
QnxAbstractRunSupport::QnxAbstractRunSupport(QnxRunConfiguration *runConfig, QObject *parent)
: QObject(parent)
, m_device(DeviceKitInformation::device(runConfig->target()->kit()))
QnxAbstractRunSupport::QnxAbstractRunSupport(RunControl *runControl)
: ToolRunner(runControl)
, m_device(DeviceKitInformation::device(runControl->runConfiguration()->target()->kit()))
, m_state(Inactive)
{
m_launcher = new ApplicationLauncher(this);

View File

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

View File

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

View File

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

View File

@@ -41,20 +41,18 @@
#include <qmldebug/qmldebugcommandlinearguments.h>
using namespace ProjectExplorer;
using namespace RemoteLinux;
namespace Qnx {
namespace Internal {
QnxDebugSupport::QnxDebugSupport(QnxRunConfiguration *runConfig, Debugger::DebuggerRunControl *runControl)
: QnxAbstractRunSupport(runConfig, 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())
QnxDebugSupport::QnxDebugSupport(RunControl *runControl)
: QnxAbstractRunSupport(runControl)
{
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();
connect(runner, &ApplicationLauncher::reportError, this, &QnxDebugSupport::handleError);
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::remoteStderr, this, &QnxDebugSupport::handleRemoteOutput);
connect(m_runControl, &Debugger::DebuggerRunControl::requestRemoteSetup,
connect(this->runControl(), &Debugger::DebuggerRunControl::requestRemoteSetup,
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());
QnxDevice::ConstPtr qnxDevice = dev.dynamicCast<const QnxDevice>();
@@ -81,8 +82,7 @@ void QnxDebugSupport::handleAdapterSetupRequested()
{
QTC_ASSERT(state() == Inactive, return);
if (m_runControl)
m_runControl->showMessage(tr("Preparing remote side...") + QLatin1Char('\n'), Debugger::AppStuff);
runControl()->showMessage(tr("Preparing remote side...") + QLatin1Char('\n'), Debugger::AppStuff);
QnxAbstractRunSupport::handleAdapterSetupRequested();
}
@@ -120,29 +120,27 @@ void QnxDebugSupport::startExecution()
void QnxDebugSupport::handleRemoteProcessStarted()
{
QnxAbstractRunSupport::handleRemoteProcessStarted();
if (m_runControl) {
Debugger::RemoteSetupResult result;
result.success = true;
result.gdbServerPort = m_pdebugPort;
result.qmlServerPort = m_qmlPort;
m_runControl->notifyEngineRemoteSetupFinished(result);
}
Debugger::RemoteSetupResult result;
result.success = true;
result.gdbServerPort = m_pdebugPort;
result.qmlServerPort = m_qmlPort;
runControl()->notifyEngineRemoteSetupFinished(result);
}
void QnxDebugSupport::handleRemoteProcessFinished(bool success)
{
if (!m_runControl || state() == Inactive)
if (state() == Inactive)
return;
if (state() == Running) {
if (!success)
m_runControl->notifyInferiorIll();
runControl()->notifyInferiorIll();
} else {
Debugger::RemoteSetupResult result;
result.success = false;
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)
{
if (m_runControl)
m_runControl->showMessage(progressOutput + QLatin1Char('\n'), Debugger::AppStuff);
runControl()->showMessage(progressOutput + QLatin1Char('\n'), Debugger::AppStuff);
}
void QnxDebugSupport::handleRemoteOutput(const QByteArray &output)
{
QTC_ASSERT(state() == Inactive || state() == Running, return);
if (m_runControl)
m_runControl->showMessage(QString::fromUtf8(output), Debugger::AppOutput);
runControl()->showMessage(QString::fromUtf8(output), Debugger::AppOutput);
}
void QnxDebugSupport::handleError(const QString &error)
{
if (state() == Running) {
if (m_runControl) {
m_runControl->showMessage(error, Debugger::AppError);
m_runControl->notifyInferiorIll();
}
runControl()->showMessage(error, Debugger::AppError);
runControl()->notifyInferiorIll();
} else if (state() != Inactive) {
setFinished();
if (m_runControl) {
Debugger::RemoteSetupResult result;
result.success = false;
result.reason = tr("Initial setup failed: %1").arg(error);
m_runControl->notifyEngineRemoteSetupFinished(result);
}
Debugger::RemoteSetupResult result;
result.success = false;
result.reason = tr("Initial setup failed: %1").arg(error);
runControl()->notifyEngineRemoteSetupFinished(result);
}
}
void QnxDebugSupport::printMissingWarning()
{
if (m_runControl)
m_runControl->showMessage(tr("Warning: \"slog2info\" is not found on the device, debug output not available."), Debugger::AppError);
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)
{
Q_UNUSED(outputFormat);
if (m_runControl)
m_runControl->showMessage(msg, Debugger::AppOutput);
runControl()->showMessage(msg, Debugger::AppOutput);
}
Debugger::DebuggerRunControl *QnxDebugSupport::runControl()
{
return qobject_cast<Debugger::DebuggerRunControl *>(QnxAbstractRunSupport::runControl());
}
} // namespace Internal

View File

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

View File

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