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 <christian.stenger@qt.io>
This commit is contained in:
Alessandro Portale
2021-11-08 11:37:19 +01:00
parent d06ddd12b6
commit 5c0c3ff6ca

View File

@@ -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())