forked from qt-creator/qt-creator
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:
@@ -2068,6 +2068,13 @@ class Tester(Dumper):
|
||||
|
||||
lldb.SBDebugger.Destroy(self.debugger)
|
||||
|
||||
if 'QT_CREATOR_LLDB_PROCESS' in os.environ:
|
||||
# Initialize Qt Creator dumper
|
||||
try:
|
||||
theDumper = Dumper()
|
||||
except Exception as error:
|
||||
print('@\nstate="enginesetupfailed",error="{}"@\n'.format(error))
|
||||
|
||||
# ------------------------------ For use in LLDB ------------------------------
|
||||
|
||||
|
||||
@@ -2437,6 +2444,9 @@ class SyntheticChildrenProvider(SummaryProvider):
|
||||
|
||||
def __lldb_init_module(debugger, internal_dict):
|
||||
# Module is being imported in an LLDB session
|
||||
if 'QT_CREATOR_LLDB_PROCESS' in os.environ:
|
||||
# Let Qt Creator take care of its own dumper
|
||||
return
|
||||
|
||||
if not __name__ == 'qt':
|
||||
# Make available under global 'qt' name for consistency,
|
||||
@@ -2471,10 +2481,3 @@ def __lldb_init_module(debugger, internal_dict):
|
||||
% ("qt.SyntheticChildrenProvider", type_category))
|
||||
|
||||
debugger.HandleCommand('type category enable %s' % type_category)
|
||||
|
||||
|
||||
if __name__ == "lldbbridge":
|
||||
try:
|
||||
theDumper = Dumper()
|
||||
except Exception as error:
|
||||
print('@\nstate="enginesetupfailed",error="{}"@\n'.format(error))
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user