[lldb] Clarify StructuredDataImpl ownership
authorPavel Labath <pavel@labath.sk>
Thu, 25 Nov 2021 13:01:41 +0000 (14:01 +0100)
committerPavel Labath <pavel@labath.sk>
Mon, 13 Dec 2021 20:04:51 +0000 (21:04 +0100)
commit82de8df26f15778793dc6b1526e14779f435f2e1
tree2afe68a74ee84b73762dce273b72631941801d39
parent34696e6542894ac63dbfb899b0181c539c223ef1
[lldb] Clarify StructuredDataImpl ownership

StructuredDataImpl ownership semantics is unclear at best. Various
structures were holding a non-owning pointer to it, with a comment that
the object is owned somewhere else. From what I was able to gather that
"somewhere else" was the SBStructuredData object, but I am not sure that
all created object eventually made its way there. (It wouldn't matter
even if they did, as we are leaking most of our SBStructuredData
objects.)

Since StructuredDataImpl is just a collection of two (shared) pointers,
there's really no point in elaborate lifetime management, so this patch
replaces all StructuredDataImpl pointers with actual objects or
unique_ptrs to it. This makes it much easier to resolve SBStructuredData
leaks in a follow-up patch.

Differential Revision: https://reviews.llvm.org/D114791
24 files changed:
lldb/bindings/lua/lua-wrapper.swig
lldb/bindings/python/python-wrapper.swig
lldb/include/lldb/API/SBStructuredData.h
lldb/include/lldb/Breakpoint/BreakpointResolverScripted.h
lldb/include/lldb/Core/StructuredDataImpl.h
lldb/include/lldb/Interpreter/ScriptInterpreter.h
lldb/include/lldb/Target/Target.h
lldb/include/lldb/Target/ThreadPlanPython.h
lldb/source/API/SBStructuredData.cpp
lldb/source/API/SBThreadPlan.cpp
lldb/source/Breakpoint/BreakpointResolverScripted.cpp
lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
lldb/source/Plugins/ScriptInterpreter/Lua/SWIGLuaBridge.h
lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp
lldb/source/Target/Target.cpp
lldb/source/Target/Thread.cpp
lldb/source/Target/ThreadPlanPython.cpp
lldb/unittests/ScriptInterpreter/Lua/LuaTests.cpp
lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp