Skip to content

Commit bf02586

Browse files
committed
[lldb] Call __lldb_init_module from __init__
Update `__init__.py` generation to implement `__lldb_init_module`, which calls `__lldb_init_module` on submodules that define it. This allows the use case where a user runs `command script import lldb.macosx`. With this change, the `__lldb_init_module` function in `crashlog.py` and `heap.py` will be run, which is where command registration is occurring. Differential Revision: https://reviews.llvm.org/D119179
1 parent 4c12a75 commit bf02586

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lldb/bindings/python/createPythonInit.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@
1010
script = """__all__ = [{import_names}]
1111
for x in __all__:
1212
__import__('lldb.{pkg_name}.' + x)
13+
14+
def __lldb_init_module(debugger, internal_dict):
15+
import lldb
16+
for x in __all__:
17+
submodule = getattr(lldb.{pkg_name}, x)
18+
lldb_init = getattr(submodule, '__lldb_init_module', None)
19+
if lldb_init:
20+
lldb_init(debugger, internal_dict)
1321
""".format(import_names=importNames, pkg_name=pkgRelDir.replace("/", "."))
1422

1523
pkgIniFile = os.path.normpath(os.path.join(pkgRelDir, "__init__.py"))

0 commit comments

Comments
 (0)