diff options
author | Greg Clayton <gclayton@apple.com> | 2012-04-11 00:24:49 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2012-04-11 00:24:49 +0000 |
commit | 37a0a24a5fdc05e18770661b4ee13a91893dee1a (patch) | |
tree | 52098bf87fb35019b5b41d9af33dd508739a8bfb /lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp | |
parent | ad66de155bbdb01bc2e0ece769bf150203bd1a63 (diff) | |
download | bcm5719-llvm-37a0a24a5fdc05e18770661b4ee13a91893dee1a.tar.gz bcm5719-llvm-37a0a24a5fdc05e18770661b4ee13a91893dee1a.zip |
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.
llvm-svn: 154458
Diffstat (limited to 'lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp')
-rw-r--r-- | lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp | 33 |
1 files changed, 8 insertions, 25 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp index caa70258e30..1535fd41260 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp @@ -158,21 +158,6 @@ GDBRemoteCommunication::SendNack () } 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 @@ char 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 @@ GDBRemoteCommunication::WaitForNotRunningPrivate (const TimeValue *timeout_ptr) } 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]; |