aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2011-05-20 23:38:13 +0000
committerGreg Clayton <gclayton@apple.com>2011-05-20 23:38:13 +0000
commitadc00cb2ba7b0dc51dab45b4440f504e6e049369 (patch)
tree4ab51d3b2fc83db800f2c84961516451ab842b9c /lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
parentd7ee0fcac992a0eced1902b643c1eca91aba565e (diff)
downloadllvm-adc00cb2ba7b0dc51dab45b4440f504e6e049369.zip
llvm-adc00cb2ba7b0dc51dab45b4440f504e6e049369.tar.gz
llvm-adc00cb2ba7b0dc51dab45b4440f504e6e049369.tar.bz2
Centralize the code that gathers the thread ID list from the remote GDB
server so that it happens in command sequence where no other packets can sneak between. llvm-svn: 131769
Diffstat (limited to 'lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp')
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
index 314d51f..d1c51ec 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -1649,3 +1649,48 @@ GDBRemoteCommunicationClient::SendGDBStoppointTypePacket (GDBStoppointType type,
return UINT8_MAX;
}
+
+size_t
+GDBRemoteCommunicationClient::GetCurrentThreadIDs (std::vector<lldb::tid_t> &thread_ids,
+ bool &sequence_mutex_unavailable)
+{
+ Mutex::Locker locker;
+ thread_ids.clear();
+
+ if (GetSequenceMutex (locker))
+ {
+ sequence_mutex_unavailable = false;
+ StringExtractorGDBRemote response;
+
+ TimeValue timeout_time;
+ timeout_time = TimeValue::Now();
+ timeout_time.OffsetWithSeconds (m_packet_timeout*2); // We will always send at least two packets here...
+
+ for (SendPacketNoLock ("qfThreadInfo", strlen("qfThreadInfo")) && WaitForPacketNoLock (response, &timeout_time);
+ response.IsNormalResponse();
+ SendPacketNoLock ("qsThreadInfo", strlen("qsThreadInfo")) && WaitForPacketNoLock (response, &timeout_time))
+ {
+ char ch = response.GetChar();
+ if (ch == 'l')
+ break;
+ if (ch == 'm')
+ {
+ do
+ {
+ tid_t tid = response.GetHexMaxU32(false, LLDB_INVALID_THREAD_ID);
+
+ if (tid != LLDB_INVALID_THREAD_ID)
+ {
+ thread_ids.push_back (tid);
+ }
+ ch = response.GetChar(); // Skip the command separator
+ } while (ch == ','); // Make sure we got a comma separator
+ }
+ }
+ }
+ else
+ {
+ sequence_mutex_unavailable = true;
+ }
+ return thread_ids.size();
+}