From 6c17cc531f9f4ee94f2298200fc4813c02999d78 Mon Sep 17 00:00:00 2001 From: Tatyana Krasnukha Date: Tue, 3 Mar 2020 13:29:12 +0300 Subject: [lldb] Make BreakpointResolver hold weak_ptr instead of raw pointer to breakpoint This prevents calling Breakpoint::shared_from_this of an object that is not owned by any shared_ptr. Differential Revision: https://reviews.llvm.org/D74557 --- .../RenderScriptRuntime/RenderScriptRuntime.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp') diff --git a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp index 3ef6a3f39aab..dd9312234d8b 100644 --- a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp +++ b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp @@ -793,6 +793,9 @@ RenderScriptRuntime::CreateInstance(Process *process, Searcher::CallbackReturn RSBreakpointResolver::SearchCallback(SearchFilter &filter, SymbolContext &context, Address *) { + BreakpointSP breakpoint_sp = GetBreakpoint(); + assert(breakpoint_sp); + ModuleSP module = context.module_sp; if (!module || !IsRenderScriptScriptModule(module)) @@ -813,7 +816,7 @@ RSBreakpointResolver::SearchCallback(SearchFilter &filter, if (kernel_sym) { Address bp_addr = kernel_sym->GetAddress(); if (filter.AddressPasses(bp_addr)) - m_breakpoint->AddLocation(bp_addr); + breakpoint_sp->AddLocation(bp_addr); } return Searcher::eCallbackReturnContinue; @@ -823,6 +826,9 @@ Searcher::CallbackReturn RSReduceBreakpointResolver::SearchCallback(lldb_private::SearchFilter &filter, lldb_private::SymbolContext &context, Address *) { + BreakpointSP breakpoint_sp = GetBreakpoint(); + assert(breakpoint_sp); + // We need to have access to the list of reductions currently parsed, as // reduce names don't actually exist as symbols in a module. They are only // identifiable by parsing the .rs.info packet, or finding the expand symbol. @@ -869,7 +875,7 @@ RSReduceBreakpointResolver::SearchCallback(lldb_private::SearchFilter &filter, if (!SkipPrologue(module, address)) { LLDB_LOGF(log, "%s: Error trying to skip prologue", __FUNCTION__); } - m_breakpoint->AddLocation(address, &new_bp); + breakpoint_sp->AddLocation(address, &new_bp); LLDB_LOGF(log, "%s: %s reduction breakpoint on %s in %s", __FUNCTION__, new_bp ? "new" : "existing", kernel_name.GetCString(), @@ -884,7 +890,8 @@ RSReduceBreakpointResolver::SearchCallback(lldb_private::SearchFilter &filter, Searcher::CallbackReturn RSScriptGroupBreakpointResolver::SearchCallback( SearchFilter &filter, SymbolContext &context, Address *addr) { - if (!m_breakpoint) + BreakpointSP breakpoint_sp = GetBreakpoint(); + if (!breakpoint_sp) return eCallbackReturnContinue; Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS)); @@ -894,7 +901,8 @@ Searcher::CallbackReturn RSScriptGroupBreakpointResolver::SearchCallback( return Searcher::eCallbackReturnContinue; std::vector names; - m_breakpoint->GetNames(names); + Breakpoint& breakpoint = *breakpoint_sp; + breakpoint.GetNames(names); if (names.empty()) return eCallbackReturnContinue; @@ -934,7 +942,7 @@ Searcher::CallbackReturn RSScriptGroupBreakpointResolver::SearchCallback( } bool new_bp; - m_breakpoint->AddLocation(address, &new_bp); + breakpoint.AddLocation(address, &new_bp); LLDB_LOGF(log, "%s: Placed %sbreakpoint on %s", __FUNCTION__, new_bp ? "new " : "", k.m_name.AsCString()); @@ -1031,8 +1039,8 @@ bool RenderScriptRuntime::CouldHaveDynamicValue(ValueObject &in_value) { } lldb::BreakpointResolverSP -RenderScriptRuntime::CreateExceptionResolver(Breakpoint *bp, bool catch_bp, - bool throw_bp) { +RenderScriptRuntime::CreateExceptionResolver(const lldb::BreakpointSP &bp, + bool catch_bp, bool throw_bp) { BreakpointResolverSP resolver_sp; return resolver_sp; } -- cgit v1.2.3