diff options
author | Greg Clayton <gclayton@apple.com> | 2015-08-31 21:25:45 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2015-08-31 21:25:45 +0000 |
commit | 7a0c9c2dd0b958e384073b71f756b774163037b7 (patch) | |
tree | 89ab1b75de0abb3616d614a7fbfeb0348fda924a /lldb/source/Plugins/MemoryHistory | |
parent | 0e06975820280e403879b8d5a6cc66b691a01320 (diff) |
Stop objects from keeping a strong reference to the process when they should have a weak reference.
Diffstat (limited to 'lldb/source/Plugins/MemoryHistory')
-rw-r--r-- | lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp | 68 | ||||
-rw-r--r-- | lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.h | 2 |
2 files changed, 36 insertions, 34 deletions
diff --git a/lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp b/lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp index da24ed5381f..13bd26d407b 100644 --- a/lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp +++ b/lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp @@ -75,7 +75,8 @@ MemoryHistoryASan::GetPluginNameStatic() MemoryHistoryASan::MemoryHistoryASan(const ProcessSP &process_sp) { - this->m_process_sp = process_sp; + if (process_sp) + m_process_wp = process_sp; } const char * @@ -133,40 +134,41 @@ static void CreateHistoryThreadFromValueObject(ProcessSP process_sp, ValueObject HistoryThreads MemoryHistoryASan::GetHistoryThreads(lldb::addr_t address) { - ProcessSP process_sp = m_process_sp; - ThreadSP thread_sp = m_process_sp->GetThreadList().GetSelectedThread(); - StackFrameSP frame_sp = thread_sp->GetSelectedFrame(); - - if (!frame_sp) - { - return HistoryThreads(); - } + HistoryThreads result; - ExecutionContext exe_ctx (frame_sp); - ValueObjectSP return_value_sp; - StreamString expr; - expr.Printf(memory_history_asan_command_format, address, address); - - EvaluateExpressionOptions options; - options.SetUnwindOnError(true); - options.SetTryAllThreads(true); - options.SetStopOthers(true); - options.SetIgnoreBreakpoints(true); - options.SetTimeoutUsec(GET_STACK_FUNCTION_TIMEOUT_USEC); - - if (m_process_sp->GetTarget().EvaluateExpression(expr.GetData(), frame_sp.get(), return_value_sp, options) != eExpressionCompleted) + ProcessSP process_sp = m_process_wp.lock(); + if (process_sp) { - return HistoryThreads(); + ThreadSP thread_sp = process_sp->GetThreadList().GetSelectedThread(); + + if (thread_sp) + { + StackFrameSP frame_sp = thread_sp->GetSelectedFrame(); + + if (frame_sp) + { + ExecutionContext exe_ctx (frame_sp); + ValueObjectSP return_value_sp; + StreamString expr; + expr.Printf(memory_history_asan_command_format, address, address); + + EvaluateExpressionOptions options; + options.SetUnwindOnError(true); + options.SetTryAllThreads(true); + options.SetStopOthers(true); + options.SetIgnoreBreakpoints(true); + options.SetTimeoutUsec(GET_STACK_FUNCTION_TIMEOUT_USEC); + + if (process_sp->GetTarget().EvaluateExpression(expr.GetData(), frame_sp.get(), return_value_sp, options) == eExpressionCompleted) + { + if (return_value_sp) + { + CreateHistoryThreadFromValueObject(process_sp, return_value_sp, "free", "Memory deallocated at", result); + CreateHistoryThreadFromValueObject(process_sp, return_value_sp, "alloc", "Memory allocated at", result); + } + } + } + } } - if (!return_value_sp) - { - return HistoryThreads(); - } - - HistoryThreads result; - - CreateHistoryThreadFromValueObject(process_sp, return_value_sp, "free", "Memory deallocated at", result); - CreateHistoryThreadFromValueObject(process_sp, return_value_sp, "alloc", "Memory allocated at", result); - return result; } diff --git a/lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.h b/lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.h index 5307e0b3408..51484b752b6 100644 --- a/lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.h +++ b/lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.h @@ -53,7 +53,7 @@ private: MemoryHistoryASan(const lldb::ProcessSP &process_sp); - lldb::ProcessSP m_process_sp; + lldb::ProcessWP m_process_wp; }; |