aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/remotelinux/remotelinuxdebugsupport.cpp
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2017-04-21 11:39:01 +0200
committerhjk <hjk@qt.io>2017-04-26 12:02:03 +0000
commit59535078285d46d88ca4287a9edae803a1b9150d (patch)
tree3a03ce3ffeeadfeed60cde4a690d050cabf2b51f /src/plugins/remotelinux/remotelinuxdebugsupport.cpp
parentdce9aa217c0e9d16a0c45e9f0cae8585a9e9f15a (diff)
RemoteLinux: Base AbstractRemotetLinuxRunSupport on PE::TargetSupport
This essentially just puts the data members and most of the original interface on the proper, i.e. the 'target', side of the tool/target divide. Since the SimpleTargetRunner base already has an ApplicationLauncher member, this can be used directly. State handling and coordination between tool and target runner parts stays as before for now, with unchanged 'custom' transition logic. The plan here is to remove the custom state handling later, including the two remaining cases of direct targetRunner->toolRunner calling (startExecution, and adapterSetupFailed) for which this patch here temporarily uses signal/slot connections. Change-Id: I664f2e333b48b582befd0531a17d4008acac7c4c Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src/plugins/remotelinux/remotelinuxdebugsupport.cpp')
-rw-r--r--src/plugins/remotelinux/remotelinuxdebugsupport.cpp71
1 files changed, 45 insertions, 26 deletions
diff --git a/src/plugins/remotelinux/remotelinuxdebugsupport.cpp b/src/plugins/remotelinux/remotelinuxdebugsupport.cpp
index b5b8924cc2..ac3d1ec9a2 100644
--- a/src/plugins/remotelinux/remotelinuxdebugsupport.cpp
+++ b/src/plugins/remotelinux/remotelinuxdebugsupport.cpp
@@ -73,14 +73,23 @@ public:
using namespace Internal;
-LinuxDeviceDebugSupport::LinuxDeviceDebugSupport(RunControl *runControl)
- : AbstractRemoteLinuxRunSupport(runControl),
+LinuxDeviceDebugSupport::LinuxDeviceDebugSupport(RunControl *runControl,
+ const Debugger::DebuggerStartParameters &sp,
+ QString *errorMessage)
+ : DebuggerRunTool(runControl, sp, errorMessage),
d(new LinuxDeviceDebugSupportPrivate(runControl->runConfiguration()))
{
connect(this->runControl(), &DebuggerRunControl::requestRemoteSetup,
this, &LinuxDeviceDebugSupport::handleRemoteSetupRequested);
connect(runControl, &RunControl::finished,
this, &LinuxDeviceDebugSupport::handleDebuggingFinished);
+
+ connect(qobject_cast<AbstractRemoteLinuxRunSupport *>(runControl->targetRunner()),
+ &AbstractRemoteLinuxRunSupport::executionStartRequested,
+ this, &LinuxDeviceDebugSupport::startExecution);
+ connect(qobject_cast<AbstractRemoteLinuxRunSupport *>(runControl->targetRunner()),
+ &AbstractRemoteLinuxRunSupport::adapterSetupFailed,
+ this, &LinuxDeviceDebugSupport::handleAdapterSetupFailed);
}
LinuxDeviceDebugSupport::~LinuxDeviceDebugSupport()
@@ -100,46 +109,57 @@ bool LinuxDeviceDebugSupport::isQmlDebugging() const
void LinuxDeviceDebugSupport::showMessage(const QString &msg, int channel)
{
- if (state() != Inactive)
+ if (state() != AbstractRemoteLinuxRunSupport::Inactive)
runControl()->toolRunner()->showMessage(msg, channel);
}
DebuggerRunControl *LinuxDeviceDebugSupport::runControl() const
{
- return qobject_cast<DebuggerRunControl *>(AbstractRemoteLinuxRunSupport::runControl());
+ return qobject_cast<DebuggerRunControl *>(ToolRunner::runControl());
+}
+
+AbstractRemoteLinuxRunSupport *LinuxDeviceDebugSupport::targetRunner() const
+{
+ return qobject_cast<AbstractRemoteLinuxRunSupport *>(runControl()->targetRunner());
+}
+
+AbstractRemoteLinuxRunSupport::State LinuxDeviceDebugSupport::state() const
+{
+ AbstractRemoteLinuxRunSupport *runner = targetRunner();
+ return runner ? runner->state() : AbstractRemoteLinuxRunSupport::Inactive;
}
void LinuxDeviceDebugSupport::handleRemoteSetupRequested()
{
- QTC_ASSERT(state() == Inactive, return);
+ QTC_ASSERT(state() == AbstractRemoteLinuxRunSupport::Inactive, return);
showMessage(tr("Checking available ports...") + QLatin1Char('\n'), LogStatus);
- startPortsGathering();
+ targetRunner()->startPortsGathering();
}
void LinuxDeviceDebugSupport::startExecution()
{
- QTC_ASSERT(state() == GatheringResources, return);
+ QTC_ASSERT(state() == AbstractRemoteLinuxRunSupport::GatheringResources, return);
if (d->cppDebugging) {
- d->gdbServerPort = findPort();
+ d->gdbServerPort = targetRunner()->findPort();
if (!d->gdbServerPort.isValid()) {
handleAdapterSetupFailed(tr("Not enough free ports on device for C++ debugging."));
return;
}
}
if (d->qmlDebugging) {
- d->qmlPort = findPort();
+ d->qmlPort = targetRunner()->findPort();
if (!d->qmlPort.isValid()) {
handleAdapterSetupFailed(tr("Not enough free ports on device for QML debugging."));
return;
}
}
- setState(StartingRunner);
+ targetRunner()->setState(AbstractRemoteLinuxRunSupport::StartingRunner);
d->gdbserverOutput.clear();
- ApplicationLauncher *launcher = appRunner();
+ ApplicationLauncher *launcher = targetRunner()->applicationLauncher();
connect(launcher, &ApplicationLauncher::remoteStderr,
this, &LinuxDeviceDebugSupport::handleRemoteErrorOutput);
connect(launcher, &ApplicationLauncher::remoteStdout,
@@ -183,54 +203,55 @@ Runnable LinuxDeviceDebugSupport::realRunnable() const
void LinuxDeviceDebugSupport::handleAppRunnerError(const QString &error)
{
- if (state() == Running) {
+ if (state() == AbstractRemoteLinuxRunSupport::Running) {
showMessage(error, AppError);
runControl()->toolRunner()->notifyInferiorIll();
- } else if (state() != Inactive) {
+ } else if (state() != AbstractRemoteLinuxRunSupport::Inactive) {
handleAdapterSetupFailed(error);
}
}
void LinuxDeviceDebugSupport::handleAppRunnerFinished(bool success)
{
- if (state() == Inactive)
+ if (state() == AbstractRemoteLinuxRunSupport::Inactive)
return;
- if (state() == Running) {
+ if (state() == AbstractRemoteLinuxRunSupport::Running) {
// The QML engine does not realize on its own that the application has finished.
if (d->qmlDebugging && !d->cppDebugging)
runControl()->toolRunner()->quitDebugger();
else if (!success)
runControl()->toolRunner()->notifyInferiorIll();
- } else if (state() == StartingRunner) {
+ } else if (state() == AbstractRemoteLinuxRunSupport::StartingRunner) {
RemoteSetupResult result;
result.success = false;
result.reason = tr("Debugging failed.");
runControl()->toolRunner()->notifyEngineRemoteSetupFinished(result);
}
- reset();
+ targetRunner()->reset();
}
void LinuxDeviceDebugSupport::handleDebuggingFinished()
{
- setFinished();
- reset();
+ targetRunner()->setFinished();
+ targetRunner()->reset();
}
void LinuxDeviceDebugSupport::handleRemoteOutput(const QByteArray &output)
{
- QTC_ASSERT(state() == Inactive || state() == Running, return);
+ QTC_ASSERT(state() == AbstractRemoteLinuxRunSupport::Inactive
+ || state() == AbstractRemoteLinuxRunSupport::Running, return);
showMessage(QString::fromUtf8(output), AppOutput);
}
void LinuxDeviceDebugSupport::handleRemoteErrorOutput(const QByteArray &output)
{
- QTC_ASSERT(state() != GatheringResources, return);
+ QTC_ASSERT(state() != AbstractRemoteLinuxRunSupport::GatheringResources, return);
showMessage(QString::fromUtf8(output), AppError);
- if (state() == StartingRunner && d->cppDebugging) {
+ if (state() == AbstractRemoteLinuxRunSupport::StartingRunner && d->cppDebugging) {
d->gdbserverOutput += output;
if (d->gdbserverOutput.contains("Listening on port")) {
handleAdapterSetupDone();
@@ -246,8 +267,6 @@ void LinuxDeviceDebugSupport::handleProgressReport(const QString &progressOutput
void LinuxDeviceDebugSupport::handleAdapterSetupFailed(const QString &error)
{
- AbstractRemoteLinuxRunSupport::handleAdapterSetupFailed(error);
-
RemoteSetupResult result;
result.success = false;
result.reason = tr("Initial setup failed: %1").arg(error);
@@ -256,7 +275,7 @@ void LinuxDeviceDebugSupport::handleAdapterSetupFailed(const QString &error)
void LinuxDeviceDebugSupport::handleAdapterSetupDone()
{
- AbstractRemoteLinuxRunSupport::handleAdapterSetupDone();
+ targetRunner()->setState(AbstractRemoteLinuxRunSupport::Running);
RemoteSetupResult result;
result.success = true;
@@ -268,7 +287,7 @@ void LinuxDeviceDebugSupport::handleAdapterSetupDone()
void LinuxDeviceDebugSupport::handleRemoteProcessStarted()
{
QTC_ASSERT(d->qmlDebugging && !d->cppDebugging, return);
- QTC_ASSERT(state() == StartingRunner, return);
+ QTC_ASSERT(state() == AbstractRemoteLinuxRunSupport::StartingRunner, return);
handleAdapterSetupDone();
}