This is an archive of the discontinued LLVM Phabricator instance.

[lldb/Python] Add lldbconfig Python module to make the lldb module configurable.
ClosedPublic

Authored by JDevlieghere on Apr 7 2020, 10:01 AM.

Details

Summary

Using the approach described in [1] and suggested by Pavel 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. More specifically it makes it possible to delay initializing the debugger, which is needed for testing the reproducer.

I chose to name the module lldbconfig rather than lldb.config because I thought it would be weird to import a "submodule" before the main module, but if anyone feels the other approach is more desirable I'd be happy to change it.

[1] https://stackoverflow.com/questions/3720740/pass-variable-on-import/39360070#39360070

Diff Detail

Event Timeline

JDevlieghere created this revision.Apr 7 2020, 10:01 AM
JDevlieghere marked an inline comment as done.Apr 7 2020, 10:02 AM
JDevlieghere added inline comments.
lldb/packages/Python/lldbsuite/test/dotest.py
957

This is a NO-OP for now, but just shows that we can load the lldbconfig module.

Thanks. This looks fine, just a question about the placement of the lldbconfig module.

lldb/CMakeLists.txt
130 ↗(On Diff #255706)

If we're not going to ship this file, should we place it under packages/Python/... (I'm sure there is some place we could put it where it would already be in sys.path ? That way it would not be accessible from regular lldb runs, only for those from dotest, which would decrease the likelyhood of lldb suddenly stopping to work after being installed.

lldb/bindings/python.swig
131

Maybe _initialize (the convention for "private" variables in python)?

JDevlieghere marked 2 inline comments as done.

Address code review feedback

labath accepted this revision.Apr 7 2020, 11:28 PM

Let's see how this goes.

This revision is now accepted and ready to land.Apr 7 2020, 11:28 PM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptApr 8 2020, 4:20 PM