This is an archive of the discontinued LLVM Phabricator instance.

[lldb/python] Use PythonObject in LLDBSwigPython functions
ClosedPublic

Authored by labath on Jan 17 2022, 2:34 AM.

Details

Summary

Return our PythonObject wrappers instead of raw PyObjects (obfuscated as
void *). This ensures that ownership (reference counts) of python
objects is automatically tracked.

Diff Detail

Event Timeline

labath requested review of this revision.Jan 17 2022, 2:34 AM
labath created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptJan 17 2022, 2:34 AM
labath added inline comments.Jan 17 2022, 2:43 AM
lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
284

fixed a leak here

lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
1442

all of these were leaked

2159–2160

I didn't convert this one now because LLDBSwigPythonCallTypeScript is doing something weird (and most likely incorrect) with reference counts.

2808

Refactoring ExecuteOneLineWithReturn into something type-safe would be a bigger undertaking than all of the changes in this patch put together.

lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp
54

btw, all of the std::moves are just performance optimizations. They don't impact correctness.

mib accepted this revision.Jan 18 2022, 12:51 AM

LGTM, thanks.

This revision is now accepted and ready to land.Jan 18 2022, 12:51 AM
This revision was automatically updated to reflect the committed changes.