llvm-capstone/lldb
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
..
bindings [lldb] Fix [some] leaks in python bindings 2021-11-22 15:14:52 +01:00
cmake Revert "Use GNUInstallDirs to support custom installation dirs. -- LLVM" 2021-11-02 19:11:44 +01:00
docs [NFC] Trim trailing whitespace in *.rst 2021-11-15 09:17:08 +08:00
examples [lldb/test] Update TestScriptedProcess to use skinny corefiles 2021-11-10 17:43:29 +01:00
include/lldb Remove unused variable. 2021-11-18 15:58:20 -08:00
packages/Python [lldb/test] Make it possible to run the mock gdb server on a single thread 2021-11-22 15:14:50 +01:00
resources [lldb] Remove stale LLDB-Info.plist 2021-01-08 10:12:16 -08:00
scripts Prefer /usr/bin/env xxx over /usr/bin/xxx where xxx = perl, python, awk 2021-02-25 11:32:27 +01:00
source [lldb] Fix [some] leaks in python bindings 2021-11-22 15:14:52 +01:00
test Skip tests when compiler with older versions of clang 2021-11-19 09:05:48 -08:00
third_party/Python/module [lldb][NFC] Inclusive language: replace master/slave names for ptys 2021-11-12 10:54:18 -06:00
tools [debugserver] Remove varaible ldb_set which is set but not used. 2021-11-10 11:56:59 -08:00
unittests [lldb] Fix [some] leaks in python bindings 2021-11-22 15:14:52 +01:00
utils [lldb] Match test dependencies name to other LLVM projects. 2021-05-21 00:10:27 -07:00
.clang-format
.clang-tidy [lldb] Replace default bodies of special member functions with = default; 2021-07-02 11:31:16 -07:00
.gitignore
CMakeLists.txt [lldb] remove usage of distutils, fix python path on debian/ubuntu 2021-11-17 13:14:30 -08:00
CODE_OWNERS.txt
LICENSE.TXT
use_lldb_suite_root.py