aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Stenger <christian.stenger@qt.io>2021-11-04 22:22:45 +0100
committerChristian Stenger <christian.stenger@qt.io>2021-11-09 07:19:35 +0000
commiteab5315904c78497b39ea88b3e93d1ae842f2c8a (patch)
treebba6d63b795e9db13b0d45dfca2f07a16ae241a8
parentbfe6c46f9f557e3fc63ed2d61bb53b9f36f3ebbf (diff)
Android: Register Lldb if it is present
Change-Id: I46a544c0541ca4f0a969064faf055c1e99b9c5ad Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
-rw-r--r--src/plugins/android/androidconfigurations.cpp78
-rw-r--r--src/plugins/android/androidconfigurations.h1
2 files changed, 65 insertions, 14 deletions
diff --git a/src/plugins/android/androidconfigurations.cpp b/src/plugins/android/androidconfigurations.cpp
index c9e3603ddd..0fb2b476e5 100644
--- a/src/plugins/android/androidconfigurations.cpp
+++ b/src/plugins/android/androidconfigurations.cpp
@@ -563,6 +563,16 @@ FilePath AndroidConfig::gdbPathFromNdk(const Abi &abi, const FilePath &ndkLocati
QString(QTC_HOST_EXE_SUFFIX)));
}
+FilePath AndroidConfig::lldbPathFromNdk(const FilePath &ndkLocation) const
+{
+ const FilePath path = ndkLocation.pathAppended(
+ QString("toolchains/llvm/prebuilt/%1/bin/lldb%2").arg(toolchainHostFromNdk(ndkLocation),
+ QString(QTC_HOST_EXE_SUFFIX)));
+ if (path.exists())
+ return path;
+ return {};
+}
+
FilePath AndroidConfig::makePathFromNdk(const FilePath &ndkLocation) const
{
return ndkLocation.pathAppended(
@@ -1241,39 +1251,79 @@ static QString getMultiOrSingleAbiString(const QStringList &abis)
return containsAllAbis(abis) ? "Multi-Abi" : abis.join(",");
}
+static const Debugger::DebuggerItem *existingDebugger(const FilePath &command,
+ Debugger::DebuggerEngineType type)
+{
+ // check if the debugger is already registered, but ignoring the display name
+ const Debugger::DebuggerItem *existing = Debugger::DebuggerItemManager::findByCommand(command);
+
+ // Return existing debugger with same command
+ if (existing && existing->engineType() == type && existing->isAutoDetected())
+ return existing;
+ return nullptr;
+}
+
static QVariant findOrRegisterDebugger(ToolChain *tc,
const QStringList &abisList,
bool customDebugger = false)
{
const auto &currentConfig = AndroidConfigurations::currentConfig();
const FilePath ndk = static_cast<AndroidToolChain *>(tc)->ndkLocation();
- const FilePath command = currentConfig.gdbPathFromNdk(tc->targetAbi(), ndk);
+ const FilePath lldbCommand = currentConfig.lldbPathFromNdk(ndk);
+ const Debugger::DebuggerItem *existingLldb = existingDebugger(lldbCommand,
+ Debugger::LldbEngineType);
+ // Return existing debugger with same command - prefer lldb (limit to sdk/ndk min version?)
+ if (existingLldb)
+ return existingLldb->id();
- // check if the debugger is already registered, but ignoring the display name
- const Debugger::DebuggerItem *existing = Debugger::DebuggerItemManager::findByCommand(command);
+ const FilePath gdbCommand = currentConfig.gdbPathFromNdk(tc->targetAbi(), ndk);
+ // check if the debugger is already registered, but ignoring the display name
+ const Debugger::DebuggerItem *existingGdb = existingDebugger(gdbCommand,
+ Debugger::GdbEngineType);
// Return existing debugger with same command
- if (existing && existing->engineType() == Debugger::GdbEngineType
- && existing->isAutoDetected()) {
- return existing->id();
- }
+ if (existingGdb)
+ return existingGdb->id();
+ const QString mainName = AndroidConfigurations::tr("Android Debugger (%1, NDK %2)");
+ const QString custom = customDebugger ? QString{"Custom "} : QString{};
// debugger not found, register a new one
+ // check lldb
+ QVariant registeredLldb;
+ if (!lldbCommand.isEmpty()) {
+ Debugger::DebuggerItem debugger;
+ debugger.setCommand(lldbCommand);
+ debugger.setEngineType(Debugger::LldbEngineType);
+ debugger.setUnexpandedDisplayName(custom + mainName
+ .arg(getMultiOrSingleAbiString(allSupportedAbis()))
+ .arg(AndroidConfigurations::currentConfig().ndkVersion(ndk).toString())
+ + ' ' + debugger.engineTypeName());
+ debugger.setAutoDetected(true);
+ debugger.reinitializeFromFile();
+ registeredLldb = Debugger::DebuggerItemManager::registerDebugger(debugger);
+ }
+
+ // we always have a value for gdb (but we shouldn't - we currently use a fallback)
+ if (!gdbCommand.exists()) {
+ if (!registeredLldb.isNull())
+ return registeredLldb;
+ return {};
+ }
+
Debugger::DebuggerItem debugger;
- debugger.setCommand(command);
+ debugger.setCommand(gdbCommand);
debugger.setEngineType(Debugger::GdbEngineType);
// NDK 10 and older have multiple gdb versions per ABI, so check for that.
const bool oldNdkVersion = currentConfig.ndkVersion(ndk) <= QVersionNumber{11};
- QString mainName = AndroidConfigurations::tr("Android Debugger (%1, NDK %2)");
- if (customDebugger)
- mainName.prepend("Custom ");
- debugger.setUnexpandedDisplayName(mainName
+ debugger.setUnexpandedDisplayName(custom + mainName
.arg(getMultiOrSingleAbiString(oldNdkVersion ? abisList : allSupportedAbis()))
- .arg(AndroidConfigurations::currentConfig().ndkVersion(ndk).toString()));
+ .arg(AndroidConfigurations::currentConfig().ndkVersion(ndk).toString())
+ + ' ' + debugger.engineTypeName());
debugger.setAutoDetected(true);
debugger.reinitializeFromFile();
- return Debugger::DebuggerItemManager::registerDebugger(debugger);
+ QVariant registeredGdb = Debugger::DebuggerItemManager::registerDebugger(debugger);
+ return registeredLldb.isNull() ? registeredGdb : registeredLldb;
}
void AndroidConfigurations::registerCustomToolChainsAndDebuggers()
diff --git a/src/plugins/android/androidconfigurations.h b/src/plugins/android/androidconfigurations.h
index 2110125ad7..84d1142cce 100644
--- a/src/plugins/android/androidconfigurations.h
+++ b/src/plugins/android/androidconfigurations.h
@@ -140,6 +140,7 @@ public:
Utils::FilePath gdbPath(const ProjectExplorer::Abi &abi, const QtSupport::BaseQtVersion *qtVersion) const;
Utils::FilePath gdbPathFromNdk(const ProjectExplorer::Abi &abi, const Utils::FilePath &ndkLocation) const;
+ Utils::FilePath lldbPathFromNdk(const Utils::FilePath &ndkLocation) const;
Utils::FilePath makePathFromNdk(const Utils::FilePath &ndkLocation) const;
Utils::FilePath keytoolPath() const;