Debugger: Consolidate search code for python-path

Not just to deduplicate/reuse code but also to make make it clear that
different places where lldb is called, the same preparations have to be
done.

Change-Id: I104aca845fd7b42f63443bda2502574f4d28b411
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Alessandro Portale
2021-11-08 13:07:00 +01:00
parent 1b6d374d62
commit d33cd5194a
3 changed files with 22 additions and 26 deletions

View File

@@ -204,18 +204,6 @@ 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());
@@ -225,7 +213,7 @@ void LldbEngine::setupEngine()
showMessage("STARTING LLDB: " + lldbCmd.toUserOutput());
Environment environment = runParameters().debugger.environment;
environment.appendOrSet("PYTHONUNBUFFERED", "1"); // avoid flushing problem on macOS
addAndroidPythonDir(lldbCmd, environment);
DebuggerItem::addAndroidLldbPythonEnv(lldbCmd, environment);
m_lldbProc.setEnvironment(environment);
if (runParameters().debugger.workingDirectory.isDir())