lldb: Set environment variable to detect when running lldb from Creator

Instead of relying on __name__ being 'lldbbridge', which can also
be the case if the lldbbridge.py script is imported into a plain
LLDB process, we can now look at the environment variable.

This also lets us break out early from __lldb_init_module
if the user has a `command script import llbdbridge.py`
in their .lldbinit, or is automatically loading the bridge
via the Qt Core debug script.

Change-Id: Id8168c692ef66ce50119b7426ca85c7bc99d9503
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Tor Arne Vestbø
2023-09-22 22:18:48 +02:00
parent b9e327bb10
commit 7033bbf7e0
2 changed files with 11 additions and 7 deletions

View File

@@ -179,6 +179,7 @@ void LldbEngine::setupEngine()
showMessage("STARTING LLDB: " + lldbCmd.toUserOutput());
Environment environment = runParameters().debugger.environment;
environment.appendOrSet("QT_CREATOR_LLDB_PROCESS", "1");
environment.appendOrSet("PYTHONUNBUFFERED", "1"); // avoid flushing problem on macOS
DebuggerItem::addAndroidLldbPythonEnv(lldbCmd, environment);