Cleaned up the SBWatchpoint public API.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@141876 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/API/SBTarget.cpp b/source/API/SBTarget.cpp
index 64af22a..3cdfe1d 100644
--- a/source/API/SBTarget.cpp
+++ b/source/API/SBTarget.cpp
@@ -883,7 +883,7 @@
 }
 
 uint32_t
-SBTarget::GetNumWatchpointLocations () const
+SBTarget::GetNumWatchpoints () const
 {
     if (m_opaque_sp)
     {
@@ -893,31 +893,10 @@
     return 0;
 }
 
-SBWatchpointLocation
-SBTarget::GetLastCreatedWatchpointLocation ()
+SBWatchpoint
+SBTarget::GetWatchpointAtIndex (uint32_t idx) const
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
-    SBWatchpointLocation sb_watchpoint_location;
-    if (m_opaque_sp)
-    {
-        Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex());
-        sb_watchpoint_location = m_opaque_sp->GetLastCreatedWatchpointLocation();
-    }
-
-    if (log)
-    {
-        log->Printf ("SBTarget(%p)::GetLastCreateWatchpointLocation () => SBWatchpointLocation(%p)", 
-                     m_opaque_sp.get(), sb_watchpoint_location.get());
-    }
-
-    return sb_watchpoint_location;
-}
-
-SBWatchpointLocation
-SBTarget::GetWatchpointLocationAtIndex (uint32_t idx) const
-{
-    SBWatchpointLocation sb_watchpoint_location;
+    SBWatchpoint sb_watchpoint_location;
     if (m_opaque_sp)
     {
         // The watchpoint location list is thread safe, no need to lock
@@ -927,7 +906,7 @@
 }
 
 bool
-SBTarget::WatchpointLocationDelete (watch_id_t wp_id)
+SBTarget::DeleteWatchpoint (watch_id_t wp_id)
 {
     LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
@@ -946,29 +925,51 @@
     return result;
 }
 
-SBWatchpointLocation
-SBTarget::FindWatchpointLocationByID (watch_id_t wp_id)
+SBWatchpoint
+SBTarget::FindWatchpointByID (lldb::watch_id_t wp_id)
 {
     LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
-    SBWatchpointLocation sb_watchpoint_location;
+    SBWatchpoint sb_watchpoint;
     if (m_opaque_sp && wp_id != LLDB_INVALID_WATCH_ID)
     {
         Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex());
-        *sb_watchpoint_location = m_opaque_sp->GetWatchpointLocationList().FindByID(wp_id);
+        *sb_watchpoint = m_opaque_sp->GetWatchpointLocationList().FindByID(wp_id);
     }
 
     if (log)
     {
-        log->Printf ("SBTarget(%p)::FindWatchpointLocationByID (bp_id=%d) => SBWatchpointLocation(%p)", 
-                     m_opaque_sp.get(), (uint32_t) wp_id, sb_watchpoint_location.get());
+        log->Printf ("SBTarget(%p)::FindWatchpointLocationByID (bp_id=%d) => SBWatchpoint(%p)", 
+                     m_opaque_sp.get(), (uint32_t) wp_id, sb_watchpoint.get());
     }
 
-    return sb_watchpoint_location;
+    return sb_watchpoint;
+}
+
+lldb::SBWatchpoint
+SBTarget::WatchAddress (lldb::addr_t addr, size_t size, bool read, bool write)
+{
+    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    
+    SBWatchpoint sb_watchpoint;
+    if (m_opaque_sp)
+    {
+        Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex());
+        // TODO: Johnny fill this in
+        //*sb_watchpoint = m_opaque_sp->GetWatchpointLocationList().FindByID(wp_id);
+    }
+    
+    if (log)
+    {
+        log->Printf ("SBTarget(%p)::WatchAddress (addr=0x%llx, 0x%u) => SBWatchpoint(%p)", 
+                     m_opaque_sp.get(), addr, (uint32_t) size, sb_watchpoint.get());
+    }
+    
+    return sb_watchpoint;
 }
 
 bool
