Commit 71ea54c0 authored by Friedemann Kleint's avatar Friedemann Kleint Committed by hjk

Fix debugger detection when attaching from output pane.

Obtain RunConfiguration from RunControl add logic to
use the ABI if that fails.

Task-number: QTCREATORBUG-7677

Change-Id: Iebf053e6b7a25644a4d4c02b80bf952ef9e6a078
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent 73f5f712
......@@ -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<Abi> 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<Abi> 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);
}
......
......@@ -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;
......
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment