summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/source/API/SBTarget.cpp11
-rw-r--r--lldb/source/Target/Target.cpp4
2 files changed, 15 insertions, 0 deletions
diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index 80a152971de..d26788642ae 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -1634,6 +1634,8 @@ SBTarget::DeleteWatchpoint (watch_id_t wp_id)
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 @@ SBTarget::FindWatchpointByID (lldb::watch_id_t wp_id)
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 @@ SBTarget::WatchAddress (lldb::addr_t addr, size_t size, bool read, bool write)
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 @@ SBTarget::EnableAllWatchpoints ()
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 @@ SBTarget::DisableAllWatchpoints ()
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 @@ SBTarget::DeleteAllWatchpoints ()
if (target_sp)
{
Mutex::Locker api_locker (target_sp->GetAPIMutex());
+ Mutex::Locker locker;
+ target_sp->GetWatchpointList().GetListMutex(locker);
target_sp->RemoveAllWatchpoints ();
return true;
}
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 7f8ae45a8d0..0fce9ae06d8 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -483,6 +483,10 @@ Target::CreateWatchpoint(lldb::addr_t addr, size_t size, uint32_t type)
// 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)
{
OpenPOWER on IntegriCloud