From 5c0c3ff6cad1c2cb2227f07b9c5b7ecf6c27dbf5 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Mon, 8 Nov 2021 11:37:19 +0100 Subject: [PATCH] Debugger: Also look for "/ndk/" path segment in LldbEngine::setupEngine And pull the env-modifying code into a function which we might want to use in other places where lldb gets executed. Change-Id: Ic9caaf8c29896c54d67c969d2812b4da627a5fc0 Reviewed-by: Christian Stenger --- src/plugins/debugger/lldb/lldbengine.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/plugins/debugger/lldb/lldbengine.cpp b/src/plugins/debugger/lldb/lldbengine.cpp index a5440edb7fd..ad2f4f2974e 100644 --- a/src/plugins/debugger/lldb/lldbengine.cpp +++ b/src/plugins/debugger/lldb/lldbengine.cpp @@ -204,6 +204,18 @@ static QString adapterStartFailed() return LldbEngine::tr("Adapter start failed."); } +static void addAndroidPythonDir(const FilePath &lldbCmd, Environment &env) +{ + if (!lldbCmd.path().contains("/ndk/") && !lldbCmd.path().contains("/ndk-bundle/")) + return; + + FilePath androidPythonDir = lldbCmd.parentDir().parentDir().pathAppended("python3"); + if (HostOsInfo::isAnyUnixHost()) + androidPythonDir = androidPythonDir.pathAppended("bin"); + if (androidPythonDir.exists()) + env.prependOrSetPath(androidPythonDir.path()); +} + void LldbEngine::setupEngine() { QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state()); @@ -213,13 +225,7 @@ void LldbEngine::setupEngine() showMessage("STARTING LLDB: " + lldbCmd.toUserOutput()); Environment environment = runParameters().debugger.environment; environment.appendOrSet("PYTHONUNBUFFERED", "1"); // avoid flushing problem on macOS - if (lldbCmd.path().contains("/ndk-bundle/")) { - FilePath androidPythonDir = lldbCmd.parentDir().parentDir().pathAppended("python3"); - if (HostOsInfo::isAnyUnixHost()) - androidPythonDir = androidPythonDir.pathAppended("bin"); - if (androidPythonDir.exists()) - environment.prependOrSetPath(androidPythonDir.path()); - } + addAndroidPythonDir(lldbCmd, environment); m_lldbProc.setEnvironment(environment); if (runParameters().debugger.workingDirectory.isDir())