diff options
| author | Johnny Chen <johnny.chen@apple.com> | 2012-05-31 22:56:36 +0000 |
|---|---|---|
| committer | Johnny Chen <johnny.chen@apple.com> | 2012-05-31 22:56:36 +0000 |
| commit | 7385a5ae0b8d8de1ccc73552e2eb97675678f52c (patch) | |
| tree | 6bb9864fea22ef95b392deb352f7e870eef85815 | |
| parent | 7d00061d876f91f4f82343113336b5735e670460 (diff) | |
| download | bcm5719-llvm-7385a5ae0b8d8de1ccc73552e2eb97675678f52c.tar.gz bcm5719-llvm-7385a5ae0b8d8de1ccc73552e2eb97675678f52c.zip | |
Thread-hardening the SB API calls related to watchpoint operations.
llvm-svn: 157776
| -rw-r--r-- | lldb/source/API/SBTarget.cpp | 11 | ||||
| -rw-r--r-- | lldb/source/Target/Target.cpp | 4 |
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) { |

