diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 3d6603fb5e0..13546e60fe0 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -637,22 +637,27 @@ private: void fillParameters(DebuggerStartParameters *sp, const Profile *profile /* = 0 */) { if (!profile) { - // This code can only be reached when starting via the command - // (-debug pid or executable) without specifying a profile. - // Try to find a profile via ABI. - if (sp->executable.isEmpty() - && (sp->startMode == AttachExternal || sp->startMode == AttachCrashedExternal)) { - sp->executable = executableForPid(sp->attachPID); + // This code can only be reached when starting via the command line + // (-debug pid or executable) or attaching from runconfiguration + // without specifying a profile. Try to find a profile via ABI. + QList abis; + if (sp->toolChainAbi.isValid()) { + abis.push_back(sp->toolChainAbi); + } else { + // Try via executable. + if (sp->executable.isEmpty() + && (sp->startMode == AttachExternal || sp->startMode == AttachCrashedExternal)) { + sp->executable = executableForPid(sp->attachPID); + } + if (!sp->executable.isEmpty()) + abis = Abi::abisOfBinary(Utils::FileName::fromString(sp->executable)); } - if (!sp->executable.isEmpty()) { - const QList abis = Abi::abisOfBinary(Utils::FileName::fromString(sp->executable)); - if (!abis.isEmpty()) { - AbiProfileMatcher matcher(abis); + if (!abis.isEmpty()) { + AbiProfileMatcher matcher(abis); + profile = ProfileManager::instance()->find(&matcher); + if (!profile) { + CompatibleAbiProfileMatcher matcher(abis); profile = ProfileManager::instance()->find(&matcher); - if (!profile) { - CompatibleAbiProfileMatcher matcher(abis); - profile = ProfileManager::instance()->find(&matcher); - } } } if (!profile) @@ -1694,12 +1699,16 @@ void DebuggerPluginPrivate::attachToProcess(bool startServerOnly) void DebuggerPluginPrivate::attachExternalApplication(ProjectExplorer::RunControl *rc) { DebuggerStartParameters sp; - fillParameters(&sp); sp.attachPID = rc->applicationProcessHandle().pid(); sp.displayName = tr("Process %1").arg(sp.attachPID); sp.startMode = AttachExternal; sp.closeMode = DetachAtClose; sp.toolChainAbi = rc->abi(); + Profile *profile = 0; + if (const RunConfiguration *runConfiguration = rc->runConfiguration()) + if (const Target *target = runConfiguration->target()) + profile = target->profile(); + fillParameters(&sp, profile); DebuggerRunControlFactory::createAndScheduleRun(sp); } diff --git a/src/plugins/projectexplorer/runconfiguration.cpp b/src/plugins/projectexplorer/runconfiguration.cpp index 87ae827ddf5..8dd520d7492 100644 --- a/src/plugins/projectexplorer/runconfiguration.cpp +++ b/src/plugins/projectexplorer/runconfiguration.cpp @@ -558,6 +558,11 @@ Abi RunControl::abi() const return Abi(); } +RunConfiguration *RunControl::runConfiguration() const +{ + return m_runConfiguration.data(); +} + ProcessHandle RunControl::applicationProcessHandle() const { return m_applicationProcessHandle; diff --git a/src/plugins/projectexplorer/runconfiguration.h b/src/plugins/projectexplorer/runconfiguration.h index ac6e85c0dba..99817ba23fa 100644 --- a/src/plugins/projectexplorer/runconfiguration.h +++ b/src/plugins/projectexplorer/runconfiguration.h @@ -274,6 +274,7 @@ public: void setApplicationProcessHandle(const ProcessHandle &handle); Abi abi() const; + RunConfiguration *runConfiguration() const; bool sameRunConfiguration(const RunControl *other) const; Utils::OutputFormatter *outputFormatter();