diff options
| author | Jim Ingham <jingham@apple.com> | 2012-05-04 23:02:50 +0000 |
|---|---|---|
| committer | Jim Ingham <jingham@apple.com> | 2012-05-04 23:02:50 +0000 |
| commit | 10ebffa48a592e2e03b2e8478b03ccdd0e8da2d5 (patch) | |
| tree | 32f9eceb84a66b9b7f0387d5b89ba089d5bb4fe1 /lldb/source | |
| parent | e326ed33a8135dca882a76128840a28c38a1e106 (diff) | |
| download | bcm5719-llvm-10ebffa48a592e2e03b2e8478b03ccdd0e8da2d5.tar.gz bcm5719-llvm-10ebffa48a592e2e03b2e8478b03ccdd0e8da2d5.zip | |
Don't expose the pthread_mutex_t underlying the Mutex & Mutex::Locker classes.
No one was using it and Locker(pthread_mutex_t *) immediately asserts for
pthread_mutex_t's that don't come from a Mutex anyway. Rather than try to make
that work, we should maintain the Mutex abstraction and not pass around the
platform implementation...
Make Mutex::Locker::Lock take a Mutex & or a Mutex *, and remove the constructor
taking a pthread_mutex_t *. You no longer need to call Mutex::GetMutex to pass
your mutex to a Locker (you can't in fact, since I made it private.)
llvm-svn: 156221
Diffstat (limited to 'lldb/source')
| -rw-r--r-- | lldb/source/API/SBCommandInterpreter.cpp | 6 | ||||
| -rw-r--r-- | lldb/source/API/SBDebugger.cpp | 4 | ||||
| -rw-r--r-- | lldb/source/API/SBFunction.cpp | 2 | ||||
| -rw-r--r-- | lldb/source/API/SBInstruction.cpp | 6 | ||||
| -rw-r--r-- | lldb/source/API/SBSymbol.cpp | 2 | ||||
| -rw-r--r-- | lldb/source/Breakpoint/BreakpointList.cpp | 2 | ||||
| -rw-r--r-- | lldb/source/Breakpoint/WatchpointList.cpp | 2 | ||||
| -rw-r--r-- | lldb/source/Commands/CommandObjectTarget.cpp | 2 | ||||
| -rw-r--r-- | lldb/source/Core/ModuleList.cpp | 4 | ||||
| -rw-r--r-- | lldb/source/Host/common/Condition.cpp | 6 | ||||
| -rw-r--r-- | lldb/source/Host/common/Mutex.cpp | 23 | ||||
| -rw-r--r-- | lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp | 2 | ||||
| -rw-r--r-- | lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp | 2 | ||||
| -rw-r--r-- | lldb/source/Target/StackFrameList.cpp | 4 |
14 files changed, 30 insertions, 37 deletions
diff --git a/lldb/source/API/SBCommandInterpreter.cpp b/lldb/source/API/SBCommandInterpreter.cpp index 7dd4b2ecf90..515fb2869fd 100644 --- a/lldb/source/API/SBCommandInterpreter.cpp +++ b/lldb/source/API/SBCommandInterpreter.cpp @@ -93,7 +93,7 @@ SBCommandInterpreter::HandleCommand (const char *command_line, SBCommandReturnOb TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget()); Mutex::Locker api_locker; if (target_sp) - api_locker.Lock(target_sp->GetAPIMutex().GetMutex()); + api_locker.Lock(target_sp->GetAPIMutex()); m_opaque_ptr->HandleCommand (command_line, add_to_history, result.ref()); } else @@ -238,7 +238,7 @@ SBCommandInterpreter::SourceInitFileInHomeDirectory (SBCommandReturnObject &resu TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget()); Mutex::Locker api_locker; if (target_sp) - api_locker.Lock(target_sp->GetAPIMutex().GetMutex()); + api_locker.Lock(target_sp->GetAPIMutex()); m_opaque_ptr->SourceInitFile (false, result.ref()); } else @@ -263,7 +263,7 @@ SBCommandInterpreter::SourceInitFileInCurrentWorkingDirectory (SBCommandReturnOb TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget()); Mutex::Locker api_locker; if (target_sp) - api_locker.Lock(target_sp->GetAPIMutex().GetMutex()); + api_locker.Lock(target_sp->GetAPIMutex()); m_opaque_ptr->SourceInitFile (true, result.ref()); } else diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp index b052f77ff6e..46d5118ef51 100644 --- a/lldb/source/API/SBDebugger.cpp +++ b/lldb/source/API/SBDebugger.cpp @@ -308,7 +308,7 @@ SBDebugger::HandleCommand (const char *command) TargetSP target_sp (m_opaque_sp->GetSelectedTarget()); Mutex::Locker api_locker; if (target_sp) - api_locker.Lock(target_sp->GetAPIMutex().GetMutex()); + api_locker.Lock(target_sp->GetAPIMutex()); SBCommandInterpreter sb_interpreter(GetCommandInterpreter ()); SBCommandReturnObject result; @@ -830,7 +830,7 @@ SBDebugger::PushInputReader (SBInputReader &reader) TargetSP target_sp (m_opaque_sp->GetSelectedTarget()); Mutex::Locker api_locker; if (target_sp) - api_locker.Lock(target_sp->GetAPIMutex().GetMutex()); + api_locker.Lock(target_sp->GetAPIMutex()); InputReaderSP reader_sp(*reader); m_opaque_sp->PushInputReader (reader_sp); } diff --git a/lldb/source/API/SBFunction.cpp b/lldb/source/API/SBFunction.cpp index 4f967b7d51a..7ac447e5f1b 100644 --- a/lldb/source/API/SBFunction.cpp +++ b/lldb/source/API/SBFunction.cpp @@ -130,7 +130,7 @@ SBFunction::GetInstructions (SBTarget target) TargetSP target_sp (target.GetSP()); if (target_sp) { - api_locker.Lock (target_sp->GetAPIMutex().GetMutex()); + api_locker.Lock (target_sp->GetAPIMutex()); target_sp->CalculateExecutionContext (exe_ctx); exe_ctx.SetProcessSP(target_sp->GetProcessSP()); } diff --git a/lldb/source/API/SBInstruction.cpp b/lldb/source/API/SBInstruction.cpp index 996b01debc0..0adb83e1fd9 100644 --- a/lldb/source/API/SBInstruction.cpp +++ b/lldb/source/API/SBInstruction.cpp @@ -78,7 +78,7 @@ SBInstruction::GetMnemonic(SBTarget target) TargetSP target_sp (target.GetSP()); if (target_sp) { - api_locker.Lock (target_sp->GetAPIMutex().GetMutex()); + api_locker.Lock (target_sp->GetAPIMutex()); target_sp->CalculateExecutionContext (exe_ctx); exe_ctx.SetProcessSP(target_sp->GetProcessSP()); } @@ -97,7 +97,7 @@ SBInstruction::GetOperands(SBTarget target) TargetSP target_sp (target.GetSP()); if (target_sp) { - api_locker.Lock (target_sp->GetAPIMutex().GetMutex()); + api_locker.Lock (target_sp->GetAPIMutex()); target_sp->CalculateExecutionContext (exe_ctx); exe_ctx.SetProcessSP(target_sp->GetProcessSP()); } @@ -116,7 +116,7 @@ SBInstruction::GetComment(SBTarget target) TargetSP target_sp (target.GetSP()); if (target_sp) { - api_locker.Lock (target_sp->GetAPIMutex().GetMutex()); + api_locker.Lock (target_sp->GetAPIMutex()); target_sp->CalculateExecutionContext (exe_ctx); exe_ctx.SetProcessSP(target_sp->GetProcessSP()); } diff --git a/lldb/source/API/SBSymbol.cpp b/lldb/source/API/SBSymbol.cpp index 89dff621dc9..3fd06f84eb1 100644 --- a/lldb/source/API/SBSymbol.cpp +++ b/lldb/source/API/SBSymbol.cpp @@ -126,7 +126,7 @@ SBSymbol::GetInstructions (SBTarget target) TargetSP target_sp (target.GetSP()); if (target_sp) { - api_locker.Lock (target_sp->GetAPIMutex().GetMutex()); + api_locker.Lock (target_sp->GetAPIMutex()); target_sp->CalculateExecutionContext (exe_ctx); } if (m_opaque_ptr->ValueIsAddress()) diff --git a/lldb/source/Breakpoint/BreakpointList.cpp b/lldb/source/Breakpoint/BreakpointList.cpp index 9ec6d8daec8..e1aa2dbcb1e 100644 --- a/lldb/source/Breakpoint/BreakpointList.cpp +++ b/lldb/source/Breakpoint/BreakpointList.cpp @@ -223,5 +223,5 @@ BreakpointList::ClearAllBreakpointSites () void BreakpointList::GetListMutex (Mutex::Locker &locker) { - return locker.Lock (m_mutex.GetMutex()); + return locker.Lock (m_mutex); } diff --git a/lldb/source/Breakpoint/WatchpointList.cpp b/lldb/source/Breakpoint/WatchpointList.cpp index f95265993ae..bfd0b4cdc5d 100644 --- a/lldb/source/Breakpoint/WatchpointList.cpp +++ b/lldb/source/Breakpoint/WatchpointList.cpp @@ -273,5 +273,5 @@ WatchpointList::RemoveAll () void WatchpointList::GetListMutex (Mutex::Locker &locker) { - return locker.Lock (m_mutex.GetMutex()); + return locker.Lock (m_mutex); } diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp index 2c2ab436838..50364327ea4 100644 --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/source/Commands/CommandObjectTarget.cpp @@ -2839,7 +2839,7 @@ public: if (use_global_module_list) { - locker.Lock (Module::GetAllocationModuleCollectionMutex()->GetMutex()); + locker.Lock (Module::GetAllocationModuleCollectionMutex()); num_modules = Module::GetNumberAllocatedModules(); } else diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp index e573555625e..c5a89554c62 100644 --- a/lldb/source/Core/ModuleList.cpp +++ b/lldb/source/Core/ModuleList.cpp @@ -118,12 +118,12 @@ ModuleList::RemoveOrphans (bool mandatory) if (mandatory) { - locker.Lock (m_modules_mutex.GetMutex()); + locker.Lock (m_modules_mutex); } else { // Not mandatory, remove orphans if we can get the mutex - if (!locker.TryLock(m_modules_mutex.GetMutex())) + if (!locker.TryLock(m_modules_mutex)) return 0; } collection::iterator pos = m_modules.begin(); diff --git a/lldb/source/Host/common/Condition.cpp b/lldb/source/Host/common/Condition.cpp index 535afcb0439..daa729cadca 100644 --- a/lldb/source/Host/common/Condition.cpp +++ b/lldb/source/Host/common/Condition.cpp @@ -78,7 +78,7 @@ Condition::Signal () // The current thread re-acquires the lock on "mutex". //---------------------------------------------------------------------- int -Condition::Wait (pthread_mutex_t *mutex, const TimeValue *abstime, bool *timed_out) +Condition::Wait (Mutex &mutex, const TimeValue *abstime, bool *timed_out) { int err = 0; do @@ -86,10 +86,10 @@ Condition::Wait (pthread_mutex_t *mutex, const TimeValue *abstime, bool *timed_o if (abstime && abstime->IsValid()) { struct timespec abstime_ts = abstime->GetAsTimeSpec(); - err = ::pthread_cond_timedwait (&m_condition, mutex, &abstime_ts); + err = ::pthread_cond_timedwait (&m_condition, mutex.GetMutex(), &abstime_ts); } else - err = ::pthread_cond_wait (&m_condition, mutex); + err = ::pthread_cond_wait (&m_condition, mutex.GetMutex()); } while (err == EINTR); if (timed_out != NULL) diff --git a/lldb/source/Host/common/Mutex.cpp b/lldb/source/Host/common/Mutex.cpp index 06908b2344c..d519baf45b6 100644 --- a/lldb/source/Host/common/Mutex.cpp +++ b/lldb/source/Host/common/Mutex.cpp @@ -108,7 +108,7 @@ Mutex::Locker::Locker () : Mutex::Locker::Locker (Mutex& m) : m_mutex_ptr(NULL) { - Lock (m.GetMutex()); + Lock (m); } //---------------------------------------------------------------------- @@ -121,18 +121,7 @@ Mutex::Locker::Locker (Mutex* m) : m_mutex_ptr(NULL) { if (m) - Lock (m->GetMutex()); -} - -//---------------------------------------------------------------------- -// Constructor with a raw pthread mutex object pointer. -// -// This will create a scoped mutex locking object that locks "mutex" -//---------------------------------------------------------------------- -Mutex::Locker::Locker (pthread_mutex_t *mutex_ptr) : - m_mutex_ptr (NULL) -{ - Lock (mutex_ptr); + Lock (m); } //---------------------------------------------------------------------- @@ -150,8 +139,10 @@ Mutex::Locker::~Locker () // mutex) and lock the new "mutex" object if it is non-NULL. //---------------------------------------------------------------------- void -Mutex::Locker::Lock (pthread_mutex_t *mutex_ptr) +Mutex::Locker::Lock (Mutex &mutex) { + pthread_mutex_t *mutex_ptr = mutex.GetMutex(); + // We already have this mutex locked or both are NULL... if (m_mutex_ptr == mutex_ptr) return; @@ -176,8 +167,10 @@ Mutex::Locker::Unlock () } bool -Mutex::Locker::TryLock (pthread_mutex_t *mutex_ptr) +Mutex::Locker::TryLock (Mutex &mutex) { + pthread_mutex_t *mutex_ptr = mutex.GetMutex(); + // We already have this mutex locked! if (m_mutex_ptr == mutex_ptr) return m_mutex_ptr != NULL; diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp b/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp index c1d9f955159..0b49f1fc279 100644 --- a/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp +++ b/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp @@ -153,7 +153,7 @@ CommunicationKDP::SendRequestPacketNoLock (const PacketStreamType &request_packe bool CommunicationKDP::GetSequenceMutex (Mutex::Locker& locker) { - return locker.TryLock (m_sequence_mutex.GetMutex()); + return locker.TryLock (m_sequence_mutex); } diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp index a6d2d114da9..e55328b93e7 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp @@ -264,7 +264,7 @@ GDBRemoteCommunication::GetAck () bool GDBRemoteCommunication::GetSequenceMutex (Mutex::Locker& locker) { - return locker.TryLock (m_sequence_mutex.GetMutex()); + return locker.TryLock (m_sequence_mutex); } diff --git a/lldb/source/Target/StackFrameList.cpp b/lldb/source/Target/StackFrameList.cpp index 3c580bca0d4..84fce4a6345 100644 --- a/lldb/source/Target/StackFrameList.cpp +++ b/lldb/source/Target/StackFrameList.cpp @@ -466,8 +466,8 @@ StackFrameList::InvalidateFrames (uint32_t start_idx) void StackFrameList::Merge (std::auto_ptr<StackFrameList>& curr_ap, lldb::StackFrameListSP& prev_sp) { - Mutex::Locker curr_locker (curr_ap.get() ? curr_ap->m_mutex.GetMutex() : NULL); - Mutex::Locker prev_locker (prev_sp.get() ? prev_sp->m_mutex.GetMutex() : NULL); + Mutex::Locker curr_locker (curr_ap.get() ? &curr_ap->m_mutex : NULL); + Mutex::Locker prev_locker (prev_sp.get() ? &prev_sp->m_mutex : NULL); #if defined (DEBUG_STACK_FRAMES) StreamFile s(stdout, false); |

