[Lldb-commits] [lldb] r154471 - in /lldb/branches/lldb-platform-work: ./ include/lldb/Host/ source/API/ source/Breakpoint/ source/Commands/ source/Core/ source/Host/common/ source/Plugins/Platform/MacOSX/ source/Plugins/Process/MacOSX-Kernel/ source/Plugins/Process/gdb-remote/
Johnny Chen
johnny.chen at apple.com
Tue Apr 10 18:44:18 PDT 2012
Author: johnny
Date: Tue Apr 10 20:44:18 2012
New Revision: 154471
URL: http://llvm.org/viewvc/llvm-project?rev=154471&view=rev
Log:
Merge r154458 from ToT, resolve conflicts, and also add back the 'platform get-size' functionality which failed due to recent interim changes.
Modified:
lldb/branches/lldb-platform-work/ (props changed)
lldb/branches/lldb-platform-work/include/lldb/Host/Mutex.h
lldb/branches/lldb-platform-work/include/lldb/Host/ReadWriteLock.h
lldb/branches/lldb-platform-work/source/API/SBCommandInterpreter.cpp
lldb/branches/lldb-platform-work/source/API/SBDebugger.cpp
lldb/branches/lldb-platform-work/source/API/SBFunction.cpp
lldb/branches/lldb-platform-work/source/API/SBInstruction.cpp
lldb/branches/lldb-platform-work/source/API/SBSymbol.cpp
lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointList.cpp
lldb/branches/lldb-platform-work/source/Breakpoint/WatchpointList.cpp
lldb/branches/lldb-platform-work/source/Commands/CommandObjectTarget.cpp
lldb/branches/lldb-platform-work/source/Core/Listener.cpp
lldb/branches/lldb-platform-work/source/Core/ModuleList.cpp
lldb/branches/lldb-platform-work/source/Host/common/Mutex.cpp
lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformMacOSX.h
lldb/branches/lldb-platform-work/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp
lldb/branches/lldb-platform-work/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h
lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp
lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
Propchange: lldb/branches/lldb-platform-work/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Apr 10 20:44:18 2012
@@ -1 +1 @@
-/lldb/trunk:154224-154450
+/lldb/trunk:154224-154458
Modified: lldb/branches/lldb-platform-work/include/lldb/Host/Mutex.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/include/lldb/Host/Mutex.h?rev=154471&r1=154470&r2=154471&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/include/lldb/Host/Mutex.h (original)
+++ lldb/branches/lldb-platform-work/include/lldb/Host/Mutex.h Tue Apr 10 20:44:18 2012
@@ -105,7 +105,7 @@
/// non-NULL.
//--------------------------------------------------------------
void
- Reset(pthread_mutex_t *mutex = NULL);
+ Lock (pthread_mutex_t *mutex);
//--------------------------------------------------------------
/// Change the contained mutex only if the mutex can be locked.
@@ -125,6 +125,9 @@
bool
TryLock (pthread_mutex_t *mutex);
+ void
+ Unlock ();
+
protected:
//--------------------------------------------------------------
/// Member variables
Modified: lldb/branches/lldb-platform-work/include/lldb/Host/ReadWriteLock.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/include/lldb/Host/ReadWriteLock.h?rev=154471&r1=154470&r2=154471&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/include/lldb/Host/ReadWriteLock.h (original)
+++ lldb/branches/lldb-platform-work/include/lldb/Host/ReadWriteLock.h Tue Apr 10 20:44:18 2012
@@ -91,6 +91,13 @@
{
}
+ ReadLocker (ReadWriteLock &lock) :
+ m_lock (NULL)
+ {
+ Lock(&lock);
+ }
+
+
ReadLocker (ReadWriteLock *lock) :
m_lock (NULL)
{
@@ -164,11 +171,17 @@
m_lock (NULL)
{
}
-
+
+ WriteLocker (ReadWriteLock &lock) :
+ m_lock (NULL)
+ {
+ Lock(&lock);
+ }
+
WriteLocker (ReadWriteLock *lock) :
- m_lock (lock)
+ m_lock (NULL)
{
- Lock();
+ Lock(lock);
}
~WriteLocker()
@@ -177,17 +190,30 @@
}
void
- Lock ()
+ Lock (ReadWriteLock *lock)
{
if (m_lock)
- m_lock->WriteLock();
+ {
+ if (m_lock == lock)
+ return; // We already have this lock locked
+ else
+ Unlock();
+ }
+ if (lock)
+ {
+ lock->WriteLock();
+ m_lock = lock;
+ }
}
void
Unlock ()
{
if (m_lock)
+ {
m_lock->WriteUnlock();
+ m_lock = NULL;
+ }
}
protected:
Modified: lldb/branches/lldb-platform-work/source/API/SBCommandInterpreter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/API/SBCommandInterpreter.cpp?rev=154471&r1=154470&r2=154471&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/API/SBCommandInterpreter.cpp (original)
+++ lldb/branches/lldb-platform-work/source/API/SBCommandInterpreter.cpp Tue Apr 10 20:44:18 2012
@@ -93,7 +93,7 @@
TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget());
Mutex::Locker api_locker;
if (target_sp)
- api_locker.Reset(target_sp->GetAPIMutex().GetMutex());
+ api_locker.Lock(target_sp->GetAPIMutex().GetMutex());
m_opaque_ptr->HandleCommand (command_line, add_to_history, result.ref());
}
else
@@ -238,7 +238,7 @@
TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget());
Mutex::Locker api_locker;
if (target_sp)
- api_locker.Reset(target_sp->GetAPIMutex().GetMutex());
+ api_locker.Lock(target_sp->GetAPIMutex().GetMutex());
m_opaque_ptr->SourceInitFile (false, result.ref());
}
else
@@ -263,7 +263,7 @@
TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget());
Mutex::Locker api_locker;
if (target_sp)
- api_locker.Reset(target_sp->GetAPIMutex().GetMutex());
+ api_locker.Lock(target_sp->GetAPIMutex().GetMutex());
m_opaque_ptr->SourceInitFile (true, result.ref());
}
else
Modified: lldb/branches/lldb-platform-work/source/API/SBDebugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/API/SBDebugger.cpp?rev=154471&r1=154470&r2=154471&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/API/SBDebugger.cpp (original)
+++ lldb/branches/lldb-platform-work/source/API/SBDebugger.cpp Tue Apr 10 20:44:18 2012
@@ -308,7 +308,7 @@
TargetSP target_sp (m_opaque_sp->GetSelectedTarget());
Mutex::Locker api_locker;
if (target_sp)
- api_locker.Reset(target_sp->GetAPIMutex().GetMutex());
+ api_locker.Lock(target_sp->GetAPIMutex().GetMutex());
SBCommandInterpreter sb_interpreter(GetCommandInterpreter ());
SBCommandReturnObject result;
@@ -830,7 +830,7 @@
TargetSP target_sp (m_opaque_sp->GetSelectedTarget());
Mutex::Locker api_locker;
if (target_sp)
- api_locker.Reset(target_sp->GetAPIMutex().GetMutex());
+ api_locker.Lock(target_sp->GetAPIMutex().GetMutex());
InputReaderSP reader_sp(*reader);
m_opaque_sp->PushInputReader (reader_sp);
}
Modified: lldb/branches/lldb-platform-work/source/API/SBFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/API/SBFunction.cpp?rev=154471&r1=154470&r2=154471&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/API/SBFunction.cpp (original)
+++ lldb/branches/lldb-platform-work/source/API/SBFunction.cpp Tue Apr 10 20:44:18 2012
@@ -130,7 +130,7 @@
TargetSP target_sp (target.GetSP());
if (target_sp)
{
- api_locker.Reset (target_sp->GetAPIMutex().GetMutex());
+ api_locker.Lock (target_sp->GetAPIMutex().GetMutex());
target_sp->CalculateExecutionContext (exe_ctx);
exe_ctx.SetProcessSP(target_sp->GetProcessSP());
}
Modified: lldb/branches/lldb-platform-work/source/API/SBInstruction.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/API/SBInstruction.cpp?rev=154471&r1=154470&r2=154471&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/API/SBInstruction.cpp (original)
+++ lldb/branches/lldb-platform-work/source/API/SBInstruction.cpp Tue Apr 10 20:44:18 2012
@@ -78,7 +78,7 @@
TargetSP target_sp (target.GetSP());
if (target_sp)
{
- api_locker.Reset (target_sp->GetAPIMutex().GetMutex());
+ api_locker.Lock (target_sp->GetAPIMutex().GetMutex());
target_sp->CalculateExecutionContext (exe_ctx);
exe_ctx.SetProcessSP(target_sp->GetProcessSP());
}
@@ -97,7 +97,7 @@
TargetSP target_sp (target.GetSP());
if (target_sp)
{
- api_locker.Reset (target_sp->GetAPIMutex().GetMutex());
+ api_locker.Lock (target_sp->GetAPIMutex().GetMutex());
target_sp->CalculateExecutionContext (exe_ctx);
exe_ctx.SetProcessSP(target_sp->GetProcessSP());
}
@@ -116,7 +116,7 @@
TargetSP target_sp (target.GetSP());
if (target_sp)
{
- api_locker.Reset (target_sp->GetAPIMutex().GetMutex());
+ api_locker.Lock (target_sp->GetAPIMutex().GetMutex());
target_sp->CalculateExecutionContext (exe_ctx);
exe_ctx.SetProcessSP(target_sp->GetProcessSP());
}
Modified: lldb/branches/lldb-platform-work/source/API/SBSymbol.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/API/SBSymbol.cpp?rev=154471&r1=154470&r2=154471&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/API/SBSymbol.cpp (original)
+++ lldb/branches/lldb-platform-work/source/API/SBSymbol.cpp Tue Apr 10 20:44:18 2012
@@ -126,7 +126,7 @@
TargetSP target_sp (target.GetSP());
if (target_sp)
{
- api_locker.Reset (target_sp->GetAPIMutex().GetMutex());
+ api_locker.Lock (target_sp->GetAPIMutex().GetMutex());
target_sp->CalculateExecutionContext (exe_ctx);
}
if (m_opaque_ptr->ValueIsAddress())
Modified: lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointList.cpp?rev=154471&r1=154470&r2=154471&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointList.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointList.cpp Tue Apr 10 20:44:18 2012
@@ -223,5 +223,5 @@
void
BreakpointList::GetListMutex (Mutex::Locker &locker)
{
- return locker.Reset (m_mutex.GetMutex());
+ return locker.Lock (m_mutex.GetMutex());
}
Modified: lldb/branches/lldb-platform-work/source/Breakpoint/WatchpointList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Breakpoint/WatchpointList.cpp?rev=154471&r1=154470&r2=154471&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Breakpoint/WatchpointList.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Breakpoint/WatchpointList.cpp Tue Apr 10 20:44:18 2012
@@ -273,5 +273,5 @@
void
WatchpointList::GetListMutex (Mutex::Locker &locker)
{
- return locker.Reset (m_mutex.GetMutex());
+ return locker.Lock (m_mutex.GetMutex());
}
Modified: lldb/branches/lldb-platform-work/source/Commands/CommandObjectTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Commands/CommandObjectTarget.cpp?rev=154471&r1=154470&r2=154471&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Commands/CommandObjectTarget.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Commands/CommandObjectTarget.cpp Tue Apr 10 20:44:18 2012
@@ -2839,7 +2839,7 @@
if (use_global_module_list)
{
- locker.Reset (Module::GetAllocationModuleCollectionMutex()->GetMutex());
+ locker.Lock (Module::GetAllocationModuleCollectionMutex()->GetMutex());
num_modules = Module::GetNumberAllocatedModules();
}
else
Modified: lldb/branches/lldb-platform-work/source/Core/Listener.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/Listener.cpp?rev=154471&r1=154470&r2=154471&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/Listener.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/Listener.cpp Tue Apr 10 20:44:18 2012
@@ -303,7 +303,7 @@
// Unlock the event queue here. We've removed this event and are about to return
// it so it should be okay to get the next event off the queue here - and it might
// be useful to do that in the "DoOnRemoval".
- lock.Reset();
+ lock.Unlock();
event_sp->DoOnRemoval();
return true;
}
Modified: lldb/branches/lldb-platform-work/source/Core/ModuleList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/ModuleList.cpp?rev=154471&r1=154470&r2=154471&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/ModuleList.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/ModuleList.cpp Tue Apr 10 20:44:18 2012
@@ -118,7 +118,7 @@
if (mandatory)
{
- locker.Reset (m_modules_mutex.GetMutex());
+ locker.Lock (m_modules_mutex.GetMutex());
}
else
{
Modified: lldb/branches/lldb-platform-work/source/Host/common/Mutex.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Host/common/Mutex.cpp?rev=154471&r1=154470&r2=154471&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Host/common/Mutex.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Host/common/Mutex.cpp Tue Apr 10 20:44:18 2012
@@ -50,10 +50,9 @@
// mutex owned by "m" and locks it.
//----------------------------------------------------------------------
Mutex::Locker::Locker (Mutex& m) :
- m_mutex_ptr(m.GetMutex())
+ m_mutex_ptr(NULL)
{
- if (m_mutex_ptr)
- Mutex::Lock (m_mutex_ptr);
+ Lock (m.GetMutex());
}
//----------------------------------------------------------------------
@@ -63,10 +62,10 @@
// mutex owned by "m" and locks it.
//----------------------------------------------------------------------
Mutex::Locker::Locker (Mutex* m) :
- m_mutex_ptr(m ? m->GetMutex() : NULL)
+ m_mutex_ptr(NULL)
{
- if (m_mutex_ptr)
- Mutex::Lock (m_mutex_ptr);
+ if (m)
+ Lock (m->GetMutex());
}
//----------------------------------------------------------------------
@@ -75,10 +74,10 @@
// This will create a scoped mutex locking object that locks "mutex"
//----------------------------------------------------------------------
Mutex::Locker::Locker (pthread_mutex_t *mutex_ptr) :
- m_mutex_ptr(mutex_ptr)
+ m_mutex_ptr (NULL)
{
if (m_mutex_ptr)
- Mutex::Lock (m_mutex_ptr);
+ Lock (m_mutex_ptr);
}
//----------------------------------------------------------------------
@@ -88,7 +87,7 @@
//----------------------------------------------------------------------
Mutex::Locker::~Locker ()
{
- Reset();
+ Unlock();
}
//----------------------------------------------------------------------
@@ -96,18 +95,29 @@
// mutex) and lock the new "mutex" object if it is non-NULL.
//----------------------------------------------------------------------
void
-Mutex::Locker::Reset (pthread_mutex_t *mutex_ptr)
+Mutex::Locker::Lock (pthread_mutex_t *mutex_ptr)
{
// We already have this mutex locked or both are NULL...
if (m_mutex_ptr == mutex_ptr)
return;
- if (m_mutex_ptr)
- Mutex::Unlock (m_mutex_ptr);
+ Unlock ();
- m_mutex_ptr = mutex_ptr;
- if (m_mutex_ptr)
+ if (mutex_ptr)
+ {
+ m_mutex_ptr = mutex_ptr;
Mutex::Lock (m_mutex_ptr);
+ }
+}
+
+void
+Mutex::Locker::Unlock ()
+{
+ if (m_mutex_ptr)
+ {
+ Mutex::Unlock (m_mutex_ptr);
+ m_mutex_ptr = NULL;
+ }
}
bool
@@ -115,9 +125,9 @@
{
// We already have this mutex locked!
if (m_mutex_ptr == mutex_ptr)
- return true;
+ return m_mutex_ptr != NULL;
- Reset ();
+ Unlock ();
if (mutex_ptr)
{
Modified: lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp?rev=154471&r1=154470&r2=154471&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp Tue Apr 10 20:44:18 2012
@@ -155,6 +155,18 @@
#endif
}
+lldb::user_id_t
+PlatformMacOSX::GetFileSize (const FileSpec& file_spec)
+{
+ if (IsHost())
+ {
+ return Host::GetFileSize(file_spec);
+ }
+ if (IsRemote() && m_remote_platform_sp)
+ return m_remote_platform_sp->GetFileSize(file_spec);
+ return Platform::GetFileSize(file_spec);
+}
+
lldb_private::Error
PlatformMacOSX::GetFile (const lldb_private::FileSpec& source /* remote file path */,
const lldb_private::FileSpec& destination /* local file path */)
Modified: lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformMacOSX.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformMacOSX.h?rev=154471&r1=154470&r2=154471&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformMacOSX.h (original)
+++ lldb/branches/lldb-platform-work/source/Plugins/Platform/MacOSX/PlatformMacOSX.h Tue Apr 10 20:44:18 2012
@@ -81,6 +81,9 @@
const lldb_private::UUID *uuid_ptr,
lldb_private::FileSpec &local_file);
+ lldb::user_id_t
+ GetFileSize (const lldb_private::FileSpec& file_spec);
+
lldb_private::Error
GetFile (const lldb_private::FileSpec& source,
const lldb_private::FileSpec& destination);
Modified: lldb/branches/lldb-platform-work/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp?rev=154471&r1=154470&r2=154471&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp Tue Apr 10 20:44:18 2012
@@ -151,7 +151,7 @@
}
bool
-CommunicationKDP::TryLockSequenceMutex (Mutex::Locker& locker)
+CommunicationKDP::GetSequenceMutex (Mutex::Locker& locker)
{
return locker.TryLock (m_sequence_mutex.GetMutex());
}
Modified: lldb/branches/lldb-platform-work/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h?rev=154471&r1=154470&r2=154471&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h (original)
+++ lldb/branches/lldb-platform-work/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h Tue Apr 10 20:44:18 2012
@@ -102,7 +102,7 @@
uint32_t usec);
bool
- TryLockSequenceMutex(lldb_private::Mutex::Locker& locker);
+ GetSequenceMutex(lldb_private::Mutex::Locker& locker);
bool
CheckForPacket (const uint8_t *src,
Modified: lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp?rev=154471&r1=154470&r2=154471&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp Tue Apr 10 20:44:18 2012
@@ -162,21 +162,6 @@
}
size_t
-GDBRemoteCommunication::SendPacket (lldb_private::StreamString &payload)
-{
- Mutex::Locker locker(m_sequence_mutex);
- const std::string &p (payload.GetString());
- return SendPacketNoLock (p.c_str(), p.size());
-}
-
-size_t
-GDBRemoteCommunication::SendPacket (const char *payload)
-{
- Mutex::Locker locker(m_sequence_mutex);
- return SendPacketNoLock (payload, ::strlen (payload));
-}
-
-size_t
GDBRemoteCommunication::SendPacket (const char *payload, size_t payload_length)
{
Mutex::Locker locker(m_sequence_mutex);
@@ -238,15 +223,20 @@
GDBRemoteCommunication::GetAck ()
{
StringExtractorGDBRemote packet;
- if (WaitForPacketWithTimeoutMicroSeconds (packet, GetPacketTimeoutInMicroSeconds ()) == 1)
+ if (WaitForPacketWithTimeoutMicroSecondsNoLock (packet, GetPacketTimeoutInMicroSeconds ()) == 1)
return packet.GetChar();
return 0;
}
bool
-GDBRemoteCommunication::TryLockSequenceMutex (Mutex::Locker& locker)
+GDBRemoteCommunication::GetSequenceMutex (Mutex::Locker& locker, uint32_t usec_timeout)
{
- return locker.TryLock (m_sequence_mutex.GetMutex());
+ if (usec_timeout == 0)
+ return locker.TryLock (m_sequence_mutex.GetMutex());
+
+ // Wait for the lock
+ locker.Lock (m_sequence_mutex.GetMutex());
+ return true;
}
@@ -257,13 +247,6 @@
}
size_t
-GDBRemoteCommunication::WaitForPacketWithTimeoutMicroSeconds (StringExtractorGDBRemote &packet, uint32_t timeout_usec)
-{
- Mutex::Locker locker(m_sequence_mutex);
- return WaitForPacketWithTimeoutMicroSecondsNoLock (packet, timeout_usec);
-}
-
-size_t
GDBRemoteCommunication::WaitForPacketWithTimeoutMicroSecondsNoLock (StringExtractorGDBRemote &packet, uint32_t timeout_usec)
{
uint8_t buffer[8192];
Modified: lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h?rev=154471&r1=154470&r2=154471&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h (original)
+++ lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h Tue Apr 10 20:44:18 2012
@@ -45,21 +45,6 @@
virtual
~GDBRemoteCommunication();
- size_t
- SendPacket (const char *payload);
-
- size_t
- SendPacket (const char *payload,
- size_t payload_length);
-
- size_t
- SendPacket (lldb_private::StreamString &response);
-
- // Wait for a packet within 'nsec' seconds
- size_t
- WaitForPacketWithTimeoutMicroSeconds (StringExtractorGDBRemote &response,
- uint32_t usec);
-
char
GetAck ();
@@ -74,7 +59,7 @@
size_t payload_length);
bool
- TryLockSequenceMutex(lldb_private::Mutex::Locker& locker);
+ GetSequenceMutex (lldb_private::Mutex::Locker& locker, uint32_t usec_timeout);
bool
CheckForPacket (const uint8_t *src,
@@ -260,6 +245,10 @@
};
size_t
+ SendPacket (const char *payload,
+ size_t payload_length);
+
+ size_t
SendPacketNoLock (const char *payload,
size_t payload_length);
Modified: lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp?rev=154471&r1=154470&r2=154471&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Tue Apr 10 20:44:18 2012
@@ -260,7 +260,7 @@
Mutex::Locker locker;
LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PROCESS));
size_t response_len = 0;
- if (TryLockSequenceMutex (locker))
+ if (GetSequenceMutex (locker, 0))
{
if (SendPacketNoLock (payload, payload_length))
response_len = WaitForPacketWithTimeoutMicroSecondsNoLock (response, GetPacketTimeoutInMicroSeconds ());
@@ -362,30 +362,6 @@
return response_len;
}
-//template<typename _Tp>
-//class ScopedValueChanger
-//{
-//public:
-// // Take a value reference and the value to assign it to when this class
-// // instance goes out of scope.
-// ScopedValueChanger (_Tp &value_ref, _Tp value) :
-// m_value_ref (value_ref),
-// m_value (value)
-// {
-// }
-//
-// // This object is going out of scope, change the value pointed to by
-// // m_value_ref to the value we got during construction which was stored in
-// // m_value;
-// ~ScopedValueChanger ()
-// {
-// m_value_ref = m_value;
-// }
-//protected:
-// _Tp &m_value_ref; // A reference to the value we will change when this object destructs
-// _Tp m_value; // The value to assign to m_value_ref when this goes out of scope.
-//};
-
StateType
GDBRemoteCommunicationClient::SendContinuePacketAndWaitForResponse
(
@@ -416,7 +392,7 @@
{
if (log)
log->Printf ("GDBRemoteCommunicationClient::%s () sending continue packet: %s", __FUNCTION__, continue_packet.c_str());
- if (SendPacket(continue_packet.c_str(), continue_packet.size()) == 0)
+ if (SendPacketNoLock(continue_packet.c_str(), continue_packet.size()) == 0)
state = eStateInvalid;
m_private_is_running.SetValue (true, eBroadcastAlways);
@@ -427,7 +403,7 @@
if (log)
log->Printf ("GDBRemoteCommunicationClient::%s () WaitForPacket(%s)", __FUNCTION__, continue_packet.c_str());
- if (WaitForPacketWithTimeoutMicroSeconds (response, UINT32_MAX))
+ if (WaitForPacketWithTimeoutMicroSecondsNoLock(response, UINT32_MAX))
{
if (response.Empty())
state = eStateInvalid;
@@ -648,7 +624,7 @@
return false;
}
-// This function takes a mutex locker as a parameter in case the TryLockSequenceMutex
+// This function takes a mutex locker as a parameter in case the GetSequenceMutex
// actually succeeds. If it doesn't succeed in acquiring the sequence mutex
// (the expected result), then it will send the halt packet. If it does succeed
// then the caller that requested the interrupt will want to keep the sequence
@@ -673,7 +649,12 @@
if (IsRunning())
{
// Only send an interrupt if our debugserver is running...
- if (TryLockSequenceMutex (locker) == false)
+ if (GetSequenceMutex (locker, 0))
+ {
+ if (log)
+ log->Printf ("SendInterrupt () - got sequence mutex without having to interrupt");
+ }
+ else
{
// Someone has the mutex locked waiting for a response or for the
// inferior to stop, so send the interrupt on the down low...
@@ -719,11 +700,6 @@
}
return false;
}
- else
- {
- if (log)
- log->Printf ("SendInterrupt () - got sequence mutex without having to interrupt");
- }
}
else
{
@@ -1175,6 +1151,12 @@
return false;
}
+bool
+GDBRemoteCommunicationClient::Detach ()
+{
+ return SendPacket ("D", 1) > 0;
+}
+
Error
GDBRemoteCommunicationClient::GetMemoryRegionInfo (lldb::addr_t addr,
lldb_private::MemoryRegionInfo ®ion_info)
@@ -1862,7 +1844,7 @@
Mutex::Locker locker;
thread_ids.clear();
- if (TryLockSequenceMutex (locker))
+ if (GetSequenceMutex (locker, 0))
{
sequence_mutex_unavailable = false;
StringExtractorGDBRemote response;
@@ -1896,6 +1878,21 @@
return thread_ids.size();
}
+lldb::addr_t
+GDBRemoteCommunicationClient::GetShlibInfoAddr()
+{
+ if (!IsRunning())
+ {
+ StringExtractorGDBRemote response;
+ if (SendPacketAndWaitForResponse("qShlibInfoAddr", ::strlen ("qShlibInfoAddr"), response, false))
+ {
+ if (response.IsNormalResponse())
+ return response.GetHexMaxU64(false, LLDB_INVALID_ADDRESS);
+ }
+ }
+ return LLDB_INVALID_ADDRESS;
+}
+
uint32_t
GDBRemoteCommunicationClient::RunShellCommand (const std::string &command_line)
{
Modified: lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h?rev=154471&r1=154470&r2=154471&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h (original)
+++ lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h Tue Apr 10 20:44:18 2012
@@ -199,6 +199,9 @@
bool
DeallocateMemory (lldb::addr_t addr);
+ bool
+ Detach ();
+
lldb_private::Error
GetMemoryRegionInfo (lldb::addr_t addr,
lldb_private::MemoryRegionInfo &range_info);
@@ -232,6 +235,9 @@
bool
GetHostname (std::string &s);
+ lldb::addr_t
+ GetShlibInfoAddr();
+
bool
GetSupportsThreadSuffix ();
Modified: lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp?rev=154471&r1=154470&r2=154471&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp Tue Apr 10 20:44:18 2012
@@ -86,7 +86,7 @@
bool &quit)
{
StringExtractorGDBRemote packet;
- if (WaitForPacketWithTimeoutMicroSeconds(packet, timeout_usec))
+ if (WaitForPacketWithTimeoutMicroSecondsNoLock (packet, timeout_usec))
{
const StringExtractorGDBRemote::ServerPacketType packet_type = packet.GetServerPacketType ();
switch (packet_type)
@@ -200,7 +200,7 @@
GDBRemoteCommunicationServer::SendUnimplementedResponse (const char *)
{
// TODO: Log the packet we aren't handling...
- return SendPacket ("");
+ return SendPacketNoLock ("", 0);
}
size_t
@@ -209,14 +209,14 @@
char packet[16];
int packet_len = ::snprintf (packet, sizeof(packet), "E%2.2x", err);
assert (packet_len < sizeof(packet));
- return SendPacket (packet, packet_len);
+ return SendPacketNoLock (packet, packet_len);
}
size_t
GDBRemoteCommunicationServer::SendOKResponse ()
{
- return SendPacket ("OK");
+ return SendPacketNoLock ("OK", 2);
}
bool
@@ -291,7 +291,7 @@
response.PutChar(';');
}
- return SendPacket (response) > 0;
+ return SendPacketNoLock (response.GetData(), response.GetSize()) > 0;
}
static void
@@ -330,7 +330,7 @@
{
StreamString response;
CreateProcessInfoResponse (proc_info, response);
- return SendPacket (response);
+ return SendPacketNoLock (response.GetData(), response.GetSize());
}
}
return SendErrorResponse (1);
@@ -445,7 +445,7 @@
StreamString response;
CreateProcessInfoResponse (m_proc_infos.GetProcessInfoAtIndex(m_proc_infos_index), response);
++m_proc_infos_index;
- return SendPacket (response);
+ return SendPacketNoLock (response.GetData(), response.GetSize());
}
return SendErrorResponse (4);
}
@@ -463,7 +463,7 @@
{
StreamString response;
response.PutCStringAsRawHex8 (name.c_str());
- return SendPacket (response);
+ return SendPacketNoLock (response.GetData(), response.GetSize());
}
}
return SendErrorResponse (5);
@@ -483,7 +483,7 @@
{
StreamString response;
response.PutCStringAsRawHex8 (name.c_str());
- return SendPacket (response);
+ return SendPacketNoLock (response.GetData(), response.GetSize());
}
}
return SendErrorResponse (6);
@@ -520,7 +520,7 @@
bytes_left = 0;
}
}
- return SendPacket (response);
+ return SendPacketNoLock (response.GetData(), response.GetSize());
}
}
return SendErrorResponse (7);
@@ -679,7 +679,7 @@
m_process_launch_info.Clear();
}
}
- return SendPacket (response);
+ return SendPacketNoLock (response.GetData(), response.GetSize());
}
bool
@@ -732,7 +732,7 @@
const int response_len = ::snprintf (response, sizeof(response), "pid:%llu;port:%u;", debugserver_pid, port);
assert (response_len < sizeof(response));
//m_port_to_pid_map[port] = debugserver_launch_info.GetProcessID();
- success = SendPacket (response, response_len) > 0;
+ success = SendPacketNoLock (response, response_len) > 0;
}
}
::unlink (unix_socket_name);
@@ -758,7 +758,7 @@
StreamString response;
response.PutChar('E');
response.PutCString(m_process_launch_error.AsCString("<unknown error>"));
- return SendPacket (response);
+ return SendPacketNoLock (response.GetData(), response.GetSize());
}
bool
@@ -864,7 +864,7 @@
uint32_t retcode = Host::RunProgramAndGetExitCode(FileSpec(path.c_str(),false));
StreamString response;
response.PutHex32(retcode);
- SendPacket(response);
+ SendPacketNoLock(response.GetData(), response.GetSize());
return true;
}
@@ -880,7 +880,7 @@
uint32_t retcode = Host::MakeDirectory(path.c_str(),mode);
StreamString response;
response.PutHex32(retcode);
- SendPacket(response);
+ SendPacketNoLock(response.GetData(), response.GetSize());
return true;
}
@@ -907,7 +907,7 @@
response.PutChar(',');
response.PutHex64(retcode); // TODO: replace with Host::GetSyswideErrorCode()
}
- SendPacket(response);
+ SendPacketNoLock(response.GetData(), response.GetSize());
return true;
}
@@ -925,7 +925,7 @@
response.PutChar(',');
response.PutHex32(retcode); // TODO: replace with Host::GetSyswideErrorCode()
}
- SendPacket(response);
+ SendPacketNoLock(response.GetData(), response.GetSize());
return true;
}
@@ -947,7 +947,7 @@
response.PutHex32(UINT32_MAX);
response.PutChar(',');
response.PutHex32(UINT32_MAX); // TODO: replace with Host::GetSyswideErrorCode()
- SendPacket(response);
+ SendPacketNoLock(response.GetData(), response.GetSize());
return true;
}
std::string buffer(count, 0);
@@ -964,7 +964,7 @@
response.PutChar(';');
response.PutEscapedBytes(&buffer[0], retcode);
}
- SendPacket(response);
+ SendPacketNoLock(response.GetData(), response.GetSize());
return true;
}
@@ -989,7 +989,7 @@
response.PutChar(',');
response.PutHex32(retcode); // TODO: replace with Host::GetSyswideErrorCode()
}
- SendPacket(response);
+ SendPacketNoLock(response.GetData(), response.GetSize());
return true;
}
@@ -1012,6 +1012,6 @@
response.PutChar(',');
response.PutHex64(retcode); // TODO: replace with Host::GetSyswideErrorCode()
}
- SendPacket(response);
+ SendPacketNoLock(response.GetData(), response.GetSize());
return true;
}
Modified: lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp?rev=154471&r1=154470&r2=154471&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp Tue Apr 10 20:44:18 2012
@@ -181,7 +181,7 @@
if (!m_reg_valid[reg])
{
Mutex::Locker locker;
- if (gdb_comm.TryLockSequenceMutex (locker))
+ if (gdb_comm.GetSequenceMutex (locker, 0))
{
const bool thread_suffix_supported = gdb_comm.GetThreadSuffixSupported();
ProcessSP process_sp (m_thread.GetProcess());
@@ -331,7 +331,7 @@
m_reg_data.GetByteOrder())) // dst byte order
{
Mutex::Locker locker;
- if (gdb_comm.TryLockSequenceMutex (locker))
+ if (gdb_comm.GetSequenceMutex (locker, 0))
{
const bool thread_suffix_supported = gdb_comm.GetThreadSuffixSupported();
ProcessSP process_sp (m_thread.GetProcess());
@@ -440,7 +440,7 @@
StringExtractorGDBRemote response;
Mutex::Locker locker;
- if (gdb_comm.TryLockSequenceMutex (locker))
+ if (gdb_comm.GetSequenceMutex (locker, 0))
{
char packet[32];
const bool thread_suffix_supported = gdb_comm.GetThreadSuffixSupported();
@@ -496,7 +496,7 @@
StringExtractorGDBRemote response;
Mutex::Locker locker;
- if (gdb_comm.TryLockSequenceMutex (locker))
+ if (gdb_comm.GetSequenceMutex (locker, 0))
{
const bool thread_suffix_supported = gdb_comm.GetThreadSuffixSupported();
ProcessSP process_sp (m_thread.GetProcess());
Modified: lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=154471&r1=154470&r2=154471&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Tue Apr 10 20:44:18 2012
@@ -1621,10 +1621,10 @@
m_thread_list.DiscardThreadPlans();
- size_t response_size = m_gdb_comm.SendPacket ("D", 1);
+ bool success = m_gdb_comm.Detach ();
if (log)
{
- if (response_size)
+ if (success)
log->PutCString ("ProcessGDBRemote::DoDetach() detach packet sent successfully");
else
log->PutCString ("ProcessGDBRemote::DoDetach() detach packet send failed");
@@ -1691,16 +1691,7 @@
addr_t
ProcessGDBRemote::GetImageInfoAddress()
{
- if (!m_gdb_comm.IsRunning())
- {
- StringExtractorGDBRemote response;
- if (m_gdb_comm.SendPacketAndWaitForResponse("qShlibInfoAddr", ::strlen ("qShlibInfoAddr"), response, false))
- {
- if (response.IsNormalResponse())
- return response.GetHexMaxU64(false, LLDB_INVALID_ADDRESS);
- }
- }
- return LLDB_INVALID_ADDRESS;
+ return m_gdb_comm.GetShlibInfoAddr();
}
//------------------------------------------------------------------
More information about the lldb-commits
mailing list