[Lldb-commits] [PATCH] D117237: [lldb] Use __lldb_init_module instead of "if lldb.debugger" idiom
Dave Lee via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Thu Jan 13 10:33:15 PST 2022
kastiglione created this revision.
kastiglione added reviewers: jingham, JDevlieghere, clayborg.
kastiglione requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
Update examples and docs to demonstrate using `__lldb_init_module` instead of
the idiom that checks for `lldb.debugger` at the top-level.
if __name__ == '__main__':
...
elif lldb.debugger:
...
Is replaced with:
if __name__ == '__main__':
...
def __lldb_init_module(debugger, internal_dict):
...
This change is for two reasons. First, it's generally encouraged not to only
use the convenience singletons (`lldb.{debugger,process,target,etc}`)
interactively from the `script` command. Second, there's a bug where
registering a python class as a command (using `command script add -c ...`),
result in the command not being runnable. Note that registering function-backed
commands does not have this bug.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D117237
Files:
lldb/docs/use/python-reference.rst
lldb/examples/darwin/heap_find/heap.py
lldb/examples/python/delta.py
lldb/examples/python/gdbremote.py
lldb/examples/python/memory.py
lldb/examples/python/types.py
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117237.399721.patch
Type: text/x-patch
Size: 8575 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220113/d942c492/attachment-0001.bin>
More information about the lldb-commits
mailing list