Make the Watchpoint IDs unique per target, not across targets as before.
Now Each newly created target has its Watchpoint IDs as 1, 2, 3 ...


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@151435 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Target/Target.cpp b/source/Target/Target.cpp
index 88976ef..3a26b77 100644
--- a/source/Target/Target.cpp
+++ b/source/Target/Target.cpp
@@ -138,7 +138,10 @@
         m_breakpoint_list.ClearAllBreakpointSites();
         m_internal_breakpoint_list.ClearAllBreakpointSites();
         // Disable watchpoints just on the debugger side.
+        Mutex::Locker locker;
+        this->GetWatchpointList().GetListMutex(locker);
         DisableAllWatchpoints(false);
+        ClearAllWatchpointHitCounts();
         m_process_sp.reset();
     }
 }
@@ -672,6 +675,26 @@
     return true; // Success!
 }
 
+// Assumption: Caller holds the list mutex lock for m_watchpoint_list.
+bool
+Target::ClearAllWatchpointHitCounts ()
+{
+    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS));
+    if (log)
+        log->Printf ("Target::%s\n", __FUNCTION__);
+
+    size_t num_watchpoints = m_watchpoint_list.GetSize();
+    for (size_t i = 0; i < num_watchpoints; ++i)
+    {
+        WatchpointSP wp_sp = m_watchpoint_list.GetByIndex(i);
+        if (!wp_sp)
+            return false;
+
+        wp_sp->ResetHitCount();
+    }
+    return true; // Success!
+}
+
 // Assumption: Caller holds the list mutex lock for m_watchpoint_list
 // during these operations.
 bool