RunWorker: Drop device() indirection

To clear RunWorker's API. It's RunControl's data.

Task-number: QTCREATORBUG-29168
Change-Id: I94367544bb76c9886bda97f3a47727e0a8777310
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Jarek Kobus
2025-01-14 16:12:35 +01:00
parent 6731d11628
commit d915c447d4
10 changed files with 21 additions and 27 deletions

View File

@@ -39,7 +39,7 @@ public:
explicit BareMetalDebugSupport(RunControl *runControl) explicit BareMetalDebugSupport(RunControl *runControl)
: Debugger::DebuggerRunTool(runControl) : Debugger::DebuggerRunTool(runControl)
{ {
const auto dev = std::static_pointer_cast<const BareMetalDevice>(device()); const auto dev = std::static_pointer_cast<const BareMetalDevice>(runControl->device());
if (!dev) { if (!dev) {
reportFailure(Tr::tr("Cannot debug: Kit has no device.")); reportFailure(Tr::tr("Cannot debug: Kit has no device."));
return; return;
@@ -59,7 +59,7 @@ public:
private: private:
void start() final void start() final
{ {
const auto dev = std::static_pointer_cast<const BareMetalDevice>(device()); const auto dev = std::static_pointer_cast<const BareMetalDevice>(runControl()->device());
QTC_ASSERT(dev, reportFailure(); return); QTC_ASSERT(dev, reportFailure(); return);
IDebugServerProvider *p = DebugServerProviderManager::findProvider( IDebugServerProvider *p = DebugServerProviderManager::findProvider(
dev->debugServerProviderId()); dev->debugServerProviderId());

View File

@@ -33,7 +33,7 @@ static RunWorker *createQdbDeviceInferiorWorker(RunControl *runControl,
worker->setId("QdbDeviceInferiorWorker"); worker->setId("QdbDeviceInferiorWorker");
worker->setStartModifier([worker, runControl, qmlServices] { worker->setStartModifier([worker, runControl, qmlServices] {
CommandLine cmd{worker->device()->filePath(Constants::AppcontrollerFilepath)}; CommandLine cmd{runControl->device()->filePath(Constants::AppcontrollerFilepath)};
int lowerPort = 0; int lowerPort = 0;
int upperPort = 0; int upperPort = 0;

View File

@@ -1296,7 +1296,7 @@ void DebuggerEngine::setRunId(const QString &id)
void DebuggerEngine::setRunTool(DebuggerRunTool *runTool) void DebuggerEngine::setRunTool(DebuggerRunTool *runTool)
{ {
d->m_runTool = runTool; d->m_runTool = runTool;
d->m_device = runTool->device(); d->m_device = runTool->runControl()->device();
validateRunParameters(d->m_runParameters); validateRunParameters(d->m_runParameters);

View File

@@ -578,11 +578,11 @@ void DebuggerRunTool::startDebugServerIfNeededAndContinueStartup()
cmd.addArg(qmlDebugTcpArguments(QmlDebuggerServices, runControl()->qmlChannel())); cmd.addArg(qmlDebugTcpArguments(QmlDebuggerServices, runControl()->qmlChannel()));
cmd.addArgs(commandLine.arguments(), CommandLine::Raw); cmd.addArgs(commandLine.arguments(), CommandLine::Raw);
} else { } else {
cmd.setExecutable(device()->debugServerPath()); cmd.setExecutable(runControl()->device()->debugServerPath());
if (cmd.isEmpty()) { if (cmd.isEmpty()) {
if (device()->osType() == Utils::OsTypeMac) { if (runControl()->device()->osType() == Utils::OsTypeMac) {
const FilePath debugServerLocation = device()->filePath( const FilePath debugServerLocation = runControl()->device()->filePath(
"/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/" "/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/"
"Resources/debugserver"); "Resources/debugserver");
@@ -592,15 +592,15 @@ void DebuggerRunTool::startDebugServerIfNeededAndContinueStartup()
// TODO: In the future it is expected that the debugserver will be // TODO: In the future it is expected that the debugserver will be
// replaced by lldb-server. Remove the check for debug server at that point. // replaced by lldb-server. Remove the check for debug server at that point.
const FilePath lldbserver const FilePath lldbserver
= device()->filePath("lldb-server").searchInPath(); = runControl()->device()->filePath("lldb-server").searchInPath();
if (lldbserver.isExecutableFile()) if (lldbserver.isExecutableFile())
cmd.setExecutable(lldbserver); cmd.setExecutable(lldbserver);
} }
} else { } else {
const FilePath gdbServerPath const FilePath gdbServerPath
= device()->filePath("gdbserver").searchInPath(); = runControl()->device()->filePath("gdbserver").searchInPath();
FilePath lldbServerPath FilePath lldbServerPath
= device()->filePath("lldb-server").searchInPath(); = runControl()->device()->filePath("lldb-server").searchInPath();
// TODO: Which one should we prefer? // TODO: Which one should we prefer?
if (gdbServerPath.isExecutableFile()) if (gdbServerPath.isExecutableFile())
@@ -643,7 +643,7 @@ void DebuggerRunTool::startDebugServerIfNeededAndContinueStartup()
const auto port = runControl()->debugChannel().port(); const auto port = runControl()->debugChannel().port();
cmd.addArg(QString(":%1").arg(port)); cmd.addArg(QString(":%1").arg(port));
if (device()->extraData(ProjectExplorer::Constants::SSH_FORWARD_DEBUGSERVER_PORT).toBool()) { if (runControl()->device()->extraData(ProjectExplorer::Constants::SSH_FORWARD_DEBUGSERVER_PORT).toBool()) {
QVariantHash extraData; QVariantHash extraData;
extraData[RemoteLinux::Constants::SshForwardPort] = port; extraData[RemoteLinux::Constants::SshForwardPort] = port;
extraData[RemoteLinux::Constants::DisableSharing] = true; extraData[RemoteLinux::Constants::DisableSharing] = true;

View File

@@ -323,7 +323,7 @@ void DeviceCtlRunnerBase::start()
} }
appendMessage(Tr::tr("Running \"%1\" on %2...") appendMessage(Tr::tr("Running \"%1\" on %2...")
.arg(m_bundlePath.toUserOutput(), device()->displayName()), .arg(m_bundlePath.toUserOutput(), runControl()->device()->displayName()),
NormalMessageFormat); NormalMessageFormat);
// If the app is already running, we should first kill it, then launch again. // If the app is already running, we should first kill it, then launch again.
@@ -906,7 +906,7 @@ IosDebugSupport::IosDebugSupport(RunControl *runControl)
{ {
setId("IosDebugSupport"); setId("IosDebugSupport");
IosDevice::ConstPtr dev = std::dynamic_pointer_cast<const IosDevice>(device()); IosDevice::ConstPtr dev = std::dynamic_pointer_cast<const IosDevice>(runControl->device());
DebuggerRunParameters &rp = runParameters(); DebuggerRunParameters &rp = runParameters();
if (dev->type() == Ios::Constants::IOS_SIMULATOR_TYPE if (dev->type() == Ios::Constants::IOS_SIMULATOR_TYPE
@@ -922,7 +922,7 @@ IosDebugSupport::IosDebugSupport(RunControl *runControl)
addStartDependency(m_deviceCtlRunner); addStartDependency(m_deviceCtlRunner);
} }
if (device()->type() == Ios::Constants::IOS_DEVICE_TYPE) { if (runControl->device()->type() == Ios::Constants::IOS_DEVICE_TYPE) {
if (dev->handler() == IosDevice::Handler::DeviceCtl) { if (dev->handler() == IosDevice::Handler::DeviceCtl) {
QTC_CHECK(IosDeviceManager::isDeviceCtlDebugSupported()); QTC_CHECK(IosDeviceManager::isDeviceCtlDebugSupported());
rp.setStartMode(AttachToIosDevice); rp.setStartMode(AttachToIosDevice);
@@ -951,7 +951,7 @@ void IosDebugSupport::start()
rp.setDisplayName(data->applicationName); rp.setDisplayName(data->applicationName);
rp.setContinueAfterAttach(true); rp.setContinueAfterAttach(true);
IosDevice::ConstPtr dev = std::dynamic_pointer_cast<const IosDevice>(device()); IosDevice::ConstPtr dev = std::dynamic_pointer_cast<const IosDevice>(runControl()->device());
if (dev->type() == Ios::Constants::IOS_DEVICE_TYPE if (dev->type() == Ios::Constants::IOS_DEVICE_TYPE
&& dev->handler() == IosDevice::Handler::DeviceCtl) { && dev->handler() == IosDevice::Handler::DeviceCtl) {
const auto msgOnlyCppDebuggingSupported = [] { const auto msgOnlyCppDebuggingSupported = [] {

View File

@@ -1882,11 +1882,6 @@ void RunWorker::appendMessage(const QString &msg, OutputFormat format, bool appe
d->runControl->postMessage(msg, format, appendNewLine); d->runControl->postMessage(msg, format, appendNewLine);
} }
IDevice::ConstPtr RunWorker::device() const
{
return d->runControl->device();
}
void RunWorker::addStartDependency(RunWorker *dependency) void RunWorker::addStartDependency(RunWorker *dependency)
{ {
d->startDependencies.append(dependency); d->startDependencies.append(dependency);

View File

@@ -58,7 +58,6 @@ public:
// Part of read-only interface of RunControl for convenience. // Part of read-only interface of RunControl for convenience.
void appendMessage(const QString &msg, Utils::OutputFormat format, bool appendNewLine = true); void appendMessage(const QString &msg, Utils::OutputFormat format, bool appendNewLine = true);
IDeviceConstPtr device() const;
// States // States
void initiateStart(); void initiateStart();

View File

@@ -185,7 +185,7 @@ public:
QStringList arguments; QStringList arguments;
if (runControl->usesDebugChannel()) { if (runControl->usesDebugChannel()) {
const int pdebugPort = runControl->debugChannel().port(); const int pdebugPort = runControl->debugChannel().port();
cmd.setExecutable(debuggeeRunner->device()->filePath(QNX_DEBUG_EXECUTABLE)); cmd.setExecutable(runControl->device()->filePath(QNX_DEBUG_EXECUTABLE));
arguments.append(QString::number(pdebugPort)); arguments.append(QString::number(pdebugPort));
} }
if (runControl->usesQmlChannel()) { if (runControl->usesQmlChannel()) {

View File

@@ -35,7 +35,7 @@ void Slog2InfoRunner::start()
QTC_CHECK(!m_taskTreeRunner.isRunning()); QTC_CHECK(!m_taskTreeRunner.isRunning());
const auto onTestSetup = [this](Process &process) { const auto onTestSetup = [this](Process &process) {
process.setCommand(CommandLine{device()->filePath("slog2info")}); process.setCommand(CommandLine{runControl()->device()->filePath("slog2info")});
}; };
const auto onTestDone = [this] { const auto onTestDone = [this] {
appendMessage(Tr::tr("Warning: \"slog2info\" is not found on the device, " appendMessage(Tr::tr("Warning: \"slog2info\" is not found on the device, "
@@ -43,7 +43,7 @@ void Slog2InfoRunner::start()
}; };
const auto onLaunchTimeSetup = [this](Process &process) { const auto onLaunchTimeSetup = [this](Process &process) {
process.setCommand({device()->filePath("date"), "+\"%d %H:%M:%S\"", CommandLine::Raw}); process.setCommand({runControl()->device()->filePath("date"), "+\"%d %H:%M:%S\"", CommandLine::Raw});
}; };
const auto onLaunchTimeDone = [this](const Process &process) { const auto onLaunchTimeDone = [this](const Process &process) {
QTC_CHECK(!m_applicationId.isEmpty()); QTC_CHECK(!m_applicationId.isEmpty());
@@ -51,7 +51,7 @@ void Slog2InfoRunner::start()
}; };
const auto onLogSetup = [this](Process &process) { const auto onLogSetup = [this](Process &process) {
process.setCommand({device()->filePath("slog2info"), {"-w"}}); process.setCommand({runControl()->device()->filePath("slog2info"), {"-w"}});
connect(&process, &Process::readyReadStandardOutput, this, [this, processPtr = &process] { connect(&process, &Process::readyReadStandardOutput, this, [this, processPtr = &process] {
processLogInput(QString::fromLatin1(processPtr->readAllRawStandardOutput())); processLogInput(QString::fromLatin1(processPtr->readAllRawStandardOutput()));
}); });

View File

@@ -123,9 +123,9 @@ QString MemcheckToolRunner::progressTitle() const
void MemcheckToolRunner::start() void MemcheckToolRunner::start()
{ {
if (device()->type() != ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) { if (runControl()->device()->type() != ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) {
m_process.reset(new Process); m_process.reset(new Process);
m_process->setCommand({device()->filePath("echo"), "-n $SSH_CLIENT", CommandLine::Raw}); m_process->setCommand({runControl()->device()->filePath("echo"), "-n $SSH_CLIENT", CommandLine::Raw});
connect(m_process.get(), &Process::done, this, [this] { connect(m_process.get(), &Process::done, this, [this] {
const ProcessResult result = m_process->result(); const ProcessResult result = m_process->result();
const QByteArrayList data = m_process->rawStdOut().split(' '); const QByteArrayList data = m_process->rawStdOut().split(' ');