diff options
author | Jan Kratochvil <jan.kratochvil@redhat.com> | 2019-10-04 19:32:57 +0000 |
---|---|---|
committer | Jan Kratochvil <jan.kratochvil@redhat.com> | 2019-10-04 19:32:57 +0000 |
commit | 4112b4733502f746b766861853c414af0e01d6f9 (patch) | |
tree | f28f290ceef9830b8e82c639255a7b16b3d6ba99 /lldb/scripts/Python/python-wrapper.swig | |
parent | f7766b1ed41aa07b6a784d0ebf074c63ada1940d (diff) | |
download | bcm5719-llvm-4112b4733502f746b766861853c414af0e01d6f9.tar.gz bcm5719-llvm-4112b4733502f746b766861853c414af0e01d6f9.zip |
[lldb] Fix crash on SBCommandReturnObject & assignment
I was writing an SB API client and it was crashing on:
bool DoExecute(SBDebugger dbg, char **command, SBCommandReturnObject &result) {
result = subcommand(dbg, "help");
That is because SBCommandReturnObject &result gets initialized inside LLDB by:
bool DoExecute(Args &command, CommandReturnObject &result) override {
// std::unique_ptr gets initialized here from `&result`!!!
SBCommandReturnObject sb_return(&result);
DoExecute(...);
sb_return.Release();
Differential revision: https://reviews.llvm.org/D67589
llvm-svn: 373775
Diffstat (limited to 'lldb/scripts/Python/python-wrapper.swig')
-rw-r--r-- | lldb/scripts/Python/python-wrapper.swig | 30 |
1 files changed, 2 insertions, 28 deletions
diff --git a/lldb/scripts/Python/python-wrapper.swig b/lldb/scripts/Python/python-wrapper.swig index b84b21ae23e..7d507b31c5c 100644 --- a/lldb/scripts/Python/python-wrapper.swig +++ b/lldb/scripts/Python/python-wrapper.swig @@ -671,30 +671,6 @@ LLDBSWIGPython_CastPyObjectToSBValue return sb_ptr; } -// Currently, SBCommandReturnObjectReleaser wraps a unique pointer to an -// lldb_private::CommandReturnObject. This means that the destructor for the -// SB object will deallocate its contained CommandReturnObject. Because that -// object is used as the real return object for Python-based commands, we want -// it to stay around. Thus, we release the unique pointer before returning from -// LLDBSwigPythonCallCommand, and to guarantee that the release will occur no -// matter how we exit from the function, we have a releaser object whose -// destructor does the right thing for us -class SBCommandReturnObjectReleaser -{ -public: - SBCommandReturnObjectReleaser (lldb::SBCommandReturnObject &obj) : - m_command_return_object_ref (obj) - { - } - - ~SBCommandReturnObjectReleaser () - { - m_command_return_object_ref.Release(); - } -private: - lldb::SBCommandReturnObject &m_command_return_object_ref; -}; - SWIGEXPORT bool LLDBSwigPythonCallCommand ( @@ -707,8 +683,7 @@ LLDBSwigPythonCallCommand ) { using namespace lldb_private; - lldb::SBCommandReturnObject cmd_retobj_sb(&cmd_retobj); - SBCommandReturnObjectReleaser cmd_retobj_sb_releaser(cmd_retobj_sb); + lldb::SBCommandReturnObject cmd_retobj_sb(cmd_retobj); lldb::SBDebugger debugger_sb(debugger); lldb::SBExecutionContext exe_ctx_sb(exe_ctx_ref_sp); @@ -745,8 +720,7 @@ LLDBSwigPythonCallCommandObject ) { using namespace lldb_private; - lldb::SBCommandReturnObject cmd_retobj_sb(&cmd_retobj); - SBCommandReturnObjectReleaser cmd_retobj_sb_releaser(cmd_retobj_sb); + lldb::SBCommandReturnObject cmd_retobj_sb(cmd_retobj); lldb::SBDebugger debugger_sb(debugger); lldb::SBExecutionContext exe_ctx_sb(exe_ctx_ref_sp); |