llvm-project/lldb/unittests
Pavel Labath 7f09ab08de [lldb] Fix [some] leaks in python bindings
Using an lldb_private object in the bindings involves three steps
- wrapping the object in it's lldb::SB variant
- using swig to convert/wrap that to a PyObject
- wrapping *that* in a lldb_private::python::PythonObject

Our SBTypeToSWIGWrapper was only handling the middle part. This doesn't
just result in increased boilerplate in the callers, but is also a
functionality problem, as it's very hard to get the lifetime of of all
of these objects right. Most of the callers are creating the SB object
(step 1) on the stack, which means that we end up with dangling python
objects after the function terminates. Most of the time this isn't a
problem, because the python code does not need to persist the objects.
However, there are legitimate cases where they can do it (and even if
the use case is not completely legitimate, crashing is not the best
response to that).

For this reason, some of our code creates the SB object on the heap, but
it has another problem -- it never gets cleaned up.

This patch begins to add a new function (ToSWIGWrapper), which does all
of the three steps, while properly taking care of ownership. In the
first step, I have converted most of the leaky code (except for
SBStructuredData, which needs a bit more work).

Differential Revision: https://reviews.llvm.org/D114259
2021-11-22 15:14:52 +01:00
..
API
Breakpoint
Core [lldb] Add support for demangling D symbols 2021-11-11 11:11:21 +01:00
DataFormatter
Disassembler
Editline [lldb][NFC] Inclusive language: replace master/slave names for ptys 2021-11-12 10:54:18 -06:00
Expression [lldb] Return StringRef from PluginInterface::GetPluginName 2021-10-18 10:14:42 +02:00
Host [lldb] [Host/Socket] Make DecodeHostAndPort() return a dedicated struct 2021-10-28 09:57:50 +02:00
Instruction
Interpreter Follow-on to fix a test from c5011aed9c. 2021-10-18 16:53:32 -07:00
Language [lldb] Return StringRef from PluginInterface::GetPluginName 2021-10-18 10:14:42 +02:00
ObjectFile [LLDB][Breakpad] Make lldb understand INLINE and INLINE_ORIGIN records in breakpad. 2021-11-10 11:20:32 -08:00
Platform [lldb] Remove nested switches from ARMGetSupportedArchitectureAtIndex (NFC) 2021-11-05 21:12:00 -07:00
Process [NFC] Inclusive language: Remove instances of master in URLs 2021-11-05 08:48:41 -05:00
ScriptInterpreter [lldb] Fix [some] leaks in python bindings 2021-11-22 15:14:52 +01:00
Signals
Symbol [lldb] Make TypeSystemClang::GetFullyUnqualifiedType work for constant arrays 2021-10-29 11:13:59 +02:00
SymbolFile Remove ConstString from Language, LanguageRuntime, SystemRuntime and SymbolFile plugin names 2021-10-27 08:25:44 +02:00
Target [lldb] Refactor Platform::ResolveExecutable 2021-11-16 12:52:51 +01:00
TestingSupport
Thread [lldb] Return StringRef from PluginInterface::GetPluginName 2021-10-18 10:14:42 +02:00
UnwindAssembly
Utility [lldb] [Utility/UriParser] Return results as 'struct URI' 2021-10-25 10:58:21 +02:00
debugserver [lldb] [unittests] Fix TcpListen() call in RNBSocketTest 2021-10-26 21:08:03 +02:00
tools Recommit: [lldb] Remove "dwarf dynamic register size expressions" from RegisterInfo 2021-10-07 11:15:00 +02:00
CMakeLists.txt
gtest_common.h