This revision was automatically updated to reflect the committed changes.
Closed by commit rG6c17cc531f9f: [lldb] Make BreakpointResolver hold weak_ptr 
instead of raw pointer to… (authored by tatyana-krasnukha).

Changed prior to commit:
  https://reviews.llvm.org/D74557?vs=244727&id=248166#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74557/new/

https://reviews.llvm.org/D74557

Files:
  lldb/include/lldb/Breakpoint/BreakpointResolver.h
  lldb/include/lldb/Breakpoint/BreakpointResolverAddress.h
  lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h
  lldb/include/lldb/Breakpoint/BreakpointResolverFileRegex.h
  lldb/include/lldb/Breakpoint/BreakpointResolverName.h
  lldb/include/lldb/Breakpoint/BreakpointResolverScripted.h
  lldb/include/lldb/Target/LanguageRuntime.h
  lldb/source/Breakpoint/Breakpoint.cpp
  lldb/source/Breakpoint/BreakpointResolver.cpp
  lldb/source/Breakpoint/BreakpointResolverAddress.cpp
  lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
  lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp
  lldb/source/Breakpoint/BreakpointResolverName.cpp
  lldb/source/Breakpoint/BreakpointResolverScripted.cpp
  
lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
  
lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
  lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
  lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
  
lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
  
lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
  lldb/source/Target/LanguageRuntime.cpp
  lldb/source/Target/Target.cpp

Index: lldb/source/Target/Target.cpp
===================================================================
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -622,7 +622,7 @@
     const bool hardware = request_hardware || GetRequireHardwareBreakpoints();
     bp_sp.reset(new Breakpoint(*this, filter_sp, resolver_sp, hardware,
                                resolve_indirect_symbols));
-    resolver_sp->SetBreakpoint(bp_sp.get());
+    resolver_sp->SetBreakpoint(bp_sp);
     AddBreakpoint(bp_sp, internal);
   }
   return bp_sp;
Index: lldb/source/Target/LanguageRuntime.cpp
===================================================================
--- lldb/source/Target/LanguageRuntime.cpp
+++ lldb/source/Target/LanguageRuntime.cpp
@@ -153,17 +153,17 @@
   }
 
 protected:
