From 3cfc715d7d33b724ad896c540af4a914d922e9bc Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 9 May 2018 14:37:02 +0200 Subject: [PATCH] Debugger: Try harder to find a usable device In remote setups without proper run configuration (e.g. attach using the menu) there was no device available. In some situation there's access to a kit, though, containing the right device. Use it. Task-number: QTCREATORBUG-20331 Change-Id: I54523f71fc10c9959901f36f3d62872d139279e5 Reviewed-by: Christian Stenger --- src/plugins/debugger/debuggerplugin.cpp | 11 +++++++---- src/plugins/projectexplorer/runconfiguration.cpp | 6 ++++++ src/plugins/projectexplorer/runconfiguration.h | 1 + 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index b58a226b095..851bebac8c0 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -1188,7 +1188,8 @@ bool DebuggerPluginPrivate::parseArgument(QStringList::const_iterator &it, if (!kit) kit = guessKitFromAbis(Abi::abisOfBinary(FileName::fromString(executable))); - auto runControl = new RunControl(nullptr, ProjectExplorer::Constants::DEBUG_RUN_MODE); + IDevice::ConstPtr device = DeviceKitInformation::device(kit); + auto runControl = new RunControl(device, ProjectExplorer::Constants::DEBUG_RUN_MODE); auto debugger = new DebuggerRunTool(runControl, kit); debugger->setInferiorExecutable(executable); if (pid) { @@ -1960,7 +1961,8 @@ void DebuggerPluginPrivate::attachCore() setConfigValue("LastExternalStartScript", dlg.overrideStartScript()); setConfigValue("LastForceLocalCoreFile", dlg.forcesLocalCoreFile()); - auto runControl = new RunControl(nullptr, ProjectExplorer::Constants::DEBUG_RUN_MODE); + IDevice::ConstPtr device = DeviceKitInformation::device(dlg.kit()); + auto runControl = new RunControl(device, ProjectExplorer::Constants::DEBUG_RUN_MODE); auto debugger = new DebuggerRunTool(runControl, dlg.kit()); debugger->setInferiorExecutable(dlg.localExecutableFile()); debugger->setCoreFileName(dlg.localCoreFile()); @@ -1987,7 +1989,8 @@ void DebuggerPluginPrivate::startRemoteCdbSession() return; setConfigValue(connectionKey, dlg.connection()); - auto runControl = new RunControl(nullptr, ProjectExplorer::Constants::DEBUG_RUN_MODE); + IDevice::ConstPtr device = DeviceKitInformation::device(kit); + auto runControl = new RunControl(device, ProjectExplorer::Constants::DEBUG_RUN_MODE); auto debugger = new DebuggerRunTool(runControl, kit); debugger->setStartMode(AttachToRemoteServer); debugger->setCloseMode(KillAtClose); @@ -2045,7 +2048,7 @@ void DebuggerPluginPrivate::attachToRunningApplication() if (device->type() == PE::DESKTOP_DEVICE_TYPE) { attachToRunningProcess(kit, process, false); } else { - auto runControl = new RunControl(nullptr, ProjectExplorer::Constants::DEBUG_RUN_MODE); + auto runControl = new RunControl(device, ProjectExplorer::Constants::DEBUG_RUN_MODE); auto debugger = new RemoteAttachRunner(runControl, kit, process.pid); debugger->startRunControl(); } diff --git a/src/plugins/projectexplorer/runconfiguration.cpp b/src/plugins/projectexplorer/runconfiguration.cpp index b13f267fd02..3caf3916ba2 100644 --- a/src/plugins/projectexplorer/runconfiguration.cpp +++ b/src/plugins/projectexplorer/runconfiguration.cpp @@ -884,6 +884,12 @@ RunControl::RunControl(RunConfiguration *runConfiguration, Core::Id mode) : #endif } +RunControl::RunControl(const IDevice::ConstPtr &device, Core::Id mode) + : RunControl(nullptr, mode) +{ + d->device = device; +} + RunControl::~RunControl() { #ifdef WITH_JOURNALD diff --git a/src/plugins/projectexplorer/runconfiguration.h b/src/plugins/projectexplorer/runconfiguration.h index e7e0c4aa73b..aba94da1aa1 100644 --- a/src/plugins/projectexplorer/runconfiguration.h +++ b/src/plugins/projectexplorer/runconfiguration.h @@ -431,6 +431,7 @@ class PROJECTEXPLORER_EXPORT RunControl : public QObject public: RunControl(RunConfiguration *runConfiguration, Core::Id mode); + RunControl(const IDevice::ConstPtr &device, Core::Id mode); ~RunControl() override; void initiateStart();