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 */)
{
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);
}

View File

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

View File

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