[Lldb-commits] [lldb] r296328 - Switch SBBreakpoint to storing a weak_ptr of the internal breakpoint object

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Mon Feb 27 03:05:35 PST 2017


Author: labath
Date: Mon Feb 27 05:05:34 2017
New Revision: 296328

URL: http://llvm.org/viewvc/llvm-project?rev=296328&view=rev
Log:
Switch SBBreakpoint to storing a weak_ptr of the internal breakpoint object

Summary:
There is nothing we can do with the breakpoint once the associated
target becomes deleted. This will make sure we don't hold on to more
resources than we need in this case. In particular, this fixes the case
TestStepOverBreakpoint on windows, where a lingering SBBreakpoint object
causes us to nor unmap the executable file from memory.

Reviewers: clayborg, jingham

Subscribers: lldb-commits

Differential Revision: https://reviews.llvm.org/D30249

Modified:
    lldb/trunk/include/lldb/API/SBBreakpoint.h
    lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py
    lldb/trunk/packages/Python/lldbsuite/test/python_api/breakpoint/TestBreakpointAPI.py
    lldb/trunk/source/API/SBBreakpoint.cpp
    lldb/trunk/source/API/SBBreakpointLocation.cpp
    lldb/trunk/source/API/SBTarget.cpp

Modified: lldb/trunk/include/lldb/API/SBBreakpoint.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBBreakpoint.h?rev=296328&r1=296327&r2=296328&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBBreakpoint.h (original)
+++ lldb/trunk/include/lldb/API/SBBreakpoint.h Mon Feb 27 05:05:34 2017
@@ -133,19 +133,13 @@ private:
 
   SBBreakpoint(const lldb::BreakpointSP &bp_sp);
 
-  lldb_private::Breakpoint *operator->() const;
-
-  lldb_private::Breakpoint *get() const;
-
-  lldb::BreakpointSP &operator*();
-
-  const lldb::BreakpointSP &operator*() const;
-
   static bool PrivateBreakpointHitCallback(
       void *baton, lldb_private::StoppointCallbackContext *context,
       lldb::user_id_t break_id, lldb::user_id_t break_loc_id);
 
-  lldb::BreakpointSP m_opaque_sp;
+  lldb::BreakpointSP GetSP() const;
+
+  lldb::BreakpointWP m_opaque_wp;
 };
 
 class LLDB_API SBBreakpointList {

Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py?rev=296328&r1=296327&r2=296328&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py Mon Feb 27 05:05:34 2017
@@ -52,7 +52,6 @@ class StepOverBreakpointsTestCase(TestBa
         self.thread = lldbutil.get_one_thread_stopped_at_breakpoint(self.process, self.breakpoint1)
         self.assertIsNotNone(self.thread, "Didn't stop at breakpoint 1.")
 
-    @skipIf(bugnumber="llvm.org/pr31972", hostoslist=["windows"])
     def test_step_instruction(self): 
         # Count instructions between breakpoint_1 and breakpoint_4
         contextList = self.target.FindFunctions('main', lldb.eFunctionNameTypeAuto)

Modified: lldb/trunk/packages/Python/lldbsuite/test/python_api/breakpoint/TestBreakpointAPI.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/python_api/breakpoint/TestBreakpointAPI.py?rev=296328&r1=296327&r2=296328&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/python_api/breakpoint/TestBreakpointAPI.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/python_api/breakpoint/TestBreakpointAPI.py Mon Feb 27 05:05:34 2017
@@ -17,6 +17,7 @@ from lldbsuite.test import lldbutil
 class BreakpointAPITestCase(TestBase):
 
     mydir = TestBase.compute_mydir(__file__)
+    NO_DEBUG_INFO_TESTCASE = True
 
     @add_test_categories(['pyapi'])
     def test_breakpoint_is_valid(self):
@@ -49,3 +50,25 @@ class BreakpointAPITestCase(TestBase):
         self.assertTrue(
             not breakpoint,
             "Breakpoint we deleted is no longer valid.")
+
+    @add_test_categories(['pyapi'])
+    def test_target_delete(self):
+        """Make sure that if an SBTarget gets deleted the associated
+        Breakpoint's IsValid returns false."""
+
+        self.build()
+        exe = os.path.join(os.getcwd(), "a.out")
+
+        # Create a target by the debugger.
+        target = self.dbg.CreateTarget(exe)
+        self.assertTrue(target, VALID_TARGET)
+
+        # Now create a breakpoint on main.c by name 'AFunction'.
+        breakpoint = target.BreakpointCreateByName('AFunction', 'a.out')
+        #print("breakpoint:", breakpoint)
+        self.assertTrue(breakpoint and
+                        breakpoint.GetNumLocations() == 1,
+                        VALID_BREAKPOINT)
+
+        self.assertTrue(self.dbg.DeleteTarget(target))
+        self.assertFalse(breakpoint.IsValid())

Modified: lldb/trunk/source/API/SBBreakpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBBreakpoint.cpp?rev=296328&r1=296327&r2=296328&view=diff
==============================================================================
--- lldb/trunk/source/API/SBBreakpoint.cpp (original)
+++ lldb/trunk/source/API/SBBreakpoint.cpp Mon Feb 27 05:05:34 2017
@@ -59,83 +59,74 @@ public:
   }
 };
 
-SBBreakpoint::SBBreakpoint() : m_opaque_sp() {}
+SBBreakpoint::SBBreakpoint() {}
 
 SBBreakpoint::SBBreakpoint(const SBBreakpoint &rhs)
-    : m_opaque_sp(rhs.m_opaque_sp) {}
+    : m_opaque_wp(rhs.m_opaque_wp) {}
 
 SBBreakpoint::SBBreakpoint(const lldb::BreakpointSP &bp_sp)
