diff options
author | hjk <[email protected]> | 2019-03-12 17:04:08 +0100 |
---|---|---|
committer | hjk <[email protected]> | 2019-03-12 16:47:47 +0000 |
commit | ceb0fe429dc2b42dfc30df3c70b39708cb86971b (patch) | |
tree | 524a70e722bd287759839b2a29e4c2b7a0bc6264 | |
parent | efb7d8deb77523cc0294d01d67e277e4ce471d33 (diff) |
ProjectExplorer: Add RunControl::set{Kit,Target}
For cases where no genuine RunConfiguration is available.
Use it in the debugger for the cases triggered from the menu.
Change-Id: I5671f4f5db2547c4a7a70bd34292bb6ccc8e6bf4
Reviewed-by: Christian Kandeler <[email protected]>
-rw-r--r-- | src/plugins/debugger/debuggerdialogs.cpp | 5 | ||||
-rw-r--r-- | src/plugins/debugger/debuggerplugin.cpp | 42 | ||||
-rw-r--r-- | src/plugins/debugger/debuggerruncontrol.cpp | 21 | ||||
-rw-r--r-- | src/plugins/debugger/debuggerruncontrol.h | 4 | ||||
-rw-r--r-- | src/plugins/projectexplorer/runconfiguration.cpp | 27 | ||||
-rw-r--r-- | src/plugins/projectexplorer/runconfiguration.h | 9 | ||||
-rw-r--r-- | src/plugins/remotelinux/remotelinuxdebugsupport.cpp | 2 |
7 files changed, 65 insertions, 45 deletions
diff --git a/src/plugins/debugger/debuggerdialogs.cpp b/src/plugins/debugger/debuggerdialogs.cpp index 17dbc383c37..1b3cacdd9d4 100644 --- a/src/plugins/debugger/debuggerdialogs.cpp +++ b/src/plugins/debugger/debuggerdialogs.cpp @@ -403,10 +403,10 @@ void StartApplicationDialog::run(bool attachRemote) return; Kit *k = dialog.d->kitChooser->currentKit(); - IDevice::ConstPtr dev = DeviceKitAspect::device(k); auto runControl = new RunControl(ProjectExplorer::Constants::DEBUG_RUN_MODE); - auto debugger = new DebuggerRunTool(runControl, k); + runControl->setKit(k); + auto debugger = new DebuggerRunTool(runControl); const StartApplicationParameters newParameters = dialog.parameters(); if (newParameters != history.back()) { @@ -423,6 +423,7 @@ void StartApplicationDialog::run(bool attachRemote) settings->endGroup(); } + IDevice::ConstPtr dev = DeviceKitAspect::device(k); Runnable inferior = newParameters.runnable; const QString inputAddress = dialog.d->channelOverrideEdit->text(); if (!inputAddress.isEmpty()) diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 66e01d6e796..2cf91a2e077 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -886,10 +886,9 @@ bool DebuggerPluginPrivate::parseArgument(QStringList::const_iterator &it, if (!kit) kit = guessKitFromAbis(Abi::abisOfBinary(FileName::fromString(executable))); - IDevice::ConstPtr device = DeviceKitAspect::device(kit); auto runControl = new RunControl(ProjectExplorer::Constants::DEBUG_RUN_MODE); - runControl->setDevice(device); - auto debugger = new DebuggerRunTool(runControl, kit); + runControl->setKit(kit); + auto debugger = new DebuggerRunTool(runControl); debugger->setInferiorExecutable(executable); if (pid) { debugger->setStartMode(AttachExternal); @@ -931,7 +930,8 @@ bool DebuggerPluginPrivate::parseArgument(QStringList::const_iterator &it, } qint64 pid = it->section(':', 1, 1).toULongLong(); auto runControl = new RunControl(ProjectExplorer::Constants::DEBUG_RUN_MODE); - auto debugger = new DebuggerRunTool(runControl, findUniversalCdbKit()); + runControl->setKit(findUniversalCdbKit()); + auto debugger = new DebuggerRunTool(runControl); debugger->setStartMode(AttachCrashedExternal); debugger->setCrashParameter(it->section(':', 0, 0)); debugger->setAttachPid(pid); @@ -1585,8 +1585,8 @@ void DebuggerPluginPrivate::attachCore() setConfigValue("LastForceLocalCoreFile", dlg.forcesLocalCoreFile()); auto runControl = new RunControl(ProjectExplorer::Constants::DEBUG_RUN_MODE); - runControl->setDevice(DeviceKitAspect::device(dlg.kit())); - auto debugger = new DebuggerRunTool(runControl, dlg.kit()); + runControl->setKit(dlg.kit()); + auto debugger = new DebuggerRunTool(runControl); debugger->setInferiorExecutable(dlg.symbolFile()); debugger->setCoreFileName(dlg.localCoreFile()); debugger->setRunControlName(tr("Core file \"%1\"") @@ -1613,8 +1613,8 @@ void DebuggerPluginPrivate::startRemoteCdbSession() setConfigValue(connectionKey, dlg.connection()); auto runControl = new RunControl(ProjectExplorer::Constants::DEBUG_RUN_MODE); - runControl->setDevice(DeviceKitAspect::device(kit)); - auto debugger = new DebuggerRunTool(runControl, kit); + runControl->setKit(kit); + auto debugger = new DebuggerRunTool(runControl); debugger->setStartMode(AttachToRemoteServer); debugger->setCloseMode(KillAtClose); debugger->setRemoteChannel(dlg.connection()); @@ -1624,17 +1624,16 @@ void DebuggerPluginPrivate::startRemoteCdbSession() class RemoteAttachRunner : public DebuggerRunTool { public: - RemoteAttachRunner(RunControl *runControl, Kit *kit, int pid) - : DebuggerRunTool(runControl, kit) + RemoteAttachRunner(RunControl *runControl, int pid) + : DebuggerRunTool(runControl) { - IDevice::ConstPtr device = DeviceKitAspect::device(kit); setId("AttachToRunningProcess"); setUsePortsGatherer(true, false); - portsGatherer()->setDevice(device); + portsGatherer()->setDevice(runControl->device()); auto gdbServer = new GdbServerRunner(runControl, portsGatherer()); gdbServer->setUseMulti(false); - gdbServer->setDevice(device); + gdbServer->setDevice(runControl->device()); gdbServer->setAttachPid(ProcessHandle(pid)); addStartDependency(gdbServer); @@ -1672,8 +1671,8 @@ void DebuggerPluginPrivate::attachToRunningApplication() attachToRunningProcess(kit, process, false); } else { auto runControl = new RunControl(ProjectExplorer::Constants::DEBUG_RUN_MODE); - runControl->setDevice(device); - auto debugger = new RemoteAttachRunner(runControl, kit, process.pid); + runControl->setKit(kit); + auto debugger = new RemoteAttachRunner(runControl, process.pid); debugger->startRunControl(); } } @@ -1726,7 +1725,7 @@ RunControl *DebuggerPluginPrivate::attachToRunningProcess(Kit *kit, } auto runControl = new RunControl(ProjectExplorer::Constants::DEBUG_RUN_MODE); - auto debugger = new DebuggerRunTool(runControl, kit); + auto debugger = new DebuggerRunTool(runControl); debugger->setAttachPid(ProcessHandle(process.pid)); debugger->setRunControlName(tr("Process %1").arg(process.pid)); debugger->setInferiorExecutable(process.exe); @@ -1743,13 +1742,9 @@ RunControl *DebuggerPluginPrivate::attachToRunningProcess(Kit *kit, void DebuggerPlugin::attachExternalApplication(RunControl *rc) { ProcessHandle pid = rc->applicationProcessHandle(); - RunConfiguration *runConfig = rc->runConfiguration(); - QTC_ASSERT(runConfig, return); - Target *target = runConfig->target(); - QTC_ASSERT(target, return); auto runControl = new RunControl(ProjectExplorer::Constants::DEBUG_RUN_MODE); - runControl->setRunConfiguration(runConfig); - auto debugger = new DebuggerRunTool(runControl, target->kit(), false); + runControl->setTarget(rc->target()); + auto debugger = new DebuggerRunTool(runControl); debugger->setAttachPid(pid); debugger->setRunControlName(tr("Process %1").arg(pid.pid())); debugger->setStartMode(AttachExternal); @@ -1808,7 +1803,8 @@ void DebuggerPluginPrivate::attachToQmlPort() QTC_ASSERT(device, return); auto runControl = new RunControl(ProjectExplorer::Constants::DEBUG_RUN_MODE); - auto debugger = new DebuggerRunTool(runControl, kit); + runControl->setKit(kit); + auto debugger = new DebuggerRunTool(runControl); QUrl qmlServer = device->toolControlChannel(IDevice::QmlControlChannel); qmlServer.setPort(dlg.port()); diff --git a/src/plugins/debugger/debuggerruncontrol.cpp b/src/plugins/debugger/debuggerruncontrol.cpp index 9e8e2ddaaff..47446080593 100644 --- a/src/plugins/debugger/debuggerruncontrol.cpp +++ b/src/plugins/debugger/debuggerruncontrol.cpp @@ -876,7 +876,7 @@ Internal::TerminalRunner *DebuggerRunTool::terminalRunner() const return d->terminalRunner; } -DebuggerRunTool::DebuggerRunTool(RunControl *runControl, Kit *kit, bool allowTerminal) +DebuggerRunTool::DebuggerRunTool(RunControl *runControl, AllowTerminal allowTerminal) : RunWorker(runControl), d(new DebuggerRunToolPrivate) { setId("DebuggerRunTool"); @@ -902,16 +902,15 @@ DebuggerRunTool::DebuggerRunTool(RunControl *runControl, Kit *kit, bool allowTer QString(), QString(), optionalPrompt); }); - if (runConfig) { + if (runConfig) m_runParameters.displayName = runConfig->displayName(); - if (auto symbolsAspect = runConfig->aspect<SymbolFileAspect>()) - m_runParameters.symbolFile = symbolsAspect->value(); - if (auto terminalAspect = runConfig->aspect<TerminalAspect>()) - m_runParameters.useTerminal = terminalAspect->useTerminal(); - } - if (runConfig && !kit) - kit = runConfig->target()->kit(); + if (auto symbolsAspect = runControl->aspect<SymbolFileAspect>()) + m_runParameters.symbolFile = symbolsAspect->value(); + if (auto terminalAspect = runControl->aspect<TerminalAspect>()) + m_runParameters.useTerminal = terminalAspect->useTerminal(); + + Kit *kit = runControl->kit(); QTC_ASSERT(kit, return); m_runParameters.sysRoot = SysRootKitAspect::sysRoot(kit); @@ -922,7 +921,7 @@ DebuggerRunTool::DebuggerRunTool(RunControl *runControl, Kit *kit, bool allowTer if (QtSupport::BaseQtVersion *qtVersion = QtSupport::QtKitAspect::qtVersion(kit)) m_runParameters.qtPackageSourceLocation = qtVersion->qtPackageSourcePath().toString(); - if (auto aspect = runConfig ? runConfig->aspect<DebuggerRunConfigurationAspect>() : nullptr) { + if (auto aspect = runControl->aspect<DebuggerRunConfigurationAspect>()) { if (!aspect->useCppDebugger()) m_runParameters.cppEngineType = NoEngineType; m_runParameters.isQmlDebugging = aspect->useQmlDebugger(); @@ -933,7 +932,7 @@ DebuggerRunTool::DebuggerRunTool(RunControl *runControl, Kit *kit, bool allowTer // Normalize to work around QTBUG-17529 (QtDeclarative fails with 'File name case mismatch'...) m_runParameters.inferior.workingDirectory = FileUtils::normalizePathName(m_runParameters.inferior.workingDirectory); - setUseTerminal(allowTerminal && m_runParameters.useTerminal); + setUseTerminal(allowTerminal == DoAllowTerminal && m_runParameters.useTerminal); const QByteArray envBinary = qgetenv("QTC_DEBUGGER_PATH"); if (!envBinary.isEmpty()) diff --git a/src/plugins/debugger/debuggerruncontrol.h b/src/plugins/debugger/debuggerruncontrol.h index cc4a1f191bd..6315d57a1ba 100644 --- a/src/plugins/debugger/debuggerruncontrol.h +++ b/src/plugins/debugger/debuggerruncontrol.h @@ -47,9 +47,9 @@ class DEBUGGER_EXPORT DebuggerRunTool : public ProjectExplorer::RunWorker Q_OBJECT public: + enum AllowTerminal { DoAllowTerminal, DoNotAllowTerminal }; explicit DebuggerRunTool(ProjectExplorer::RunControl *runControl, - ProjectExplorer::Kit *kit = nullptr, - bool allowTerminal = true); + AllowTerminal allowTerminal = DoAllowTerminal); ~DebuggerRunTool() override; void startRunControl(); diff --git a/src/plugins/projectexplorer/runconfiguration.cpp b/src/plugins/projectexplorer/runconfiguration.cpp index 74b126b0325..b0a3eeecc8e 100644 --- a/src/plugins/projectexplorer/runconfiguration.cpp +++ b/src/plugins/projectexplorer/runconfiguration.cpp @@ -847,6 +847,7 @@ public: Core::Id runMode; Utils::Icon icon; QPointer<RunConfiguration> runConfiguration; // Not owned. Avoid use. + Kit *kit = nullptr; // Not owned. QPointer<Target> target; // Not owned. QPointer<Utils::OutputFormatter> outputFormatter = nullptr; std::function<bool(bool*)> promptToStop; @@ -872,6 +873,7 @@ RunControl::RunControl(Core::Id mode) : void RunControl::setRunConfiguration(RunConfiguration *runConfig) { QTC_ASSERT(runConfig, return); + QTC_CHECK(!d->runConfiguration); d->runConfiguration = runConfig; d->runnable = runConfig->runnable(); d->displayName = runConfig->displayName(); @@ -879,15 +881,32 @@ void RunControl::setRunConfiguration(RunConfiguration *runConfig) delete d->outputFormatter; d->outputFormatter = outputFormatter; } - d->target = runConfig->target(); + setTarget(runConfig->target()); +} + +void RunControl::setTarget(Target *target) +{ + QTC_ASSERT(target, return); + QTC_CHECK(!d->target); + d->target = target; + setKit(target->kit()); +} + +void RunControl::setKit(Kit *kit) +{ + QTC_ASSERT(kit, return); + QTC_CHECK(!d->kit); + d->kit = kit; + if (d->runnable.device) setDevice(d->runnable.device); else - setDevice(DeviceKitAspect::device(d->target->kit())); + setDevice(DeviceKitAspect::device(kit)); } void RunControl::setDevice(const IDevice::ConstPtr &device) { + QTC_CHECK(!d->device); d->device = device; #ifdef WITH_JOURNALD if (!device.isNull() && device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) { @@ -1375,12 +1394,12 @@ Project *RunControl::project() const Kit *RunControl::kit() const { - return d->target->kit(); + return d->kit; } ProjectConfigurationAspect *RunControl::aspect(Core::Id id) const { - return d->runConfiguration->aspect(id); + return d->runConfiguration ? d->runConfiguration->aspect(id) : nullptr; } BuildTargetInfo RunControl::buildTargetInfo() const diff --git a/src/plugins/projectexplorer/runconfiguration.h b/src/plugins/projectexplorer/runconfiguration.h index a451f0729d8..90e50db6be2 100644 --- a/src/plugins/projectexplorer/runconfiguration.h +++ b/src/plugins/projectexplorer/runconfiguration.h @@ -416,7 +416,8 @@ public: ~RunControl() override; void setRunConfiguration(RunConfiguration *runConfig); - void setDevice(const IDevice::ConstPtr &device); + void setTarget(Target *target); + void setKit(Kit *kit); void initiateStart(); void initiateReStart(); @@ -450,7 +451,9 @@ public: Project *project() const; Kit *kit() const; ProjectConfigurationAspect *aspect(Core::Id id) const; - template <typename T> T *aspect() const { return runConfiguration()->aspect<T>(); } + template <typename T> T *aspect() const { + return runConfiguration() ? runConfiguration()->aspect<T>() : nullptr; + } QString buildKey() const; BuildTargetInfo buildTargetInfo() const; @@ -500,6 +503,8 @@ signals: void applicationProcessHandleChanged(QPrivateSignal); // Use setApplicationProcessHandle private: + void setDevice(const IDevice::ConstPtr &device); + friend class RunWorker; friend class Internal::RunWorkerPrivate; diff --git a/src/plugins/remotelinux/remotelinuxdebugsupport.cpp b/src/plugins/remotelinux/remotelinuxdebugsupport.cpp index eebf891e91b..5143efe7d95 100644 --- a/src/plugins/remotelinux/remotelinuxdebugsupport.cpp +++ b/src/plugins/remotelinux/remotelinuxdebugsupport.cpp @@ -34,7 +34,7 @@ namespace RemoteLinux { namespace Internal { LinuxDeviceDebugSupport::LinuxDeviceDebugSupport(RunControl *runControl) - : DebuggerRunTool(runControl, nullptr, false) + : DebuggerRunTool(runControl, DebuggerRunTool::DoNotAllowTerminal) { setId("LinuxDeviceDebugSupport"); |