// 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"
// 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();
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);
}
bool
BreakpointSite::ShouldStop (StoppointCallbackContext *context)
{
+ Mutex::Locker(m_owners_mutex);
IncrementHitCount();
return m_owners.ShouldStop (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++)
{
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);
bool
BreakpointSite::IsInternal() const
{
+ Mutex::Locker(m_owners_mutex);
return m_owners.IsInternal();
}
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();
}
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);
}