From e980d87b5004351ff63e573f0f2c035abe60b6d2 Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 17 Jun 2022 17:10:38 +0200 Subject: [PATCH] Debugger: Fix LLDB start on Ubuntu 22.04 The LLDB (14) installation on Ubuntu 22.04 is broken, see https://bugs.launchpad.net/ubuntu/+source/llvm-defaults/+bug/1972855 Work around by using a corrected PYTHONPATH when starting LLDB. Change-Id: I9bede8f146c32f60247ca3416a14cf9ccf4b0fb6 Reviewed-by: Reviewed-by: Christian Stenger --- src/plugins/debugger/lldb/lldbengine.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/plugins/debugger/lldb/lldbengine.cpp b/src/plugins/debugger/lldb/lldbengine.cpp index cb8f0909d3d..62009240f55 100644 --- a/src/plugins/debugger/lldb/lldbengine.cpp +++ b/src/plugins/debugger/lldb/lldbengine.cpp @@ -203,6 +203,22 @@ void LldbEngine::setupEngine() Environment environment = runParameters().debugger.environment; environment.appendOrSet("PYTHONUNBUFFERED", "1"); // avoid flushing problem on macOS DebuggerItem::addAndroidLldbPythonEnv(lldbCmd, environment); + + if (lldbCmd.osType() == OsTypeLinux) { + // LLDB 14 installation on Ubuntu 22.04 is broken: + // https://bugs.launchpad.net/ubuntu/+source/llvm-defaults/+bug/1972855 + // Brush over it: + QtcProcess lldbPythonPathFinder; + lldbPythonPathFinder.setCommand({lldbCmd, {"-P"}}); + lldbPythonPathFinder.start(); + lldbPythonPathFinder.waitForFinished(); + QString lldbPythonPath = lldbPythonPathFinder.cleanedStdOut(); + if (lldbPythonPath.endsWith('\n')) + lldbPythonPath.chop(1); + if (lldbPythonPath == "/usr/lib/local/lib/python3.10/dist-packages") + environment.appendOrSet("PYTHONPATH", "/usr/lib/llvm-14/lib/python3.10/dist-packages"); + } + m_lldbProc.setEnvironment(environment); if (runParameters().debugger.workingDirectory.isDir())