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 <christian.stenger@qt.io>
This commit is contained in:
hjk
2018-05-09 14:37:02 +02:00
parent 2c5e8e8d64
commit 3cfc715d7d
3 changed files with 14 additions and 4 deletions

View File

@@ -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();
}

View File

@@ -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

View File

@@ -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();