-SBTarget::EnableAllWatchpointLocations ()
+SBTarget::EnableAllWatchpoints ()
 {
     if (m_opaque_sp)
     {
@@ -980,7 +981,7 @@
 }
 
 bool
-SBTarget::DisableAllWatchpointLocations ()
+SBTarget::DisableAllWatchpoints ()
 {
     if (m_opaque_sp)
     {
@@ -992,7 +993,7 @@
 }
 
 bool
-SBTarget::DeleteAllWatchpointLocations ()
+SBTarget::DeleteAllWatchpoints ()
 {
     if (m_opaque_sp)
     {
diff --git a/source/API/SBValue.cpp b/source/API/SBValue.cpp
index 37a5244..8afd564 100644
--- a/source/API/SBValue.cpp
+++ b/source/API/SBValue.cpp
@@ -1097,3 +1097,31 @@
     
     return sb_data;
 }
+
+lldb::SBWatchpoint
+SBValue::Watch (bool resolve_location, bool read, bool write)
+{
+    lldb::SBWatchpoint sb_watchpoint;
+    Target* target = m_opaque_sp->GetUpdatePoint().GetTargetSP().get();
+    if (target)
+    {
+        Mutex::Locker api_locker (target->GetAPIMutex());
+        // TODO: Johnny fill this in
+    }
+    return sb_watchpoint;
+}
+
+lldb::SBWatchpoint
+SBValue::WatchPointee (bool resolve_location, bool read, bool write)
+{
+    lldb::SBWatchpoint sb_watchpoint;
+    Target* target = m_opaque_sp->GetUpdatePoint().GetTargetSP().get();
+    if (target)
+    {
+        Mutex::Locker api_locker (target->GetAPIMutex());
+        // TODO: Johnny fill this in
+    }
+    return sb_watchpoint;
+}
+
+
diff --git a/source/API/SBWatchpointLocation.cpp b/source/API/SBWatchpoint.cpp
similarity index 69%
rename from source/API/SBWatchpointLocation.cpp
rename to source/API/SBWatchpoint.cpp
index 33b035f..a921ea1 100644
--- a/source/API/SBWatchpointLocation.cpp
+++ b/source/API/SBWatchpoint.cpp
@@ -1,4 +1,4 @@
-//===-- SBWatchpointLocation.cpp --------------------------------*- C++ -*-===//
+//===-- SBWatchpoint.cpp --------------------------------*- C++ -*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -7,7 +7,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "lldb/API/SBWatchpointLocation.h"
+#include "lldb/API/SBWatchpoint.h"
 #include "lldb/API/SBDefines.h"
 #include "lldb/API/SBAddress.h"
 #include "lldb/API/SBDebugger.h"
@@ -26,12 +26,12 @@
 using namespace lldb_private;
 
 
-SBWatchpointLocation::SBWatchpointLocation () :
+SBWatchpoint::SBWatchpoint () :
     m_opaque_sp ()
 {
 }
 
-SBWatchpointLocation::SBWatchpointLocation (const lldb::WatchpointLocationSP &watch_loc_sp) :
+SBWatchpoint::SBWatchpoint (const lldb::WatchpointLocationSP &watch_loc_sp) :
     m_opaque_sp (watch_loc_sp)
 {
     LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
@@ -40,18 +40,18 @@
     {
         SBStream sstr;
         GetDescription (sstr, lldb::eDescriptionLevelBrief);
-        log->Printf ("SBWatchpointLocation::SBWatchpointLocation (const lldb::WatchpointLocationsSP &watch_loc_sp"
+        log->Printf ("SBWatchpoint::SBWatchpoint (const lldb::WatchpointLocationsSP &watch_loc_sp"
                      "=%p)  => this.sp = %p (%s)", watch_loc_sp.get(), m_opaque_sp.get(), sstr.GetData());
     }
 }
 
-SBWatchpointLocation::SBWatchpointLocation(const SBWatchpointLocation &rhs) :
+SBWatchpoint::SBWatchpoint(const SBWatchpoint &rhs) :
     m_opaque_sp (rhs.m_opaque_sp)
 {
 }
 
-const SBWatchpointLocation &
-SBWatchpointLocation::operator = (const SBWatchpointLocation &rhs)
+const SBWatchpoint &
+SBWatchpoint::operator = (const SBWatchpoint &rhs)
 {
     if (this != &rhs)
         m_opaque_sp = rhs.m_opaque_sp;
@@ -59,12 +59,12 @@
 }
 
 
-SBWatchpointLocation::~SBWatchpointLocation ()
+SBWatchpoint::~SBWatchpoint ()
 {
 }
 
 watch_id_t
-SBWatchpointLocation::GetID () const
+SBWatchpoint::GetID ()
 {
     LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
@@ -75,22 +75,41 @@
     if (log)
     {
         if (watch_id == LLDB_INVALID_WATCH_ID)
-            log->Printf ("SBWatchpointLocation(%p)::GetID () => LLDB_INVALID_WATCH_ID", m_opaque_sp.get());
+            log->Printf ("SBWatchpoint(%p)::GetID () => LLDB_INVALID_WATCH_ID", m_opaque_sp.get());
         else
-            log->Printf ("SBWatchpointLocation(%p)::GetID () => %u", m_opaque_sp.get(), watch_id);
+            log->Printf ("SBWatchpoint(%p)::GetID () => %u", m_opaque_sp.get(), watch_id);
     }
 
     return watch_id;
 }
 
 bool
-SBWatchpointLocation::IsValid() const
+SBWatchpoint::IsValid() const
 {
     return m_opaque_sp.get() != NULL;
+#if 0
+    if (m_opaque_sp)
+        return m_opaque_sp->GetError().Success();
+    return false;
+#endif
+}
+
+SBError
+SBWatchpoint::GetError ()
+{
+    SBError sb_error;
+#if 0
+    if (m_opaque_sp)
+    {
+        // TODO: Johnny fill this in
+        sb_error.ref() = m_opaque_sp->GetError();
+    }
+#endif
+    return sb_error;
 }
 
 int32_t
-SBWatchpointLocation::GetHardwareIndex () const
+SBWatchpoint::GetHardwareIndex ()
 {
     int32_t hw_index = -1;
 
@@ -104,7 +123,7 @@
 }
 
 addr_t
-SBWatchpointLocation::GetWatchAddress () const
+SBWatchpoint::GetWatchAddress ()
 {
     addr_t ret_addr = LLDB_INVALID_ADDRESS;
 
@@ -118,7 +137,7 @@
 }
 
 size_t
-SBWatchpointLocation::GetWatchSize () const
+SBWatchpoint::GetWatchSize ()
 {
     size_t watch_size = 0;
 
@@ -132,7 +151,7 @@
 }
 
 void
-SBWatchpointLocation::SetEnabled (bool enabled)
+SBWatchpoint::SetEnabled (bool enabled)
 {
     if (m_opaque_sp)
     {
@@ -142,7 +161,7 @@
 }
 
 bool
-SBWatchpointLocation::IsEnabled ()
+SBWatchpoint::IsEnabled ()
 {
     if (m_opaque_sp)
     {
@@ -154,7 +173,7 @@
 }
 
 uint32_t
-SBWatchpointLocation::GetHitCount () const
+SBWatchpoint::GetHitCount ()
 {
     uint32_t count = 0;
     if (m_opaque_sp)
@@ -165,13 +184,13 @@
 
     LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
-        log->Printf ("SBWatchpointLocation(%p)::GetHitCount () => %u", m_opaque_sp.get(), count);
+        log->Printf ("SBWatchpoint(%p)::GetHitCount () => %u", m_opaque_sp.get(), count);
 
     return count;
 }
 
 uint32_t
-SBWatchpointLocation::GetIgnoreCount ()
+SBWatchpoint::GetIgnoreCount ()
 {
     if (m_opaque_sp)
     {
@@ -183,7 +202,7 @@
 }
 
 void
-SBWatchpointLocation::SetIgnoreCount (uint32_t n)
+SBWatchpoint::SetIgnoreCount (uint32_t n)
 {
     if (m_opaque_sp)
     {
@@ -193,7 +212,7 @@
 }
 
 bool
-SBWatchpointLocation::GetDescription (SBStream &description, DescriptionLevel level)
+SBWatchpoint::GetDescription (SBStream &description, DescriptionLevel level)
 {
     if (m_opaque_sp)
     {
@@ -209,26 +228,19 @@
 }
 
 lldb_private::WatchpointLocation *
-SBWatchpointLocation::operator->() const
+SBWatchpoint::operator->()
 {
     return m_opaque_sp.get();
 }
 
 lldb_private::WatchpointLocation *
-SBWatchpointLocation::get() const
+SBWatchpoint::get()
 {
     return m_opaque_sp.get();
 }
 
 lldb::WatchpointLocationSP &
-SBWatchpointLocation::operator *()
+SBWatchpoint::operator *()
 {
     return m_opaque_sp;
 }
-
-const lldb::WatchpointLocationSP &
-SBWatchpointLocation::operator *() const
-{
-    return m_opaque_sp;
-}
-