From 2d7a07e9dd3176ea366859873c0567ee694456ff Mon Sep 17 00:00:00 2001 From: David Schulz Date: Fri, 23 Aug 2024 09:13:20 +0200 Subject: [PATCH] Debugger: reenable 32 bit cdb detection The 64 bit cdb has unfortunately limited 32 bit debugging capabilities and there are still a bunch of users that still need to work with 32 bit MSVC builds. Also add functionality to reset the 64 bit cdb in kits with a 32 bit toolchain. This reverts commit 9a06e1f65c25424696ad9a1ced5eec7560f30f80. This reverts commit 421210e609f865aeaf18e0a6e02c1bf3b4339892. Task-number: QTCREATORBUG-31345 Change-Id: I072353b8ab6a2b93594dd4f11ecd17ca031ab6ec Reviewed-by: Cristian Adam Reviewed-by: Christian Stenger --- src/plugins/debugger/debuggeritem.cpp | 7 ++----- src/plugins/debugger/debuggeritemmanager.cpp | 8 +------- src/plugins/debugger/debuggerkitaspect.cpp | 19 +++++++++++++++---- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/plugins/debugger/debuggeritem.cpp b/src/plugins/debugger/debuggeritem.cpp index 120684c9fe4..455b4e39862 100644 --- a/src/plugins/debugger/debuggeritem.cpp +++ b/src/plugins/debugger/debuggeritem.cpp @@ -434,11 +434,8 @@ static DebuggerItem::MatchLevel matchSingle(const Abi &debuggerAbi, const Abi &t return matchOnMultiarch; } - if (debuggerAbi.wordWidth() == 64 && targetAbi.wordWidth() == 32) { - return HostOsInfo::isWindowsHost() && engineType == CdbEngineType - ? DebuggerItem::MatchesPerfectly - : DebuggerItem::MatchesSomewhat; - } + if (debuggerAbi.wordWidth() == 64 && targetAbi.wordWidth() == 32) + return DebuggerItem::MatchesSomewhat; if (debuggerAbi.wordWidth() != 0 && debuggerAbi.wordWidth() != targetAbi.wordWidth()) return matchOnMultiarch; diff --git a/src/plugins/debugger/debuggeritemmanager.cpp b/src/plugins/debugger/debuggeritemmanager.cpp index 23dcee4ee6a..b93e0800dec 100644 --- a/src/plugins/debugger/debuggeritemmanager.cpp +++ b/src/plugins/debugger/debuggeritemmanager.cpp @@ -549,7 +549,7 @@ void DebuggerItemModel::autoDetectCdbDebuggers() for (const QFileInfo &kitFolderFi : kitFolders) { const QString path = kitFolderFi.absoluteFilePath(); - QStringList abis = {"x64"}; + QStringList abis = {"x86", "x64"}; if (HostOsInfo::hostArchitecture() == Utils::OsArchArm64) abis << "arm64"; for (const QString &abi: abis) { @@ -783,12 +783,6 @@ void DebuggerItemModel::readDebuggers(const FilePath &fileName, bool isSystem) .arg(item.command().toUserOutput(), item.id().toString(), fileName.toUserOutput()); continue; } - if (item.engineType() == CdbEngineType - && Abi::abisOfBinary(item.command()).value(0).wordWidth() == 32) { - qWarning() << QString("32 bit CDB \"%1\" (%2) read from \"%3\" dropped since it is not supported anymore.") - .arg(item.command().toUserOutput(), item.id().toString(), fileName.toUserOutput()); - continue; - } // FIXME: During startup, devices are not yet available, so we cannot check if the file still exists. if (!item.command().needsDevice() && !item.command().isExecutableFile()) { qWarning() << QString("DebuggerItem \"%1\" (%2) read from \"%3\" dropped since the command is not executable.") diff --git a/src/plugins/debugger/debuggerkitaspect.cpp b/src/plugins/debugger/debuggerkitaspect.cpp index 15a3e8827c1..a7496bf6f0f 100644 --- a/src/plugins/debugger/debuggerkitaspect.cpp +++ b/src/plugins/debugger/debuggerkitaspect.cpp @@ -391,10 +391,21 @@ public: void fix(Kit *k) override { const QVariant id = k->value(DebuggerKitAspect::id()); - if (Utils::anyOf(DebuggerItemManager::debuggers(), Utils::equal(&DebuggerItem::id, id))) - return; - k->removeKeySilently(DebuggerKitAspect::id()); - setup(k); + const DebuggerItem debugger = Utils::findOrDefault( + DebuggerItemManager::debuggers(), Utils::equal(&DebuggerItem::id, id)); + if (debugger.isValid() && debugger.engineType() == CdbEngineType) { + const int tcWordWidth = ToolchainKitAspect::targetAbi(k).wordWidth(); + if (Utils::anyOf(debugger.abis(), Utils::equal(&Abi::wordWidth, tcWordWidth))) + return; + + for (const DebuggerItem &item : DebuggerItemManager::debuggers()) { + if (item.engineType() == CdbEngineType + && Utils::anyOf(item.abis(), Utils::equal(&Abi::wordWidth, tcWordWidth))) { + k->setValue(DebuggerKitAspect::id(), item.id()); + return; + } + } + } } KitAspect *createKitAspect(Kit *k) const override