Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1 | //===-- GDBRemoteCommunication.h --------------------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #ifndef liblldb_GDBRemoteCommunication_h_ |
| 11 | #define liblldb_GDBRemoteCommunication_h_ |
| 12 | |
| 13 | // C Includes |
| 14 | // C++ Includes |
| 15 | #include <list> |
| 16 | #include <string> |
Ewan Crawford | fab40d3 | 2015-06-16 15:50:18 +0000 | [diff] [blame] | 17 | #include <queue> |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 18 | |
| 19 | // Other libraries and framework includes |
| 20 | // Project includes |
Greg Clayton | c1422c1 | 2012-04-09 22:46:21 +0000 | [diff] [blame] | 21 | #include "lldb/lldb-public.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 22 | #include "lldb/Core/Communication.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 23 | #include "lldb/Core/Listener.h" |
Zachary Turner | 39de311 | 2014-09-09 20:54:56 +0000 | [diff] [blame] | 24 | #include "lldb/Host/HostThread.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 25 | #include "lldb/Host/Mutex.h" |
| 26 | #include "lldb/Host/Predicate.h" |
Peter Collingbourne | ba23ca0 | 2011-06-18 23:52:14 +0000 | [diff] [blame] | 27 | #include "lldb/Host/TimeValue.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 28 | |
Greg Clayton | c982c76 | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 29 | #include "Utility/StringExtractorGDBRemote.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 30 | |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 31 | namespace lldb_private { |
| 32 | namespace process_gdb_remote { |
| 33 | |
Chaoren Lin | 18fe640 | 2015-02-03 01:51:47 +0000 | [diff] [blame] | 34 | typedef enum |
| 35 | { |
| 36 | eStoppointInvalid = -1, |
| 37 | eBreakpointSoftware = 0, |
| 38 | eBreakpointHardware, |
| 39 | eWatchpointWrite, |
| 40 | eWatchpointRead, |
| 41 | eWatchpointReadWrite |
| 42 | } GDBStoppointType; |
| 43 | |
Jason Molenda | 91ffe0a | 2015-06-18 21:46:06 +0000 | [diff] [blame^] | 44 | enum class CompressionType |
| 45 | { |
| 46 | None = 0, // no compression |
| 47 | ZlibDeflate, // zlib's deflate compression scheme, requires zlib or Apple's libcompression |
| 48 | LZFSE, // an Apple compression scheme, requires Apple's libcompression |
| 49 | LZ4, // lz compression - called "lz4 raw" in libcompression terms, compat with https://code.google.com/p/lz4/ |
| 50 | LZMA, // Lempel–Ziv–Markov chain algorithm |
| 51 | }; |
| 52 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 53 | class ProcessGDBRemote; |
| 54 | |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 55 | class GDBRemoteCommunication : public Communication |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 56 | { |
| 57 | public: |
Greg Clayton | e521966 | 2010-12-03 06:02:24 +0000 | [diff] [blame] | 58 | enum |
| 59 | { |
Ewan Crawford | fab40d3 | 2015-06-16 15:50:18 +0000 | [diff] [blame] | 60 | eBroadcastBitRunPacketSent = kLoUserBroadcastBit, |
| 61 | eBroadcastBitGdbReadThreadGotNotify = kLoUserBroadcastBit << 1 // Sent when we received a notify packet. |
Greg Clayton | e521966 | 2010-12-03 06:02:24 +0000 | [diff] [blame] | 62 | }; |
Ewan Crawford | 9aa2da00 | 2015-05-27 14:12:34 +0000 | [diff] [blame] | 63 | |
| 64 | enum class PacketType |
| 65 | { |
| 66 | Invalid = 0, |
| 67 | Standard, |
| 68 | Notify |
| 69 | }; |
| 70 | |
Greg Clayton | 3dedae1 | 2013-12-06 21:45:27 +0000 | [diff] [blame] | 71 | enum class PacketResult |
| 72 | { |
| 73 | Success = 0, // Success |
| 74 | ErrorSendFailed, // Error sending the packet |
| 75 | ErrorSendAck, // Didn't get an ack back after sending a packet |
| 76 | ErrorReplyFailed, // Error getting the reply |
| 77 | ErrorReplyTimeout, // Timed out waiting for reply |
| 78 | ErrorReplyInvalid, // Got a reply but it wasn't valid for the packet that was sent |
| 79 | ErrorReplyAck, // Sending reply ack failed |
Steve Pucci | 5ae54ae | 2014-01-25 05:46:51 +0000 | [diff] [blame] | 80 | ErrorDisconnected, // We were disconnected |
| 81 | ErrorNoSequenceLock // We couldn't get the sequence lock for a multi-packet request |
Greg Clayton | 3dedae1 | 2013-12-06 21:45:27 +0000 | [diff] [blame] | 82 | }; |
Tamas Berghammer | 912800c | 2015-02-24 10:23:39 +0000 | [diff] [blame] | 83 | |
| 84 | // Class to change the timeout for a given scope and restore it to the original value when the |
| 85 | // created ScopedTimeout object got out of scope |
| 86 | class ScopedTimeout |
| 87 | { |
| 88 | public: |
| 89 | ScopedTimeout (GDBRemoteCommunication& gdb_comm, uint32_t timeout); |
| 90 | ~ScopedTimeout (); |
| 91 | |
| 92 | private: |
| 93 | GDBRemoteCommunication& m_gdb_comm; |
| 94 | uint32_t m_saved_timeout; |
| 95 | }; |
| 96 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 97 | //------------------------------------------------------------------ |
| 98 | // Constructors and Destructors |
| 99 | //------------------------------------------------------------------ |
Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 100 | GDBRemoteCommunication(const char *comm_name, |
Tamas Berghammer | e13c273 | 2015-02-11 10:29:30 +0000 | [diff] [blame] | 101 | const char *listener_name); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 102 | |
| 103 | virtual |
| 104 | ~GDBRemoteCommunication(); |
| 105 | |
Greg Clayton | 3dedae1 | 2013-12-06 21:45:27 +0000 | [diff] [blame] | 106 | PacketResult |
Greg Clayton | c574ede | 2011-03-10 02:26:48 +0000 | [diff] [blame] | 107 | GetAck (); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 108 | |
| 109 | size_t |
Greg Clayton | 6ed9594 | 2011-01-22 07:12:45 +0000 | [diff] [blame] | 110 | SendAck (); |
| 111 | |
| 112 | size_t |
| 113 | SendNack (); |
| 114 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 115 | char |
| 116 | CalculcateChecksum (const char *payload, |
| 117 | size_t payload_length); |
| 118 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 119 | bool |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 120 | GetSequenceMutex (Mutex::Locker& locker, const char *failure_message = NULL); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 121 | |
Ewan Crawford | 9aa2da00 | 2015-05-27 14:12:34 +0000 | [diff] [blame] | 122 | PacketType |
Greg Clayton | 73bf5db | 2011-06-17 01:22:15 +0000 | [diff] [blame] | 123 | CheckForPacket (const uint8_t *src, |
| 124 | size_t src_len, |
| 125 | StringExtractorGDBRemote &packet); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 126 | bool |
| 127 | IsRunning() const |
| 128 | { |
Greg Clayton | 4dc7228 | 2011-01-20 07:53:45 +0000 | [diff] [blame] | 129 | return m_public_is_running.GetValue(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 130 | } |
Greg Clayton | 6779606a | 2011-01-22 23:43:18 +0000 | [diff] [blame] | 131 | |
Greg Clayton | 1cb6496 | 2011-03-24 04:28:38 +0000 | [diff] [blame] | 132 | bool |
| 133 | GetSendAcks () |
| 134 | { |
| 135 | return m_send_acks; |
| 136 | } |
| 137 | |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 138 | //------------------------------------------------------------------ |
| 139 | // Client and server must implement these pure virtual functions |
| 140 | //------------------------------------------------------------------ |
| 141 | virtual bool |
| 142 | GetThreadSuffixSupported () = 0; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 143 | |
Greg Clayton | 576d883 | 2011-03-22 04:00:09 +0000 | [diff] [blame] | 144 | //------------------------------------------------------------------ |
| 145 | // Set the global packet timeout. |
| 146 | // |
| 147 | // For clients, this is the timeout that gets used when sending |
| 148 | // packets and waiting for responses. For servers, this might not |
| 149 | // get used, and if it doesn't this should be moved to the |
| 150 | // GDBRemoteCommunicationClient. |
| 151 | //------------------------------------------------------------------ |
Greg Clayton | c574ede | 2011-03-10 02:26:48 +0000 | [diff] [blame] | 152 | uint32_t |
| 153 | SetPacketTimeout (uint32_t packet_timeout) |
| 154 | { |
| 155 | const uint32_t old_packet_timeout = m_packet_timeout; |
| 156 | m_packet_timeout = packet_timeout; |
| 157 | return old_packet_timeout; |
| 158 | } |
Greg Clayton | 71fc2a3 | 2011-02-12 06:28:37 +0000 | [diff] [blame] | 159 | |
Greg Clayton | 73bf5db | 2011-06-17 01:22:15 +0000 | [diff] [blame] | 160 | uint32_t |
| 161 | GetPacketTimeoutInMicroSeconds () const |
| 162 | { |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 163 | return m_packet_timeout * TimeValue::MicroSecPerSec; |
Greg Clayton | 73bf5db | 2011-06-17 01:22:15 +0000 | [diff] [blame] | 164 | } |
Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 165 | //------------------------------------------------------------------ |
| 166 | // Start a debugserver instance on the current host using the |
| 167 | // supplied connection URL. |
| 168 | //------------------------------------------------------------------ |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 169 | Error |
Greg Clayton | fda4fab | 2014-01-10 22:24:11 +0000 | [diff] [blame] | 170 | StartDebugserverProcess (const char *hostname, |
| 171 | uint16_t in_port, // If set to zero, then out_port will contain the bound port on exit |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 172 | ProcessLaunchInfo &launch_info, |
Greg Clayton | fda4fab | 2014-01-10 22:24:11 +0000 | [diff] [blame] | 173 | uint16_t &out_port); |
Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 174 | |
Greg Clayton | c1422c1 | 2012-04-09 22:46:21 +0000 | [diff] [blame] | 175 | void |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 176 | DumpHistory(Stream &strm); |
Greg Clayton | 73bf5db | 2011-06-17 01:22:15 +0000 | [diff] [blame] | 177 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 178 | protected: |
Greg Clayton | c1422c1 | 2012-04-09 22:46:21 +0000 | [diff] [blame] | 179 | |
| 180 | class History |
| 181 | { |
| 182 | public: |
| 183 | enum PacketType |
| 184 | { |
| 185 | ePacketTypeInvalid = 0, |
| 186 | ePacketTypeSend, |
| 187 | ePacketTypeRecv |
| 188 | }; |
| 189 | |
| 190 | struct Entry |
| 191 | { |
| 192 | Entry() : |
| 193 | packet(), |
| 194 | type (ePacketTypeInvalid), |
| 195 | bytes_transmitted (0), |
Greg Clayton | d451c1a | 2012-04-13 21:24:18 +0000 | [diff] [blame] | 196 | packet_idx (0), |
| 197 | tid (LLDB_INVALID_THREAD_ID) |
Greg Clayton | c1422c1 | 2012-04-09 22:46:21 +0000 | [diff] [blame] | 198 | { |
| 199 | } |
| 200 | |
| 201 | void |
| 202 | Clear () |
| 203 | { |
| 204 | packet.clear(); |
| 205 | type = ePacketTypeInvalid; |
| 206 | bytes_transmitted = 0; |
| 207 | packet_idx = 0; |
Greg Clayton | d451c1a | 2012-04-13 21:24:18 +0000 | [diff] [blame] | 208 | tid = LLDB_INVALID_THREAD_ID; |
Greg Clayton | c1422c1 | 2012-04-09 22:46:21 +0000 | [diff] [blame] | 209 | } |
| 210 | std::string packet; |
| 211 | PacketType type; |
| 212 | uint32_t bytes_transmitted; |
| 213 | uint32_t packet_idx; |
Greg Clayton | d451c1a | 2012-04-13 21:24:18 +0000 | [diff] [blame] | 214 | lldb::tid_t tid; |
Greg Clayton | c1422c1 | 2012-04-09 22:46:21 +0000 | [diff] [blame] | 215 | }; |
| 216 | |
| 217 | History (uint32_t size); |
| 218 | |
| 219 | ~History (); |
| 220 | |
| 221 | // For single char packets for ack, nack and /x03 |
| 222 | void |
| 223 | AddPacket (char packet_char, |
| 224 | PacketType type, |
Greg Clayton | d451c1a | 2012-04-13 21:24:18 +0000 | [diff] [blame] | 225 | uint32_t bytes_transmitted); |
Greg Clayton | c1422c1 | 2012-04-09 22:46:21 +0000 | [diff] [blame] | 226 | void |
| 227 | AddPacket (const std::string &src, |
| 228 | uint32_t src_len, |
| 229 | PacketType type, |
Greg Clayton | d451c1a | 2012-04-13 21:24:18 +0000 | [diff] [blame] | 230 | uint32_t bytes_transmitted); |
Greg Clayton | c1422c1 | 2012-04-09 22:46:21 +0000 | [diff] [blame] | 231 | |
| 232 | void |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 233 | Dump (Stream &strm) const; |
Greg Clayton | c1422c1 | 2012-04-09 22:46:21 +0000 | [diff] [blame] | 234 | |
| 235 | void |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 236 | Dump (Log *log) const; |
Greg Clayton | c1422c1 | 2012-04-09 22:46:21 +0000 | [diff] [blame] | 237 | |
| 238 | bool |
| 239 | DidDumpToLog () const |
| 240 | { |
| 241 | return m_dumped_to_log; |
| 242 | } |
| 243 | |
| 244 | protected: |
| 245 | uint32_t |
| 246 | GetFirstSavedPacketIndex () const |
| 247 | { |
| 248 | if (m_total_packet_count < m_packets.size()) |
| 249 | return 0; |
| 250 | else |
| 251 | return m_curr_idx + 1; |
| 252 | } |
| 253 | |
| 254 | uint32_t |
| 255 | GetNumPacketsInHistory () const |
| 256 | { |
| 257 | if (m_total_packet_count < m_packets.size()) |
| 258 | return m_total_packet_count; |
| 259 | else |
| 260 | return (uint32_t)m_packets.size(); |
| 261 | } |
| 262 | |
| 263 | uint32_t |
| 264 | GetNextIndex() |
| 265 | { |
| 266 | ++m_total_packet_count; |
| 267 | const uint32_t idx = m_curr_idx; |
| 268 | m_curr_idx = NormalizeIndex(idx + 1); |
| 269 | return idx; |
| 270 | } |
| 271 | |
| 272 | uint32_t |
| 273 | NormalizeIndex (uint32_t i) const |
| 274 | { |
| 275 | return i % m_packets.size(); |
| 276 | } |
| 277 | |
| 278 | |
| 279 | std::vector<Entry> m_packets; |
| 280 | uint32_t m_curr_idx; |
| 281 | uint32_t m_total_packet_count; |
| 282 | mutable bool m_dumped_to_log; |
| 283 | }; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 284 | |
Greg Clayton | 3dedae1 | 2013-12-06 21:45:27 +0000 | [diff] [blame] | 285 | PacketResult |
Greg Clayton | 37a0a24 | 2012-04-11 00:24:49 +0000 | [diff] [blame] | 286 | SendPacket (const char *payload, |
| 287 | size_t payload_length); |
| 288 | |
Greg Clayton | 3dedae1 | 2013-12-06 21:45:27 +0000 | [diff] [blame] | 289 | PacketResult |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 290 | SendPacketNoLock (const char *payload, |
| 291 | size_t payload_length); |
| 292 | |
Greg Clayton | 3dedae1 | 2013-12-06 21:45:27 +0000 | [diff] [blame] | 293 | PacketResult |
Ewan Crawford | fab40d3 | 2015-06-16 15:50:18 +0000 | [diff] [blame] | 294 | ReadPacket (StringExtractorGDBRemote &response, uint32_t timeout_usec, bool sync_on_timeout); |
| 295 | |
| 296 | // Pop a packet from the queue in a thread safe manner |
| 297 | PacketResult |
| 298 | PopPacketFromQueue (StringExtractorGDBRemote &response, uint32_t timeout_usec); |
| 299 | |
| 300 | PacketResult |
Greg Clayton | 73bf5db | 2011-06-17 01:22:15 +0000 | [diff] [blame] | 301 | WaitForPacketWithTimeoutMicroSecondsNoLock (StringExtractorGDBRemote &response, |
Greg Clayton | b30c50c | 2015-05-29 00:01:55 +0000 | [diff] [blame] | 302 | uint32_t timeout_usec, |
| 303 | bool sync_on_timeout); |
Greg Clayton | 6779606a | 2011-01-22 23:43:18 +0000 | [diff] [blame] | 304 | |
| 305 | bool |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 306 | WaitForNotRunningPrivate (const TimeValue *timeout_ptr); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 307 | |
Jason Molenda | 91ffe0a | 2015-06-18 21:46:06 +0000 | [diff] [blame^] | 308 | bool |
| 309 | CompressionIsEnabled () |
| 310 | { |
| 311 | return m_compression_type != CompressionType::None; |
| 312 | } |
| 313 | |
| 314 | // If compression is enabled, decompress the packet in m_bytes and update |
| 315 | // m_bytes with the uncompressed version. |
| 316 | // Returns 'true' packet was decompressed and m_bytes is the now-decompressed text. |
| 317 | // Returns 'false' if unable to decompress or if the checksum was invalid. |
| 318 | // |
| 319 | // NB: Once the packet has been decompressed, checksum cannot be computed based |
| 320 | // on m_bytes. The checksum was for the compressed packet. |
| 321 | bool |
| 322 | DecompressPacket (); |
| 323 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 324 | //------------------------------------------------------------------ |
| 325 | // Classes that inherit from GDBRemoteCommunication can see and modify these |
| 326 | //------------------------------------------------------------------ |
Greg Clayton | c574ede | 2011-03-10 02:26:48 +0000 | [diff] [blame] | 327 | uint32_t m_packet_timeout; |
Greg Clayton | b30c50c | 2015-05-29 00:01:55 +0000 | [diff] [blame] | 328 | uint32_t m_echo_number; |
| 329 | LazyBool m_supports_qEcho; |
Greg Clayton | b09c538 | 2013-12-13 17:20:18 +0000 | [diff] [blame] | 330 | #ifdef ENABLE_MUTEX_ERROR_CHECKING |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 331 | TrackingMutex m_sequence_mutex; |
Jim Ingham | 4ceb928 | 2012-06-08 22:50:40 +0000 | [diff] [blame] | 332 | #else |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 333 | Mutex m_sequence_mutex; // Restrict access to sending/receiving packets to a single thread at a time |
Jim Ingham | 4ceb928 | 2012-06-08 22:50:40 +0000 | [diff] [blame] | 334 | #endif |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 335 | Predicate<bool> m_public_is_running; |
| 336 | Predicate<bool> m_private_is_running; |
Greg Clayton | c1422c1 | 2012-04-09 22:46:21 +0000 | [diff] [blame] | 337 | History m_history; |
Greg Clayton | 1cb6496 | 2011-03-24 04:28:38 +0000 | [diff] [blame] | 338 | bool m_send_acks; |
Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 339 | bool m_is_platform; // Set to true if this class represents a platform, |
| 340 | // false if this class represents a debug session for |
| 341 | // a single process |
Greg Clayton | 1cb6496 | 2011-03-24 04:28:38 +0000 | [diff] [blame] | 342 | |
Jason Molenda | 91ffe0a | 2015-06-18 21:46:06 +0000 | [diff] [blame^] | 343 | CompressionType m_compression_type; |
Greg Clayton | 1cb6496 | 2011-03-24 04:28:38 +0000 | [diff] [blame] | 344 | |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 345 | Error |
| 346 | StartListenThread (const char *hostname = "127.0.0.1", uint16_t port = 0); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 347 | |
Greg Clayton | 00fe87b | 2013-12-05 22:58:22 +0000 | [diff] [blame] | 348 | bool |
| 349 | JoinListenThread (); |
| 350 | |
| 351 | static lldb::thread_result_t |
| 352 | ListenThread (lldb::thread_arg_t arg); |
Greg Clayton | 8b82f08 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 353 | |
Ewan Crawford | fab40d3 | 2015-06-16 15:50:18 +0000 | [diff] [blame] | 354 | // GDB-Remote read thread |
| 355 | // . this thread constantly tries to read from the communication |
| 356 | // class and stores all packets received in a queue. The usual |
| 357 | // threads read requests simply pop packets off the queue in the |
| 358 | // usual order. |
| 359 | // This setup allows us to intercept and handle async packets, such |
| 360 | // as the notify packet. |
| 361 | |
| 362 | // This method is defined as part of communication.h |
| 363 | // when the read thread gets any bytes it will pass them on to this function |
| 364 | virtual void AppendBytesToCache (const uint8_t * bytes, size_t len, bool broadcast, lldb::ConnectionStatus status); |
| 365 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 366 | private: |
Ewan Crawford | fab40d3 | 2015-06-16 15:50:18 +0000 | [diff] [blame] | 367 | |
| 368 | std::queue<StringExtractorGDBRemote> m_packet_queue; // The packet queue |
| 369 | lldb_private::Mutex m_packet_queue_mutex; // Mutex for accessing queue |
| 370 | Condition m_condition_queue_not_empty; // Condition variable to wait for packets |
| 371 | |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 372 | HostThread m_listen_thread; |
Greg Clayton | 00fe87b | 2013-12-05 22:58:22 +0000 | [diff] [blame] | 373 | std::string m_listen_url; |
Greg Clayton | 00fe87b | 2013-12-05 22:58:22 +0000 | [diff] [blame] | 374 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 375 | //------------------------------------------------------------------ |
| 376 | // For GDBRemoteCommunication only |
| 377 | //------------------------------------------------------------------ |
| 378 | DISALLOW_COPY_AND_ASSIGN (GDBRemoteCommunication); |
| 379 | }; |
| 380 | |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 381 | } // namespace process_gdb_remote |
| 382 | } // namespace lldb_private |
| 383 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 384 | #endif // liblldb_GDBRemoteCommunication_h_ |