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: hjk <qthjk@ovi.com>
This commit is contained in:
Friedemann Kleint
2012-08-31 15:06:07 +02:00
committed by hjk
parent 73f5f71282
commit 71ea54c036
3 changed files with 30 additions and 15 deletions

View File

@@ -637,22 +637,27 @@ private:
void fillParameters(DebuggerStartParameters *sp, const Profile *profile /* = 0 */) void fillParameters(DebuggerStartParameters *sp, const Profile *profile /* = 0 */)
{ {
if (!profile) { if (!profile) {
// This code can only be reached when starting via the command // This code can only be reached when starting via the command line
// (-debug pid or executable) without specifying a profile. // (-debug pid or executable) or attaching from runconfiguration
// Try to find a profile via ABI. // without specifying a profile. Try to find a profile via ABI.
if (sp->executable.isEmpty() QList<Abi> abis;
&& (sp->startMode == AttachExternal || sp->startMode == AttachCrashedExternal)) { if (sp->toolChainAbi.isValid()) {
sp->executable = executableForPid(sp->attachPID); 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()) { if (!abis.isEmpty()) {
const QList<Abi> abis = Abi::abisOfBinary(Utils::FileName::fromString(sp->executable)); AbiProfileMatcher matcher(abis);
if (!abis.isEmpty()) { profile = ProfileManager::instance()->find(&matcher);
AbiProfileMatcher matcher(abis); if (!profile) {
CompatibleAbiProfileMatcher matcher(abis);
profile = ProfileManager::instance()->find(&matcher); profile = ProfileManager::instance()->find(&matcher);
if (!profile) {
CompatibleAbiProfileMatcher matcher(abis);
profile = ProfileManager::instance()->find(&matcher);
}
} }
} }
if (!profile) if (!profile)
@@ -1694,12 +1699,16 @@ void DebuggerPluginPrivate::attachToProcess(bool startServerOnly)
void DebuggerPluginPrivate::attachExternalApplication(ProjectExplorer::RunControl *rc) void DebuggerPluginPrivate::attachExternalApplication(ProjectExplorer::RunControl *rc)
{ {
DebuggerStartParameters sp; DebuggerStartParameters sp;
fillParameters(&sp);
sp.attachPID = rc->applicationProcessHandle().pid(); sp.attachPID = rc->applicationProcessHandle().pid();
sp.displayName = tr("Process %1").arg(sp.attachPID); sp.displayName = tr("Process %1").arg(sp.attachPID);
sp.startMode = AttachExternal; sp.startMode = AttachExternal;
sp.closeMode = DetachAtClose; sp.closeMode = DetachAtClose;
sp.toolChainAbi = rc->abi(); 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); DebuggerRunControlFactory::createAndScheduleRun(sp);
} }

View File

@@ -558,6 +558,11 @@ Abi RunControl::abi() const
return Abi(); return Abi();
} }
RunConfiguration *RunControl::runConfiguration() const
{
return m_runConfiguration.data();
}
ProcessHandle RunControl::applicationProcessHandle() const ProcessHandle RunControl::applicationProcessHandle() const
{ {
return m_applicationProcessHandle; return m_applicationProcessHandle;

View File

@@ -274,6 +274,7 @@ public:
void setApplicationProcessHandle(const ProcessHandle &handle); void setApplicationProcessHandle(const ProcessHandle &handle);
Abi abi() const; Abi abi() const;
RunConfiguration *runConfiguration() const;
bool sameRunConfiguration(const RunControl *other) const; bool sameRunConfiguration(const RunControl *other) const;
Utils::OutputFormatter *outputFormatter(); Utils::OutputFormatter *outputFormatter();