[Lldb-commits] [lldb] r211136 - Add locking around the m_owners collection in the breakpoint site. If we are in the middle of "BreakpointLocation::ShouldStop" we don't
Jim Ingham
jingham at apple.com
Tue Jun 17 18:04:40 PDT 2014
Author: jingham
Date: Tue Jun 17 20:04:40 2014
New Revision: 211136
URL: http://llvm.org/viewvc/llvm-project?rev=211136&view=rev
Log:
Add locking around the m_owners collection in the breakpoint site. If we are in the middle of "BreakpointLocation::ShouldStop" we don't
want other commands (like "break disable") to mutate the owners of this breakpoint out from under us.
<rdar://problem/17255589>
Modified:
lldb/trunk/include/lldb/Breakpoint/BreakpointSite.h
lldb/trunk/source/Breakpoint/BreakpointSite.cpp
Modified: lldb/trunk/include/lldb/Breakpoint/BreakpointSite.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/BreakpointSite.h?rev=211136&r1=211135&r2=211136&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/BreakpointSite.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/BreakpointSite.h Tue Jun 17 20:04:40 2014
@@ -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();
Modified: lldb/trunk/source/Breakpoint/BreakpointSite.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointSite.cpp?rev=211136&r1=211135&r2=211136&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/BreakpointSite.cpp (original)
+++ lldb/trunk/source/Breakpoint/BreakpointSite.cpp Tue Jun 17 20:04:40 2014
@@ -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 (StoppointCal
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 *
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
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);
}
More information about the lldb-commits
mailing list