[Lldb-commits] [lldb] r157776 - in /lldb/trunk/source: API/SBTarget.cpp Target/Target.cpp

Johnny Chen johnny.chen at apple.com
Thu May 31 15:56:37 PDT 2012


Author: johnny
Date: Thu May 31 17:56:36 2012
New Revision: 157776

URL: http://llvm.org/viewvc/llvm-project?rev=157776&view=rev
Log:
Thread-hardening the SB API calls related to watchpoint operations.

Modified:
    lldb/trunk/source/API/SBTarget.cpp
    lldb/trunk/source/Target/Target.cpp

Modified: lldb/trunk/source/API/SBTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=157776&r1=157775&r2=157776&view=diff
==============================================================================
--- lldb/trunk/source/API/SBTarget.cpp (original)
+++ lldb/trunk/source/API/SBTarget.cpp Thu May 31 17:56:36 2012
@@ -1634,6 +1634,8 @@
     if (target_sp)
     {
         Mutex::Locker api_locker (target_sp->GetAPIMutex());
+        Mutex::Locker locker;
+        target_sp->GetWatchpointList().GetListMutex(locker);
         result = target_sp->RemoveWatchpointByID (wp_id);
     }
 
@@ -1656,6 +1658,8 @@
     if (target_sp && wp_id != LLDB_INVALID_WATCH_ID)
     {
         Mutex::Locker api_locker (target_sp->GetAPIMutex());
+        Mutex::Locker locker;
+        target_sp->GetWatchpointList().GetListMutex(locker);
         watchpoint_sp = target_sp->GetWatchpointList().FindByID(wp_id);
         sb_watchpoint.SetSP (watchpoint_sp);
     }
@@ -1685,6 +1689,7 @@
             watch_type |= LLDB_WATCH_TYPE_READ;
         if (write)
             watch_type |= LLDB_WATCH_TYPE_WRITE;
+        // Target::CreateWatchpoint() is thread safe.
         watchpoint_sp = target_sp->CreateWatchpoint(addr, size, watch_type);
         sb_watchpoint.SetSP (watchpoint_sp);
     }
@@ -1705,6 +1710,8 @@
     if (target_sp)
     {
         Mutex::Locker api_locker (target_sp->GetAPIMutex());
+        Mutex::Locker locker;
+        target_sp->GetWatchpointList().GetListMutex(locker);
         target_sp->EnableAllWatchpoints ();
         return true;
     }
@@ -1718,6 +1725,8 @@
     if (target_sp)
     {
         Mutex::Locker api_locker (target_sp->GetAPIMutex());
+        Mutex::Locker locker;
+        target_sp->GetWatchpointList().GetListMutex(locker);
         target_sp->DisableAllWatchpoints ();
         return true;
     }
@@ -1731,6 +1740,8 @@
     if (target_sp)
     {
         Mutex::Locker api_locker (target_sp->GetAPIMutex());
+        Mutex::Locker locker;
+        target_sp->GetWatchpointList().GetListMutex(locker);
         target_sp->RemoveAllWatchpoints ();
         return true;
     }

Modified: lldb/trunk/source/Target/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=157776&r1=157775&r2=157776&view=diff
==============================================================================
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Thu May 31 17:56:36 2012
@@ -483,6 +483,10 @@
 
     // Currently we only support one watchpoint per address, with total number
     // of watchpoints limited by the hardware which the inferior is running on.
+
+    // Grab the list mutex while doing operations.
+    Mutex::Locker locker;
+    this->GetWatchpointList().GetListMutex(locker);
     WatchpointSP matched_sp = m_watchpoint_list.FindByAddress(addr);
     if (matched_sp)
     {





More information about the lldb-commits mailing list