forked from qt-creator/qt-creator
ApplicationLauncher: Remove start(IDevice *) overload
Take the device from runnable passed in setRunnable().
If the intention is to run locally, set the device
to nullptr inside runnable. Otherwise we don't run locally.
Follows 47957de2dc
Change-Id: I5b381bb499cf76e469c844ac7474ce2f60761cef
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
@@ -66,10 +66,11 @@ public:
|
|||||||
{
|
{
|
||||||
ProjectExplorer::Runnable r;
|
ProjectExplorer::Runnable r;
|
||||||
r.command = {Constants::AppcontrollerFilepath, {"--stop"}};
|
r.command = {Constants::AppcontrollerFilepath, {"--stop"}};
|
||||||
|
r.device = device();
|
||||||
|
|
||||||
auto launcher = new ApplicationLauncher(this);
|
auto launcher = new ApplicationLauncher(this);
|
||||||
launcher->setRunnable(r);
|
launcher->setRunnable(r);
|
||||||
launcher->start(device());
|
launcher->start();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -91,8 +92,9 @@ public:
|
|||||||
|
|
||||||
Runnable r;
|
Runnable r;
|
||||||
r.command = command;
|
r.command = command;
|
||||||
|
r.device = device;
|
||||||
m_appRunner.setRunnable(r);
|
m_appRunner.setRunnable(r);
|
||||||
m_appRunner.start(device);
|
m_appRunner.start();
|
||||||
showMessage(QdbDevice::tr("Starting command \"%1\" on device \"%2\".")
|
showMessage(QdbDevice::tr("Starting command \"%1\" on device \"%2\".")
|
||||||
.arg(command.toUserOutput(), m_deviceName));
|
.arg(command.toUserOutput(), m_deviceName));
|
||||||
}
|
}
|
||||||
|
@@ -117,9 +117,10 @@ public:
|
|||||||
|
|
||||||
r.command.setArguments(args);
|
r.command.setArguments(args);
|
||||||
r.command.setExecutable(FilePath::fromString(Constants::AppcontrollerFilepath));
|
r.command.setExecutable(FilePath::fromString(Constants::AppcontrollerFilepath));
|
||||||
|
r.device = device();
|
||||||
|
|
||||||
m_launcher.setRunnable(r);
|
m_launcher.setRunnable(r);
|
||||||
m_launcher.start(device());
|
m_launcher.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void stop() override { m_launcher.stop(); }
|
void stop() override { m_launcher.stop(); }
|
||||||
|
@@ -98,9 +98,10 @@ void QdbStopApplicationService::doDeploy()
|
|||||||
ProjectExplorer::Runnable runnable;
|
ProjectExplorer::Runnable runnable;
|
||||||
runnable.command = {Constants::AppcontrollerFilepath, {"--stop"}};
|
runnable.command = {Constants::AppcontrollerFilepath, {"--stop"}};
|
||||||
runnable.workingDirectory = "/usr/bin";
|
runnable.workingDirectory = "/usr/bin";
|
||||||
|
runnable.device = ProjectExplorer::DeviceKitAspect::device(target()->kit());
|
||||||
|
|
||||||
d->applicationLauncher.setRunnable(runnable);
|
d->applicationLauncher.setRunnable(runnable);
|
||||||
d->applicationLauncher.start(ProjectExplorer::DeviceKitAspect::device(target()->kit()));
|
d->applicationLauncher.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QdbStopApplicationService::stopDeployment()
|
void QdbStopApplicationService::stopDeployment()
|
||||||
|
@@ -504,7 +504,8 @@ void QmlEngine::closeConnection()
|
|||||||
void QmlEngine::startApplicationLauncher()
|
void QmlEngine::startApplicationLauncher()
|
||||||
{
|
{
|
||||||
if (!d->applicationLauncher.isRunning()) {
|
if (!d->applicationLauncher.isRunning()) {
|
||||||
const Runnable runnable = runParameters().inferior;
|
Runnable runnable = runParameters().inferior;
|
||||||
|
runnable.device.reset();
|
||||||
showMessage(tr("Starting %1").arg(runnable.command.toUserOutput()),
|
showMessage(tr("Starting %1").arg(runnable.command.toUserOutput()),
|
||||||
NormalMessageFormat);
|
NormalMessageFormat);
|
||||||
d->applicationLauncher.setRunnable(runnable);
|
d->applicationLauncher.setRunnable(runnable);
|
||||||
|
@@ -70,7 +70,7 @@ public:
|
|||||||
explicit ApplicationLauncherPrivate(ApplicationLauncher *parent);
|
explicit ApplicationLauncherPrivate(ApplicationLauncher *parent);
|
||||||
~ApplicationLauncherPrivate() override { setFinished(); }
|
~ApplicationLauncherPrivate() override { setFinished(); }
|
||||||
|
|
||||||
void start(const IDevice::ConstPtr &device, bool local);
|
void start();
|
||||||
void stop();
|
void stop();
|
||||||
|
|
||||||
void handleStandardOutput();
|
void handleStandardOutput();
|
||||||
@@ -324,17 +324,12 @@ QProcess::ExitStatus ApplicationLauncher::exitStatus() const
|
|||||||
|
|
||||||
void ApplicationLauncher::start()
|
void ApplicationLauncher::start()
|
||||||
{
|
{
|
||||||
d->start(IDevice::ConstPtr(), true);
|
d->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApplicationLauncher::start(const IDevice::ConstPtr &device)
|
void ApplicationLauncherPrivate::start()
|
||||||
{
|
{
|
||||||
d->start(device, false);
|
m_isLocal = m_runnable.device.isNull();
|
||||||
}
|
|
||||||
|
|
||||||
void ApplicationLauncherPrivate::start(const IDevice::ConstPtr &device, bool local)
|
|
||||||
{
|
|
||||||
m_isLocal = local;
|
|
||||||
|
|
||||||
m_exitCode = 0;
|
m_exitCode = 0;
|
||||||
m_exitStatus = QProcess::NormalExit;
|
m_exitStatus = QProcess::NormalExit;
|
||||||
@@ -381,19 +376,19 @@ void ApplicationLauncherPrivate::start(const IDevice::ConstPtr &device, bool loc
|
|||||||
QTC_ASSERT(m_state == Inactive, return);
|
QTC_ASSERT(m_state == Inactive, return);
|
||||||
|
|
||||||
m_state = Run;
|
m_state = Run;
|
||||||
if (!device) {
|
if (!m_runnable.device) {
|
||||||
doReportError(ApplicationLauncher::tr("Cannot run: No device."));
|
doReportError(ApplicationLauncher::tr("Cannot run: No device."));
|
||||||
setFinished();
|
setFinished();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!device->canCreateProcess()) {
|
if (!m_runnable.device->canCreateProcess()) {
|
||||||
doReportError(ApplicationLauncher::tr("Cannot run: Device is not able to create processes."));
|
doReportError(ApplicationLauncher::tr("Cannot run: Device is not able to create processes."));
|
||||||
setFinished();
|
setFinished();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!device->isEmptyCommandAllowed() && m_runnable.command.isEmpty()) {
|
if (!m_runnable.device->isEmptyCommandAllowed() && m_runnable.command.isEmpty()) {
|
||||||
doReportError(ApplicationLauncher::tr("Cannot run: No command given."));
|
doReportError(ApplicationLauncher::tr("Cannot run: No command given."));
|
||||||
setFinished();
|
setFinished();
|
||||||
return;
|
return;
|
||||||
@@ -401,7 +396,7 @@ void ApplicationLauncherPrivate::start(const IDevice::ConstPtr &device, bool loc
|
|||||||
|
|
||||||
m_stopRequested = false;
|
m_stopRequested = false;
|
||||||
|
|
||||||
m_process.reset(device->createProcess(this));
|
m_process.reset(m_runnable.device->createProcess(this));
|
||||||
connect(m_process.get(), &QtcProcess::errorOccurred,
|
connect(m_process.get(), &QtcProcess::errorOccurred,
|
||||||
this, &ApplicationLauncherPrivate::handleApplicationError);
|
this, &ApplicationLauncherPrivate::handleApplicationError);
|
||||||
connect(m_process.get(), &QtcProcess::finished,
|
connect(m_process.get(), &QtcProcess::finished,
|
||||||
|
@@ -58,7 +58,6 @@ public:
|
|||||||
void setRunnable(const Runnable &runnable);
|
void setRunnable(const Runnable &runnable);
|
||||||
|
|
||||||
void start();
|
void start();
|
||||||
void start(const IDevice::ConstPtr &device);
|
|
||||||
void stop();
|
void stop();
|
||||||
bool isRunning() const;
|
bool isRunning() const;
|
||||||
Utils::ProcessHandle applicationPID() const;
|
Utils::ProcessHandle applicationPID() const;
|
||||||
|
@@ -1244,14 +1244,18 @@ void SimpleTargetRunner::doStart(const Runnable &runnable, const IDevice::ConstP
|
|||||||
if (runnable.command.isEmpty()) {
|
if (runnable.command.isEmpty()) {
|
||||||
reportFailure(RunControl::tr("No executable specified."));
|
reportFailure(RunControl::tr("No executable specified."));
|
||||||
} else {
|
} else {
|
||||||
m_launcher.setRunnable(runnable);
|
Runnable runnableWithoutDevice = runnable;
|
||||||
|
runnableWithoutDevice.device.reset();
|
||||||
|
m_launcher.setRunnable(runnableWithoutDevice);
|
||||||
m_launcher.start();
|
m_launcher.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
connect(&m_launcher, &ApplicationLauncher::processStarted, this, &RunWorker::reportStarted);
|
connect(&m_launcher, &ApplicationLauncher::processStarted, this, &RunWorker::reportStarted);
|
||||||
|
Runnable runnableWithDevice = runnable;
|
||||||
|
runnableWithDevice.device = device;
|
||||||
m_launcher.setRunnable(runnable);
|
m_launcher.setRunnable(runnable);
|
||||||
m_launcher.start(device);
|
m_launcher.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -125,13 +125,12 @@ void CallgrindController::run(Option option)
|
|||||||
Runnable controller = m_valgrindRunnable;
|
Runnable controller = m_valgrindRunnable;
|
||||||
controller.command.setExecutable(FilePath::fromString(CALLGRIND_CONTROL_BINARY));
|
controller.command.setExecutable(FilePath::fromString(CALLGRIND_CONTROL_BINARY));
|
||||||
controller.command.setArguments(QString("%1 %2").arg(toOptionString(option)).arg(m_pid));
|
controller.command.setArguments(QString("%1 %2").arg(toOptionString(option)).arg(m_pid));
|
||||||
|
if (m_valgrindRunnable.device
|
||||||
|
&& m_valgrindRunnable.device->type() != ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) {
|
||||||
|
controller.device = m_valgrindRunnable.device;
|
||||||
|
}
|
||||||
m_controllerProcess->setRunnable(controller);
|
m_controllerProcess->setRunnable(controller);
|
||||||
if (!m_valgrindRunnable.device
|
m_controllerProcess->start();
|
||||||
|| m_valgrindRunnable.device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE)
|
|
||||||
m_controllerProcess->start();
|
|
||||||
else
|
|
||||||
m_controllerProcess->start(m_valgrindRunnable.device);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CallgrindController::setValgrindPid(qint64 pid)
|
void CallgrindController::setValgrindPid(qint64 pid)
|
||||||
|
@@ -135,20 +135,12 @@ bool ValgrindRunner::Private::run()
|
|||||||
valgrind.command = cmd;
|
valgrind.command = cmd;
|
||||||
valgrind.workingDirectory = m_debuggee.workingDirectory;
|
valgrind.workingDirectory = m_debuggee.workingDirectory;
|
||||||
valgrind.environment = m_debuggee.environment;
|
valgrind.environment = m_debuggee.environment;
|
||||||
valgrind.device = m_device;
|
if (m_device->type() != ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE
|
||||||
|
&& m_device->type() != "DockerDeviceType") {
|
||||||
if (m_device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) {
|
valgrind.device = m_device;
|
||||||
m_valgrindProcess.setRunnable(valgrind);
|
|
||||||
m_valgrindProcess.start();
|
|
||||||
} else if (m_device->type() == "DockerDeviceType") {
|
|
||||||
valgrind.device = {};
|
|
||||||
m_valgrindProcess.setRunnable(valgrind);
|
|
||||||
m_valgrindProcess.start();
|
|
||||||
} else {
|
|
||||||
m_valgrindProcess.setRunnable(valgrind);
|
|
||||||
m_valgrindProcess.start(m_device);
|
|
||||||
}
|
}
|
||||||
|
m_valgrindProcess.setRunnable(valgrind);
|
||||||
|
m_valgrindProcess.start();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,12 +184,13 @@ void ValgrindRunner::Private::remoteProcessStarted()
|
|||||||
" | awk '\\$5 ~ /^%3/" // 5th column must start with valgrind process
|
" | awk '\\$5 ~ /^%3/" // 5th column must start with valgrind process
|
||||||
" {print \\$1;}'" // print 1st then (with PID)
|
" {print \\$1;}'" // print 1st then (with PID)
|
||||||
"\"").arg(proc, m_debuggee.command.executable().fileName(), procEscaped));
|
"\"").arg(proc, m_debuggee.command.executable().fileName(), procEscaped));
|
||||||
|
findPid.device = m_device;
|
||||||
|
|
||||||
// m_remote.m_findPID = m_remote.m_connection->createRemoteProcess(cmd.toUtf8());
|
// m_remote.m_findPID = m_remote.m_connection->createRemoteProcess(cmd.toUtf8());
|
||||||
connect(&m_findPID, &ApplicationLauncher::appendMessage,
|
connect(&m_findPID, &ApplicationLauncher::appendMessage,
|
||||||
this, &ValgrindRunner::Private::findPidOutputReceived);
|
this, &ValgrindRunner::Private::findPidOutputReceived);
|
||||||
m_findPID.setRunnable(findPid);
|
m_findPID.setRunnable(findPid);
|
||||||
m_findPID.start(m_device);
|
m_findPID.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ValgrindRunner::Private::findPidOutputReceived(const QString &out, Utils::OutputFormat format)
|
void ValgrindRunner::Private::findPidOutputReceived(const QString &out, Utils::OutputFormat format)
|
||||||
|
Reference in New Issue
Block a user