From 40a1a719fef2c3342a4394769986fc972e5ef05c Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Thu, 4 Aug 2022 15:25:28 +0300 Subject: [PATCH] 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 c04f3a94ea12a40e776b0a2830a984828fbb1401. Fixes: QTCREATORBUG-28020 Change-Id: I555c4e886c641bfdf50ca660eda499c18260f6f4 Reviewed-by: Christian Kandeler --- src/plugins/debugger/debuggeritem.cpp | 17 +++++++++++------ src/plugins/debugger/debuggerkitinformation.cpp | 6 ++---- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/plugins/debugger/debuggeritem.cpp b/src/plugins/debugger/debuggeritem.cpp index 4848393050b..6eb1b3e6808 100644 --- a/src/plugins/debugger/debuggeritem.cpp +++ b/src/plugins/debugger/debuggeritem.cpp @@ -406,29 +406,34 @@ void DebuggerItem::setAbi(const Abi &abi) 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 && debuggerAbi.architecture() != targetAbi.architecture()) - return DebuggerItem::DoesNotMatch; + return matchOnMultiarch; if (debuggerAbi.os() != Abi::UnknownOS && debuggerAbi.os() != targetAbi.os()) - return DebuggerItem::DoesNotMatch; + return matchOnMultiarch; if (debuggerAbi.binaryFormat() != Abi::UnknownFormat && debuggerAbi.binaryFormat() != targetAbi.binaryFormat()) - return DebuggerItem::DoesNotMatch; + return matchOnMultiarch; if (debuggerAbi.os() == Abi::WindowsOS) { if (debuggerAbi.osFlavor() == Abi::WindowsMSysFlavor && targetAbi.osFlavor() != Abi::WindowsMSysFlavor) - return DebuggerItem::DoesNotMatch; + return matchOnMultiarch; if (debuggerAbi.osFlavor() != Abi::WindowsMSysFlavor && targetAbi.osFlavor() == Abi::WindowsMSysFlavor) - return DebuggerItem::DoesNotMatch; + return matchOnMultiarch; } if (debuggerAbi.wordWidth() == 64 && targetAbi.wordWidth() == 32) return DebuggerItem::MatchesSomewhat; 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. if (HostOsInfo::isWindowsHost() && engineType == CdbEngineType diff --git a/src/plugins/debugger/debuggerkitinformation.cpp b/src/plugins/debugger/debuggerkitinformation.cpp index 16bc885e52a..c05d96b1db2 100644 --- a/src/plugins/debugger/debuggerkitinformation.cpp +++ b/src/plugins/debugger/debuggerkitinformation.cpp @@ -250,10 +250,8 @@ void DebuggerKitAspect::fix(Kit *k) return; } const Abi tcAbi = ToolChainKitAspect::targetAbi(k); - for (const Abi &abi : item->abis()) { - if (abi.isCompatibleWith(tcAbi)) - return; - } + if (item->matchTarget(tcAbi) != DebuggerItem::DoesNotMatch) + return; k->setValue(DebuggerKitAspect::id(), QVariant()); setup(k); return; // All fine (now).