[Lldb-commits] [lldb] b0bdaf9 - [lldb/Python] Add lldbconfig module to make the lldb module configurable
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Wed Apr 8 15:59:33 PDT 2020
Author: Jonas Devlieghere
Date: 2020-04-08T15:59:24-07:00
New Revision: b0bdaf9ba2bfa9e099c7cb650650133f6ea2024f
URL: https://github.com/llvm/llvm-project/commit/b0bdaf9ba2bfa9e099c7cb650650133f6ea2024f
DIFF: https://github.com/llvm/llvm-project/commit/b0bdaf9ba2bfa9e099c7cb650650133f6ea2024f.diff
LOG: [lldb/Python] Add lldbconfig module to make the lldb module configurable
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
Added:
lldb/packages/Python/lldbconfig/__init__.py
Modified:
lldb/bindings/python.swig
lldb/packages/Python/lldbsuite/test/dotest.py
Removed:
################################################################################
diff --git a/lldb/bindings/python.swig b/lldb/bindings/python.swig
index b086d436e57b..5b1269878dac 100644
--- a/lldb/bindings/python.swig
+++ b/lldb/bindings/python.swig
@@ -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
index 000000000000..6c43d709df71
--- /dev/null
+++ b/lldb/packages/Python/lldbconfig/__init__.py
@@ -0,0 +1 @@
+INITIALIZE = True
diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py b/lldb/packages/Python/lldbsuite/test/dotest.py
index 4e86d1a59322..31c617c1f311 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -954,7 +954,9 @@ def run_suite():
setupSysPath()
+ import lldbconfig
import lldb
+
# Use host platform by default.
lldb.selected_platform = lldb.SBPlatform.GetHostPlatform()
More information about the lldb-commits
mailing list