-  BreakpointResolverSP CopyForBreakpoint(Breakpoint &breakpoint) override {
+  BreakpointResolverSP CopyForBreakpoint(BreakpointSP &breakpoint) override {
     BreakpointResolverSP ret_sp(
         new ExceptionBreakpointResolver(m_language, m_catch_bp, m_throw_bp));
-    ret_sp->SetBreakpoint(&breakpoint);
+    ret_sp->SetBreakpoint(breakpoint);
     return ret_sp;
   }
 
   bool SetActualResolver() {
-    ProcessSP process_sp;
-    if (m_breakpoint) {
-      process_sp = m_breakpoint->GetTarget().GetProcessSP();
+    BreakpointSP breakpoint_sp = GetBreakpoint();
+    if (breakpoint_sp) {
+      ProcessSP process_sp = breakpoint_sp->GetTarget().GetProcessSP();
       if (process_sp) {
         bool refreash_resolver = !m_actual_resolver_sp;
         if (m_language_runtime == nullptr) {
@@ -180,7 +180,7 @@
 
         if (refreash_resolver && m_language_runtime) {
           m_actual_resolver_sp = m_language_runtime->CreateExceptionResolver(
-              m_breakpoint, m_catch_bp, m_throw_bp);
+              breakpoint_sp, m_catch_bp, m_throw_bp);
         }
       } else {
         m_actual_resolver_sp.reset();
Index: lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
===================================================================
--- lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
+++ lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
@@ -58,7 +58,7 @@
 // for .expand kernels as a fallback.
 class RSBreakpointResolver : public BreakpointResolver {
 public:
-  RSBreakpointResolver(Breakpoint *bp, ConstString name)
+  RSBreakpointResolver(const lldb::BreakpointSP &bp, ConstString name)
       : BreakpointResolver(bp, BreakpointResolver::NameResolver),
         m_kernel_name(name) {}
 
@@ -77,9 +77,9 @@
   lldb::SearchDepth GetDepth() override { return lldb::eSearchDepthModule; }
 
   lldb::BreakpointResolverSP
-  CopyForBreakpoint(Breakpoint &breakpoint) override {
+  CopyForBreakpoint(lldb::BreakpointSP &breakpoint) override {
     lldb::BreakpointResolverSP ret_sp(
-        new RSBreakpointResolver(&breakpoint, m_kernel_name));
+        new RSBreakpointResolver(breakpoint, m_kernel_name));
     return ret_sp;
   }
 
@@ -100,7 +100,7 @@
   };
 
   RSReduceBreakpointResolver(
-      Breakpoint *breakpoint, ConstString reduce_name,
+      const lldb::BreakpointSP &breakpoint, ConstString reduce_name,
       std::vector<lldb_renderscript::RSModuleDescriptorSP> *rs_modules,
       int kernel_types = eKernelTypeAll)
       : BreakpointResolver(breakpoint, BreakpointResolver::NameResolver),
@@ -127,9 +127,9 @@
   lldb::SearchDepth GetDepth() override { return lldb::eSearchDepthModule; }
 
   lldb::BreakpointResolverSP
-  CopyForBreakpoint(Breakpoint &breakpoint) override {
+  CopyForBreakpoint(lldb::BreakpointSP &breakpoint) override {
     lldb::BreakpointResolverSP ret_sp(new RSReduceBreakpointResolver(
-        &breakpoint, m_reduce_name, m_rsmodules, m_kernel_types));
+        breakpoint, m_reduce_name, m_rsmodules, m_kernel_types));
     return ret_sp;
   }
 
@@ -250,7 +250,8 @@
 
 class RSScriptGroupBreakpointResolver : public BreakpointResolver {
 public:
-  RSScriptGroupBreakpointResolver(Breakpoint *bp, ConstString name,
+  RSScriptGroupBreakpointResolver(const lldb::BreakpointSP &bp,
+                                  ConstString name,
                                   const RSScriptGroupList &groups,
                                   bool stop_on_all)
       : BreakpointResolver(bp, BreakpointResolver::NameResolver),
@@ -272,9 +273,9 @@
   lldb::SearchDepth GetDepth() override { return lldb::eSearchDepthModule; }
 
   lldb::BreakpointResolverSP
-  CopyForBreakpoint(Breakpoint &breakpoint) override {
+  CopyForBreakpoint(lldb::BreakpointSP &breakpoint) override {
     lldb::BreakpointResolverSP ret_sp(new RSScriptGroupBreakpointResolver(
-        &breakpoint, m_group_name, m_script_groups, m_stop_on_all));
+        breakpoint, m_group_name, m_script_groups, m_stop_on_all));
     return ret_sp;
   }
 
@@ -347,9 +348,9 @@
 
   bool CouldHaveDynamicValue(ValueObject &in_value) override;
 
-  lldb::BreakpointResolverSP CreateExceptionResolver(Breakpoint *bp,
-                                                     bool catch_bp,
-                                                     bool throw_bp) override;
+  lldb::BreakpointResolverSP
+  CreateExceptionResolver(const lldb::BreakpointSP &bp,
+                          bool catch_bp, bool throw_bp) override;
 
   bool LoadModule(const lldb::ModuleSP &module_sp);
 
Index: lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
===================================================================
--- lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
+++ lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
@@ -793,6 +793,9 @@
 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 @@
   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 @@
 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 @@
           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 @@
 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 @@
     return Searcher::eCallbackReturnContinue;
 
   std::vector<std::string> names;
-  m_breakpoint->GetNames(names);
+  Breakpoint& breakpoint = *breakpoint_sp;
+  breakpoint.GetNames(names);
   if (names.empty())
     return eCallbackReturnContinue;
 
@@ -934,7 +942,7 @@
       }
 
       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 @@
 }
 
 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;
 }
Index: lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
===================================================================
--- lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
+++ lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
@@ -103,9 +103,9 @@
   static const ObjCLanguageRuntime::ObjCISA g_objc_Tagged_ISA_NSDate = 6;
 
 protected:
-  lldb::BreakpointResolverSP CreateExceptionResolver(Breakpoint *bkpt,
-                                                     bool catch_bp,
-                                                     bool throw_bp) override;
+  lldb::BreakpointResolverSP
+  CreateExceptionResolver(const lldb::BreakpointSP &bkpt,
+                          bool catch_bp, bool throw_bp) override;
 
 private:
   class HashTableSignature {
Index: lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
===================================================================
--- lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
+++ lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
@@ -825,8 +825,8 @@
 uint32_t AppleObjCRuntimeV2::GetPluginVersion() { return 1; }
 
 BreakpointResolverSP
-AppleObjCRuntimeV2::CreateExceptionResolver(Breakpoint *bkpt, bool catch_bp,
-                                            bool throw_bp) {
+AppleObjCRuntimeV2::CreateExceptionResolver(const BreakpointSP &bkpt,
+                                            bool catch_bp, bool throw_bp) {
   BreakpointResolverSP resolver_sp;
 
   if (throw_bp)
Index: lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h
===================================================================
--- lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h
+++ lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h
@@ -113,9 +113,9 @@
   DeclVendor *GetDeclVendor() override;
 
 protected:
-  lldb::BreakpointResolverSP CreateExceptionResolver(Breakpoint *bkpt,
-                                                     bool catch_bp,
-                                                     bool throw_bp) override;
+  lldb::BreakpointResolverSP
+  CreateExceptionResolver(const lldb::BreakpointSP &bkpt,
+                          bool catch_bp, bool throw_bp) override;
 
   class HashTableSignature {
   public:
Index: lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
===================================================================
--- lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
+++ lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
@@ -105,8 +105,8 @@
 uint32_t AppleObjCRuntimeV1::GetPluginVersion() { return 1; }
 
 BreakpointResolverSP
-AppleObjCRuntimeV1::CreateExceptionResolver(Breakpoint *bkpt, bool catch_bp,
-                                            bool throw_bp) {
+AppleObjCRuntimeV1::CreateExceptionResolver(const BreakpointSP &bkpt,
+                                            bool catch_bp, bool throw_bp) {
   BreakpointResolverSP resolver_sp;
 
   if (throw_bp)
Index: lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h
===================================================================
--- lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h
+++ lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h
@@ -66,9 +66,9 @@
 
   bool ExceptionBreakpointsExplainStop(lldb::StopInfoSP stop_reason) override;
 
-  lldb::BreakpointResolverSP CreateExceptionResolver(Breakpoint *bkpt,
-                                                     bool catch_bp,
-                                                     bool throw_bp) override;
+  lldb::BreakpointResolverSP
+  CreateExceptionResolver(const lldb::BreakpointSP &bkpt,
+                          bool catch_bp, bool throw_bp) override;
 
   lldb::SearchFilterSP CreateExceptionSearchFilter() override;
   
@@ -81,10 +81,9 @@
   uint32_t GetPluginVersion() override;
 
 protected:
-  lldb::BreakpointResolverSP CreateExceptionResolver(Breakpoint *bkpt,
-                                                     bool catch_bp,
-                                                     bool throw_bp,
-                                                     bool for_expressions);
+  lldb::BreakpointResolverSP
+  CreateExceptionResolver(const lldb::BreakpointSP &bkpt,
+                          bool catch_bp, bool throw_bp, bool for_expressions);
 
   lldb::BreakpointSP CreateExceptionBreakpoint(bool catch_bp, bool throw_bp,
                                                bool for_expressions,
Index: lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
===================================================================
--- lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
+++ lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
@@ -418,12 +418,13 @@
 uint32_t ItaniumABILanguageRuntime::GetPluginVersion() { return 1; }
 
 BreakpointResolverSP ItaniumABILanguageRuntime::CreateExceptionResolver(
-    Breakpoint *bkpt, bool catch_bp, bool throw_bp) {
+    const BreakpointSP &bkpt, bool catch_bp, bool throw_bp) {
   return CreateExceptionResolver(bkpt, catch_bp, throw_bp, false);
 }
 
 BreakpointResolverSP ItaniumABILanguageRuntime::CreateExceptionResolver(
-    Breakpoint *bkpt, bool catch_bp, bool throw_bp, bool for_expressions) {
+    const BreakpointSP &bkpt, bool catch_bp, bool throw_bp,
+    bool for_expressions) {
   // One complication here is that most users DON'T want to stop at
   // __cxa_allocate_expression, but until we can do anything better with
   // predicting unwinding the expression parser does.  So we have two forms of
Index: lldb/source/Breakpoint/BreakpointResolverScripted.cpp
===================================================================
--- lldb/source/Breakpoint/BreakpointResolverScripted.cpp
+++ lldb/source/Breakpoint/BreakpointResolverScripted.cpp
@@ -26,42 +26,42 @@
 
 // BreakpointResolverScripted:
 BreakpointResolverScripted::BreakpointResolverScripted(
-    Breakpoint *bkpt, const llvm::StringRef class_name, lldb::SearchDepth depth,
-    StructuredDataImpl *args_data)
+    const BreakpointSP &bkpt, const llvm::StringRef class_name,
+    lldb::SearchDepth depth, StructuredDataImpl *args_data)
     : BreakpointResolver(bkpt, BreakpointResolver::PythonResolver),
       m_class_name(std::string(class_name)), m_depth(depth),
       m_args_ptr(args_data) {
-  CreateImplementationIfNeeded();
+  CreateImplementationIfNeeded(bkpt);
 }
 
-void BreakpointResolverScripted::CreateImplementationIfNeeded() {
+void BreakpointResolverScripted::CreateImplementationIfNeeded(
+    BreakpointSP breakpoint_sp) {
   if (m_implementation_sp)
     return;
-  
+
   if (m_class_name.empty())
     return;
-  
-  if (m_breakpoint) {
-    TargetSP target_sp = m_breakpoint->GetTargetSP();
-    ScriptInterpreter *script_interp = target_sp->GetDebugger()
-                                                .GetScriptInterpreter();
-    if (!script_interp)
-      return;
-    lldb::BreakpointSP bkpt_sp(m_breakpoint->shared_from_this());
-    m_implementation_sp = script_interp->CreateScriptedBreakpointResolver(
-        m_class_name.c_str(), m_args_ptr, bkpt_sp);
-  }
+
+  if (!breakpoint_sp)
+    return;
+
+  TargetSP target_sp = breakpoint_sp->GetTargetSP();
+  ScriptInterpreter *script_interp = target_sp->GetDebugger()
+                                              .GetScriptInterpreter();
+  if (!script_interp)
+    return;
+
+  m_implementation_sp = script_interp->CreateScriptedBreakpointResolver(
+      m_class_name.c_str(), m_args_ptr, breakpoint_sp);
 }
 
 void BreakpointResolverScripted::NotifyBreakpointSet() {
-  CreateImplementationIfNeeded();
+  CreateImplementationIfNeeded(GetBreakpoint());
 }
 
-BreakpointResolverScripted::~BreakpointResolverScripted() {}
-
 BreakpointResolver *
 BreakpointResolverScripted::CreateFromStructuredData(
-    Breakpoint *bkpt, const StructuredData::Dictionary &options_dict,
+    const BreakpointSP &bkpt, const StructuredData::Dictionary &options_dict,
     Status &error) {
   llvm::StringRef class_name;
   bool success;
@@ -102,29 +102,27 @@
 }
 
 ScriptInterpreter *BreakpointResolverScripted::GetScriptInterpreter() {
-  return m_breakpoint->GetTarget().GetDebugger().GetScriptInterpreter();
+  return GetBreakpoint()->GetTarget().GetDebugger().GetScriptInterpreter();
 }
 
 Searcher::CallbackReturn BreakpointResolverScripted::SearchCallback(
     SearchFilter &filter, SymbolContext &context, Address *addr) {
-  assert(m_breakpoint != nullptr);
   bool should_continue = true;
   if (!m_implementation_sp)
     return Searcher::eCallbackReturnStop;
-  
+
   ScriptInterpreter *interp = GetScriptInterpreter();
   should_continue = interp->ScriptedBreakpointResolverSearchCallback(
       m_implementation_sp,
       &context);
   if (should_continue)
     return Searcher::eCallbackReturnContinue;
-  else
-    return Searcher::eCallbackReturnStop;
+
+  return Searcher::eCallbackReturnStop;
 }
 
 lldb::SearchDepth
 BreakpointResolverScripted::GetDepth() {
-  assert(m_breakpoint != nullptr);
   lldb::SearchDepth depth = lldb::eSearchDepthModule;
   if (m_implementation_sp) {
     ScriptInterpreter *interp = GetScriptInterpreter();
@@ -152,11 +150,11 @@
 void BreakpointResolverScripted::Dump(Stream *s) const {}
 
 lldb::BreakpointResolverSP
-BreakpointResolverScripted::CopyForBreakpoint(Breakpoint &breakpoint) {
+BreakpointResolverScripted::CopyForBreakpoint(BreakpointSP &breakpoint) {
   // FIXME: Have to make a copy of the arguments from the m_args_ptr and then
   // pass that to the new resolver.
   lldb::BreakpointResolverSP ret_sp(
-      new BreakpointResolverScripted(&breakpoint, m_class_name, m_depth, 
+      new BreakpointResolverScripted(breakpoint, m_class_name, m_depth, 
                                      nullptr));
   return ret_sp;
 }
Index: lldb/source/Breakpoint/BreakpointResolverName.cpp
===================================================================
--- lldb/source/Breakpoint/BreakpointResolverName.cpp
+++ lldb/source/Breakpoint/BreakpointResolverName.cpp
@@ -23,8 +23,8 @@
 using namespace lldb;
 using namespace lldb_private;
 
-BreakpointResolverName::BreakpointResolverName(
-    Breakpoint *bkpt, const char *name_cstr, FunctionNameType name_type_mask,
+BreakpointResolverName::BreakpointResolverName(const BreakpointSP &bkpt,
+    const char *name_cstr, FunctionNameType name_type_mask,
     LanguageType language, Breakpoint::MatchType type, lldb::addr_t offset,
     bool skip_prologue)
     : BreakpointResolver(bkpt, BreakpointResolver::NameResolver, offset),
@@ -45,7 +45,7 @@
 }
 
 BreakpointResolverName::BreakpointResolverName(
-    Breakpoint *bkpt, const char *names[], size_t num_names,
+    const BreakpointSP &bkpt, const char *names[], size_t num_names,
     FunctionNameType name_type_mask, LanguageType language, lldb::addr_t offset,
     bool skip_prologue)
     : BreakpointResolver(bkpt, BreakpointResolver::NameResolver, offset),
@@ -56,7 +56,7 @@
   }
 }
 
-BreakpointResolverName::BreakpointResolverName(Breakpoint *bkpt,
+BreakpointResolverName::BreakpointResolverName(const BreakpointSP &bkpt,
                                                std::vector<std::string> names,
                                                FunctionNameType name_type_mask,
                                                LanguageType language,
@@ -70,7 +70,7 @@
   }
 }
 
-BreakpointResolverName::BreakpointResolverName(Breakpoint *bkpt,
+BreakpointResolverName::BreakpointResolverName(const BreakpointSP &bkpt,
                                                RegularExpression func_regex,
                                                lldb::LanguageType language,
                                                lldb::addr_t offset,
@@ -80,18 +80,16 @@
       m_match_type(Breakpoint::Regexp), m_language(language),
       m_skip_prologue(skip_prologue) {}
 
-BreakpointResolverName::~BreakpointResolverName() = default;
-
 BreakpointResolverName::BreakpointResolverName(
     const BreakpointResolverName &rhs)
-    : BreakpointResolver(rhs.m_breakpoint, BreakpointResolver::NameResolver,
-                         rhs.m_offset),
+    : BreakpointResolver(rhs.GetBreakpoint(), BreakpointResolver::NameResolver,
+                         rhs.GetOffset()),
       m_lookups(rhs.m_lookups), m_class_name(rhs.m_class_name),
       m_regex(rhs.m_regex), m_match_type(rhs.m_match_type),
       m_language(rhs.m_language), m_skip_prologue(rhs.m_skip_prologue) {}
 
 BreakpointResolver *BreakpointResolverName::CreateFromStructuredData(
-    Breakpoint *bkpt, const StructuredData::Dictionary &options_dict,
+    const BreakpointSP &bkpt, const StructuredData::Dictionary &options_dict,
     Status &error) {
   LanguageType language = eLanguageTypeUnknown;
   llvm::StringRef language_name;
@@ -257,7 +255,6 @@
   uint32_t i;
   bool new_location;
   Address break_addr;
-  assert(m_breakpoint != nullptr);
 
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
 
@@ -266,6 +263,7 @@
       log->Warning("Class/method function specification not supported yet.\n");
     return Searcher::eCallbackReturnStop;
   }
+
   bool filter_by_cu =
       (filter.GetFilterRequiredItems() & eSymbolContextCompUnit) != 0;
   bool filter_by_language = (m_language != eLanguageTypeUnknown);
@@ -334,6 +332,9 @@
     }
   }
 
+  BreakpointSP breakpoint_sp = GetBreakpoint();
+  Breakpoint &breakpoint = *breakpoint_sp;
+
   // Remove any duplicates between the function list and the symbol list
   SymbolContext sc;
   if (func_list.GetSize()) {
@@ -355,7 +356,7 @@
         } else if (sc.symbol) {
           if (sc.symbol->GetType() == eSymbolTypeReExported) {
             const Symbol *actual_symbol =
-                sc.symbol->ResolveReExportedSymbol(m_breakpoint->GetTarget());
+                sc.symbol->ResolveReExportedSymbol(breakpoint.GetTarget());
             if (actual_symbol) {
               is_reexported = true;
               break_addr = actual_symbol->GetAddress();
@@ -371,7 +372,7 @@
               break_addr.SetOffset(break_addr.GetOffset() + prologue_byte_size);
             else {
               const Architecture *arch =
-                  m_breakpoint->GetTarget().GetArchitecturePlugin();
+                  breakpoint.GetTarget().GetArchitecturePlugin();
               if (arch)
                 arch->AdjustBreakpointAddress(*sc.symbol, break_addr);
             }
@@ -383,7 +384,7 @@
             BreakpointLocationSP bp_loc_sp(
                 AddLocation(break_addr, &new_location));
             bp_loc_sp->SetIsReExported(is_reexported);
-            if (bp_loc_sp && new_location && !m_breakpoint->IsInternal()) {
+            if (bp_loc_sp && new_location && !breakpoint.IsInternal()) {
               if (log) {
                 StreamString s;
                 bp_loc_sp->GetDescription(&s, lldb::eDescriptionLevelVerbose);
@@ -427,8 +428,8 @@
 void BreakpointResolverName::Dump(Stream *s) const {}
 
 lldb::BreakpointResolverSP
-BreakpointResolverName::CopyForBreakpoint(Breakpoint &breakpoint) {
+BreakpointResolverName::CopyForBreakpoint(BreakpointSP &breakpoint) {
   lldb::BreakpointResolverSP ret_sp(new BreakpointResolverName(*this));
-  ret_sp->SetBreakpoint(&breakpoint);
+  ret_sp->SetBreakpoint(breakpoint);
   return ret_sp;
 }
Index: lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp
===================================================================
--- lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp
+++ lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp
@@ -20,16 +20,14 @@
 
 // BreakpointResolverFileRegex:
 BreakpointResolverFileRegex::BreakpointResolverFileRegex(
-    Breakpoint *bkpt, RegularExpression regex,
+    const lldb::BreakpointSP &bkpt, RegularExpression regex,
     const std::unordered_set<std::string> &func_names, bool exact_match)
     : BreakpointResolver(bkpt, BreakpointResolver::FileRegexResolver),
       m_regex(std::move(regex)), m_exact_match(exact_match),
       m_function_names(func_names) {}
 
-BreakpointResolverFileRegex::~BreakpointResolverFileRegex() {}
-
 BreakpointResolver *BreakpointResolverFileRegex::CreateFromStructuredData(
-    Breakpoint *bkpt, const StructuredData::Dictionary &options_dict,
+    const lldb::BreakpointSP &bkpt, const StructuredData::Dictionary &options_dict,
     Status &error) {
   bool success;
 
@@ -97,7 +95,6 @@
 Searcher::CallbackReturn BreakpointResolverFileRegex::SearchCallback(
     SearchFilter &filter, SymbolContext &context, Address *addr) {
 
-  assert(m_breakpoint != nullptr);
   if (!context.target_sp)
     return eCallbackReturnContinue;
 
@@ -144,7 +141,6 @@
     BreakpointResolver::SetSCMatchesByLine(filter, sc_list, skip_prologue,
                                            m_regex.GetText());
   }
-  assert(m_breakpoint != nullptr);
 
   return Searcher::eCallbackReturnContinue;
 }
@@ -161,9 +157,9 @@
 void BreakpointResolverFileRegex::Dump(Stream *s) const {}
 
 lldb::BreakpointResolverSP
-BreakpointResolverFileRegex::CopyForBreakpoint(Breakpoint &breakpoint) {
+BreakpointResolverFileRegex::CopyForBreakpoint(BreakpointSP &breakpoint) {
   lldb::BreakpointResolverSP ret_sp(new BreakpointResolverFileRegex(
-      &breakpoint, m_regex, m_function_names, m_exact_match));
+      breakpoint, m_regex, m_function_names, m_exact_match));
   return ret_sp;
 }
 
Index: lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
===================================================================
--- lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
+++ lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
@@ -20,7 +20,7 @@
 
 // BreakpointResolverFileLine:
 BreakpointResolverFileLine::BreakpointResolverFileLine(
-    Breakpoint *bkpt, const FileSpec &file_spec, uint32_t line_no,
+    const BreakpointSP &bkpt, const FileSpec &file_spec, uint32_t line_no,
     uint32_t column, lldb::addr_t offset, bool check_inlines,
     bool skip_prologue, bool exact_match)
     : BreakpointResolver(bkpt, BreakpointResolver::FileLineResolver, offset),
@@ -28,10 +28,8 @@
       m_inlines(check_inlines), m_skip_prologue(skip_prologue),
       m_exact_match(exact_match) {}
 
-BreakpointResolverFileLine::~BreakpointResolverFileLine() {}
-
 BreakpointResolver *BreakpointResolverFileLine::CreateFromStructuredData(
-    Breakpoint *bkpt, const StructuredData::Dictionary &options_dict,
+    const BreakpointSP &bkpt, const StructuredData::Dictionary &options_dict,
     Status &error) {
   llvm::StringRef filename;
   uint32_t line_no;
@@ -202,8 +200,6 @@
     SearchFilter &filter, SymbolContext &context, Address *addr) {
   SymbolContextList sc_list;
 
-  assert(m_breakpoint != nullptr);
-
   // There is a tricky bit here.  You can have two compilation units that
   // #include the same file, and in one of them the function at m_line_number
   // is used (and so code and a line entry for it is generated) but in the
@@ -263,9 +259,9 @@
 void BreakpointResolverFileLine::Dump(Stream *s) const {}
 
 lldb::BreakpointResolverSP
-BreakpointResolverFileLine::CopyForBreakpoint(Breakpoint &breakpoint) {
+BreakpointResolverFileLine::CopyForBreakpoint(BreakpointSP &breakpoint) {
   lldb::BreakpointResolverSP ret_sp(new BreakpointResolverFileLine(
-      &breakpoint, m_file_spec, m_line_number, m_column, m_offset, m_inlines,
+      breakpoint, m_file_spec, m_line_number, m_column, GetOffset(), m_inlines,
       m_skip_prologue, m_exact_match));
 
   return ret_sp;
Index: lldb/source/Breakpoint/BreakpointResolverAddress.cpp
===================================================================
--- lldb/source/Breakpoint/BreakpointResolverAddress.cpp
+++ lldb/source/Breakpoint/BreakpointResolverAddress.cpp
@@ -22,21 +22,19 @@
 
 // BreakpointResolverAddress:
 BreakpointResolverAddress::BreakpointResolverAddress(
-    Breakpoint *bkpt, const Address &addr, const FileSpec &module_spec)
+    const BreakpointSP &bkpt, const Address &addr, const FileSpec &module_spec)
     : BreakpointResolver(bkpt, BreakpointResolver::AddressResolver),
       m_addr(addr), m_resolved_addr(LLDB_INVALID_ADDRESS),
       m_module_filespec(module_spec) {}
 
-BreakpointResolverAddress::BreakpointResolverAddress(Breakpoint *bkpt,
+BreakpointResolverAddress::BreakpointResolverAddress(const BreakpointSP &bkpt,
                                                      const Address &addr)
     : BreakpointResolver(bkpt, BreakpointResolver::AddressResolver),
       m_addr(addr), m_resolved_addr(LLDB_INVALID_ADDRESS), m_module_filespec() {
 }
 
-BreakpointResolverAddress::~BreakpointResolverAddress() {}
-
 BreakpointResolver *BreakpointResolverAddress::CreateFromStructuredData(
-    Breakpoint *bkpt, const StructuredData::Dictionary &options_dict,
+    const BreakpointSP &bkpt, const StructuredData::Dictionary &options_dict,
     Status &error) {
   llvm::StringRef module_name;
   lldb::addr_t addr_offset;
@@ -100,7 +98,7 @@
   bool re_resolve = false;
   if (m_addr.GetSection() || m_module_filespec)
     re_resolve = true;
-  else if (m_breakpoint->GetNumLocations() == 0)
+  else if (GetBreakpoint()->GetNumLocations() == 0)
     re_resolve = true;
 
   if (re_resolve)
@@ -113,7 +111,7 @@
   bool re_resolve = false;
   if (m_addr.GetSection())
     re_resolve = true;
-  else if (m_breakpoint->GetNumLocations() == 0)
+  else if (GetBreakpoint()->GetNumLocations() == 0)
     re_resolve = true;
 
   if (re_resolve)
@@ -122,15 +120,16 @@
 
 Searcher::CallbackReturn BreakpointResolverAddress::SearchCallback(
     SearchFilter &filter, SymbolContext &context, Address *addr) {
-  assert(m_breakpoint != nullptr);
+  BreakpointSP breakpoint_sp = GetBreakpoint();
+  Breakpoint &breakpoint = *breakpoint_sp;
 
   if (filter.AddressPasses(m_addr)) {
-    if (m_breakpoint->GetNumLocations() == 0) {
+    if (breakpoint.GetNumLocations() == 0) {
       // If the address is just an offset, and we're given a module, see if we
       // can find the appropriate module loaded in the binary, and fix up
       // m_addr to use that.
       if (!m_addr.IsSectionOffset() && m_module_filespec) {
-        Target &target = m_breakpoint->GetTarget();
+        Target &target = breakpoint.GetTarget();
         ModuleSpec module_spec(m_module_filespec);
         ModuleSP module_sp = target.GetImages().FindFirstModule(module_spec);
         if (module_sp) {
@@ -140,9 +139,9 @@
         }
       }
 
-      m_resolved_addr = m_addr.GetLoadAddress(&m_breakpoint->GetTarget());
+      m_resolved_addr = m_addr.GetLoadAddress(&breakpoint.GetTarget());
       BreakpointLocationSP bp_loc_sp(AddLocation(m_addr));
-      if (bp_loc_sp && !m_breakpoint->IsInternal()) {
+      if (bp_loc_sp && !breakpoint.IsInternal()) {
         StreamString s;
         bp_loc_sp->GetDescription(&s, lldb::eDescriptionLevelVerbose);
         Log *log(
@@ -150,9 +149,9 @@
         LLDB_LOGF(log, "Added location: %s\n", s.GetData());
       }
     } else {
-      BreakpointLocationSP loc_sp = m_breakpoint->GetLocationAtIndex(0);
+      BreakpointLocationSP loc_sp = breakpoint.GetLocationAtIndex(0);
       lldb::addr_t cur_load_location =
-          m_addr.GetLoadAddress(&m_breakpoint->GetTarget());
+          m_addr.GetLoadAddress(&breakpoint.GetTarget());
       if (cur_load_location != m_resolved_addr) {
         m_resolved_addr = cur_load_location;
         loc_sp->ClearBreakpointSite();
@@ -169,7 +168,7 @@
 
 void BreakpointResolverAddress::GetDescription(Stream *s) {
   s->PutCString("address = ");
-  m_addr.Dump(s, m_breakpoint->GetTarget().GetProcessSP().get(),
+  m_addr.Dump(s, GetBreakpoint()->GetTarget().GetProcessSP().get(),
               Address::DumpStyleModuleWithFileAddress,
               Address::DumpStyleLoadAddress);
 }
@@ -177,8 +176,8 @@
 void BreakpointResolverAddress::Dump(Stream *s) const {}
 
 lldb::BreakpointResolverSP
-BreakpointResolverAddress::CopyForBreakpoint(Breakpoint &breakpoint) {
+BreakpointResolverAddress::CopyForBreakpoint(BreakpointSP &breakpoint) {
   lldb::BreakpointResolverSP ret_sp(
-      new BreakpointResolverAddress(&breakpoint, m_addr));
+      new BreakpointResolverAddress(breakpoint, m_addr));
   return ret_sp;
 }
Index: lldb/source/Breakpoint/BreakpointResolver.cpp
===================================================================
--- lldb/source/Breakpoint/BreakpointResolver.cpp
+++ lldb/source/Breakpoint/BreakpointResolver.cpp
@@ -60,7 +60,7 @@
   return UnknownResolver;
 }
 
-BreakpointResolver::BreakpointResolver(Breakpoint *bkpt,
+BreakpointResolver::BreakpointResolver(const BreakpointSP &bkpt,
                                        const unsigned char resolverTy,
                                        lldb::addr_t offset)
     : m_breakpoint(bkpt), m_offset(offset), SubclassID(resolverTy) {}
@@ -163,7 +163,8 @@
   return type_dict_sp;
 }
 
-void BreakpointResolver::SetBreakpoint(Breakpoint *bkpt) {
+void BreakpointResolver::SetBreakpoint(const BreakpointSP &bkpt) {
+  assert(bkpt);
   m_breakpoint = bkpt;
   NotifyBreakpointSet();
 }
@@ -327,7 +328,7 @@
   }
 
   BreakpointLocationSP bp_loc_sp(AddLocation(line_start));
-  if (log && bp_loc_sp && !m_breakpoint->IsInternal()) {
+  if (log && bp_loc_sp && !GetBreakpoint()->IsInternal()) {
     StreamString s;
     bp_loc_sp->GetDescription(&s, lldb::eDescriptionLevelVerbose);
     LLDB_LOGF(log, "Added location (skipped prologue: %s): %s \n",
@@ -338,7 +339,7 @@
 BreakpointLocationSP BreakpointResolver::AddLocation(Address loc_addr,
                                                      bool *new_location) {
   loc_addr.Slide(m_offset);
-  return m_breakpoint->AddLocation(loc_addr, new_location);
+  return GetBreakpoint()->AddLocation(loc_addr, new_location);
 }
 
 void BreakpointResolver::SetOffset(lldb::addr_t offset) {
Index: lldb/source/Breakpoint/Breakpoint.cpp
===================================================================
--- lldb/source/Breakpoint/Breakpoint.cpp
+++ lldb/source/Breakpoint/Breakpoint.cpp
@@ -73,7 +73,7 @@
 
   BreakpointSP bp(new Breakpoint(*new_target, bp_to_copy_from));
   // Now go through and copy the filter & resolver:
-  bp->m_resolver_sp = bp_to_copy_from.m_resolver_sp->CopyForBreakpoint(*bp);
+  bp->m_resolver_sp = bp_to_copy_from.m_resolver_sp->CopyForBreakpoint(bp);
   bp->m_filter_sp = bp_to_copy_from.m_filter_sp->CreateCopy(new_target);
   return bp;
 }
Index: lldb/include/lldb/Target/LanguageRuntime.h
===================================================================
--- lldb/include/lldb/Target/LanguageRuntime.h
+++ lldb/include/lldb/Target/LanguageRuntime.h
@@ -134,7 +134,8 @@
   virtual DeclVendor *GetDeclVendor() { return nullptr; }
 
   virtual lldb::BreakpointResolverSP
-  CreateExceptionResolver(Breakpoint *bkpt, bool catch_bp, bool throw_bp) = 0;
+  CreateExceptionResolver(const lldb::BreakpointSP &bkpt,
+                          bool catch_bp, bool throw_bp) = 0;
 
   virtual lldb::SearchFilterSP CreateExceptionSearchFilter() {
     return m_process->GetTarget().GetSearchFilterForModule(nullptr);
Index: lldb/include/lldb/Breakpoint/BreakpointResolverScripted.h
===================================================================
--- lldb/include/lldb/Breakpoint/BreakpointResolverScripted.h
+++ lldb/include/lldb/Breakpoint/BreakpointResolverScripted.h
@@ -23,15 +23,15 @@
 
 class BreakpointResolverScripted : public BreakpointResolver {
 public:
-  BreakpointResolverScripted(Breakpoint *bkpt,
+  BreakpointResolverScripted(const lldb::BreakpointSP &bkpt,
                              const llvm::StringRef class_name,
                              lldb::SearchDepth depth,
                              StructuredDataImpl *args_data);
 
-  ~BreakpointResolverScripted() override;
+  ~BreakpointResolverScripted() override = default;
 
   static BreakpointResolver *
-  CreateFromStructuredData(Breakpoint *bkpt,
+  CreateFromStructuredData(const lldb::BreakpointSP &bkpt,
                            const StructuredData::Dictionary &options_dict,
                            Status &error);
 
@@ -53,12 +53,13 @@
     return V->getResolverID() == BreakpointResolver::PythonResolver;
   }
 
-  lldb::BreakpointResolverSP CopyForBreakpoint(Breakpoint &breakpoint) override;
+  lldb::BreakpointResolverSP
+  CopyForBreakpoint(lldb::BreakpointSP &breakpoint) override;
 
 protected:
   void NotifyBreakpointSet() override;
 private:
-  void CreateImplementationIfNeeded();
+  void CreateImplementationIfNeeded(lldb::BreakpointSP bkpt);
   ScriptInterpreter *GetScriptInterpreter();
   
   std::string m_class_name;
Index: lldb/include/lldb/Breakpoint/BreakpointResolverName.h
===================================================================
--- lldb/include/lldb/Breakpoint/BreakpointResolverName.h
+++ lldb/include/lldb/Breakpoint/BreakpointResolverName.h
@@ -23,39 +23,41 @@
 
 class BreakpointResolverName : public BreakpointResolver {
 public:
-  BreakpointResolverName(Breakpoint *bkpt, const char *name,
+  BreakpointResolverName(const lldb::BreakpointSP &bkpt, const char *name,
                          lldb::FunctionNameType name_type_mask,
                          lldb::LanguageType language,
                          Breakpoint::MatchType type, lldb::addr_t offset,
                          bool skip_prologue);
 
   // This one takes an array of names.  It is always MatchType = Exact.
-  BreakpointResolverName(Breakpoint *bkpt, const char *names[],
+  BreakpointResolverName(const lldb::BreakpointSP &bkpt, const char *names[],
                          size_t num_names,
                          lldb::FunctionNameType name_type_mask,
                          lldb::LanguageType language, lldb::addr_t offset,
                          bool skip_prologue);
 
   // This one takes a C++ array of names.  It is always MatchType = Exact.
-  BreakpointResolverName(Breakpoint *bkpt, std::vector<std::string> names,
+  BreakpointResolverName(const lldb::BreakpointSP &bkpt,
+                         std::vector<std::string> names,
                          lldb::FunctionNameType name_type_mask,
                          lldb::LanguageType language, lldb::addr_t offset,
                          bool skip_prologue);
 
   // Creates a function breakpoint by regular expression.  Takes over control
   // of the lifespan of func_regex.
-  BreakpointResolverName(Breakpoint *bkpt, RegularExpression func_regex,
+  BreakpointResolverName(const lldb::BreakpointSP &bkpt,
+                         RegularExpression func_regex,
                          lldb::LanguageType language, lldb::addr_t offset,
                          bool skip_prologue);
 
   static BreakpointResolver *
-  CreateFromStructuredData(Breakpoint *bkpt,
+  CreateFromStructuredData(const lldb::BreakpointSP &bkpt,
                            const StructuredData::Dictionary &data_dict,
                            Status &error);
 
   StructuredData::ObjectSP SerializeToStructuredData() override;
 
-  ~BreakpointResolverName() override;
+  ~BreakpointResolverName() override = default;
 
   Searcher::CallbackReturn SearchCallback(SearchFilter &filter,
                                           SymbolContext &context,
@@ -73,7 +75,8 @@
     return V->getResolverID() == BreakpointResolver::NameResolver;
   }
 
-  lldb::BreakpointResolverSP CopyForBreakpoint(Breakpoint &breakpoint) override;
+  lldb::BreakpointResolverSP
+  CopyForBreakpoint(lldb::BreakpointSP &breakpoint) override;
 
 protected:
   BreakpointResolverName(const BreakpointResolverName &rhs);
Index: lldb/include/lldb/Breakpoint/BreakpointResolverFileRegex.h
===================================================================
--- lldb/include/lldb/Breakpoint/BreakpointResolverFileRegex.h
+++ lldb/include/lldb/Breakpoint/BreakpointResolverFileRegex.h
@@ -24,17 +24,17 @@
 class BreakpointResolverFileRegex : public BreakpointResolver {
 public:
   BreakpointResolverFileRegex(
-      Breakpoint *bkpt, RegularExpression regex,
+      const lldb::BreakpointSP &bkpt, RegularExpression regex,
       const std::unordered_set<std::string> &func_name_set, bool exact_match);
 
   static BreakpointResolver *
-  CreateFromStructuredData(Breakpoint *bkpt,
+  CreateFromStructuredData(const lldb::BreakpointSP &bkpt,
                            const StructuredData::Dictionary &options_dict,
                            Status &error);
 
   StructuredData::ObjectSP SerializeToStructuredData() override;
 
-  ~BreakpointResolverFileRegex() override;
+  ~BreakpointResolverFileRegex() override = default;
 
   Searcher::CallbackReturn SearchCallback(SearchFilter &filter,
                                           SymbolContext &context,
@@ -56,7 +56,8 @@
     return V->getResolverID() == BreakpointResolver::FileRegexResolver;
   }
 
-  lldb::BreakpointResolverSP CopyForBreakpoint(Breakpoint &breakpoint) override;
+  lldb::BreakpointResolverSP
+  CopyForBreakpoint(lldb::BreakpointSP &breakpoint) override;
 
 protected:
   friend class Breakpoint;
Index: lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h
===================================================================
--- lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h
+++ lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h
@@ -20,19 +20,20 @@
 
 class BreakpointResolverFileLine : public BreakpointResolver {
 public:
-  BreakpointResolverFileLine(Breakpoint *bkpt, const FileSpec &resolver,
+  BreakpointResolverFileLine(const lldb::BreakpointSP &bkpt,
+                             const FileSpec &resolver,
                              uint32_t line_no, uint32_t column,
                              lldb::addr_t m_offset, bool check_inlines,
                              bool skip_prologue, bool exact_match);
 
   static BreakpointResolver *
-  CreateFromStructuredData(Breakpoint *bkpt,
+  CreateFromStructuredData(const lldb::BreakpointSP &bkpt,
                            const StructuredData::Dictionary &data_dict,
                            Status &error);
 
   StructuredData::ObjectSP SerializeToStructuredData() override;
 
-  ~BreakpointResolverFileLine() override;
+  ~BreakpointResolverFileLine() override = default;
 
   Searcher::CallbackReturn SearchCallback(SearchFilter &filter,
                                           SymbolContext &context,
@@ -52,7 +53,8 @@
     return V->getResolverID() == BreakpointResolver::FileLineResolver;
   }
 
-  lldb::BreakpointResolverSP CopyForBreakpoint(Breakpoint &breakpoint) override;
+  lldb::BreakpointResolverSP
+  CopyForBreakpoint(lldb::BreakpointSP &breakpoint) override;
 
 protected:
   void FilterContexts(SymbolContextList &sc_list, bool is_relative);
Index: lldb/include/lldb/Breakpoint/BreakpointResolverAddress.h
===================================================================
--- lldb/include/lldb/Breakpoint/BreakpointResolverAddress.h
+++ lldb/include/lldb/Breakpoint/BreakpointResolverAddress.h
@@ -21,15 +21,17 @@
 
 class BreakpointResolverAddress : public BreakpointResolver {
 public:
-  BreakpointResolverAddress(Breakpoint *bkpt, const Address &addr);
+  BreakpointResolverAddress(const lldb::BreakpointSP &bkpt,
+                            const Address &addr);
 
-  BreakpointResolverAddress(Breakpoint *bkpt, const Address &addr,
+  BreakpointResolverAddress(const lldb::BreakpointSP &bkpt,
+                            const Address &addr,
                             const FileSpec &module_spec);
 
-  ~BreakpointResolverAddress() override;
+  ~BreakpointResolverAddress() override = default;
 
   static BreakpointResolver *
-  CreateFromStructuredData(Breakpoint *bkpt,
+  CreateFromStructuredData(const lldb::BreakpointSP &bkpt,
                            const StructuredData::Dictionary &options_dict,
                            Status &error);
 
@@ -56,11 +58,12 @@
     return V->getResolverID() == BreakpointResolver::AddressResolver;
   }
 
-  lldb::BreakpointResolverSP CopyForBreakpoint(Breakpoint &breakpoint) override;
+  lldb::BreakpointResolverSP
+  CopyForBreakpoint(lldb::BreakpointSP &breakpoint) override;
 
 protected:
-  Address
-      m_addr; // The address - may be Section Offset or may be just an offset
+  Address m_addr;               // The address - may be Section Offset or
+                                // may be just an offset
   lldb::addr_t m_resolved_addr; // The current value of the resolved load
                                 // address for this breakpoint,
   FileSpec m_module_filespec;   // If this filespec is Valid, and m_addr is an
Index: lldb/include/lldb/Breakpoint/BreakpointResolver.h
===================================================================
--- lldb/include/lldb/Breakpoint/BreakpointResolver.h
+++ lldb/include/lldb/Breakpoint/BreakpointResolver.h
@@ -44,7 +44,8 @@
   ///   The breakpoint that owns this resolver.
   /// \param[in] resolverType
   ///   The concrete breakpoint resolver type for this breakpoint.
-  BreakpointResolver(Breakpoint *bkpt, unsigned char resolverType,
+  BreakpointResolver(const lldb::BreakpointSP &bkpt,
+                     unsigned char resolverType,
                      lldb::addr_t offset = 0);
 
   /// The Destructor is virtual, all significant breakpoint resolvers derive
@@ -55,7 +56,15 @@
   ///
   /// \param[in] bkpt
   ///   The breakpoint that owns this resolver.
-  void SetBreakpoint(Breakpoint *bkpt);
+  void SetBreakpoint(const lldb::BreakpointSP &bkpt);
+
+  /// This gets the breakpoint for this resolver.
+  lldb::BreakpointSP GetBreakpoint() const {
+    auto breakpoint_sp = m_breakpoint.expired() ? lldb::BreakpointSP() :
+                                                  m_breakpoint.lock();
+    assert(breakpoint_sp);
+    return breakpoint_sp;
+  }
 
   /// This updates the offset for this breakpoint.  All the locations
   /// currently set for this breakpoint will have their offset adjusted when
@@ -149,7 +158,7 @@
   static ResolverTy NameToResolverTy(llvm::StringRef name);
 
   virtual lldb::BreakpointResolverSP
-  CopyForBreakpoint(Breakpoint &breakpoint) = 0;
+  CopyForBreakpoint(lldb::BreakpointSP &breakpoint) = 0;
 
 protected:
   // Used for serializing resolver options:
@@ -202,15 +211,15 @@
   lldb::BreakpointLocationSP AddLocation(Address loc_addr,
                                          bool *new_location = nullptr);
 
-  Breakpoint *m_breakpoint; // This is the breakpoint we add locations to.
-  lldb::addr_t m_offset;    // A random offset the user asked us to add to any
-                            // breakpoints we set.
-
 private:
   /// Helper for \p SetSCMatchesByLine.
   void AddLocation(SearchFilter &filter, const SymbolContext &sc,
                    bool skip_prologue, llvm::StringRef log_ident);
 
+  lldb::BreakpointWP m_breakpoint; // This is the breakpoint we add locations to.
+  lldb::addr_t m_offset;    // A random offset the user asked us to add to any
+                            // breakpoints we set.
+
   // Subclass identifier (for llvm isa/dyn_cast)
   const unsigned char SubclassID;
   DISALLOW_COPY_AND_ASSIGN(BreakpointResolver);
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to