[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
This commit is contained in:
Jonas Devlieghere 2020-04-08 15:34:13 -07:00
parent 223154d267
commit b0bdaf9ba2
3 changed files with 11 additions and 1 deletions

View 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

View File

@ -0,0 +1 @@
INITIALIZE = True

View File

@ -954,7 +954,9 @@ def run_suite():
setupSysPath()
import lldbconfig
import lldb
# Use host platform by default.
lldb.selected_platform = lldb.SBPlatform.GetHostPlatform()