[lldb/Python] Add lldbconfig module to make the lldb module configurable
authorJonas Devlieghere <jonas@devlieghere.com>
Wed, 8 Apr 2020 22:34:13 +0000 (15:34 -0700)
committerJonas Devlieghere <jonas@devlieghere.com>
Wed, 8 Apr 2020 22:59:24 +0000 (15:59 -0700)
Using the approach suggested by Pavel in D77588, this patch introduces a
new lldbconfig module that lives next to the lldb module. It makes it
possible to make the lldb module configurable before importing it. More
specifically it makes it possible to delay initializing the debugger,
which is needed for testing the reproducer.

Differential revision: https://reviews.llvm.org/D77661

lldb/bindings/python.swig
lldb/packages/Python/lldbconfig/__init__.py [new file with mode: 0644]
lldb/packages/Python/lldbsuite/test/dotest.py

index b086d43..5b12698 100644 (file)
@@ -128,8 +128,15 @@ using namespace lldb;
 %include "./python/python-wrapper.swig"
 
 %pythoncode%{
+_initialize = True
+try:
+   import lldbconfig
+   _initialize = lldbconfig.INITIALIZE
+except ImportError:
+   pass
 debugger_unique_id = 0
-SBDebugger.Initialize()
+if _initialize:
+   SBDebugger.Initialize()
 debugger = None
 target = None
 process = None
diff --git a/lldb/packages/Python/lldbconfig/__init__.py b/lldb/packages/Python/lldbconfig/__init__.py
new file mode 100644 (file)
index 0000000..6c43d70
--- /dev/null
@@ -0,0 +1 @@
+INITIALIZE = True
index 4e86d1a..31c617c 100644 (file)
@@ -954,7 +954,9 @@ def run_suite():
 
     setupSysPath()
 
+    import lldbconfig
     import lldb
+
     # Use host platform by default.
     lldb.selected_platform = lldb.SBPlatform.GetHostPlatform()