summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/include/lldb/Breakpoint/BreakpointSite.h2
-rw-r--r--lldb/source/Breakpoint/BreakpointSite.cpp12
2 files changed, 13 insertions, 1 deletions
diff --git a/lldb/include/lldb/Breakpoint/BreakpointSite.h b/lldb/include/lldb/Breakpoint/BreakpointSite.h
index 6292b307fc9..204206f2124 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointSite.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointSite.h
@@ -19,6 +19,7 @@
// Project includes
#include "lldb/lldb-private.h"
+#include "lldb/Host/Mutex.h"
#include "lldb/Core/UserID.h"
#include "lldb/Breakpoint/StoppointLocation.h"
#include "lldb/Breakpoint/BreakpointLocationCollection.h"
@@ -277,6 +278,7 @@ private:
// Consider adding an optimization where if there is only one
// owner, we don't store a list. The usual case will be only one owner...
BreakpointLocationCollection m_owners; ///< This has the BreakpointLocations that share this breakpoint site.
+ Mutex m_owners_mutex; ///< This mutex protects the owners collection.
static lldb::break_id_t
GetNextID();
diff --git a/lldb/source/Breakpoint/BreakpointSite.cpp b/lldb/source/Breakpoint/BreakpointSite.cpp
index fa5d8c1f9f8..8290341a88e 100644
--- a/lldb/source/Breakpoint/BreakpointSite.cpp
+++ b/lldb/source/Breakpoint/BreakpointSite.cpp
@@ -32,7 +32,8 @@ BreakpointSite::BreakpointSite
m_saved_opcode(),
m_trap_opcode(),
m_enabled(false), // Need to create it disabled, so the first enable turns it on.
- m_owners()
+ m_owners(),
+ m_owners_mutex(Mutex::eMutexTypeRecursive)
{
m_owners.Add(owner);
}
@@ -60,6 +61,7 @@ BreakpointSite::GetNextID()
bool
BreakpointSite::ShouldStop (StoppointCallbackContext *context)
{
+ Mutex::Locker(m_owners_mutex);
IncrementHitCount();
return m_owners.ShouldStop (context);
}
@@ -67,6 +69,7 @@ BreakpointSite::ShouldStop (StoppointCallbackContext *context)
bool
BreakpointSite::IsBreakpointAtThisSite (lldb::break_id_t bp_id)
{
+ Mutex::Locker(m_owners_mutex);
const size_t owner_count = m_owners.GetSize();
for (size_t i = 0; i < owner_count; i++)
{
@@ -93,6 +96,7 @@ BreakpointSite::Dump(Stream *s) const
void
BreakpointSite::GetDescription (Stream *s, lldb::DescriptionLevel level)
{
+ Mutex::Locker(m_owners_mutex);
if (level != lldb::eDescriptionLevelBrief)
s->Printf ("breakpoint site: %d at 0x%8.8" PRIx64, GetID(), GetLoadAddress());
m_owners.GetDescription (s, level);
@@ -101,6 +105,7 @@ BreakpointSite::GetDescription (Stream *s, lldb::DescriptionLevel level)
bool
BreakpointSite::IsInternal() const
{
+ Mutex::Locker(m_owners_mutex);
return m_owners.IsInternal();
}
@@ -162,12 +167,14 @@ BreakpointSite::SetEnabled (bool enabled)
void
BreakpointSite::AddOwner (const BreakpointLocationSP &owner)
{
+ Mutex::Locker(m_owners_mutex);
m_owners.Add(owner);
}
size_t
BreakpointSite::RemoveOwner (lldb::break_id_t break_id, lldb::break_id_t break_loc_id)
{
+ Mutex::Locker(m_owners_mutex);
m_owners.Remove(break_id, break_loc_id);
return m_owners.GetSize();
}
@@ -175,18 +182,21 @@ BreakpointSite::RemoveOwner (lldb::break_id_t break_id, lldb::break_id_t break_l
size_t
BreakpointSite::GetNumberOfOwners ()
{
+ Mutex::Locker(m_owners_mutex);
return m_owners.GetSize();
}
BreakpointLocationSP
BreakpointSite::GetOwnerAtIndex (size_t index)
{
+ Mutex::Locker(m_owners_mutex);
return m_owners.GetByIndex (index);
}
bool
BreakpointSite::ValidForThisThread (Thread *thread)
{
+ Mutex::Locker(m_owners_mutex);
return m_owners.ValidForThisThread(thread);
}
OpenPOWER on IntegriCloud