From 58be2708a353128fd83555d8e20b5a32d6efd6d7 Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 27 Jan 2016 18:25:13 +0100 Subject: [PATCH] ProjectExplorer: Use Runnable in DeviceProcess::start Change-Id: I8ce5b536745db11980f43449a055b7ebf9da83d2 Reviewed-by: Christian Stenger Reviewed-by: Christian Kandeler --- .../baremetal/baremetaldebugsupport.cpp | 12 +++-- .../baremetal/gdbserverproviderprocess.cpp | 26 +++------- .../baremetal/gdbserverproviderprocess.h | 7 +-- .../devicesupport/desktopdeviceprocess.cpp | 25 ++++------ .../devicesupport/desktopdeviceprocess.h | 7 +-- .../devicesupport/deviceapplicationrunner.cpp | 22 ++------- .../devicesupport/deviceapplicationrunner.h | 14 ++---- .../devicesupport/deviceprocess.h | 12 ++--- .../devicesupport/sshdeviceprocess.cpp | 47 +++++-------------- .../devicesupport/sshdeviceprocess.h | 13 ++--- src/plugins/qnx/qnxanalyzesupport.cpp | 13 +++-- src/plugins/qnx/qnxattachdebugsupport.cpp | 9 ++-- src/plugins/qnx/qnxdebugsupport.cpp | 9 ++-- src/plugins/qnx/qnxdeviceconfiguration.cpp | 8 ++-- src/plugins/qnx/qnxdeviceprocess.cpp | 19 ++++---- src/plugins/qnx/qnxdeviceprocess.h | 5 +- src/plugins/qnx/slog2inforunner.cpp | 21 ++++++--- .../remotelinux/linuxdeviceprocess.cpp | 25 +++++----- src/plugins/remotelinux/linuxdeviceprocess.h | 5 +- .../remotelinux/remotelinuxanalyzesupport.cpp | 12 ++--- .../remotelinux/remotelinuxdebugsupport.cpp | 24 +++++----- .../remotelinux/remotelinuxruncontrol.cpp | 8 +--- 22 files changed, 135 insertions(+), 208 deletions(-) diff --git a/src/plugins/baremetal/baremetaldebugsupport.cpp b/src/plugins/baremetal/baremetaldebugsupport.cpp index c755f553aed..56f6b1e2264 100644 --- a/src/plugins/baremetal/baremetaldebugsupport.cpp +++ b/src/plugins/baremetal/baremetaldebugsupport.cpp @@ -34,6 +34,11 @@ #include #include +#include + +#include + +using namespace ProjectExplorer; namespace BareMetal { namespace Internal { @@ -167,9 +172,10 @@ void BareMetalDebugSupport::startExecution() connect(m_appRunner, &ProjectExplorer::DeviceApplicationRunner::reportError, this, &BareMetalDebugSupport::appRunnerError); - const QString cmd = p->executable(); - const QStringList args = p->arguments(); - m_appRunner->start(m_device, cmd, args); + StandardRunnable r; + r.executable = p->executable(); + r.commandLineArguments = Utils::QtcProcess::joinArgs(p->arguments(), Utils::OsTypeLinux); + m_appRunner->start(m_device, r); } void BareMetalDebugSupport::setFinished() diff --git a/src/plugins/baremetal/gdbserverproviderprocess.cpp b/src/plugins/baremetal/gdbserverproviderprocess.cpp index 574093e276b..b7dc005d007 100644 --- a/src/plugins/baremetal/gdbserverproviderprocess.cpp +++ b/src/plugins/baremetal/gdbserverproviderprocess.cpp @@ -26,6 +26,7 @@ #include "gdbserverproviderprocess.h" #include +#include #include #include @@ -33,6 +34,8 @@ #include +using namespace ProjectExplorer; + namespace BareMetal { namespace Internal { @@ -60,12 +63,12 @@ GdbServerProviderProcess::GdbServerProviderProcess( this, &ProjectExplorer::DeviceProcess::started); } -void GdbServerProviderProcess::start(const QString &executable, const QStringList &arguments) +void GdbServerProviderProcess::start(const ProjectExplorer::Runnable &runnable) { + QTC_ASSERT(runnable.is(), return); QTC_ASSERT(m_process->state() == QProcess::NotRunning, return); - QString args; - Utils::QtcProcess::addArgs(&args, arguments); - m_process->setCommand(executable, args); + auto r = runnable.as(); + m_process->setCommand(r.executable, r.commandLineArguments); m_process->start(); } @@ -104,21 +107,6 @@ QString GdbServerProviderProcess::errorString() const return m_process->errorString(); } -Utils::Environment GdbServerProviderProcess::environment() const -{ - return Utils::Environment(m_process->processEnvironment().toStringList()); -} - -void GdbServerProviderProcess::setEnvironment(const Utils::Environment &env) -{ - m_process->setProcessEnvironment(env.toProcessEnvironment()); -} - -void GdbServerProviderProcess::setWorkingDirectory(const QString &dir) -{ - m_process->setWorkingDirectory(dir); -} - QByteArray GdbServerProviderProcess::readAllStandardOutput() { return m_process->readAllStandardOutput(); diff --git a/src/plugins/baremetal/gdbserverproviderprocess.h b/src/plugins/baremetal/gdbserverproviderprocess.h index 7d8461dc07c..af698517802 100644 --- a/src/plugins/baremetal/gdbserverproviderprocess.h +++ b/src/plugins/baremetal/gdbserverproviderprocess.h @@ -28,6 +28,7 @@ #include +namespace ProjectExplorer { class Runnable; } namespace Utils { class QtcProcess; } namespace BareMetal { @@ -41,7 +42,7 @@ public: const QSharedPointer &device, QObject *parent = 0); - void start(const QString &executable, const QStringList &arguments); + void start(const ProjectExplorer::Runnable &runnable); void interrupt(); void terminate(); void kill(); @@ -51,10 +52,6 @@ public: int exitCode() const; QString errorString() const; - Utils::Environment environment() const; - void setEnvironment(const Utils::Environment &); - void setWorkingDirectory(const QString &); - QByteArray readAllStandardOutput(); QByteArray readAllStandardError(); diff --git a/src/plugins/projectexplorer/devicesupport/desktopdeviceprocess.cpp b/src/plugins/projectexplorer/devicesupport/desktopdeviceprocess.cpp index dd348a0b533..67dbb684485 100644 --- a/src/plugins/projectexplorer/devicesupport/desktopdeviceprocess.cpp +++ b/src/plugins/projectexplorer/devicesupport/desktopdeviceprocess.cpp @@ -24,7 +24,9 @@ ****************************************************************************/ #include "desktopdeviceprocess.h" + #include "idevice.h" +#include "../runnables.h" #include #include @@ -48,10 +50,14 @@ DesktopDeviceProcess::DesktopDeviceProcess(const QSharedPointer & connect(&m_process, &QProcess::started, this, &DeviceProcess::started); } -void DesktopDeviceProcess::start(const QString &executable, const QStringList &arguments) +void DesktopDeviceProcess::start(const Runnable &runnable) { + QTC_ASSERT(runnable.is(), return); QTC_ASSERT(m_process.state() == QProcess::NotRunning, return); - m_process.start(executable, arguments); + auto r = runnable.as(); + m_process.setProcessEnvironment(r.environment.toProcessEnvironment()); + m_process.setWorkingDirectory(r.workingDirectory); + m_process.start(r.executable, Utils::QtcProcess::splitArgs(r.commandLineArguments)); } void DesktopDeviceProcess::interrupt() @@ -89,21 +95,6 @@ QString DesktopDeviceProcess::errorString() const return m_process.errorString(); } -Utils::Environment DesktopDeviceProcess::environment() const -{ - return Utils::Environment(m_process.processEnvironment().toStringList()); -} - -void DesktopDeviceProcess::setEnvironment(const Utils::Environment &env) -{ - m_process.setProcessEnvironment(env.toProcessEnvironment()); -} - -void DesktopDeviceProcess::setWorkingDirectory(const QString &directory) -{ - m_process.setWorkingDirectory(directory); -} - QByteArray DesktopDeviceProcess::readAllStandardOutput() { return m_process.readAllStandardOutput(); diff --git a/src/plugins/projectexplorer/devicesupport/desktopdeviceprocess.h b/src/plugins/projectexplorer/devicesupport/desktopdeviceprocess.h index ab8304bc55a..9435c090c97 100644 --- a/src/plugins/projectexplorer/devicesupport/desktopdeviceprocess.h +++ b/src/plugins/projectexplorer/devicesupport/desktopdeviceprocess.h @@ -38,7 +38,7 @@ class DesktopDeviceProcess : public DeviceProcess public: DesktopDeviceProcess(const QSharedPointer &device, QObject *parent = 0); - void start(const QString &executable, const QStringList &arguments) override; + void start(const Runnable &runnable) override; void interrupt() override; void terminate() override; void kill() override; @@ -48,11 +48,6 @@ public: int exitCode() const override; QString errorString() const override; - Utils::Environment environment() const override; - void setEnvironment(const Utils::Environment &env) override; - - void setWorkingDirectory(const QString &directory) override; - QByteArray readAllStandardOutput() override; QByteArray readAllStandardError() override; diff --git a/src/plugins/projectexplorer/devicesupport/deviceapplicationrunner.cpp b/src/plugins/projectexplorer/devicesupport/deviceapplicationrunner.cpp index cbaf7604f49..a1bc90ba653 100644 --- a/src/plugins/projectexplorer/devicesupport/deviceapplicationrunner.cpp +++ b/src/plugins/projectexplorer/devicesupport/deviceapplicationrunner.cpp @@ -26,6 +26,7 @@ #include "deviceapplicationrunner.h" #include "sshdeviceprocess.h" +#include "../runnables.h" #include #include @@ -46,8 +47,6 @@ class DeviceApplicationRunner::DeviceApplicationRunnerPrivate { public: DeviceProcess *deviceProcess; - Utils::Environment environment; - QString workingDir; State state; bool stopRequested; bool success; @@ -67,18 +66,7 @@ DeviceApplicationRunner::~DeviceApplicationRunner() delete d; } -void DeviceApplicationRunner::setEnvironment(const Utils::Environment &env) -{ - d->environment = env; -} - -void DeviceApplicationRunner::setWorkingDirectory(const QString &workingDirectory) -{ - d->workingDir = workingDirectory; -} - -void DeviceApplicationRunner::start(const IDevice::ConstPtr &device, - const QString &command, const QStringList &arguments) +void DeviceApplicationRunner::start(const IDevice::ConstPtr &device, const Runnable &runnable) { QTC_ASSERT(d->state == Inactive, return); @@ -95,7 +83,7 @@ void DeviceApplicationRunner::start(const IDevice::ConstPtr &device, return; } - if (command.isEmpty()) { + if (runnable.is() && runnable.as().executable.isEmpty()) { doReportError(tr("Cannot run: No command given.")); setFinished(); return; @@ -115,9 +103,7 @@ void DeviceApplicationRunner::start(const IDevice::ConstPtr &device, this, &DeviceApplicationRunner::handleApplicationError); connect(d->deviceProcess, &DeviceProcess::finished, this, &DeviceApplicationRunner::handleApplicationFinished); - d->deviceProcess->setEnvironment(d->environment); - d->deviceProcess->setWorkingDirectory(d->workingDir); - d->deviceProcess->start(command, arguments); + d->deviceProcess->start(runnable); } void DeviceApplicationRunner::stop() diff --git a/src/plugins/projectexplorer/devicesupport/deviceapplicationrunner.h b/src/plugins/projectexplorer/devicesupport/deviceapplicationrunner.h index d01a9e3b5f3..4b5610fec53 100644 --- a/src/plugins/projectexplorer/devicesupport/deviceapplicationrunner.h +++ b/src/plugins/projectexplorer/devicesupport/deviceapplicationrunner.h @@ -33,14 +33,10 @@ #include #include -QT_BEGIN_NAMESPACE -class QStringList; -QT_END_NAMESPACE - -namespace Utils { class Environment; } - namespace ProjectExplorer { +class Runnable; + class PROJECTEXPLORER_EXPORT DeviceApplicationRunner : public QObject { Q_OBJECT @@ -49,11 +45,7 @@ public: explicit DeviceApplicationRunner(QObject *parent = 0); ~DeviceApplicationRunner(); - void setEnvironment(const Utils::Environment &env); - void setWorkingDirectory(const QString &workingDirectory); - - void start(const IDevice::ConstPtr &device, const QString &command, - const QStringList &arguments); + void start(const IDevice::ConstPtr &device, const Runnable &runnable); void stop(); signals: diff --git a/src/plugins/projectexplorer/devicesupport/deviceprocess.h b/src/plugins/projectexplorer/devicesupport/deviceprocess.h index 732c5e2740b..35631728254 100644 --- a/src/plugins/projectexplorer/devicesupport/deviceprocess.h +++ b/src/plugins/projectexplorer/devicesupport/deviceprocess.h @@ -27,16 +27,17 @@ #define QTC_DEVICEPROCESS_H #include "../projectexplorer_export.h" +#include "../runconfiguration.h" #include #include #include #include -namespace Utils { class Environment; } - namespace ProjectExplorer { + class IDevice; +class Runnable; class PROJECTEXPLORER_EXPORT DeviceProcess : public QObject { @@ -44,7 +45,7 @@ class PROJECTEXPLORER_EXPORT DeviceProcess : public QObject public: virtual ~DeviceProcess(); - virtual void start(const QString &executable, const QStringList &arguments = QStringList()) = 0; + virtual void start(const Runnable &runnable) = 0; virtual void interrupt() = 0; virtual void terminate() = 0; virtual void kill() = 0; @@ -54,11 +55,6 @@ public: virtual int exitCode() const = 0; virtual QString errorString() const = 0; - virtual Utils::Environment environment() const = 0; - virtual void setEnvironment(const Utils::Environment &env) = 0; - - virtual void setWorkingDirectory(const QString &workingDirectory) = 0; - virtual QByteArray readAllStandardOutput() = 0; virtual QByteArray readAllStandardError() = 0; diff --git a/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.cpp b/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.cpp index f9194181e12..6469cd59ded 100644 --- a/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.cpp +++ b/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.cpp @@ -26,6 +26,7 @@ #include "sshdeviceprocess.h" #include "idevice.h" +#include "../runnables.h" #include #include @@ -47,8 +48,7 @@ public: bool serverSupportsSignals; QSsh::SshConnection *connection; QSsh::SshRemoteProcess::Ptr process; - QString executable; - QStringList arguments; + StandardRunnable runnable; QString errorMessage; QSsh::SshRemoteProcess::ExitStatus exitStatus; DeviceProcessSignalOperation::Ptr killOperation; @@ -57,7 +57,6 @@ public: QByteArray stdErr; int exitCode; enum State { Inactive, Connecting, Connected, ProcessRunning } state; - Utils::Environment environment; void setState(State newState); void doSignal(QSsh::SshRemoteProcess::Signal signal); @@ -78,15 +77,15 @@ SshDeviceProcess::~SshDeviceProcess() delete d; } -void SshDeviceProcess::start(const QString &executable, const QStringList &arguments) +void SshDeviceProcess::start(const Runnable &runnable) { QTC_ASSERT(d->state == SshDeviceProcessPrivate::Inactive, return); + QTC_ASSERT(runnable.is(), return); d->setState(SshDeviceProcessPrivate::Connecting); d->errorMessage.clear(); d->exitCode = -1; - d->executable = executable; - d->arguments = arguments; + d->runnable = runnable.as(); d->connection = QSsh::acquireConnection(device()->sshParameters()); connect(d->connection, SIGNAL(error(QSsh::SshError)), SLOT(handleConnectionError())); connect(d->connection, SIGNAL(disconnected()), SLOT(handleDisconnected())); @@ -115,16 +114,6 @@ void SshDeviceProcess::kill() d->doSignal(QSsh::SshRemoteProcess::KillSignal); } -QString SshDeviceProcess::executable() const -{ - return d->executable; -} - -QStringList SshDeviceProcess::arguments() const -{ - return d->arguments; -} - QProcess::ProcessState SshDeviceProcess::state() const { switch (d->state) { @@ -157,16 +146,6 @@ QString SshDeviceProcess::errorString() const return d->errorMessage; } -Utils::Environment SshDeviceProcess::environment() const -{ - return d->environment; -} - -void SshDeviceProcess::setEnvironment(const Utils::Environment &env) -{ - d->environment = env; -} - QByteArray SshDeviceProcess::readAllStandardOutput() { const QByteArray data = d->stdOut; @@ -191,14 +170,14 @@ void SshDeviceProcess::handleConnected() QTC_ASSERT(d->state == SshDeviceProcessPrivate::Connecting, return); d->setState(SshDeviceProcessPrivate::Connected); - d->process = d->connection->createRemoteProcess(fullCommandLine().toUtf8()); + d->process = d->connection->createRemoteProcess(fullCommandLine(d->runnable).toUtf8()); connect(d->process.data(), SIGNAL(started()), SLOT(handleProcessStarted())); connect(d->process.data(), SIGNAL(closed(int)), SLOT(handleProcessFinished(int))); connect(d->process.data(), SIGNAL(readyReadStandardOutput()), SLOT(handleStdout())); connect(d->process.data(), SIGNAL(readyReadStandardError()), SLOT(handleStderr())); d->process->clearEnvironment(); - const Utils::Environment env = environment(); + const Utils::Environment env = d->runnable.environment; for (Utils::Environment::const_iterator it = env.constBegin(); it != env.constEnd(); ++it) d->process->addToEnvironment(env.key(it).toUtf8(), env.value(it).toUtf8()); d->process->start(); @@ -292,11 +271,11 @@ void SshDeviceProcess::handleKillOperationTimeout() emit finished(); } -QString SshDeviceProcess::fullCommandLine() const +QString SshDeviceProcess::fullCommandLine(const StandardRunnable &runnable) const { - QString cmdLine = executable(); - if (!arguments().isEmpty()) - cmdLine.append(QLatin1Char(' ')).append(arguments().join(QLatin1Char(' '))); + QString cmdLine = runnable.executable; + if (!runnable.commandLineArguments.isEmpty()) + cmdLine.append(QLatin1Char(' ')).append(runnable.commandLineArguments); return cmdLine; } @@ -318,7 +297,7 @@ void SshDeviceProcess::SshDeviceProcessPrivate::doSignal(QSsh::SshRemoteProcess: } else { DeviceProcessSignalOperation::Ptr signalOperation = q->device()->signalOperation(); if (signal == QSsh::SshRemoteProcess::IntSignal) { - signalOperation->interruptProcess(executable); + signalOperation->interruptProcess(runnable.executable); } else { if (killOperation) // We are already in the process of killing the app. return; @@ -326,7 +305,7 @@ void SshDeviceProcess::SshDeviceProcessPrivate::doSignal(QSsh::SshRemoteProcess: connect(signalOperation.data(), SIGNAL(finished(QString)), q, SLOT(handleKillOperationFinished(QString))); killTimer.start(5000); - signalOperation->killProcess(executable); + signalOperation->killProcess(runnable.executable); } } break; diff --git a/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.h b/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.h index 08fe8c3df0f..b90b8a28ea8 100644 --- a/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.h +++ b/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.h @@ -30,6 +30,8 @@ namespace ProjectExplorer { +class StandardRunnable; + class PROJECTEXPLORER_EXPORT SshDeviceProcess : public DeviceProcess { Q_OBJECT @@ -37,23 +39,16 @@ public: SshDeviceProcess(const QSharedPointer &device, QObject *parent = 0); ~SshDeviceProcess(); - void start(const QString &executable, const QStringList &arguments); + void start(const Runnable &runnable); void interrupt(); void terminate(); void kill(); - QString executable() const; - QStringList arguments() const; QProcess::ProcessState state() const; QProcess::ExitStatus exitStatus() const; int exitCode() const; QString errorString() const; - Utils::Environment environment() const; - void setEnvironment(const Utils::Environment &env); - - void setWorkingDirectory(const QString & /* directory */) { } // No such thing in the RFC. - QByteArray readAllStandardOutput(); QByteArray readAllStandardError(); @@ -74,7 +69,7 @@ private slots: void handleKillOperationTimeout(); private: - virtual QString fullCommandLine() const; + virtual QString fullCommandLine(const StandardRunnable &runnable) const; class SshDeviceProcessPrivate; friend class SshDeviceProcessPrivate; diff --git a/src/plugins/qnx/qnxanalyzesupport.cpp b/src/plugins/qnx/qnxanalyzesupport.cpp index 7a881bd3646..58bb10462e6 100644 --- a/src/plugins/qnx/qnxanalyzesupport.cpp +++ b/src/plugins/qnx/qnxanalyzesupport.cpp @@ -102,13 +102,12 @@ void QnxAnalyzeSupport::startExecution() setState(StartingRemoteProcess); - const QStringList args = QStringList() - << QtcProcess::splitArgs(m_runControl->runnable().commandLineArguments) - << QmlDebug::qmlDebugTcpArguments(QmlDebug::QmlProfilerServices, m_qmlPort); - - appRunner()->setEnvironment(m_runnable.environment); - appRunner()->setWorkingDirectory(m_runnable.workingDirectory); - appRunner()->start(device(), m_runnable.executable, args); + StandardRunnable r = m_runnable; + if (!r.commandLineArguments.isEmpty()) + r.commandLineArguments += QLatin1Char(' '); + r.commandLineArguments + += QmlDebug::qmlDebugTcpArguments(QmlDebug::QmlProfilerServices, m_qmlPort); + appRunner()->start(device(), r); } void QnxAnalyzeSupport::handleRemoteProcessFinished(bool success) diff --git a/src/plugins/qnx/qnxattachdebugsupport.cpp b/src/plugins/qnx/qnxattachdebugsupport.cpp index a96c0feeafc..7eb5ceed8a6 100644 --- a/src/plugins/qnx/qnxattachdebugsupport.cpp +++ b/src/plugins/qnx/qnxattachdebugsupport.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -109,10 +110,10 @@ void QnxAttachDebugSupport::launchPDebug() return; } - const QString remoteCommand = QLatin1String("pdebug"); - QStringList arguments; - arguments << QString::number(m_pdebugPort); - m_runner->start(m_device, remoteCommand, arguments); + StandardRunnable r; + r.executable = QLatin1String("pdebug"); + r.commandLineArguments = QString::number(m_pdebugPort); + m_runner->start(m_device, r); } void QnxAttachDebugSupport::attachToProcess() diff --git a/src/plugins/qnx/qnxdebugsupport.cpp b/src/plugins/qnx/qnxdebugsupport.cpp index dc2b81620fa..2f9a3acf4be 100644 --- a/src/plugins/qnx/qnxdebugsupport.cpp +++ b/src/plugins/qnx/qnxdebugsupport.cpp @@ -108,9 +108,12 @@ void QnxDebugSupport::startExecution() arguments << QString::number(m_pdebugPort); else if (m_useQmlDebugger && !m_useCppDebugger) arguments = Utils::QtcProcess::splitArgs(m_runControl->startParameters().processArgs); - appRunner()->setEnvironment(m_runnable.environment); - appRunner()->setWorkingDirectory(m_runnable.workingDirectory); - appRunner()->start(device(), processExecutable(), arguments); + StandardRunnable r; + r.executable = processExecutable(); + r.commandLineArguments = Utils::QtcProcess::joinArgs(arguments); + r.environment = m_runnable.environment; + r.workingDirectory = m_runnable.workingDirectory; + appRunner()->start(device(), r); } void QnxDebugSupport::handleRemoteProcessStarted() diff --git a/src/plugins/qnx/qnxdeviceconfiguration.cpp b/src/plugins/qnx/qnxdeviceconfiguration.cpp index 40f94b8ae47..ce093014338 100644 --- a/src/plugins/qnx/qnxdeviceconfiguration.cpp +++ b/src/plugins/qnx/qnxdeviceconfiguration.cpp @@ -31,6 +31,7 @@ #include "qnxdeviceprocess.h" #include +#include #include #include @@ -135,9 +136,10 @@ void QnxDeviceConfiguration::updateVersionNumber() const QObject::connect(&versionNumberProcess, SIGNAL(finished()), &eventLoop, SLOT(quit())); QObject::connect(&versionNumberProcess, SIGNAL(error(QProcess::ProcessError)), &eventLoop, SLOT(quit())); - QStringList arguments; - arguments << QLatin1String("-r"); - versionNumberProcess.start(QLatin1String("uname"), arguments); + StandardRunnable r; + r.executable = QLatin1String("uname"); + r.commandLineArguments = QLatin1String("-r"); + versionNumberProcess.start(r); bool isGuiThread = QThread::currentThread() == QCoreApplication::instance()->thread(); if (isGuiThread) diff --git a/src/plugins/qnx/qnxdeviceprocess.cpp b/src/plugins/qnx/qnxdeviceprocess.cpp index 374c0dfe8bc..82e195dc9cd 100644 --- a/src/plugins/qnx/qnxdeviceprocess.cpp +++ b/src/plugins/qnx/qnxdeviceprocess.cpp @@ -26,6 +26,7 @@ #include "qnxdeviceprocess.h" #include +#include #include using namespace ProjectExplorer; @@ -39,14 +40,13 @@ static int pidFileCounter = 0; QnxDeviceProcess::QnxDeviceProcess(const QSharedPointer &device, QObject *parent) : SshDeviceProcess(device, parent) { - setEnvironment(Environment(OsTypeLinux)); m_pidFile = QString::fromLatin1("/var/run/qtc.%1.pid").arg(++pidFileCounter); } -QString QnxDeviceProcess::fullCommandLine() const +QString QnxDeviceProcess::fullCommandLine(const StandardRunnable &runnable) const { - QStringList args = arguments(); - args.prepend(executable()); + QStringList args = QtcProcess::splitArgs(runnable.commandLineArguments); + args.prepend(runnable.executable); QString cmd = QtcProcess::Arguments::createUnixArgs(args).toString(); QString fullCommandLine = QLatin1String( @@ -54,10 +54,10 @@ QString QnxDeviceProcess::fullCommandLine() const "test -f $HOME/profile && . $HOME/profile ; " ); - if (!m_workingDir.isEmpty()) - fullCommandLine += QString::fromLatin1("cd %1 ; ").arg(QtcProcess::quoteArg(m_workingDir)); + if (!runnable.workingDirectory.isEmpty()) + fullCommandLine += QString::fromLatin1("cd %1 ; ").arg(QtcProcess::quoteArg(runnable.workingDirectory)); - const Environment env = environment(); + const Environment env = runnable.environment; for (auto it = env.constBegin(); it != env.constEnd(); ++it) fullCommandLine += QString::fromLatin1("%1='%2' ").arg(it.key()).arg(it.value()); @@ -69,9 +69,10 @@ QString QnxDeviceProcess::fullCommandLine() const void QnxDeviceProcess::doSignal(int sig) { auto signaler = new SshDeviceProcess(device(), this); - QString cmd = QString::fromLatin1("kill -%2 `cat %1`").arg(m_pidFile).arg(sig); + StandardRunnable r; + r.executable = QString::fromLatin1("kill -%2 `cat %1`").arg(m_pidFile).arg(sig); connect(signaler, &SshDeviceProcess::finished, signaler, &QObject::deleteLater); - signaler->start(cmd, QStringList()); + signaler->start(r); } } // namespace Internal diff --git a/src/plugins/qnx/qnxdeviceprocess.h b/src/plugins/qnx/qnxdeviceprocess.h index bc261401059..d425b0600ce 100644 --- a/src/plugins/qnx/qnxdeviceprocess.h +++ b/src/plugins/qnx/qnxdeviceprocess.h @@ -38,17 +38,14 @@ class QnxDeviceProcess : public ProjectExplorer::SshDeviceProcess public: QnxDeviceProcess(const QSharedPointer &device, QObject *parent); - void setWorkingDirectory(const QString &directory) { m_workingDir = directory; } - void interrupt() { doSignal(2); } void terminate() { doSignal(15); } void kill() { doSignal(9); } - QString fullCommandLine() const; + QString fullCommandLine(const ProjectExplorer::StandardRunnable &runnable) const; private: void doSignal(int sig); QString m_pidFile; - QString m_workingDir; }; } // namespace Internal diff --git a/src/plugins/qnx/slog2inforunner.cpp b/src/plugins/qnx/slog2inforunner.cpp index 15233d29817..befca6f9aec 100644 --- a/src/plugins/qnx/slog2inforunner.cpp +++ b/src/plugins/qnx/slog2inforunner.cpp @@ -27,8 +27,11 @@ #include "qnxdeviceprocess.h" +#include #include +using namespace ProjectExplorer; + namespace Qnx { namespace Internal { @@ -59,7 +62,9 @@ Slog2InfoRunner::Slog2InfoRunner(const QString &applicationId, void Slog2InfoRunner::start() { - m_testProcess->start(QLatin1String("slog2info"), QStringList()); + StandardRunnable r; + r.executable = QLatin1String("slog2info"); + m_testProcess->start(r); } void Slog2InfoRunner::stop() @@ -89,9 +94,10 @@ void Slog2InfoRunner::handleTestProcessCompleted() void Slog2InfoRunner::readLaunchTime() { - QStringList arguments; - arguments << QLatin1String("+\"%d %H:%M:%S\""); - m_launchDateTimeProcess->start(QLatin1String("date"), arguments); + StandardRunnable r; + r.executable = QLatin1String("date"); + r.commandLineArguments = QLatin1String("+\"%d %H:%M:%S\""); + m_launchDateTimeProcess->start(r); } void Slog2InfoRunner::launchSlog2Info() @@ -105,9 +111,10 @@ void Slog2InfoRunner::launchSlog2Info() m_launchDateTime = QDateTime::fromString(QString::fromLatin1(m_launchDateTimeProcess->readAllStandardOutput()).trimmed(), QString::fromLatin1("dd HH:mm:ss")); - QStringList arguments; - arguments << QLatin1String("-w"); - m_logProcess->start(QLatin1String("slog2info"), arguments); + StandardRunnable r; + r.executable = QLatin1String("slog2info"); + r.commandLineArguments = QLatin1String("-w"); + m_logProcess->start(r); } void Slog2InfoRunner::readLogStandardOutput() diff --git a/src/plugins/remotelinux/linuxdeviceprocess.cpp b/src/plugins/remotelinux/linuxdeviceprocess.cpp index e9a4e09fd4f..4cd28c975ce 100644 --- a/src/plugins/remotelinux/linuxdeviceprocess.cpp +++ b/src/plugins/remotelinux/linuxdeviceprocess.cpp @@ -25,9 +25,14 @@ #include "linuxdeviceprocess.h" +#include + #include #include +using namespace ProjectExplorer; +using namespace Utils; + namespace RemoteLinux { static QString quote(const QString &s) { return Utils::QtcProcess::quoteArgUnix(s); } @@ -36,7 +41,6 @@ LinuxDeviceProcess::LinuxDeviceProcess(const QSharedPointerqmlPort)); - - runner->setWorkingDirectory(runnable().workingDirectory); - runner->setEnvironment(runnable().environment); - runner->start(device(), runnable().executable, args); + auto r = runnable(); + if (!r.commandLineArguments.isEmpty()) + r.commandLineArguments.append(QLatin1Char(' ')); + r.commandLineArguments + += QmlDebug::qmlDebugTcpArguments(QmlDebug::QmlProfilerServices, d->qmlPort); + runner->start(device(), r); } void RemoteLinuxAnalyzeSupport::handleAppRunnerError(const QString &error) diff --git a/src/plugins/remotelinux/remotelinuxdebugsupport.cpp b/src/plugins/remotelinux/remotelinuxdebugsupport.cpp index 02c7c101ac8..8316dbfedce 100644 --- a/src/plugins/remotelinux/remotelinuxdebugsupport.cpp +++ b/src/plugins/remotelinux/remotelinuxdebugsupport.cpp @@ -124,18 +124,25 @@ void LinuxDeviceDebugSupport::startExecution() this, &LinuxDeviceDebugSupport::handleRemoteErrorOutput); connect(runner, &DeviceApplicationRunner::remoteStdout, this, &LinuxDeviceDebugSupport::handleRemoteOutput); + connect(runner, &DeviceApplicationRunner::finished, + this, &LinuxDeviceDebugSupport::handleAppRunnerFinished); + connect(runner, &DeviceApplicationRunner::reportProgress, + this, &LinuxDeviceDebugSupport::handleProgressReport); + connect(runner, &DeviceApplicationRunner::reportError, + this, &LinuxDeviceDebugSupport::handleAppRunnerError); if (d->qmlDebugging && !d->cppDebugging) connect(runner, &DeviceApplicationRunner::remoteProcessStarted, this, &LinuxDeviceDebugSupport::handleRemoteProcessStarted); - QStringList args = QtcProcess::splitArgs(runnable().commandLineArguments, OsTypeLinux); + StandardRunnable r = runnable(); + QStringList args = QtcProcess::splitArgs(r.commandLineArguments, OsTypeLinux); QString command; if (d->qmlDebugging) args.prepend(QmlDebug::qmlDebugTcpArguments(QmlDebug::QmlDebuggerServices, d->qmlPort)); if (d->qmlDebugging && !d->cppDebugging) { - command = runnable().executable; + command = r.executable; } else { command = device()->debugServerPath(); if (command.isEmpty()) @@ -144,16 +151,9 @@ void LinuxDeviceDebugSupport::startExecution() args.append(QString::fromLatin1("--multi")); args.append(QString::fromLatin1(":%1").arg(d->gdbServerPort)); } - - connect(runner, &DeviceApplicationRunner::finished, - this, &LinuxDeviceDebugSupport::handleAppRunnerFinished); - connect(runner, &DeviceApplicationRunner::reportProgress, - this, &LinuxDeviceDebugSupport::handleProgressReport); - connect(runner, &DeviceApplicationRunner::reportError, - this, &LinuxDeviceDebugSupport::handleAppRunnerError); - runner->setEnvironment(runnable().environment); - runner->setWorkingDirectory(runnable().workingDirectory); - runner->start(device(), command, args); + r.executable = command; + r.commandLineArguments = QtcProcess::joinArgs(args, OsTypeLinux); + runner->start(device(), r); } void LinuxDeviceDebugSupport::handleAppRunnerError(const QString &error) diff --git a/src/plugins/remotelinux/remotelinuxruncontrol.cpp b/src/plugins/remotelinux/remotelinuxruncontrol.cpp index 090c87e8fe0..50685154cda 100644 --- a/src/plugins/remotelinux/remotelinuxruncontrol.cpp +++ b/src/plugins/remotelinux/remotelinuxruncontrol.cpp @@ -31,8 +31,6 @@ #include #include -#include - using namespace ProjectExplorer; namespace RemoteLinux { @@ -76,11 +74,7 @@ void RemoteLinuxRunControl::start() this, &RemoteLinuxRunControl::handleRunnerFinished); connect(&d->runner, &DeviceApplicationRunner::reportProgress, this, &RemoteLinuxRunControl::handleProgressReport); - d->runner.setEnvironment(d->runnable.environment); - d->runner.setWorkingDirectory(d->runnable.workingDirectory); - d->runner.start(d->device, d->runnable.executable, - Utils::QtcProcess::splitArgs(d->runnable.commandLineArguments, - Utils::OsTypeLinux)); + d->runner.start(d->device, d->runnable); } RunControl::StopResult RemoteLinuxRunControl::stop()