No functionality changes, mostly cleanup.
Cleaned up the Mutex::Locker and the ReadWriteLock classes a bit.
Also cleaned up the GDBRemoteCommunication class to not have so many packet functions. Used the "NoLock" versions of send/receive packet functions when possible for a bit of performance.
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@154458 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
index caa7025..1535fd4 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -158,21 +158,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);
@@ -234,15 +219,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;
}
@@ -253,13 +243,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];