-    : m_opaque_sp(bp_sp) {}
+    : m_opaque_wp(bp_sp) {}
 
 SBBreakpoint::~SBBreakpoint() = default;
 
 const SBBreakpoint &SBBreakpoint::operator=(const SBBreakpoint &rhs) {
-  if (this != &rhs)
-    m_opaque_sp = rhs.m_opaque_sp;
+  m_opaque_wp = rhs.m_opaque_wp;
   return *this;
 }
 
 bool SBBreakpoint::operator==(const lldb::SBBreakpoint &rhs) {
-  if (m_opaque_sp && rhs.m_opaque_sp)
-    return m_opaque_sp.get() == rhs.m_opaque_sp.get();
-  return false;
+  return m_opaque_wp.lock() == rhs.m_opaque_wp.lock();
 }
 
 bool SBBreakpoint::operator!=(const lldb::SBBreakpoint &rhs) {
-  if (m_opaque_sp && rhs.m_opaque_sp)
-    return m_opaque_sp.get() != rhs.m_opaque_sp.get();
-  return (m_opaque_sp && !rhs.m_opaque_sp) || (rhs.m_opaque_sp && !m_opaque_sp);
+  return m_opaque_wp.lock() != rhs.m_opaque_wp.lock();
 }
 
 break_id_t SBBreakpoint::GetID() const {
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
 
   break_id_t break_id = LLDB_INVALID_BREAK_ID;
-  if (m_opaque_sp)
-    break_id = m_opaque_sp->GetID();
-
-  if (log) {
-    if (break_id == LLDB_INVALID_BREAK_ID)
-      log->Printf("SBBreakpoint(%p)::GetID () => LLDB_INVALID_BREAK_ID",
-                  static_cast<void *>(m_opaque_sp.get()));
-    else
-      log->Printf("SBBreakpoint(%p)::GetID () => %u",
-                  static_cast<void *>(m_opaque_sp.get()), break_id);
-  }
+  BreakpointSP bkpt_sp = GetSP();
+  if (bkpt_sp)
+    break_id = bkpt_sp->GetID();
 
+  LLDB_LOG(log, "breakpoint = {0}, id = {1}", bkpt_sp.get(), break_id);
   return break_id;
 }
 
 bool SBBreakpoint::IsValid() const {
-  if (!m_opaque_sp)
+  BreakpointSP bkpt_sp = GetSP();
+  if (!bkpt_sp)
     return false;
-  else if (m_opaque_sp->GetTarget().GetBreakpointByID(m_opaque_sp->GetID()))
+  else if (bkpt_sp->GetTarget().GetBreakpointByID(bkpt_sp->GetID()))
     return true;
   else
     return false;
 }
 
 void SBBreakpoint::ClearAllBreakpointSites() {
-  if (m_opaque_sp) {
+  BreakpointSP bkpt_sp = GetSP();
+  if (bkpt_sp) {
     std::lock_guard<std::recursive_mutex> guard(
-        m_opaque_sp->GetTarget().GetAPIMutex());
-    m_opaque_sp->ClearAllBreakpointSites();
+        bkpt_sp->GetTarget().GetAPIMutex());
+    bkpt_sp->ClearAllBreakpointSites();
   }
 }
 
 SBBreakpointLocation SBBreakpoint::FindLocationByAddress(addr_t vm_addr) {
   SBBreakpointLocation sb_bp_location;
 
-  if (m_opaque_sp) {
+  BreakpointSP bkpt_sp = GetSP();
+  if (bkpt_sp) {
     if (vm_addr != LLDB_INVALID_ADDRESS) {
       std::lock_guard<std::recursive_mutex> guard(
-          m_opaque_sp->GetTarget().GetAPIMutex());
+          bkpt_sp->GetTarget().GetAPIMutex());
       Address address;
-      Target &target = m_opaque_sp->GetTarget();
+      Target &target = bkpt_sp->GetTarget();
       if (!target.GetSectionLoadList().ResolveLoadAddress(vm_addr, address)) {
         address.SetRawAddress(vm_addr);
       }
-      sb_bp_location.SetLocation(m_opaque_sp->FindLocationByAddress(address));
+      sb_bp_location.SetLocation(bkpt_sp->FindLocationByAddress(address));
     }
   }
   return sb_bp_location;
@@ -143,16 +134,17 @@ SBBreakpointLocation SBBreakpoint::FindL
 
 break_id_t SBBreakpoint::FindLocationIDByAddress(addr_t vm_addr) {
   break_id_t break_id = LLDB_INVALID_BREAK_ID;
+  BreakpointSP bkpt_sp = GetSP();
 
-  if (m_opaque_sp && vm_addr != LLDB_INVALID_ADDRESS) {
+  if (bkpt_sp && vm_addr != LLDB_INVALID_ADDRESS) {
     std::lock_guard<std::recursive_mutex> guard(
-        m_opaque_sp->GetTarget().GetAPIMutex());
+        bkpt_sp->GetTarget().GetAPIMutex());
     Address address;
-    Target &target = m_opaque_sp->GetTarget();
+    Target &target = bkpt_sp->GetTarget();
     if (!target.GetSectionLoadList().ResolveLoadAddress(vm_addr, address)) {
       address.SetRawAddress(vm_addr);
     }
-    break_id = m_opaque_sp->FindLocationIDByAddress(address);
+    break_id = bkpt_sp->FindLocationIDByAddress(address);
   }
 
   return break_id;
@@ -160,11 +152,12 @@ break_id_t SBBreakpoint::FindLocationIDB
 
 SBBreakpointLocation SBBreakpoint::FindLocationByID(break_id_t bp_loc_id) {
   SBBreakpointLocation sb_bp_location;
+  BreakpointSP bkpt_sp = GetSP();
 
-  if (m_opaque_sp) {
+  if (bkpt_sp) {
     std::lock_guard<std::recursive_mutex> guard(
-        m_opaque_sp->GetTarget().GetAPIMutex());
-    sb_bp_location.SetLocation(m_opaque_sp->FindLocationByID(bp_loc_id));
+        bkpt_sp->GetTarget().GetAPIMutex());
+    sb_bp_location.SetLocation(bkpt_sp->FindLocationByID(bp_loc_id));
   }
 
   return sb_bp_location;
@@ -172,11 +165,12 @@ SBBreakpointLocation SBBreakpoint::FindL
 
 SBBreakpointLocation SBBreakpoint::GetLocationAtIndex(uint32_t index) {
   SBBreakpointLocation sb_bp_location;
+  BreakpointSP bkpt_sp = GetSP();
 
-  if (m_opaque_sp) {
+  if (bkpt_sp) {
     std::lock_guard<std::recursive_mutex> guard(
-        m_opaque_sp->GetTarget().GetAPIMutex());
-    sb_bp_location.SetLocation(m_opaque_sp->GetLocationAtIndex(index));
+        bkpt_sp->GetTarget().GetAPIMutex());
+    sb_bp_location.SetLocation(bkpt_sp->GetLocationAtIndex(index));
   }
 
   return sb_bp_location;
@@ -184,290 +178,282 @@ SBBreakpointLocation SBBreakpoint::GetLo
 
 void SBBreakpoint::SetEnabled(bool enable) {
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+  BreakpointSP bkpt_sp = GetSP();
 
-  if (log)
-    log->Printf("SBBreakpoint(%p)::SetEnabled (enabled=%i)",
-                static_cast<void *>(m_opaque_sp.get()), enable);
+  LLDB_LOG(log, "breakpoint = {0}, enable = {1}", bkpt_sp.get(), enable);
 
-  if (m_opaque_sp) {
+  if (bkpt_sp) {
     std::lock_guard<std::recursive_mutex> guard(
-        m_opaque_sp->GetTarget().GetAPIMutex());
-    m_opaque_sp->SetEnabled(enable);
+        bkpt_sp->GetTarget().GetAPIMutex());
+    bkpt_sp->SetEnabled(enable);
   }
 }
 
 bool SBBreakpoint::IsEnabled() {
-  if (m_opaque_sp) {
+  BreakpointSP bkpt_sp = GetSP();
+  if (bkpt_sp) {
     std::lock_guard<std::recursive_mutex> guard(
-        m_opaque_sp->GetTarget().GetAPIMutex());
-    return m_opaque_sp->IsEnabled();
+        bkpt_sp->GetTarget().GetAPIMutex());
+    return bkpt_sp->IsEnabled();
   } else
     return false;
 }
 
 void SBBreakpoint::SetOneShot(bool one_shot) {
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+  BreakpointSP bkpt_sp = GetSP();
 
-  if (log)
-    log->Printf("SBBreakpoint(%p)::SetOneShot (one_shot=%i)",
-                static_cast<void *>(m_opaque_sp.get()), one_shot);
+  LLDB_LOG(log, "breakpoint = {0}, one_shot = {1}", bkpt_sp.get(), one_shot);
 
-  if (m_opaque_sp) {
+  if (bkpt_sp) {
     std::lock_guard<std::recursive_mutex> guard(
-        m_opaque_sp->GetTarget().GetAPIMutex());
-    m_opaque_sp->SetOneShot(one_shot);
+        bkpt_sp->GetTarget().GetAPIMutex());
+    bkpt_sp->SetOneShot(one_shot);
   }
 }
 
 bool SBBreakpoint::IsOneShot() const {
-  if (m_opaque_sp) {
+  BreakpointSP bkpt_sp = GetSP();
+  if (bkpt_sp) {
     std::lock_guard<std::recursive_mutex> guard(
-        m_opaque_sp->GetTarget().GetAPIMutex());
-    return m_opaque_sp->IsOneShot();
+        bkpt_sp->GetTarget().GetAPIMutex());
+    return bkpt_sp->IsOneShot();
   } else
     return false;
 }
 
 bool SBBreakpoint::IsInternal() {
-  if (m_opaque_sp) {
+  BreakpointSP bkpt_sp = GetSP();
+  if (bkpt_sp) {
     std::lock_guard<std::recursive_mutex> guard(
-        m_opaque_sp->GetTarget().GetAPIMutex());
-    return m_opaque_sp->IsInternal();
+        bkpt_sp->GetTarget().GetAPIMutex());
+    return bkpt_sp->IsInternal();
   } else
     return false;
 }
 
 void SBBreakpoint::SetIgnoreCount(uint32_t count) {
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+  BreakpointSP bkpt_sp = GetSP();
 
-  if (log)
-    log->Printf("SBBreakpoint(%p)::SetIgnoreCount (count=%u)",
-                static_cast<void *>(m_opaque_sp.get()), count);
+  LLDB_LOG(log, "breakpoint = {0}, count = {1}", bkpt_sp.get(), count);
 
-  if (m_opaque_sp) {
+  if (bkpt_sp) {
     std::lock_guard<std::recursive_mutex> guard(
-        m_opaque_sp->GetTarget().GetAPIMutex());
-    m_opaque_sp->SetIgnoreCount(count);
+        bkpt_sp->GetTarget().GetAPIMutex());
+    bkpt_sp->SetIgnoreCount(count);
   }
 }
 
 void SBBreakpoint::SetCondition(const char *condition) {
-  if (m_opaque_sp) {
+  BreakpointSP bkpt_sp = GetSP();
+  if (bkpt_sp) {
     std::lock_guard<std::recursive_mutex> guard(
-        m_opaque_sp->GetTarget().GetAPIMutex());
-    m_opaque_sp->SetCondition(condition);
+        bkpt_sp->GetTarget().GetAPIMutex());
+    bkpt_sp->SetCondition(condition);
   }
 }
 
 const char *SBBreakpoint::GetCondition() {
-  if (m_opaque_sp) {
+  BreakpointSP bkpt_sp = GetSP();
+  if (bkpt_sp) {
     std::lock_guard<std::recursive_mutex> guard(
-        m_opaque_sp->GetTarget().GetAPIMutex());
-    return m_opaque_sp->GetConditionText();
+        bkpt_sp->GetTarget().GetAPIMutex());
+    return bkpt_sp->GetConditionText();
   }
   return nullptr;
 }
 
 uint32_t SBBreakpoint::GetHitCount() const {
   uint32_t count = 0;
-  if (m_opaque_sp) {
+  BreakpointSP bkpt_sp = GetSP();
+  if (bkpt_sp) {
     std::lock_guard<std::recursive_mutex> guard(
-        m_opaque_sp->GetTarget().GetAPIMutex());
-    count = m_opaque_sp->GetHitCount();
+        bkpt_sp->GetTarget().GetAPIMutex());
+    count = bkpt_sp->GetHitCount();
   }
 
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-  if (log)
-    log->Printf("SBBreakpoint(%p)::GetHitCount () => %u",
-                static_cast<void *>(m_opaque_sp.get()), count);
+  LLDB_LOG(log, "breakpoint = {0}, count = {1}", bkpt_sp.get(), count);
 
   return count;
 }
 
 uint32_t SBBreakpoint::GetIgnoreCount() const {
   uint32_t count = 0;
-  if (m_opaque_sp) {
+  BreakpointSP bkpt_sp = GetSP();
+  if (bkpt_sp) {
     std::lock_guard<std::recursive_mutex> guard(
-        m_opaque_sp->GetTarget().GetAPIMutex());
-    count = m_opaque_sp->GetIgnoreCount();
+        bkpt_sp->GetTarget().GetAPIMutex());
+    count = bkpt_sp->GetIgnoreCount();
   }
 
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-  if (log)
-    log->Printf("SBBreakpoint(%p)::GetIgnoreCount () => %u",
-                static_cast<void *>(m_opaque_sp.get()), count);
+  LLDB_LOG(log, "breakpoint = {0}, count = {1}", bkpt_sp.get(), count);
 
   return count;
 }
 
 void SBBreakpoint::SetThreadID(tid_t tid) {
-  if (m_opaque_sp) {
+  BreakpointSP bkpt_sp = GetSP();
+  if (bkpt_sp) {
     std::lock_guard<std::recursive_mutex> guard(
-        m_opaque_sp->GetTarget().GetAPIMutex());
-    m_opaque_sp->SetThreadID(tid);
+        bkpt_sp->GetTarget().GetAPIMutex());
+    bkpt_sp->SetThreadID(tid);
   }
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-  if (log)
-    log->Printf("SBBreakpoint(%p)::SetThreadID (tid=0x%4.4" PRIx64 ")",
-                static_cast<void *>(m_opaque_sp.get()), tid);
+  LLDB_LOG(log, "breakpoint = {0}, tid = {1:x}", bkpt_sp.get(), tid);
 }
 
 tid_t SBBreakpoint::GetThreadID() {
   tid_t tid = LLDB_INVALID_THREAD_ID;
-  if (m_opaque_sp) {
+  BreakpointSP bkpt_sp = GetSP();
+  if (bkpt_sp) {
     std::lock_guard<std::recursive_mutex> guard(
-        m_opaque_sp->GetTarget().GetAPIMutex());
-    tid = m_opaque_sp->GetThreadID();
+        bkpt_sp->GetTarget().GetAPIMutex());
+    tid = bkpt_sp->GetThreadID();
   }
 
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-  if (log)
-    log->Printf("SBBreakpoint(%p)::GetThreadID () => 0x%4.4" PRIx64,
-                static_cast<void *>(m_opaque_sp.get()), tid);
+  LLDB_LOG(log, "breakpoint = {0}, tid = {1:x}", bkpt_sp.get(), tid);
   return tid;
 }
 
 void SBBreakpoint::SetThreadIndex(uint32_t index) {
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-  if (log)
-    log->Printf("SBBreakpoint(%p)::SetThreadIndex (%u)",
-                static_cast<void *>(m_opaque_sp.get()), index);
-  if (m_opaque_sp) {
+  BreakpointSP bkpt_sp = GetSP();
+  LLDB_LOG(log, "breakpoint = {0}, index = {1}", bkpt_sp.get(), index);
+  if (bkpt_sp) {
     std::lock_guard<std::recursive_mutex> guard(
-        m_opaque_sp->GetTarget().GetAPIMutex());
-    m_opaque_sp->GetOptions()->GetThreadSpec()->SetIndex(index);
+        bkpt_sp->GetTarget().GetAPIMutex());
+    bkpt_sp->GetOptions()->GetThreadSpec()->SetIndex(index);
   }
 }
 
 uint32_t SBBreakpoint::GetThreadIndex() const {
   uint32_t thread_idx = UINT32_MAX;
-  if (m_opaque_sp) {
+  BreakpointSP bkpt_sp = GetSP();
+  if (bkpt_sp) {
     std::lock_guard<std::recursive_mutex> guard(
-        m_opaque_sp->GetTarget().GetAPIMutex());
+        bkpt_sp->GetTarget().GetAPIMutex());
     const ThreadSpec *thread_spec =
-        m_opaque_sp->GetOptions()->GetThreadSpecNoCreate();
+        bkpt_sp->GetOptions()->GetThreadSpecNoCreate();
     if (thread_spec != nullptr)
       thread_idx = thread_spec->GetIndex();
   }
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-  if (log)
-    log->Printf("SBBreakpoint(%p)::GetThreadIndex () => %u",
-                static_cast<void *>(m_opaque_sp.get()), thread_idx);
+  LLDB_LOG(log, "breakpoint = {0}, index = {1}", bkpt_sp.get(), thread_idx);
 
   return thread_idx;
 }
 
 void SBBreakpoint::SetThreadName(const char *thread_name) {
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-  if (log)
-    log->Printf("SBBreakpoint(%p)::SetThreadName (%s)",
-                static_cast<void *>(m_opaque_sp.get()), thread_name);
+  BreakpointSP bkpt_sp = GetSP();
+  LLDB_LOG(log, "breakpoint = {0}, name = {1}", bkpt_sp.get(), thread_name);
 
-  if (m_opaque_sp) {
+  if (bkpt_sp) {
     std::lock_guard<std::recursive_mutex> guard(
-        m_opaque_sp->GetTarget().GetAPIMutex());
-    m_opaque_sp->GetOptions()->GetThreadSpec()->SetName(thread_name);
+        bkpt_sp->GetTarget().GetAPIMutex());
+    bkpt_sp->GetOptions()->GetThreadSpec()->SetName(thread_name);
   }
 }
 
 const char *SBBreakpoint::GetThreadName() const {
   const char *name = nullptr;
-  if (m_opaque_sp) {
+  BreakpointSP bkpt_sp = GetSP();
+  if (bkpt_sp) {
     std::lock_guard<std::recursive_mutex> guard(
-        m_opaque_sp->GetTarget().GetAPIMutex());
+        bkpt_sp->GetTarget().GetAPIMutex());
     const ThreadSpec *thread_spec =
-        m_opaque_sp->GetOptions()->GetThreadSpecNoCreate();
+        bkpt_sp->GetOptions()->GetThreadSpecNoCreate();
     if (thread_spec != nullptr)
       name = thread_spec->GetName();
   }
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-  if (log)
-    log->Printf("SBBreakpoint(%p)::GetThreadName () => %s",
-                static_cast<void *>(m_opaque_sp.get()), name);
+  LLDB_LOG(log, "breakpoint = {0}, name = {1}", bkpt_sp.get(), name);
 
   return name;
 }
 
 void SBBreakpoint::SetQueueName(const char *queue_name) {
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-  if (log)
-    log->Printf("SBBreakpoint(%p)::SetQueueName (%s)",
-                static_cast<void *>(m_opaque_sp.get()), queue_name);
-  if (m_opaque_sp) {
+  BreakpointSP bkpt_sp = GetSP();
+  LLDB_LOG(log, "breakpoint = {0}, queue_name = {1}", bkpt_sp.get(),
+           queue_name);
+  if (bkpt_sp) {
     std::lock_guard<std::recursive_mutex> guard(
-        m_opaque_sp->GetTarget().GetAPIMutex());
-    m_opaque_sp->GetOptions()->GetThreadSpec()->SetQueueName(queue_name);
+        bkpt_sp->GetTarget().GetAPIMutex());
+    bkpt_sp->GetOptions()->GetThreadSpec()->SetQueueName(queue_name);
   }
 }
 
 const char *SBBreakpoint::GetQueueName() const {
   const char *name = nullptr;
-  if (m_opaque_sp) {
+  BreakpointSP bkpt_sp = GetSP();
+  if (bkpt_sp) {
     std::lock_guard<std::recursive_mutex> guard(
-        m_opaque_sp->GetTarget().GetAPIMutex());
+        bkpt_sp->GetTarget().GetAPIMutex());
     const ThreadSpec *thread_spec =
-        m_opaque_sp->GetOptions()->GetThreadSpecNoCreate();
+        bkpt_sp->GetOptions()->GetThreadSpecNoCreate();
     if (thread_spec)
       name = thread_spec->GetQueueName();
   }
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-  if (log)
-    log->Printf("SBBreakpoint(%p)::GetQueueName () => %s",
-                static_cast<void *>(m_opaque_sp.get()), name);
+  LLDB_LOG(log, "breakpoint = {0}, name = {1}", bkpt_sp.get(), name);
 
   return name;
 }
 
 size_t SBBreakpoint::GetNumResolvedLocations() const {
   size_t num_resolved = 0;
-  if (m_opaque_sp) {
+  BreakpointSP bkpt_sp = GetSP();
+  if (bkpt_sp) {
     std::lock_guard<std::recursive_mutex> guard(
-        m_opaque_sp->GetTarget().GetAPIMutex());
-    num_resolved = m_opaque_sp->GetNumResolvedLocations();
+        bkpt_sp->GetTarget().GetAPIMutex());
+    num_resolved = bkpt_sp->GetNumResolvedLocations();
   }
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-  if (log)
-    log->Printf("SBBreakpoint(%p)::GetNumResolvedLocations () => %" PRIu64,
-                static_cast<void *>(m_opaque_sp.get()),
-                static_cast<uint64_t>(num_resolved));
+  LLDB_LOG(log, "breakpoint = {0}, num_resolved = {1}", bkpt_sp.get(),
+           num_resolved);
   return num_resolved;
 }
 
 size_t SBBreakpoint::GetNumLocations() const {
+  BreakpointSP bkpt_sp = GetSP();
   size_t num_locs = 0;
-  if (m_opaque_sp) {
+  if (bkpt_sp) {
     std::lock_guard<std::recursive_mutex> guard(
-        m_opaque_sp->GetTarget().GetAPIMutex());
-    num_locs = m_opaque_sp->GetNumLocations();
+        bkpt_sp->GetTarget().GetAPIMutex());
+    num_locs = bkpt_sp->GetNumLocations();
   }
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-  if (log)
-    log->Printf("SBBreakpoint(%p)::GetNumLocations () => %" PRIu64,
-                static_cast<void *>(m_opaque_sp.get()),
-                static_cast<uint64_t>(num_locs));
+  LLDB_LOG(log, "breakpoint = {0}, num_locs = {1}", bkpt_sp.get(), num_locs);
   return num_locs;
 }
 
 void SBBreakpoint::SetCommandLineCommands(SBStringList &commands) {
-  if (!m_opaque_sp)
+  BreakpointSP bkpt_sp = GetSP();
+  if (!bkpt_sp)
     return;
   if (commands.GetSize() == 0)
     return;
 
   std::lock_guard<std::recursive_mutex> guard(
-      m_opaque_sp->GetTarget().GetAPIMutex());
+      bkpt_sp->GetTarget().GetAPIMutex());
   std::unique_ptr<BreakpointOptions::CommandData> cmd_data_up(
       new BreakpointOptions::CommandData(*commands, eScriptLanguageNone));
 
-  m_opaque_sp->GetOptions()->SetCommandDataCallback(cmd_data_up);
+  bkpt_sp->GetOptions()->SetCommandDataCallback(cmd_data_up);
 }
 
 bool SBBreakpoint::GetCommandLineCommands(SBStringList &commands) {
-  if (!m_opaque_sp)
+  BreakpointSP bkpt_sp = GetSP();
+  if (!bkpt_sp)
     return false;
   StringList command_list;
   bool has_commands =
-      m_opaque_sp->GetOptions()->GetCommandLineCallbacks(command_list);
+      bkpt_sp->GetOptions()->GetCommandLineCallbacks(command_list);
   if (has_commands)
     commands.AppendList(command_list);
   return has_commands;
@@ -478,14 +464,15 @@ bool SBBreakpoint::GetDescription(SBStre
 }
 
 bool SBBreakpoint::GetDescription(SBStream &s, bool include_locations) {
-  if (m_opaque_sp) {
+  BreakpointSP bkpt_sp = GetSP();
+  if (bkpt_sp) {
     std::lock_guard<std::recursive_mutex> guard(
-        m_opaque_sp->GetTarget().GetAPIMutex());
-    s.Printf("SBBreakpoint: id = %i, ", m_opaque_sp->GetID());
-    m_opaque_sp->GetResolverDescription(s.get());
-    m_opaque_sp->GetFilterDescription(s.get());
+        bkpt_sp->GetTarget().GetAPIMutex());
+    s.Printf("SBBreakpoint: id = %i, ", bkpt_sp->GetID());
+    bkpt_sp->GetResolverDescription(s.get());
+    bkpt_sp->GetFilterDescription(s.get());
     if (include_locations) {
-      const size_t num_locations = m_opaque_sp->GetNumLocations();
+      const size_t num_locations = bkpt_sp->GetNumLocations();
       s.Printf(", locations = %" PRIu64, (uint64_t)num_locations);
     }
     return true;
@@ -526,36 +513,31 @@ bool SBBreakpoint::PrivateBreakpointHitC
 
 void SBBreakpoint::SetCallback(BreakpointHitCallback callback, void *baton) {
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+  BreakpointSP bkpt_sp = GetSP();
+  LLDB_LOG(log, "breakpoint = {0}, callback = {1}, baton = {2}", bkpt_sp.get(),
+           callback, baton);
 
-  if (log) {
-    void *pointer = &callback;
-    log->Printf("SBBreakpoint(%p)::SetCallback (callback=%p, baton=%p)",
-                static_cast<void *>(m_opaque_sp.get()),
-                *static_cast<void **>(&pointer), static_cast<void *>(baton));
-  }
-
-  if (m_opaque_sp) {
+  if (bkpt_sp) {
     std::lock_guard<std::recursive_mutex> guard(
-        m_opaque_sp->GetTarget().GetAPIMutex());
+        bkpt_sp->GetTarget().GetAPIMutex());
     BatonSP baton_sp(new SBBreakpointCallbackBaton(callback, baton));
-    m_opaque_sp->SetCallback(SBBreakpoint::PrivateBreakpointHitCallback,
-                             baton_sp, false);
+    bkpt_sp->SetCallback(SBBreakpoint::PrivateBreakpointHitCallback, baton_sp,
+                         false);
   }
 }
 
 void SBBreakpoint::SetScriptCallbackFunction(
     const char *callback_function_name) {
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-
-  if (log)
-    log->Printf("SBBreakpoint(%p)::SetScriptCallbackFunction (callback=%s)",
-                static_cast<void *>(m_opaque_sp.get()), callback_function_name);
-
-  if (m_opaque_sp) {
-    std::lock_guard<std::recursive_mutex> guard(
-        m_opaque_sp->GetTarget().GetAPIMutex());
-    BreakpointOptions *bp_options = m_opaque_sp->GetOptions();
-    m_opaque_sp->GetTarget()
+  BreakpointSP bkpt_sp = GetSP();
+  LLDB_LOG(log, "breakpoint = {0}, callback = {1}", bkpt_sp.get(),
+           callback_function_name);
+
+  if (bkpt_sp) {
+    std::lock_guard<std::recursive_mutex> guard(
+        bkpt_sp->GetTarget().GetAPIMutex());
+    BreakpointOptions *bp_options = bkpt_sp->GetOptions();
+    bkpt_sp->GetTarget()
         .GetDebugger()
         .GetCommandInterpreter()
         .GetScriptInterpreter()
@@ -566,18 +548,17 @@ void SBBreakpoint::SetScriptCallbackFunc
 
 SBError SBBreakpoint::SetScriptCallbackBody(const char *callback_body_text) {
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-
-  if (log)
-    log->Printf("SBBreakpoint(%p)::SetScriptCallbackBody: callback body:\n%s)",
-                static_cast<void *>(m_opaque_sp.get()), callback_body_text);
+  BreakpointSP bkpt_sp = GetSP();
+  LLDB_LOG(log, "breakpoint = {0}, callback body:\n{1}", bkpt_sp.get(),
+           callback_body_text);
 
   SBError sb_error;
-  if (m_opaque_sp) {
+  if (bkpt_sp) {
     std::lock_guard<std::recursive_mutex> guard(
-        m_opaque_sp->GetTarget().GetAPIMutex());
-    BreakpointOptions *bp_options = m_opaque_sp->GetOptions();
+        bkpt_sp->GetTarget().GetAPIMutex());
+    BreakpointOptions *bp_options = bkpt_sp->GetOptions();
     Error error =
-        m_opaque_sp->GetTarget()
+        bkpt_sp->GetTarget()
             .GetDebugger()
             .GetCommandInterpreter()
             .GetScriptInterpreter()
@@ -591,17 +572,15 @@ SBError SBBreakpoint::SetScriptCallbackB
 
 bool SBBreakpoint::AddName(const char *new_name) {
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+  BreakpointSP bkpt_sp = GetSP();
+  LLDB_LOG(log, "breakpoint = {0}, name = {1}", bkpt_sp.get(), new_name);
 
-  if (log)
-    log->Printf("SBBreakpoint(%p)::AddName (name=%s)",
-                static_cast<void *>(m_opaque_sp.get()), new_name);
-
-  if (m_opaque_sp) {
+  if (bkpt_sp) {
     std::lock_guard<std::recursive_mutex> guard(
-        m_opaque_sp->GetTarget().GetAPIMutex());
+        bkpt_sp->GetTarget().GetAPIMutex());
     Error error; // Think I'm just going to swallow the error here, it's
                  // probably more annoying to have to provide it.
-    return m_opaque_sp->AddName(new_name, error);
+    return bkpt_sp->AddName(new_name, error);
   }
 
   return false;
@@ -609,29 +588,25 @@ bool SBBreakpoint::AddName(const char *n
 
 void SBBreakpoint::RemoveName(const char *name_to_remove) {
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+  BreakpointSP bkpt_sp = GetSP();
+  LLDB_LOG(log, "breakpoint = {0}, name = {1}", bkpt_sp.get(), name_to_remove);
 
-  if (log)
-    log->Printf("SBBreakpoint(%p)::RemoveName (name=%s)",
-                static_cast<void *>(m_opaque_sp.get()), name_to_remove);
-
-  if (m_opaque_sp) {
+  if (bkpt_sp) {
     std::lock_guard<std::recursive_mutex> guard(
-        m_opaque_sp->GetTarget().GetAPIMutex());
-    m_opaque_sp->RemoveName(name_to_remove);
+        bkpt_sp->GetTarget().GetAPIMutex());
+    bkpt_sp->RemoveName(name_to_remove);
   }
 }
 
 bool SBBreakpoint::MatchesName(const char *name) {
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+  BreakpointSP bkpt_sp = GetSP();
+  LLDB_LOG(log, "breakpoint = {0}, name = {1}", bkpt_sp.get(), name);
 
-  if (log)
-    log->Printf("SBBreakpoint(%p)::MatchesName (name=%s)",
-                static_cast<void *>(m_opaque_sp.get()), name);
-
-  if (m_opaque_sp) {
+  if (bkpt_sp) {
     std::lock_guard<std::recursive_mutex> guard(
-        m_opaque_sp->GetTarget().GetAPIMutex());
-    return m_opaque_sp->MatchesName(name);
+        bkpt_sp->GetTarget().GetAPIMutex());
+    return bkpt_sp->MatchesName(name);
   }
 
   return false;
@@ -639,36 +614,20 @@ bool SBBreakpoint::MatchesName(const cha
 
 void SBBreakpoint::GetNames(SBStringList &names) {
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+  BreakpointSP bkpt_sp = GetSP();
+  LLDB_LOG(log, "breakpoint = {0}", bkpt_sp.get());
 
-  if (log)
-    log->Printf("SBBreakpoint(%p)::GetNames ()",
-                static_cast<void *>(m_opaque_sp.get()));
-
-  if (m_opaque_sp) {
+  if (bkpt_sp) {
     std::lock_guard<std::recursive_mutex> guard(
-        m_opaque_sp->GetTarget().GetAPIMutex());
+        bkpt_sp->GetTarget().GetAPIMutex());
     std::vector<std::string> names_vec;
-    m_opaque_sp->GetNames(names_vec);
+    bkpt_sp->GetNames(names_vec);
     for (std::string name : names_vec) {
       names.AppendString(name.c_str());
     }
   }
 }
 
-lldb_private::Breakpoint *SBBreakpoint::operator->() const {
-  return m_opaque_sp.get();
-}
-
-lldb_private::Breakpoint *SBBreakpoint::get() const {
-  return m_opaque_sp.get();
-}
-
-lldb::BreakpointSP &SBBreakpoint::operator*() { return m_opaque_sp; }
-
-const lldb::BreakpointSP &SBBreakpoint::operator*() const {
-  return m_opaque_sp;
-}
-
 bool SBBreakpoint::EventIsBreakpointEvent(const lldb::SBEvent &event) {
   return Breakpoint::BreakpointEventData::GetEventDataFromEvent(event.get()) !=
          nullptr;
@@ -683,11 +642,10 @@ SBBreakpoint::GetBreakpointEventTypeFrom
 }
 
 SBBreakpoint SBBreakpoint::GetBreakpointFromEvent(const lldb::SBEvent &event) {
-  SBBreakpoint sb_breakpoint;
   if (event.IsValid())
-    sb_breakpoint.m_opaque_sp =
-        Breakpoint::BreakpointEventData::GetBreakpointFromEvent(event.GetSP());
-  return sb_breakpoint;
+    return SBBreakpoint(
+        Breakpoint::BreakpointEventData::GetBreakpointFromEvent(event.GetSP()));
+  return SBBreakpoint();
 }
 
 SBBreakpointLocation
@@ -711,6 +669,8 @@ SBBreakpoint::GetNumBreakpointLocationsF
   return num_locations;
 }
 
+BreakpointSP SBBreakpoint::GetSP() const { return m_opaque_wp.lock(); }
+
 // This is simple collection of breakpoint id's and their target.
 class SBBreakpointListImpl {
 public:
@@ -745,28 +705,28 @@ public:
     return BreakpointSP();
   }
 
-  bool Append(Breakpoint &bkpt) {
+  bool Append(BreakpointSP bkpt) {
     TargetSP target_sp = m_target_wp.lock();
-    if (!target_sp)
+    if (!target_sp || !bkpt)
       return false;
-    if (bkpt.GetTargetSP() != target_sp)
+    if (bkpt->GetTargetSP() != target_sp)
       return false;
-    m_break_ids.push_back(bkpt.GetID());
+    m_break_ids.push_back(bkpt->GetID());
     return true;
   }
 
-  bool AppendIfUnique(Breakpoint &bkpt) {
+  bool AppendIfUnique(BreakpointSP bkpt) {
     TargetSP target_sp = m_target_wp.lock();
-    if (!target_sp)
+    if (!target_sp || !bkpt)
       return false;
-    if (bkpt.GetTargetSP() != target_sp)
+    if (bkpt->GetTargetSP() != target_sp)
       return false;
-    lldb::break_id_t bp_id = bkpt.GetID();
+    lldb::break_id_t bp_id = bkpt->GetID();
     if (find(m_break_ids.begin(), m_break_ids.end(), bp_id) ==
         m_break_ids.end())
       return false;
 
-    m_break_ids.push_back(bkpt.GetID());
+    m_break_ids.push_back(bkpt->GetID());
     return true;
   }
 
@@ -827,7 +787,7 @@ void SBBreakpointList::Append(const SBBr
     return;
   if (!m_opaque_sp)
     return;
-  m_opaque_sp->Append(*sb_bkpt.get());
+  m_opaque_sp->Append(sb_bkpt.m_opaque_wp.lock());
 }
 
 void SBBreakpointList::AppendByID(lldb::break_id_t id) {
@@ -841,7 +801,7 @@ bool SBBreakpointList::AppendIfUnique(co
     return false;
   if (!m_opaque_sp)
     return false;
-  return m_opaque_sp->AppendIfUnique(*sb_bkpt.get());
+  return m_opaque_sp->AppendIfUnique(sb_bkpt.GetSP());
 }
 
 void SBBreakpointList::Clear() {

Modified: lldb/trunk/source/API/SBBreakpointLocation.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBBreakpointLocation.cpp?rev=296328&r1=296327&r2=296328&view=diff
==============================================================================
--- lldb/trunk/source/API/SBBreakpointLocation.cpp (original)
+++ lldb/trunk/source/API/SBBreakpointLocation.cpp Mon Feb 27 05:05:34 2017
@@ -301,7 +301,7 @@ SBBreakpoint SBBreakpointLocation::GetBr
   if (m_opaque_sp) {
     std::lock_guard<std::recursive_mutex> guard(
         m_opaque_sp->GetTarget().GetAPIMutex());
-    *sb_bp = m_opaque_sp->GetBreakpoint().shared_from_this();
+    sb_bp = m_opaque_sp->GetBreakpoint().shared_from_this();
   }
 
   if (log) {
@@ -310,7 +310,7 @@ SBBreakpoint SBBreakpointLocation::GetBr
     log->Printf(
         "SBBreakpointLocation(%p)::GetBreakpoint () => SBBreakpoint(%p) %s",
         static_cast<void *>(m_opaque_sp.get()),
-        static_cast<void *>(sb_bp.get()), sstr.GetData());
+        static_cast<void *>(sb_bp.GetSP().get()), sstr.GetData());
   }
   return sb_bp;
 }

Modified: lldb/trunk/source/API/SBTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=296328&r1=296327&r2=296328&view=diff
==============================================================================
--- lldb/trunk/source/API/SBTarget.cpp (original)
+++ lldb/trunk/source/API/SBTarget.cpp Mon Feb 27 05:05:34 2017
@@ -686,7 +686,7 @@ SBTarget::BreakpointCreateByLocation(con
     if (sb_module_list.GetSize() > 0) {
       module_list = sb_module_list.get();
     }
-    *sb_bp = target_sp->CreateBreakpoint(
+    sb_bp = target_sp->CreateBreakpoint(
         module_list, *sb_file_spec, line, offset, check_inlines, skip_prologue,
         internal, hardware, move_to_nearest_code);
   }
@@ -699,7 +699,7 @@ SBTarget::BreakpointCreateByLocation(con
     log->Printf("SBTarget(%p)::BreakpointCreateByLocation ( %s:%u ) => "
                 "SBBreakpoint(%p): %s",
                 static_cast<void *>(target_sp.get()), path, line,
-                static_cast<void *>(sb_bp.get()), sstr.GetData());
+                static_cast<void *>(sb_bp.GetSP().get()), sstr.GetData());
   }
 
   return sb_bp;
@@ -721,11 +721,11 @@ SBBreakpoint SBTarget::BreakpointCreateB
     if (module_name && module_name[0]) {
       FileSpecList module_spec_list;
       module_spec_list.Append(FileSpec(module_name, false));
-      *sb_bp = target_sp->CreateBreakpoint(
+      sb_bp = target_sp->CreateBreakpoint(
           &module_spec_list, NULL, symbol_name, eFunctionNameTypeAuto,
           eLanguageTypeUnknown, offset, skip_prologue, internal, hardware);
     } else {
-      *sb_bp = target_sp->CreateBreakpoint(
+      sb_bp = target_sp->CreateBreakpoint(
           NULL, NULL, symbol_name, eFunctionNameTypeAuto, eLanguageTypeUnknown,
           offset, skip_prologue, internal, hardware);
     }
@@ -735,7 +735,7 @@ SBBreakpoint SBTarget::BreakpointCreateB
     log->Printf("SBTarget(%p)::BreakpointCreateByName (symbol=\"%s\", "
                 "module=\"%s\") => SBBreakpoint(%p)",
                 static_cast<void *>(target_sp.get()), symbol_name, module_name,
-                static_cast<void *>(sb_bp.get()));
+                static_cast<void *>(sb_bp.GetSP().get()));
 
   return sb_bp;
 }
@@ -771,7 +771,7 @@ lldb::SBBreakpoint SBTarget::BreakpointC
     const bool hardware = false;
     const LazyBool skip_prologue = eLazyBoolCalculate;
     std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
-    *sb_bp = target_sp->CreateBreakpoint(
+    sb_bp = target_sp->CreateBreakpoint(
         module_list.get(), comp_unit_list.get(), symbol_name, name_type_mask,
         symbol_language, 0, skip_prologue, internal, hardware);
   }
@@ -780,7 +780,7 @@ lldb::SBBreakpoint SBTarget::BreakpointC
     log->Printf("SBTarget(%p)::BreakpointCreateByName (symbol=\"%s\", "
                 "name_type: %d) => SBBreakpoint(%p)",
                 static_cast<void *>(target_sp.get()), symbol_name,
-                name_type_mask, static_cast<void *>(sb_bp.get()));
+                name_type_mask, static_cast<void *>(sb_bp.GetSP().get()));
 
   return sb_bp;
 }
@@ -815,7 +815,7 @@ lldb::SBBreakpoint SBTarget::BreakpointC
     const bool internal = false;
     const bool hardware = false;
     const LazyBool skip_prologue = eLazyBoolCalculate;
-    *sb_bp = target_sp->CreateBreakpoint(
+    sb_bp = target_sp->CreateBreakpoint(
         module_list.get(), comp_unit_list.get(), symbol_names, num_names,
         name_type_mask, symbol_language, offset, skip_prologue, internal,
         hardware);
@@ -836,7 +836,7 @@ lldb::SBBreakpoint SBTarget::BreakpointC
         log->Printf("\"<NULL>\"%c ", sep);
     }
     log->Printf("name_type: %d) => SBBreakpoint(%p)", name_type_mask,
-                static_cast<void *>(sb_bp.get()));
+                static_cast<void *>(sb_bp.GetSP().get()));
   }
 
   return sb_bp;
@@ -875,7 +875,7 @@ lldb::SBBreakpoint SBTarget::BreakpointC
     const bool hardware = false;
     const LazyBool skip_prologue = eLazyBoolCalculate;
 
-    *sb_bp = target_sp->CreateFuncRegexBreakpoint(
+    sb_bp = target_sp->CreateFuncRegexBreakpoint(
         module_list.get(), comp_unit_list.get(), regexp, symbol_language,
         skip_prologue, internal, hardware);
   }
@@ -884,7 +884,7 @@ lldb::SBBreakpoint SBTarget::BreakpointC
     log->Printf("SBTarget(%p)::BreakpointCreateByRegex (symbol_regex=\"%s\") "
                 "=> SBBreakpoint(%p)",
                 static_cast<void *>(target_sp.get()), symbol_name_regex,
-                static_cast<void *>(sb_bp.get()));
+                static_cast<void *>(sb_bp.GetSP().get()));
 
   return sb_bp;
 }
@@ -897,7 +897,7 @@ SBBreakpoint SBTarget::BreakpointCreateB
   if (target_sp) {
     std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
     const bool hardware = false;
-    *sb_bp = target_sp->CreateBreakpoint(address, false, hardware);
+    sb_bp = target_sp->CreateBreakpoint(address, false, hardware);
   }
 
   if (log)
@@ -905,7 +905,7 @@ SBBreakpoint SBTarget::BreakpointCreateB
                 ") => SBBreakpoint(%p)",
                 static_cast<void *>(target_sp.get()),
                 static_cast<uint64_t>(address),
-                static_cast<void *>(sb_bp.get()));
+                static_cast<void *>(sb_bp.GetSP().get()));
 
   return sb_bp;
 }
@@ -926,7 +926,7 @@ SBBreakpoint SBTarget::BreakpointCreateB
   if (target_sp) {
     std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
     const bool hardware = false;
-    *sb_bp = target_sp->CreateBreakpoint(sb_address.ref(), false, hardware);
+    sb_bp = target_sp->CreateBreakpoint(sb_address.ref(), false, hardware);
   }
 
   if (log) {
@@ -935,7 +935,7 @@ SBBreakpoint SBTarget::BreakpointCreateB
     log->Printf("SBTarget(%p)::BreakpointCreateBySBAddress (address=%s) => "
                 "SBBreakpoint(%p)",
                 static_cast<void *>(target_sp.get()), s.GetData(),
-                static_cast<void *>(sb_bp.get()));
+                static_cast<void *>(sb_bp.GetSP().get()));
   }
 
   return sb_bp;
@@ -985,7 +985,7 @@ lldb::SBBreakpoint SBTarget::BreakpointC
       func_names_set.insert(func_names.GetStringAtIndex(i));
     }
 
-    *sb_bp = target_sp->CreateSourceRegexBreakpoint(
+    sb_bp = target_sp->CreateSourceRegexBreakpoint(
         module_list.get(), source_file_list.get(), func_names_set, regexp,
         false, hardware, move_to_nearest_code);
   }
@@ -994,7 +994,7 @@ lldb::SBBreakpoint SBTarget::BreakpointC
     log->Printf("SBTarget(%p)::BreakpointCreateByRegex (source_regex=\"%s\") "
                 "=> SBBreakpoint(%p)",
                 static_cast<void *>(target_sp.get()), source_regex,
-                static_cast<void *>(sb_bp.get()));
+                static_cast<void *>(sb_bp.GetSP().get()));
 
   return sb_bp;
 }
@@ -1009,7 +1009,7 @@ SBTarget::BreakpointCreateForException(l
   if (target_sp) {
     std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
     const bool hardware = false;
-    *sb_bp = target_sp->CreateExceptionBreakpoint(language, catch_bp, throw_bp,
+    sb_bp = target_sp->CreateExceptionBreakpoint(language, catch_bp, throw_bp,
                                                   hardware);
   }
 
@@ -1019,7 +1019,7 @@ SBTarget::BreakpointCreateForException(l
                 static_cast<void *>(target_sp.get()),
                 Language::GetNameForLanguageType(language),
                 catch_bp ? "on" : "off", throw_bp ? "on" : "off",
-                static_cast<void *>(sb_bp.get()));
+                static_cast<void *>(sb_bp.GetSP().get()));
 
   return sb_bp;
 }
@@ -1038,7 +1038,7 @@ SBBreakpoint SBTarget::GetBreakpointAtIn
   TargetSP target_sp(GetSP());
   if (target_sp) {
     // The breakpoint list is thread safe, no need to lock
-    *sb_breakpoint = target_sp->GetBreakpointList().GetBreakpointAtIndex(idx);
+    sb_breakpoint = target_sp->GetBreakpointList().GetBreakpointAtIndex(idx);
   }
   return sb_breakpoint;
 }
@@ -1068,14 +1068,14 @@ SBBreakpoint SBTarget::FindBreakpointByI
   TargetSP target_sp(GetSP());
   if (target_sp && bp_id != LLDB_INVALID_BREAK_ID) {
     std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
-    *sb_breakpoint = target_sp->GetBreakpointByID(bp_id);
+    sb_breakpoint = target_sp->GetBreakpointByID(bp_id);
   }
 
   if (log)
     log->Printf(
         "SBTarget(%p)::FindBreakpointByID (bp_id=%d) => SBBreakpoint(%p)",
         static_cast<void *>(target_sp.get()), static_cast<uint32_t>(bp_id),
-        static_cast<void *>(sb_breakpoint.get()));
+        static_cast<void *>(sb_breakpoint.GetSP().get()));
 
   return sb_breakpoint;
 }




More information about the lldb-commits mailing list