Skip to content

Commit b0bdaf9

Browse files
committed
[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
1 parent 223154d commit b0bdaf9

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

lldb/bindings/python.swig

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,15 @@ using namespace lldb;
128128
%include "./python/python-wrapper.swig"
129129

130130
%pythoncode%{
131+
_initialize = True
132+
try:
133+
import lldbconfig
134+
_initialize = lldbconfig.INITIALIZE
135+
except ImportError:
136+
pass
131137
debugger_unique_id = 0
132-
SBDebugger.Initialize()
138+
if _initialize:
139+
SBDebugger.Initialize()
133140
debugger = None
134141
target = None
135142
process = None
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
INITIALIZE = True

lldb/packages/Python/lldbsuite/test/dotest.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,9 @@ def run_suite():
954954

955955
setupSysPath()
956956

957+
import lldbconfig
957958
import lldb
959+
958960
# Use host platform by default.
959961
lldb.selected_platform = lldb.SBPlatform.GetHostPlatform()
960962

0 commit comments

Comments
 (0)