This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Introduce OperatingSystem{,Python}Interface and make use it
ClosedPublic

Authored by mib on Aug 31 2023, 3:03 PM.

Details

Summary

This patch aims to consolidate the OperatingSystem scripting affordance
by introducing a stable interface that conforms to the
Scripted{,Python}Interface.

This unifies the way we call into python methods from lldb while
also improving its capabilities by allowing us to pass lldb_private
objects are arguments.

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>

Diff Detail

Event Timeline

mib created this revision.Aug 31 2023, 3:03 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 31 2023, 3:03 PM
mib requested review of this revision.Aug 31 2023, 3:03 PM

This change seems mostly red in that we're removing a lot of things. What are the replacements? I also see you're removing the API lock acquisition in a few places, where does that now occur?

lldb/bindings/python/python-wrapper.swig
266–279 ↗(On Diff #555174)

Is there no way to check the types of the positional args? This seems like it might be a source of future subtle bugs or unexpected behavior.

lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp
153–155

nit: Remove commented out code.

side note, maybe OperatingSystemPython should have a static factory method so we can actually return a meaningful error like this? Since the constructor can fail, we might end up with a half-initialized object. Doesn't have to be in this change, I think it would make sense for a follow-up.

164–169

Same here

mib updated this revision to Diff 557856.Oct 23 2023, 3:28 PM
mib marked 2 inline comments as done.

Address @bulbazord comments.

mib retitled this revision from [lldb] Introduce OperatingSystem{,Python}Interface and make us it to [lldb] Introduce OperatingSystem{,Python}Interface and make use it.Oct 23 2023, 3:29 PM
mib edited the summary of this revision. (Show Details)
mib added a comment.Oct 23 2023, 5:22 PM

Since @bulbazord asked me offline, all the repeat it here: Everything that was deleted here was replaced by either a call to the existing ScriptedPythonInterface::Dispatch method or depends on the new way to create scripted plugin objects.

lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp
153–155

I added a // FIXME: and I'll do the error handling in a followup.

bulbazord accepted this revision.Oct 26 2023, 10:33 AM

Ok, makes sense to me. Since this is a refactor, I assume that the current test suite should be enough to cover this change?

This revision is now accepted and ready to land.Oct 26 2023, 10:33 AM
mib added a comment.Oct 26 2023, 1:33 PM

Ok, makes sense to me. Since this is a refactor, I assume that the current test suite should be enough to cover this change?

@bulbazord yes!

This revision was landed with ongoing or failed builds.Oct 26 2023, 3:12 PM
This revision was automatically updated to reflect the committed changes.