Debugger: Improve ABI compatibility matching

Debugger ABI compatibility is not the same as the implementation in ABI.
For instance, GDB can support multiarch targets, so matching the arch is
not good enough.

Use DebuggerItem::matchTarget and adapt it to consider ABI mismatches as
MatchesSomewhat for GDB/LLDB, which are potentially build with multiarch
(unfortunately there is no easy way to tell, at least for GDB).

Amends commit c04f3a94ea.

Fixes: QTCREATORBUG-28020
Change-Id: I555c4e886c641bfdf50ca660eda499c18260f6f4
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Orgad Shaneh
2022-08-04 15:25:28 +03:00
committed by Orgad Shaneh
parent 497b20ade7
commit 40a1a719fe
2 changed files with 13 additions and 10 deletions

View File

@@ -406,29 +406,34 @@ void DebuggerItem::setAbi(const Abi &abi)
static DebuggerItem::MatchLevel matchSingle(const Abi &debuggerAbi, const Abi &targetAbi, DebuggerEngineType engineType) static DebuggerItem::MatchLevel matchSingle(const Abi &debuggerAbi, const Abi &targetAbi, DebuggerEngineType engineType)
{ {
DebuggerItem::MatchLevel matchOnMultiarch = DebuggerItem::DoesNotMatch;
const bool isMsvcTarget = targetAbi.osFlavor() >= Abi::WindowsMsvc2005Flavor &&
targetAbi.osFlavor() <= Abi::WindowsLastMsvcFlavor;
if (!isMsvcTarget && (engineType == GdbEngineType || engineType == LldbEngineType))
matchOnMultiarch = DebuggerItem::MatchesSomewhat;
if (debuggerAbi.architecture() != Abi::UnknownArchitecture if (debuggerAbi.architecture() != Abi::UnknownArchitecture
&& debuggerAbi.architecture() != targetAbi.architecture()) && debuggerAbi.architecture() != targetAbi.architecture())
return DebuggerItem::DoesNotMatch; return matchOnMultiarch;
if (debuggerAbi.os() != Abi::UnknownOS if (debuggerAbi.os() != Abi::UnknownOS
&& debuggerAbi.os() != targetAbi.os()) && debuggerAbi.os() != targetAbi.os())
return DebuggerItem::DoesNotMatch; return matchOnMultiarch;
if (debuggerAbi.binaryFormat() != Abi::UnknownFormat if (debuggerAbi.binaryFormat() != Abi::UnknownFormat
&& debuggerAbi.binaryFormat() != targetAbi.binaryFormat()) && debuggerAbi.binaryFormat() != targetAbi.binaryFormat())
return DebuggerItem::DoesNotMatch; return matchOnMultiarch;
if (debuggerAbi.os() == Abi::WindowsOS) { if (debuggerAbi.os() == Abi::WindowsOS) {
if (debuggerAbi.osFlavor() == Abi::WindowsMSysFlavor && targetAbi.osFlavor() != Abi::WindowsMSysFlavor) if (debuggerAbi.osFlavor() == Abi::WindowsMSysFlavor && targetAbi.osFlavor() != Abi::WindowsMSysFlavor)
return DebuggerItem::DoesNotMatch; return matchOnMultiarch;
if (debuggerAbi.osFlavor() != Abi::WindowsMSysFlavor && targetAbi.osFlavor() == Abi::WindowsMSysFlavor) if (debuggerAbi.osFlavor() != Abi::WindowsMSysFlavor && targetAbi.osFlavor() == Abi::WindowsMSysFlavor)
return DebuggerItem::DoesNotMatch; return matchOnMultiarch;
} }
if (debuggerAbi.wordWidth() == 64 && targetAbi.wordWidth() == 32) if (debuggerAbi.wordWidth() == 64 && targetAbi.wordWidth() == 32)
return DebuggerItem::MatchesSomewhat; return DebuggerItem::MatchesSomewhat;
if (debuggerAbi.wordWidth() != 0 && debuggerAbi.wordWidth() != targetAbi.wordWidth()) if (debuggerAbi.wordWidth() != 0 && debuggerAbi.wordWidth() != targetAbi.wordWidth())
return DebuggerItem::DoesNotMatch; return matchOnMultiarch;
// We have at least 'Matches well' now. Mark the combinations we really like. // We have at least 'Matches well' now. Mark the combinations we really like.
if (HostOsInfo::isWindowsHost() && engineType == CdbEngineType if (HostOsInfo::isWindowsHost() && engineType == CdbEngineType

View File

@@ -250,10 +250,8 @@ void DebuggerKitAspect::fix(Kit *k)
return; return;
} }
const Abi tcAbi = ToolChainKitAspect::targetAbi(k); const Abi tcAbi = ToolChainKitAspect::targetAbi(k);
for (const Abi &abi : item->abis()) { if (item->matchTarget(tcAbi) != DebuggerItem::DoesNotMatch)
if (abi.isCompatibleWith(tcAbi)) return;
return;
}
k->setValue(DebuggerKitAspect::id(), QVariant()); k->setValue(DebuggerKitAspect::id(), QVariant());
setup(k); setup(k);
return; // All fine (now). return; // All fine (now).