diff options
author | hjk <hjk@qt.io> | 2023-03-28 07:40:26 +0200 |
---|---|---|
committer | hjk <hjk@qt.io> | 2023-03-28 13:57:50 +0000 |
commit | 463e47bbdd10b33e3be85b47299f1b5d253d8c3e (patch) | |
tree | 030a2d8d27560d5650e9af947d80c3280c7b3321 | |
parent | 5cfc52a92c5858e90c650e74c2d84df6705e37a0 (diff) | |
download | qt-creator-463e47bbdd10b33e3be85b47299f1b5d253d8c3e.tar.gz |
Debugger: Have a generic "GDB in PATH on Build Device" item
This is only checked at run-time, but allows smoother creation of
kits for standard setups as the (possibly remote) full path is
not needed.
Remove the DebuggerKitAspect::fixup() implementation. Too much magic
by now, and worst thing that could happen is a non-matching debugger
that will clearly bark when used.
Change-Id: If2414610d479a5b93c3e6227b8736ddc61f70635
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
-rw-r--r-- | src/plugins/debugger/debuggeritemmanager.cpp | 28 | ||||
-rw-r--r-- | src/plugins/debugger/debuggerkitinformation.cpp | 94 | ||||
-rw-r--r-- | src/plugins/debugger/debuggerkitinformation.h | 1 | ||||
-rw-r--r-- | src/plugins/remotelinux/linuxdevice.cpp | 2 |
4 files changed, 44 insertions, 81 deletions
diff --git a/src/plugins/debugger/debuggeritemmanager.cpp b/src/plugins/debugger/debuggeritemmanager.cpp index b379255416..3e77bf73bf 100644 --- a/src/plugins/debugger/debuggeritemmanager.cpp +++ b/src/plugins/debugger/debuggeritemmanager.cpp @@ -170,6 +170,7 @@ class DebuggerItemModel : public TreeModel<TreeItem, StaticTreeItem, DebuggerTre { public: DebuggerItemModel(); + enum { Generic, AutoDetected, Manual }; QModelIndex lastIndex() const; void setCurrentIndex(const QModelIndex &index); @@ -202,16 +203,35 @@ const DebuggerItem *findDebugger(const Predicate &pred) DebuggerItemModel::DebuggerItemModel() { setHeader({Tr::tr("Name"), Tr::tr("Path"), Tr::tr("Type")}); - rootItem()->appendChild( - new StaticTreeItem({ProjectExplorer::Constants::msgAutoDetected()}, - {ProjectExplorer::Constants::msgAutoDetectedToolTip()})); + + auto generic = new StaticTreeItem(Tr::tr("Generic")); + auto autoDetected = new StaticTreeItem({ProjectExplorer::Constants::msgAutoDetected()}, + {ProjectExplorer::Constants::msgAutoDetectedToolTip()}); + rootItem()->appendChild(generic); + rootItem()->appendChild(autoDetected); rootItem()->appendChild(new StaticTreeItem(ProjectExplorer::Constants::msgManual())); + + DebuggerItem genericGdb(QVariant("gdb")); + genericGdb.setAutoDetected(true); + genericGdb.setEngineType(GdbEngineType); + genericGdb.setAbi(Abi()); + genericGdb.setCommand("gdb"); + genericGdb.setUnexpandedDisplayName(Tr::tr("%1 from PATH on Build Device").arg("GDB")); + generic->appendChild(new DebuggerTreeItem(genericGdb, false)); + + DebuggerItem genericLldb(QVariant("lldb")); + genericLldb.setAutoDetected(true); + genericLldb.setEngineType(LldbEngineType); + genericLldb.setAbi(Abi()); + genericLldb.setCommand("lldb"); + genericLldb.setUnexpandedDisplayName(Tr::tr("%1 from PATH on Build Device").arg("LLDB")); + generic->appendChild(new DebuggerTreeItem(genericLldb, false)); } void DebuggerItemModel::addDebugger(const DebuggerItem &item, bool changed) { QTC_ASSERT(item.id().isValid(), return); - int group = item.isAutoDetected() ? 0 : 1; + int group = item.isAutoDetected() ? AutoDetected : Manual; rootItem()->childAt(group)->appendChild(new DebuggerTreeItem(item, changed)); } diff --git a/src/plugins/debugger/debuggerkitinformation.cpp b/src/plugins/debugger/debuggerkitinformation.cpp index cac42d5a42..f3d01a1cc3 100644 --- a/src/plugins/debugger/debuggerkitinformation.cpp +++ b/src/plugins/debugger/debuggerkitinformation.cpp @@ -228,66 +228,6 @@ void DebuggerKitAspect::setup(Kit *k) k->setValue(DebuggerKitAspect::id(), bestLevel != DebuggerItem::DoesNotMatch ? bestItem.id() : QVariant()); } - -// This handles the upgrade path from 2.8 to 3.0 -void DebuggerKitAspect::fix(Kit *k) -{ - QTC_ASSERT(k, return); - - // This can be Id, binary path, but not "auto" anymore. - const QVariant rawId = k->value(DebuggerKitAspect::id()); - - if (rawId.toString().isEmpty()) // No debugger set, that is fine. - return; - - if (rawId.type() == QVariant::String) { - const DebuggerItem * const item = DebuggerItemManager::findById(rawId); - if (!item) { - qWarning("Unknown debugger id %s in kit %s", - qPrintable(rawId.toString()), qPrintable(k->displayName())); - k->setValue(DebuggerKitAspect::id(), QVariant()); - setup(k); - return; - } - - Abi kitAbi; - if (ToolChainKitAspect::toolChains(k).isEmpty()) { - if (DeviceTypeKitAspect::deviceTypeId(k) - != ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) { - return; - } - kitAbi = Abi(Abi::UnknownArchitecture, Abi::hostAbi().os()); - } else { - kitAbi = ToolChainKitAspect::targetAbi(k); - } - if (item->matchTarget(kitAbi) != DebuggerItem::DoesNotMatch) - return; - k->setValue(DebuggerKitAspect::id(), QVariant()); - setup(k); - return; // All fine (now). - } - - QMap<QString, QVariant> map = rawId.toMap(); - QString binary = map.value("Binary").toString(); - if (binary == "auto") { - // This should not happen as "auto" is handled by setup() already. - QTC_CHECK(false); - k->setValue(DebuggerKitAspect::id(), QVariant()); - return; - } - - FilePath fileName = FilePath::fromUserInput(binary); - const DebuggerItem *item = DebuggerItemManager::findByCommand(fileName); - if (!item) { - qWarning("Debugger command %s invalid in kit %s", - qPrintable(binary), qPrintable(k->displayName())); - k->setValue(DebuggerKitAspect::id(), QVariant()); - return; - } - - k->setValue(DebuggerKitAspect::id(), item->id()); -} - // Check the configuration errors and return a flag mask. Provide a quick check and // a verbose one with a list of errors. @@ -299,15 +239,15 @@ DebuggerKitAspect::ConfigurationErrors DebuggerKitAspect::configurationErrors(co if (!item) return NoDebugger; - if (item->command().isEmpty()) + const FilePath debugger = item->command(); + if (debugger.isEmpty()) return NoDebugger; + if (debugger.isRelativePath()) + return NoConfigurationError; + ConfigurationErrors result = NoConfigurationError; - const FilePath debugger = item->command(); - const bool found = debugger.exists() && !debugger.isDir(); - if (!found) - result |= DebuggerNotFound; - else if (!debugger.isExecutableFile()) + if (!debugger.isExecutableFile()) result |= DebuggerNotExecutable; const Abi tcAbi = ToolChainKitAspect::targetAbi(k); @@ -318,16 +258,15 @@ DebuggerKitAspect::ConfigurationErrors DebuggerKitAspect::configurationErrors(co result |= DebuggerDoesNotMatch; } - if (!found) { - if (item->engineType() == NoEngineType) - return NoDebugger; + if (item->engineType() == NoEngineType) + return NoDebugger; - // We need an absolute path to be able to locate Python on Windows. - if (item->engineType() == GdbEngineType) { - if (tcAbi.os() == Abi::WindowsOS && !debugger.isAbsolutePath()) - result |= DebuggerNeedsAbsolutePath; - } + // We need an absolute path to be able to locate Python on Windows. + if (item->engineType() == GdbEngineType) { + if (tcAbi.os() == Abi::WindowsOS && !debugger.isAbsolutePath()) + result |= DebuggerNeedsAbsolutePath; } + return result; } @@ -342,7 +281,12 @@ Runnable DebuggerKitAspect::runnable(const Kit *kit) { Runnable runnable; if (const DebuggerItem *item = debugger(kit)) { - runnable.command = CommandLine{item->command()}; + FilePath cmd = item->command(); + if (cmd.isRelativePath()) { + if (const IDeviceConstPtr buildDevice = BuildDeviceKitAspect::device(kit)) + cmd = buildDevice->searchExecutableInPath(cmd.path()); + } + runnable.command.setExecutable(cmd); runnable.workingDirectory = item->workingDirectory(); runnable.environment = kit->runEnvironment(); runnable.environment.set("LC_NUMERIC", "C"); diff --git a/src/plugins/debugger/debuggerkitinformation.h b/src/plugins/debugger/debuggerkitinformation.h index eb6ad1d58a..548f76793b 100644 --- a/src/plugins/debugger/debuggerkitinformation.h +++ b/src/plugins/debugger/debuggerkitinformation.h @@ -21,7 +21,6 @@ public: { return DebuggerKitAspect::validateDebugger(k); } void setup(ProjectExplorer::Kit *k) override; - void fix(ProjectExplorer::Kit *k) override; static const DebuggerItem *debugger(const ProjectExplorer::Kit *kit); static ProjectExplorer::Runnable runnable(const ProjectExplorer::Kit *kit); diff --git a/src/plugins/remotelinux/linuxdevice.cpp b/src/plugins/remotelinux/linuxdevice.cpp index d70ca77295..e8b7d30eec 100644 --- a/src/plugins/remotelinux/linuxdevice.cpp +++ b/src/plugins/remotelinux/linuxdevice.cpp @@ -339,7 +339,7 @@ Environment LinuxDevicePrivate::getEnvironment() return m_environmentCache.value(); QtcProcess getEnvProc; - getEnvProc.setCommand({FilePath("env").onDevice(q->rootPath()), {}}); + getEnvProc.setCommand({q->filePath("env"), {}}); getEnvProc.runBlocking(); const QString remoteOutput = getEnvProc.cleanedStdOut(); |