LLDB  mainline
GDBRemoteCommunication.cpp
Go to the documentation of this file.
1 //===-- GDBRemoteCommunication.cpp ----------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
10 
11 #include <climits>
12 #include <cstring>
13 #include <future>
14 #include <sys/stat.h>
15 
16 #include "lldb/Core/StreamFile.h"
17 #include "lldb/Host/Config.h"
19 #include "lldb/Host/FileSystem.h"
20 #include "lldb/Host/Host.h"
21 #include "lldb/Host/HostInfo.h"
22 #include "lldb/Host/Pipe.h"
24 #include "lldb/Host/Socket.h"
28 #include "lldb/Target/Platform.h"
29 #include "lldb/Utility/Event.h"
30 #include "lldb/Utility/FileSpec.h"
31 #include "lldb/Utility/Log.h"
35 #include "llvm/ADT/SmallString.h"
36 #include "llvm/Support/ScopedPrinter.h"
37 
38 #include "ProcessGDBRemoteLog.h"
39 
40 #if defined(__APPLE__)
41 #define DEBUGSERVER_BASENAME "debugserver"
42 #elif defined(_WIN32)
43 #define DEBUGSERVER_BASENAME "lldb-server.exe"
44 #else
45 #define DEBUGSERVER_BASENAME "lldb-server"
46 #endif
47 
48 #if defined(HAVE_LIBCOMPRESSION)
49 #include <compression.h>
50 #endif
51 
52 #if LLVM_ENABLE_ZLIB
53 #include <zlib.h>
54 #endif
55 
56 using namespace lldb;
57 using namespace lldb_private;
58 using namespace lldb_private::process_gdb_remote;
59 
60 // GDBRemoteCommunication constructor
61 GDBRemoteCommunication::GDBRemoteCommunication(const char *comm_name,
62  const char *listener_name)
63  : Communication(comm_name),
64 #ifdef LLDB_CONFIGURATION_DEBUG
65  m_packet_timeout(1000),
66 #else
67  m_packet_timeout(1),
68 #endif
69  m_echo_number(0), m_supports_qEcho(eLazyBoolCalculate), m_history(512),
70  m_send_acks(true), m_compression_type(CompressionType::None),
71  m_listen_url() {
72 }
73 
74 // Destructor
76  if (IsConnected()) {
77  Disconnect();
78  }
79 
80 #if defined(HAVE_LIBCOMPRESSION)
81  if (m_decompression_scratch)
82  free (m_decompression_scratch);
83 #endif
84 
85  // Stop the communications read thread which is used to parse all incoming
86  // packets. This function will block until the read thread returns.
89 }
90 
91 char GDBRemoteCommunication::CalculcateChecksum(llvm::StringRef payload) {
92  int checksum = 0;
93 
94  for (char c : payload)
95  checksum += c;
96 
97  return checksum & 255;
98 }
99 
103  char ch = '+';
104  const size_t bytes_written = Write(&ch, 1, status, nullptr);
105  LLDB_LOGF(log, "<%4" PRIu64 "> send packet: %c", (uint64_t)bytes_written, ch);
107  return bytes_written;
108 }
109 
113  char ch = '-';
114  const size_t bytes_written = Write(&ch, 1, status, nullptr);
115  LLDB_LOGF(log, "<%4" PRIu64 "> send packet: %c", (uint64_t)bytes_written, ch);
117  return bytes_written;
118 }
119 
122  StreamString packet(0, 4, eByteOrderBig);
123  packet.PutChar('$');
124  packet.Write(payload.data(), payload.size());
125  packet.PutChar('#');
126  packet.PutHex8(CalculcateChecksum(payload));
127  std::string packet_str = std::string(packet.GetString());
128 
129  return SendRawPacketNoLock(packet_str);
130 }
131 
134  bool skip_ack) {
135  if (IsConnected()) {
138  const char *packet_data = packet.data();
139  const size_t packet_length = packet.size();
140  size_t bytes_written = Write(packet_data, packet_length, status, nullptr);
141  if (log) {
142  size_t binary_start_offset = 0;
143  if (strncmp(packet_data, "$vFile:pwrite:", strlen("$vFile:pwrite:")) ==
144  0) {
145  const char *first_comma = strchr(packet_data, ',');
146  if (first_comma) {
147  const char *second_comma = strchr(first_comma + 1, ',');
148  if (second_comma)
149  binary_start_offset = second_comma - packet_data + 1;
150  }
151  }
152 
153  // If logging was just enabled and we have history, then dump out what we
154  // have to the log so we get the historical context. The Dump() call that
155  // logs all of the packet will set a boolean so that we don't dump this
156  // more than once
157  if (!m_history.DidDumpToLog())
158  m_history.Dump(log);
159 
160  if (binary_start_offset) {
161  StreamString strm;
162  // Print non binary data header
163  strm.Printf("<%4" PRIu64 "> send packet: %.*s", (uint64_t)bytes_written,
164  (int)binary_start_offset, packet_data);
165  const uint8_t *p;
166  // Print binary data exactly as sent
167  for (p = (const uint8_t *)packet_data + binary_start_offset; *p != '#';
168  ++p)
169  strm.Printf("\\x%2.2x", *p);
170  // Print the checksum
171  strm.Printf("%*s", (int)3, p);
172  log->PutString(strm.GetString());
173  } else
174  LLDB_LOGF(log, "<%4" PRIu64 "> send packet: %.*s",
175  (uint64_t)bytes_written, (int)packet_length, packet_data);
176  }
177 
178  m_history.AddPacket(packet.str(), packet_length,
179  GDBRemotePacket::ePacketTypeSend, bytes_written);
180 
181  if (bytes_written == packet_length) {
182  if (!skip_ack && GetSendAcks())
183  return GetAck();
184  else
185  return PacketResult::Success;
186  } else {
187  LLDB_LOGF(log, "error: failed to send packet: %.*s", (int)packet_length,
188  packet_data);
189  }
190  }
192 }
193 
196  PacketResult result = ReadPacket(packet, GetPacketTimeout(), false);
197  if (result == PacketResult::Success) {
198  if (packet.GetResponseType() ==
199  StringExtractorGDBRemote::ResponseType::eAck)
200  return PacketResult::Success;
201  else
203  }
204  return result;
205 }
206 
210  bool sync_on_timeout,
211  llvm::function_ref<void(llvm::StringRef)> output_callback) {
212  auto result = ReadPacket(response, timeout, sync_on_timeout);
213  while (result == PacketResult::Success && response.IsNormalResponse() &&
214  response.PeekChar() == 'O') {
215  response.GetChar();
216  std::string output;
217  if (response.GetHexByteString(output))
218  output_callback(output);
219  result = ReadPacket(response, timeout, sync_on_timeout);
220  }
221  return result;
222 }
223 
226  Timeout<std::micro> timeout,
227  bool sync_on_timeout) {
229  return PopPacketFromQueue(response, timeout);
230  else
231  return WaitForPacketNoLock(response, timeout, sync_on_timeout);
232 }
233 
234 // This function is called when a packet is requested.
235 // A whole packet is popped from the packet queue and returned to the caller.
236 // Packets are placed into this queue from the communication read thread. See
237 // GDBRemoteCommunication::AppendBytesToCache.
240  Timeout<std::micro> timeout) {
241  auto pred = [&] { return !m_packet_queue.empty() && IsConnected(); };
242  // lock down the packet queue
243  std::unique_lock<std::mutex> lock(m_packet_queue_mutex);
244 
245  if (!timeout)
246  m_condition_queue_not_empty.wait(lock, pred);
247  else {
248  if (!m_condition_queue_not_empty.wait_for(lock, *timeout, pred))
250  if (!IsConnected())
252  }
253 
254  // get the front element of the queue
255  response = m_packet_queue.front();
256 
257  // remove the front element
258  m_packet_queue.pop();
259 
260  // we got a packet
261  return PacketResult::Success;
262 }
263 
266  Timeout<std::micro> timeout,
267  bool sync_on_timeout) {
268  uint8_t buffer[8192];
269  Status error;
270 
272 
273  // Check for a packet from our cache first without trying any reading...
274  if (CheckForPacket(nullptr, 0, packet) != PacketType::Invalid)
275  return PacketResult::Success;
276 
277  bool timed_out = false;
278  bool disconnected = false;
279  while (IsConnected() && !timed_out) {
281  size_t bytes_read = Read(buffer, sizeof(buffer), timeout, status, &error);
282 
283  LLDB_LOGV(log,
284  "Read(buffer, sizeof(buffer), timeout = {0}, "
285  "status = {1}, error = {2}) => bytes_read = {3}",
287  bytes_read);
288 
289  if (bytes_read > 0) {
290  if (CheckForPacket(buffer, bytes_read, packet) != PacketType::Invalid)
291  return PacketResult::Success;
292  } else {
293  switch (status) {
296  if (sync_on_timeout) {
297  /// Sync the remote GDB server and make sure we get a response that
298  /// corresponds to what we send.
299  ///
300  /// Sends a "qEcho" packet and makes sure it gets the exact packet
301  /// echoed back. If the qEcho packet isn't supported, we send a qC
302  /// packet and make sure we get a valid thread ID back. We use the
303  /// "qC" packet since its response if very unique: is responds with
304  /// "QC%x" where %x is the thread ID of the current thread. This
305  /// makes the response unique enough from other packet responses to
306  /// ensure we are back on track.
307  ///
308  /// This packet is needed after we time out sending a packet so we
309  /// can ensure that we are getting the response for the packet we
310  /// are sending. There are no sequence IDs in the GDB remote
311  /// protocol (there used to be, but they are not supported anymore)
312  /// so if you timeout sending packet "abc", you might then send
313  /// packet "cde" and get the response for the previous "abc" packet.
314  /// Many responses are "OK" or "" (unsupported) or "EXX" (error) so
315  /// many responses for packets can look like responses for other
316  /// packets. So if we timeout, we need to ensure that we can get
317  /// back on track. If we can't get back on track, we must
318  /// disconnect.
319  bool sync_success = false;
320  bool got_actual_response = false;
321  // We timed out, we need to sync back up with the
322  char echo_packet[32];
323  int echo_packet_len = 0;
324  RegularExpression response_regex;
325 
327  echo_packet_len = ::snprintf(echo_packet, sizeof(echo_packet),
328  "qEcho:%u", ++m_echo_number);
329  std::string regex_str = "^";
330  regex_str += echo_packet;
331  regex_str += "$";
332  response_regex = RegularExpression(regex_str);
333  } else {
334  echo_packet_len =
335  ::snprintf(echo_packet, sizeof(echo_packet), "qC");
336  response_regex =
337  RegularExpression(llvm::StringRef("^QC[0-9A-Fa-f]+$"));
338  }
339 
340  PacketResult echo_packet_result =
341  SendPacketNoLock(llvm::StringRef(echo_packet, echo_packet_len));
342  if (echo_packet_result == PacketResult::Success) {
343  const uint32_t max_retries = 3;
344  uint32_t successful_responses = 0;
345  for (uint32_t i = 0; i < max_retries; ++i) {
346  StringExtractorGDBRemote echo_response;
347  echo_packet_result =
348  WaitForPacketNoLock(echo_response, timeout, false);
349  if (echo_packet_result == PacketResult::Success) {
350  ++successful_responses;
351  if (response_regex.Execute(echo_response.GetStringRef())) {
352  sync_success = true;
353  break;
354  } else if (successful_responses == 1) {
355  // We got something else back as the first successful
356  // response, it probably is the response to the packet we
357  // actually wanted, so copy it over if this is the first
358  // success and continue to try to get the qEcho response
359  packet = echo_response;
360  got_actual_response = true;
361  }
362  } else if (echo_packet_result == PacketResult::ErrorReplyTimeout)
363  continue; // Packet timed out, continue waiting for a response
364  else
365  break; // Something else went wrong getting the packet back, we
366  // failed and are done trying
367  }
368  }
369 
370  // We weren't able to sync back up with the server, we must abort
371  // otherwise all responses might not be from the right packets...
372  if (sync_success) {
373  // We timed out, but were able to recover
374  if (got_actual_response) {
375  // We initially timed out, but we did get a response that came in
376  // before the successful reply to our qEcho packet, so lets say
377  // everything is fine...
378  return PacketResult::Success;
379  }
380  } else {
381  disconnected = true;
382  Disconnect();
383  }
384  }
385  timed_out = true;
386  break;
388  // printf ("status = success but error = %s\n",
389  // error.AsCString("<invalid>"));
390  break;
391 
396  disconnected = true;
397  Disconnect();
398  break;
399  }
400  }
401  }
402  packet.Clear();
403  if (disconnected)
405  if (timed_out)
407  else
409 }
410 
413 
414  if (!CompressionIsEnabled())
415  return true;
416 
417  size_t pkt_size = m_bytes.size();
418 
419  // Smallest possible compressed packet is $N#00 - an uncompressed empty
420  // reply, most commonly indicating an unsupported packet. Anything less than
421  // 5 characters, it's definitely not a compressed packet.
422  if (pkt_size < 5)
423  return true;
424 
425  if (m_bytes[0] != '$' && m_bytes[0] != '%')
426  return true;
427  if (m_bytes[1] != 'C' && m_bytes[1] != 'N')
428  return true;
429 
430  size_t hash_mark_idx = m_bytes.find('#');
431  if (hash_mark_idx == std::string::npos)
432  return true;
433  if (hash_mark_idx + 2 >= m_bytes.size())
434  return true;
435 
436  if (!::isxdigit(m_bytes[hash_mark_idx + 1]) ||
437  !::isxdigit(m_bytes[hash_mark_idx + 2]))
438  return true;
439 
440  size_t content_length =
441  pkt_size -
442  5; // not counting '$', 'C' | 'N', '#', & the two hex checksum chars
443  size_t content_start = 2; // The first character of the
444  // compressed/not-compressed text of the packet
445  size_t checksum_idx =
446  hash_mark_idx +
447  1; // The first character of the two hex checksum characters
448 
449  // Normally size_of_first_packet == m_bytes.size() but m_bytes may contain
450  // multiple packets. size_of_first_packet is the size of the initial packet
451  // which we'll replace with the decompressed version of, leaving the rest of
452  // m_bytes unmodified.
453  size_t size_of_first_packet = hash_mark_idx + 3;
454 
455  // Compressed packets ("$C") start with a base10 number which is the size of
456  // the uncompressed payload, then a : and then the compressed data. e.g.
457  // $C1024:<binary>#00 Update content_start and content_length to only include
458  // the <binary> part of the packet.
459 
460  uint64_t decompressed_bufsize = ULONG_MAX;
461  if (m_bytes[1] == 'C') {
462  size_t i = content_start;
463  while (i < hash_mark_idx && isdigit(m_bytes[i]))
464  i++;
465  if (i < hash_mark_idx && m_bytes[i] == ':') {
466  i++;
467  content_start = i;
468  content_length = hash_mark_idx - content_start;
469  std::string bufsize_str(m_bytes.data() + 2, i - 2 - 1);
470  errno = 0;
471  decompressed_bufsize = ::strtoul(bufsize_str.c_str(), nullptr, 10);
472  if (errno != 0 || decompressed_bufsize == ULONG_MAX) {
473  m_bytes.erase(0, size_of_first_packet);
474  return false;
475  }
476  }
477  }
478 
479  if (GetSendAcks()) {
480  char packet_checksum_cstr[3];
481  packet_checksum_cstr[0] = m_bytes[checksum_idx];
482  packet_checksum_cstr[1] = m_bytes[checksum_idx + 1];
483  packet_checksum_cstr[2] = '\0';
484  long packet_checksum = strtol(packet_checksum_cstr, nullptr, 16);
485 
486  long actual_checksum = CalculcateChecksum(
487  llvm::StringRef(m_bytes).substr(1, hash_mark_idx - 1));
488  bool success = packet_checksum == actual_checksum;
489  if (!success) {
490  LLDB_LOGF(log,
491  "error: checksum mismatch: %.*s expected 0x%2.2x, got 0x%2.2x",
492  (int)(pkt_size), m_bytes.c_str(), (uint8_t)packet_checksum,
493  (uint8_t)actual_checksum);
494  }
495  // Send the ack or nack if needed
496  if (!success) {
497  SendNack();
498  m_bytes.erase(0, size_of_first_packet);
499  return false;
500  } else {
501  SendAck();
502  }
503  }
504 
505  if (m_bytes[1] == 'N') {
506  // This packet was not compressed -- delete the 'N' character at the start
507  // and the packet may be processed as-is.
508  m_bytes.erase(1, 1);
509  return true;
510  }
511 
512  // Reverse the gdb-remote binary escaping that was done to the compressed
513  // text to guard characters like '$', '#', '}', etc.
514  std::vector<uint8_t> unescaped_content;
515  unescaped_content.reserve(content_length);
516  size_t i = content_start;
517  while (i < hash_mark_idx) {
518  if (m_bytes[i] == '}') {
519  i++;
520  unescaped_content.push_back(m_bytes[i] ^ 0x20);
521  } else {
522  unescaped_content.push_back(m_bytes[i]);
523  }
524  i++;
525  }
526 
527  uint8_t *decompressed_buffer = nullptr;
528  size_t decompressed_bytes = 0;
529 
530  if (decompressed_bufsize != ULONG_MAX) {
531  decompressed_buffer = (uint8_t *)malloc(decompressed_bufsize);
532  if (decompressed_buffer == nullptr) {
533  m_bytes.erase(0, size_of_first_packet);
534  return false;
535  }
536  }
537 
538 #if defined(HAVE_LIBCOMPRESSION)
543  compression_algorithm compression_type;
545  compression_type = COMPRESSION_LZFSE;
547  compression_type = COMPRESSION_ZLIB;
549  compression_type = COMPRESSION_LZ4_RAW;
551  compression_type = COMPRESSION_LZMA;
552 
553  if (m_decompression_scratch_type != m_compression_type) {
554  if (m_decompression_scratch) {
555  free (m_decompression_scratch);
556  m_decompression_scratch = nullptr;
557  }
558  size_t scratchbuf_size = 0;
560  scratchbuf_size = compression_decode_scratch_buffer_size (COMPRESSION_LZFSE);
562  scratchbuf_size = compression_decode_scratch_buffer_size (COMPRESSION_LZ4_RAW);
564  scratchbuf_size = compression_decode_scratch_buffer_size (COMPRESSION_ZLIB);
566  scratchbuf_size = compression_decode_scratch_buffer_size (COMPRESSION_LZMA);
568  scratchbuf_size = compression_decode_scratch_buffer_size (COMPRESSION_LZFSE);
569  if (scratchbuf_size > 0) {
570  m_decompression_scratch = (void*) malloc (scratchbuf_size);
571  m_decompression_scratch_type = m_compression_type;
572  }
573  }
574 
575  if (decompressed_bufsize != ULONG_MAX && decompressed_buffer != nullptr) {
576  decompressed_bytes = compression_decode_buffer(
577  decompressed_buffer, decompressed_bufsize,
578  (uint8_t *)unescaped_content.data(), unescaped_content.size(),
579  m_decompression_scratch, compression_type);
580  }
581  }
582 #endif
583 
584 #if LLVM_ENABLE_ZLIB
585  if (decompressed_bytes == 0 && decompressed_bufsize != ULONG_MAX &&
586  decompressed_buffer != nullptr &&
588  z_stream stream;
589  memset(&stream, 0, sizeof(z_stream));
590  stream.next_in = (Bytef *)unescaped_content.data();
591  stream.avail_in = (uInt)unescaped_content.size();
592  stream.total_in = 0;
593  stream.next_out = (Bytef *)decompressed_buffer;
594  stream.avail_out = decompressed_bufsize;
595  stream.total_out = 0;
596  stream.zalloc = Z_NULL;
597  stream.zfree = Z_NULL;
598  stream.opaque = Z_NULL;
599 
600  if (inflateInit2(&stream, -15) == Z_OK) {
601  int status = inflate(&stream, Z_NO_FLUSH);
602  inflateEnd(&stream);
603  if (status == Z_STREAM_END) {
604  decompressed_bytes = stream.total_out;
605  }
606  }
607  }
608 #endif
609 
610  if (decompressed_bytes == 0 || decompressed_buffer == nullptr) {
611  if (decompressed_buffer)
612  free(decompressed_buffer);
613  m_bytes.erase(0, size_of_first_packet);
614  return false;
615  }
616 
617  std::string new_packet;
618  new_packet.reserve(decompressed_bytes + 6);
619  new_packet.push_back(m_bytes[0]);
620  new_packet.append((const char *)decompressed_buffer, decompressed_bytes);
621  new_packet.push_back('#');
622  if (GetSendAcks()) {
623  uint8_t decompressed_checksum = CalculcateChecksum(
624  llvm::StringRef((const char *)decompressed_buffer, decompressed_bytes));
625  char decompressed_checksum_str[3];
626  snprintf(decompressed_checksum_str, 3, "%02x", decompressed_checksum);
627  new_packet.append(decompressed_checksum_str);
628  } else {
629  new_packet.push_back('0');
630  new_packet.push_back('0');
631  }
632 
633  m_bytes.replace(0, size_of_first_packet, new_packet.data(),
634  new_packet.size());
635 
636  free(decompressed_buffer);
637  return true;
638 }
639 
641 GDBRemoteCommunication::CheckForPacket(const uint8_t *src, size_t src_len,
642  StringExtractorGDBRemote &packet) {
643  // Put the packet data into the buffer in a thread safe fashion
644  std::lock_guard<std::recursive_mutex> guard(m_bytes_mutex);
645 
647 
648  if (src && src_len > 0) {
649  if (log && log->GetVerbose()) {
650  StreamString s;
651  LLDB_LOGF(log, "GDBRemoteCommunication::%s adding %u bytes: %.*s",
652  __FUNCTION__, (uint32_t)src_len, (uint32_t)src_len, src);
653  }
654  m_bytes.append((const char *)src, src_len);
655  }
656 
657  bool isNotifyPacket = false;
658 
659  // Parse up the packets into gdb remote packets
660  if (!m_bytes.empty()) {
661  // end_idx must be one past the last valid packet byte. Start it off with
662  // an invalid value that is the same as the current index.
663  size_t content_start = 0;
664  size_t content_length = 0;
665  size_t total_length = 0;
666  size_t checksum_idx = std::string::npos;
667 
668  // Size of packet before it is decompressed, for logging purposes
669  size_t original_packet_size = m_bytes.size();
670  if (CompressionIsEnabled()) {
671  if (!DecompressPacket()) {
672  packet.Clear();
674  }
675  }
676 
677  switch (m_bytes[0]) {
678  case '+': // Look for ack
679  case '-': // Look for cancel
680  case '\x03': // ^C to halt target
681  content_length = total_length = 1; // The command is one byte long...
682  break;
683 
684  case '%': // Async notify packet
685  isNotifyPacket = true;
686  LLVM_FALLTHROUGH;
687 
688  case '$':
689  // Look for a standard gdb packet?
690  {
691  size_t hash_pos = m_bytes.find('#');
692  if (hash_pos != std::string::npos) {
693  if (hash_pos + 2 < m_bytes.size()) {
694  checksum_idx = hash_pos + 1;
695  // Skip the dollar sign
696  content_start = 1;
697  // Don't include the # in the content or the $ in the content
698  // length
699  content_length = hash_pos - 1;
700 
701  total_length =
702  hash_pos + 3; // Skip the # and the two hex checksum bytes
703  } else {
704  // Checksum bytes aren't all here yet
705  content_length = std::string::npos;
706  }
707  }
708  }
709  break;
710 
711  default: {
712  // We have an unexpected byte and we need to flush all bad data that is
713  // in m_bytes, so we need to find the first byte that is a '+' (ACK), '-'
714  // (NACK), \x03 (CTRL+C interrupt), or '$' character (start of packet
715  // header) or of course, the end of the data in m_bytes...
716  const size_t bytes_len = m_bytes.size();
717  bool done = false;
718  uint32_t idx;
719  for (idx = 1; !done && idx < bytes_len; ++idx) {
720  switch (m_bytes[idx]) {
721  case '+':
722  case '-':
723  case '\x03':
724  case '%':
725  case '$':
726  done = true;
727  break;
728 
729  default:
730  break;
731  }
732  }
733  LLDB_LOGF(log, "GDBRemoteCommunication::%s tossing %u junk bytes: '%.*s'",
734  __FUNCTION__, idx - 1, idx - 1, m_bytes.c_str());
735  m_bytes.erase(0, idx - 1);
736  } break;
737  }
738 
739  if (content_length == std::string::npos) {
740  packet.Clear();
742  } else if (total_length > 0) {
743 
744  // We have a valid packet...
745  assert(content_length <= m_bytes.size());
746  assert(total_length <= m_bytes.size());
747  assert(content_length <= total_length);
748  size_t content_end = content_start + content_length;
749 
750  bool success = true;
751  if (log) {
752  // If logging was just enabled and we have history, then dump out what
753  // we have to the log so we get the historical context. The Dump() call
754  // that logs all of the packet will set a boolean so that we don't dump
755  // this more than once
756  if (!m_history.DidDumpToLog())
757  m_history.Dump(log);
758 
759  bool binary = false;
760  // Only detect binary for packets that start with a '$' and have a
761  // '#CC' checksum
762  if (m_bytes[0] == '$' && total_length > 4) {
763  for (size_t i = 0; !binary && i < total_length; ++i) {
764  unsigned char c = m_bytes[i];
765  if (!llvm::isPrint(c) && !llvm::isSpace(c)) {
766  binary = true;
767  }
768  }
769  }
770  if (binary) {
771  StreamString strm;
772  // Packet header...
773  if (CompressionIsEnabled())
774  strm.Printf("<%4" PRIu64 ":%" PRIu64 "> read packet: %c",
775  (uint64_t)original_packet_size, (uint64_t)total_length,
776  m_bytes[0]);
777  else
778  strm.Printf("<%4" PRIu64 "> read packet: %c",
779  (uint64_t)total_length, m_bytes[0]);
780  for (size_t i = content_start; i < content_end; ++i) {
781  // Remove binary escaped bytes when displaying the packet...
782  const char ch = m_bytes[i];
783  if (ch == 0x7d) {
784  // 0x7d is the escape character. The next character is to be
785  // XOR'd with 0x20.
786  const char escapee = m_bytes[++i] ^ 0x20;
787  strm.Printf("%2.2x", escapee);
788  } else {
789  strm.Printf("%2.2x", (uint8_t)ch);
790  }
791  }
792  // Packet footer...
793  strm.Printf("%c%c%c", m_bytes[total_length - 3],
794  m_bytes[total_length - 2], m_bytes[total_length - 1]);
795  log->PutString(strm.GetString());
796  } else {
797  if (CompressionIsEnabled())
798  LLDB_LOGF(log, "<%4" PRIu64 ":%" PRIu64 "> read packet: %.*s",
799  (uint64_t)original_packet_size, (uint64_t)total_length,
800  (int)(total_length), m_bytes.c_str());
801  else
802  LLDB_LOGF(log, "<%4" PRIu64 "> read packet: %.*s",
803  (uint64_t)total_length, (int)(total_length),
804  m_bytes.c_str());
805  }
806  }
807 
808  m_history.AddPacket(m_bytes, total_length,
809  GDBRemotePacket::ePacketTypeRecv, total_length);
810 
811  // Copy the packet from m_bytes to packet_str expanding the run-length
812  // encoding in the process.
813  std ::string packet_str =
814  ExpandRLE(m_bytes.substr(content_start, content_end - content_start));
815  packet = StringExtractorGDBRemote(packet_str);
816 
817  if (m_bytes[0] == '$' || m_bytes[0] == '%') {
818  assert(checksum_idx < m_bytes.size());
819  if (::isxdigit(m_bytes[checksum_idx + 0]) ||
820  ::isxdigit(m_bytes[checksum_idx + 1])) {
821  if (GetSendAcks()) {
822  const char *packet_checksum_cstr = &m_bytes[checksum_idx];
823  char packet_checksum = strtol(packet_checksum_cstr, nullptr, 16);
824  char actual_checksum = CalculcateChecksum(
825  llvm::StringRef(m_bytes).slice(content_start, content_end));
826  success = packet_checksum == actual_checksum;
827  if (!success) {
828  LLDB_LOGF(log,
829  "error: checksum mismatch: %.*s expected 0x%2.2x, "
830  "got 0x%2.2x",
831  (int)(total_length), m_bytes.c_str(),
832  (uint8_t)packet_checksum, (uint8_t)actual_checksum);
833  }
834  // Send the ack or nack if needed
835  if (!success)
836  SendNack();
837  else
838  SendAck();
839  }
840  } else {
841  success = false;
842  LLDB_LOGF(log, "error: invalid checksum in packet: '%s'\n",
843  m_bytes.c_str());
844  }
845  }
846 
847  m_bytes.erase(0, total_length);
848  packet.SetFilePos(0);
849 
850  if (isNotifyPacket)
852  else
854  }
855  }
856  packet.Clear();
858 }
859 
861  uint16_t port) {
863  return Status("listen thread already running");
864 
865  char listen_url[512];
866  if (hostname && hostname[0])
867  snprintf(listen_url, sizeof(listen_url), "listen://%s:%i", hostname, port);
868  else
869  snprintf(listen_url, sizeof(listen_url), "listen://%i", port);
870  m_listen_url = listen_url;
871  SetConnection(std::make_unique<ConnectionFileDescriptor>());
872  llvm::Expected<HostThread> listen_thread = ThreadLauncher::LaunchThread(
873  listen_url, GDBRemoteCommunication::ListenThread, this);
874  if (!listen_thread)
875  return Status(listen_thread.takeError());
876  m_listen_thread = *listen_thread;
877 
878  return Status();
879 }
880 
883  m_listen_thread.Join(nullptr);
884  return true;
885 }
886 
890  Status error;
891  ConnectionFileDescriptor *connection =
893 
894  if (connection) {
895  // Do the listen on another thread so we can continue on...
896  if (connection->Connect(comm->m_listen_url.c_str(), &error) !=
898  comm->SetConnection(nullptr);
899  }
900  return {};
901 }
902 
904  const char *url, Platform *platform, ProcessLaunchInfo &launch_info,
905  uint16_t *port, const Args *inferior_args, int pass_comm_fd) {
907  LLDB_LOGF(log, "GDBRemoteCommunication::%s(url=%s, port=%" PRIu16 ")",
908  __FUNCTION__, url ? url : "<empty>", port ? *port : uint16_t(0));
909 
910  Status error;
911  // If we locate debugserver, keep that located version around
912  static FileSpec g_debugserver_file_spec;
913 
914  char debugserver_path[PATH_MAX];
915  FileSpec &debugserver_file_spec = launch_info.GetExecutableFile();
916 
917  Environment host_env = Host::GetEnvironment();
918 
919  // Always check to see if we have an environment override for the path to the
920  // debugserver to use and use it if we do.
921  std::string env_debugserver_path = host_env.lookup("LLDB_DEBUGSERVER_PATH");
922  if (!env_debugserver_path.empty()) {
923  debugserver_file_spec.SetFile(env_debugserver_path,
924  FileSpec::Style::native);
925  LLDB_LOGF(log,
926  "GDBRemoteCommunication::%s() gdb-remote stub exe path set "
927  "from environment variable: %s",
928  __FUNCTION__, env_debugserver_path.c_str());
929  } else
930  debugserver_file_spec = g_debugserver_file_spec;
931  bool debugserver_exists =
932  FileSystem::Instance().Exists(debugserver_file_spec);
933  if (!debugserver_exists) {
934  // The debugserver binary is in the LLDB.framework/Resources directory.
935  debugserver_file_spec = HostInfo::GetSupportExeDir();
936  if (debugserver_file_spec) {
937  debugserver_file_spec.AppendPathComponent(DEBUGSERVER_BASENAME);
938  debugserver_exists = FileSystem::Instance().Exists(debugserver_file_spec);
939  if (debugserver_exists) {
940  LLDB_LOGF(log,
941  "GDBRemoteCommunication::%s() found gdb-remote stub exe '%s'",
942  __FUNCTION__, debugserver_file_spec.GetPath().c_str());
943 
944  g_debugserver_file_spec = debugserver_file_spec;
945  } else {
946  if (platform)
947  debugserver_file_spec =
949  else
950  debugserver_file_spec.Clear();
951  if (debugserver_file_spec) {
952  // Platform::LocateExecutable() wouldn't return a path if it doesn't
953  // exist
954  debugserver_exists = true;
955  } else {
956  LLDB_LOGF(log,
957  "GDBRemoteCommunication::%s() could not find "
958  "gdb-remote stub exe '%s'",
959  __FUNCTION__, debugserver_file_spec.GetPath().c_str());
960  }
961  // Don't cache the platform specific GDB server binary as it could
962  // change from platform to platform
963  g_debugserver_file_spec.Clear();
964  }
965  }
966  }
967 
968  if (debugserver_exists) {
969  debugserver_file_spec.GetPath(debugserver_path, sizeof(debugserver_path));
970 
971  Args &debugserver_args = launch_info.GetArguments();
972  debugserver_args.Clear();
973 
974  // Start args with "debugserver /file/path -r --"
975  debugserver_args.AppendArgument(llvm::StringRef(debugserver_path));
976 
977 #if !defined(__APPLE__)
978  // First argument to lldb-server must be mode in which to run.
979  debugserver_args.AppendArgument(llvm::StringRef("gdbserver"));
980 #endif
981 
982  // If a url is supplied then use it
983  if (url)
984  debugserver_args.AppendArgument(llvm::StringRef(url));
985 
986  if (pass_comm_fd >= 0) {
987  StreamString fd_arg;
988  fd_arg.Printf("--fd=%i", pass_comm_fd);
989  debugserver_args.AppendArgument(fd_arg.GetString());
990  // Send "pass_comm_fd" down to the inferior so it can use it to
991  // communicate back with this process
992  launch_info.AppendDuplicateFileAction(pass_comm_fd, pass_comm_fd);
993  }
994 
995  // use native registers, not the GDB registers
996  debugserver_args.AppendArgument(llvm::StringRef("--native-regs"));
997 
998  if (launch_info.GetLaunchInSeparateProcessGroup()) {
999  debugserver_args.AppendArgument(llvm::StringRef("--setsid"));
1000  }
1001 
1002  llvm::SmallString<128> named_pipe_path;
1003  // socket_pipe is used by debug server to communicate back either
1004  // TCP port or domain socket name which it listens on.
1005  // The second purpose of the pipe to serve as a synchronization point -
1006  // once data is written to the pipe, debug server is up and running.
1007  Pipe socket_pipe;
1008 
1009  // port is null when debug server should listen on domain socket - we're
1010  // not interested in port value but rather waiting for debug server to
1011  // become available.
1012  if (pass_comm_fd == -1) {
1013  if (url) {
1014 // Create a temporary file to get the stdout/stderr and redirect the output of
1015 // the command into this file. We will later read this file if all goes well
1016 // and fill the data into "command_output_ptr"
1017 #if defined(__APPLE__)
1018  // Binding to port zero, we need to figure out what port it ends up
1019  // using using a named pipe...
1020  error = socket_pipe.CreateWithUniqueName("debugserver-named-pipe",
1021  false, named_pipe_path);
1022  if (error.Fail()) {
1023  LLDB_LOGF(log,
1024  "GDBRemoteCommunication::%s() "
1025  "named pipe creation failed: %s",
1026  __FUNCTION__, error.AsCString());
1027  return error;
1028  }
1029  debugserver_args.AppendArgument(llvm::StringRef("--named-pipe"));
1030  debugserver_args.AppendArgument(named_pipe_path);
1031 #else
1032  // Binding to port zero, we need to figure out what port it ends up
1033  // using using an unnamed pipe...
1034  error = socket_pipe.CreateNew(true);
1035  if (error.Fail()) {
1036  LLDB_LOGF(log,
1037  "GDBRemoteCommunication::%s() "
1038  "unnamed pipe creation failed: %s",
1039  __FUNCTION__, error.AsCString());
1040  return error;
1041  }
1042  pipe_t write = socket_pipe.GetWritePipe();
1043  debugserver_args.AppendArgument(llvm::StringRef("--pipe"));
1044  debugserver_args.AppendArgument(llvm::to_string(write));
1045  launch_info.AppendCloseFileAction(socket_pipe.GetReadFileDescriptor());
1046 #endif
1047  } else {
1048  // No host and port given, so lets listen on our end and make the
1049  // debugserver connect to us..
1050  error = StartListenThread("127.0.0.1", 0);
1051  if (error.Fail()) {
1052  LLDB_LOGF(log,
1053  "GDBRemoteCommunication::%s() unable to start listen "
1054  "thread: %s",
1055  __FUNCTION__, error.AsCString());
1056  return error;
1057  }
1058 
1059  ConnectionFileDescriptor *connection =
1061  // Wait for 10 seconds to resolve the bound port
1062  uint16_t port_ = connection->GetListeningPort(std::chrono::seconds(10));
1063  if (port_ > 0) {
1064  char port_cstr[32];
1065  snprintf(port_cstr, sizeof(port_cstr), "127.0.0.1:%i", port_);
1066  // Send the host and port down that debugserver and specify an option
1067  // so that it connects back to the port we are listening to in this
1068  // process
1069  debugserver_args.AppendArgument(llvm::StringRef("--reverse-connect"));
1070  debugserver_args.AppendArgument(llvm::StringRef(port_cstr));
1071  if (port)
1072  *port = port_;
1073  } else {
1074  error.SetErrorString("failed to bind to port 0 on 127.0.0.1");
1075  LLDB_LOGF(log, "GDBRemoteCommunication::%s() failed: %s",
1076  __FUNCTION__, error.AsCString());
1077  return error;
1078  }
1079  }
1080  }
1081  std::string env_debugserver_log_file =
1082  host_env.lookup("LLDB_DEBUGSERVER_LOG_FILE");
1083  if (!env_debugserver_log_file.empty()) {
1084  debugserver_args.AppendArgument(
1085  llvm::formatv("--log-file={0}", env_debugserver_log_file).str());
1086  }
1087 
1088 #if defined(__APPLE__)
1089  const char *env_debugserver_log_flags =
1090  getenv("LLDB_DEBUGSERVER_LOG_FLAGS");
1091  if (env_debugserver_log_flags) {
1092  debugserver_args.AppendArgument(
1093  llvm::formatv("--log-flags={0}", env_debugserver_log_flags).str());
1094  }
1095 #else
1096  std::string env_debugserver_log_channels =
1097  host_env.lookup("LLDB_SERVER_LOG_CHANNELS");
1098  if (!env_debugserver_log_channels.empty()) {
1099  debugserver_args.AppendArgument(
1100  llvm::formatv("--log-channels={0}", env_debugserver_log_channels)
1101  .str());
1102  }
1103 #endif
1104 
1105  // Add additional args, starting with LLDB_DEBUGSERVER_EXTRA_ARG_1 until an
1106  // env var doesn't come back.
1107  uint32_t env_var_index = 1;
1108  bool has_env_var;
1109  do {
1110  char env_var_name[64];
1111  snprintf(env_var_name, sizeof(env_var_name),
1112  "LLDB_DEBUGSERVER_EXTRA_ARG_%" PRIu32, env_var_index++);
1113  std::string extra_arg = host_env.lookup(env_var_name);
1114  has_env_var = !extra_arg.empty();
1115 
1116  if (has_env_var) {
1117  debugserver_args.AppendArgument(llvm::StringRef(extra_arg));
1118  LLDB_LOGF(log,
1119  "GDBRemoteCommunication::%s adding env var %s contents "
1120  "to stub command line (%s)",
1121  __FUNCTION__, env_var_name, extra_arg.c_str());
1122  }
1123  } while (has_env_var);
1124 
1125  if (inferior_args && inferior_args->GetArgumentCount() > 0) {
1126  debugserver_args.AppendArgument(llvm::StringRef("--"));
1127  debugserver_args.AppendArguments(*inferior_args);
1128  }
1129 
1130  // Copy the current environment to the gdbserver/debugserver instance
1131  launch_info.GetEnvironment() = host_env;
1132 
1133  // Close STDIN, STDOUT and STDERR.
1134  launch_info.AppendCloseFileAction(STDIN_FILENO);
1135  launch_info.AppendCloseFileAction(STDOUT_FILENO);
1136  launch_info.AppendCloseFileAction(STDERR_FILENO);
1137 
1138  // Redirect STDIN, STDOUT and STDERR to "/dev/null".
1139  launch_info.AppendSuppressFileAction(STDIN_FILENO, true, false);
1140  launch_info.AppendSuppressFileAction(STDOUT_FILENO, false, true);
1141  launch_info.AppendSuppressFileAction(STDERR_FILENO, false, true);
1142 
1143  if (log) {
1144  StreamString string_stream;
1145  Platform *const platform = nullptr;
1146  launch_info.Dump(string_stream, platform);
1147  LLDB_LOGF(log, "launch info for gdb-remote stub:\n%s",
1148  string_stream.GetData());
1149  }
1150  error = Host::LaunchProcess(launch_info);
1151 
1152  if (error.Success() &&
1153  (launch_info.GetProcessID() != LLDB_INVALID_PROCESS_ID) &&
1154  pass_comm_fd == -1) {
1155  if (named_pipe_path.size() > 0) {
1156  error = socket_pipe.OpenAsReader(named_pipe_path, false);
1157  if (error.Fail())
1158  LLDB_LOGF(log,
1159  "GDBRemoteCommunication::%s() "
1160  "failed to open named pipe %s for reading: %s",
1161  __FUNCTION__, named_pipe_path.c_str(), error.AsCString());
1162  }
1163 
1164  if (socket_pipe.CanWrite())
1165  socket_pipe.CloseWriteFileDescriptor();
1166  if (socket_pipe.CanRead()) {
1167  char port_cstr[PATH_MAX] = {0};
1168  port_cstr[0] = '\0';
1169  size_t num_bytes = sizeof(port_cstr);
1170  // Read port from pipe with 10 second timeout.
1171  error = socket_pipe.ReadWithTimeout(
1172  port_cstr, num_bytes, std::chrono::seconds{10}, num_bytes);
1173  if (error.Success() && (port != nullptr)) {
1174  assert(num_bytes > 0 && port_cstr[num_bytes - 1] == '\0');
1175  uint16_t child_port = 0;
1176  // FIXME: improve error handling
1177  llvm::to_integer(port_cstr, child_port);
1178  if (*port == 0 || *port == child_port) {
1179  *port = child_port;
1180  LLDB_LOGF(log,
1181  "GDBRemoteCommunication::%s() "
1182  "debugserver listens %u port",
1183  __FUNCTION__, *port);
1184  } else {
1185  LLDB_LOGF(log,
1186  "GDBRemoteCommunication::%s() "
1187  "debugserver listening on port "
1188  "%d but requested port was %d",
1189  __FUNCTION__, (uint32_t)child_port, (uint32_t)(*port));
1190  }
1191  } else {
1192  LLDB_LOGF(log,
1193  "GDBRemoteCommunication::%s() "
1194  "failed to read a port value from pipe %s: %s",
1195  __FUNCTION__, named_pipe_path.c_str(), error.AsCString());
1196  }
1197  socket_pipe.Close();
1198  }
1199 
1200  if (named_pipe_path.size() > 0) {
1201  const auto err = socket_pipe.Delete(named_pipe_path);
1202  if (err.Fail()) {
1203  LLDB_LOGF(log,
1204  "GDBRemoteCommunication::%s failed to delete pipe %s: %s",
1205  __FUNCTION__, named_pipe_path.c_str(), err.AsCString());
1206  }
1207  }
1208 
1209  // Make sure we actually connect with the debugserver...
1210  JoinListenThread();
1211  }
1212  } else {
1213  error.SetErrorStringWithFormat("unable to locate " DEBUGSERVER_BASENAME);
1214  }
1215 
1216  if (error.Fail()) {
1217  LLDB_LOGF(log, "GDBRemoteCommunication::%s() failed: %s", __FUNCTION__,
1218  error.AsCString());
1219  }
1220 
1221  return error;
1222 }
1223 
1225 
1227  repro::PacketRecorder *recorder) {
1228  m_history.SetRecorder(recorder);
1229 }
1230 
1233  GDBRemoteCommunication &server) {
1234  const bool child_processes_inherit = false;
1235  const int backlog = 5;
1236  TCPSocket listen_socket(true, child_processes_inherit);
1237  if (llvm::Error error =
1238  listen_socket.Listen("localhost:0", backlog).ToError())
1239  return error;
1240 
1241  Socket *accept_socket;
1242  std::future<Status> accept_status = std::async(
1243  std::launch::async, [&] { return listen_socket.Accept(accept_socket); });
1244 
1245  llvm::SmallString<32> remote_addr;
1246  llvm::raw_svector_ostream(remote_addr)
1247  << "connect://localhost:" << listen_socket.GetLocalPortNumber();
1248 
1249  std::unique_ptr<ConnectionFileDescriptor> conn_up(
1250  new ConnectionFileDescriptor());
1251  Status status;
1252  if (conn_up->Connect(remote_addr, &status) != lldb::eConnectionStatusSuccess)
1253  return llvm::createStringError(llvm::inconvertibleErrorCode(),
1254  "Unable to connect: %s", status.AsCString());
1255 
1256  client.SetConnection(std::move(conn_up));
1257  if (llvm::Error error = accept_status.get().ToError())
1258  return error;
1259 
1260  server.SetConnection(
1261  std::make_unique<ConnectionFileDescriptor>(accept_socket));
1262  return llvm::Error::success();
1263 }
1264 
1266  GDBRemoteCommunication &gdb_comm, std::chrono::seconds timeout)
1267  : m_gdb_comm(gdb_comm), m_timeout_modified(false) {
1268  auto curr_timeout = gdb_comm.GetPacketTimeout();
1269  // Only update the timeout if the timeout is greater than the current
1270  // timeout. If the current timeout is larger, then just use that.
1271  if (curr_timeout < timeout) {
1272  m_timeout_modified = true;
1274  }
1275 }
1276 
1278  // Only restore the timeout if we set it in the constructor.
1279  if (m_timeout_modified)
1280  m_gdb_comm.SetPacketTimeout(m_saved_timeout);
1281 }
1282 
1283 // This function is called via the Communications class read thread when bytes
1284 // become available for this connection. This function will consume all
1285 // incoming bytes and try to parse whole packets as they become available. Full
1286 // packets are placed in a queue, so that all packet requests can simply pop
1287 // from this queue. Async notification packets will be dispatched immediately
1288 // to the ProcessGDBRemote Async thread via an event.
1290  size_t len, bool broadcast,
1291  lldb::ConnectionStatus status) {
1292  StringExtractorGDBRemote packet;
1293 
1294  while (true) {
1295  PacketType type = CheckForPacket(bytes, len, packet);
1296 
1297  // scrub the data so we do not pass it back to CheckForPacket on future
1298  // passes of the loop
1299  bytes = nullptr;
1300  len = 0;
1301 
1302  // we may have received no packet so lets bail out
1303  if (type == PacketType::Invalid)
1304  break;
1305 
1306  if (type == PacketType::Standard) {
1307  // scope for the mutex
1308  {
1309  // lock down the packet queue
1310  std::lock_guard<std::mutex> guard(m_packet_queue_mutex);
1311  // push a new packet into the queue
1312  m_packet_queue.push(packet);
1313  // Signal condition variable that we have a packet
1314  m_condition_queue_not_empty.notify_one();
1315  }
1316  }
1317 
1318  if (type == PacketType::Notify) {
1319  // put this packet into an event
1320  const char *pdata = packet.GetStringRef().data();
1321 
1322  // as the communication class, we are a broadcaster and the async thread
1323  // is tuned to listen to us
1325  new EventDataBytes(pdata));
1326  }
1327  }
1328 }
1329 
1330 void llvm::format_provider<GDBRemoteCommunication::PacketResult>::format(
1331  const GDBRemoteCommunication::PacketResult &result, raw_ostream &Stream,
1332  StringRef Style) {
1334 
1335  switch (result) {
1336  case PacketResult::Success:
1337  Stream << "Success";
1338  break;
1340  Stream << "ErrorSendFailed";
1341  break;
1343  Stream << "ErrorSendAck";
1344  break;
1346  Stream << "ErrorReplyFailed";
1347  break;
1349  Stream << "ErrorReplyTimeout";
1350  break;
1352  Stream << "ErrorReplyInvalid";
1353  break;
1355  Stream << "ErrorReplyAck";
1356  break;
1358  Stream << "ErrorDisconnected";
1359  break;
1361  Stream << "ErrorNoSequenceLock";
1362  break;
1363  }
1364 }
1365 
1367  // Reserve enough byte for the most common case (no RLE used).
1368  std::string decoded;
1369  decoded.reserve(packet.size());
1370  for (std::string::const_iterator c = packet.begin(); c != packet.end(); ++c) {
1371  if (*c == '*') {
1372  // '*' indicates RLE. Next character will give us the repeat count and
1373  // previous character is what is to be repeated.
1374  char char_to_repeat = decoded.back();
1375  // Number of time the previous character is repeated.
1376  int repeat_count = *++c + 3 - ' ';
1377  // We have the char_to_repeat and repeat_count. Now push it in the
1378  // packet.
1379  for (int i = 0; i < repeat_count; ++i)
1380  decoded.push_back(char_to_repeat);
1381  } else if (*c == 0x7d) {
1382  // 0x7d is the escape character. The next character is to be XOR'd with
1383  // 0x20.
1384  char escapee = *++c ^ 0x20;
1385  decoded.push_back(escapee);
1386  } else {
1387  decoded.push_back(*c);
1388  }
1389  }
1390  return decoded;
1391 }
RegularExpression.h
lldb_private::process_gdb_remote::GDBRemoteCommunication::PacketType::Notify
@ Notify
lldb_private::process_gdb_remote::GDBRemoteCommunication::~GDBRemoteCommunication
~GDBRemoteCommunication() override
Definition: GDBRemoteCommunication.cpp:75
lldb_private::ProcessInfo::GetArguments
Args & GetArguments()
Definition: ProcessInfo.h:75
lldb_private::process_gdb_remote::CompressionType
CompressionType
Definition: GDBRemoteCommunication.h:44
lldb_private::process_gdb_remote::GDBRemoteCommunication::PopPacketFromQueue
PacketResult PopPacketFromQueue(StringExtractorGDBRemote &response, Timeout< std::micro > timeout)
Definition: GDBRemoteCommunication.cpp:239
StringExtractor::PeekChar
char PeekChar(char fail_value='\0')
Definition: StringExtractor.h:60
lldb_private::process_gdb_remote::GDBRemoteCommunication::AppendBytesToCache
void AppendBytesToCache(const uint8_t *bytes, size_t len, bool broadcast, lldb::ConnectionStatus status) override
Append new bytes that get read from the read thread into the internal object byte cache.
Definition: GDBRemoteCommunication.cpp:1289
lldb_private::ProcessLaunchInfo::AppendDuplicateFileAction
bool AppendDuplicateFileAction(int fd, int dup_fd)
Definition: ProcessLaunchInfo.cpp:81
lldb_private::Pipe
PipePosix Pipe
Definition: Pipe.h:20
lldb_private::Log::PutString
void PutString(llvm::StringRef str)
Definition: Log.cpp:119
lldb_private::RegularExpression
Definition: RegularExpression.h:18
lldb_private::Host::LaunchProcess
static Status LaunchProcess(ProcessLaunchInfo &launch_info)
Launch the process specified in launch_info.
Definition: common/Host.cpp:616
FileSystem.h
x20
@ x20
Definition: CompactUnwindInfo.cpp:1237
lldb_private::Log::GetVerbose
bool GetVerbose() const
Definition: Log.cpp:276
lldb_private::TCPSocket::Accept
Status Accept(Socket *&conn_socket) override
Definition: TCPSocket.cpp:254
LLDB_INVALID_PROCESS_ID
#define LLDB_INVALID_PROCESS_ID
Definition: lldb-defines.h:93
lldb_private::process_gdb_remote::GDBRemoteCommunication::CalculcateChecksum
char CalculcateChecksum(llvm::StringRef payload)
Definition: GDBRemoteCommunication.cpp:91
lldb_private::process_gdb_remote::GDBRemoteCommunication::SetPacketTimeout
std::chrono::seconds SetPacketTimeout(std::chrono::seconds packet_timeout)
Definition: GDBRemoteCommunication.h:146
StringExtractor::SetFilePos
void SetFilePos(uint32_t idx)
Definition: StringExtractor.h:39
lldb_private::process_gdb_remote::GDBRemoteCommunication::m_packet_queue
std::queue< StringExtractorGDBRemote > m_packet_queue
Definition: GDBRemoteCommunication.h:242
lldb_private::process_gdb_remote::GDBRemoteCommunication::SendAck
size_t SendAck()
Definition: GDBRemoteCommunication.cpp:100
Host.h
StringExtractor::GetStringRef
llvm::StringRef GetStringRef() const
Definition: StringExtractor.h:48
lldb_private::process_gdb_remote::GDBRemoteCommunication::PacketResult
PacketResult
Definition: GDBRemoteCommunication.h:92
ProcessLaunchInfo.h
lldb_private::process_gdb_remote::GDBRemoteCommunication::DecompressPacket
bool DecompressPacket()
Definition: GDBRemoteCommunication.cpp:411
lldb_private::Communication::ConnectionStatusAsString
static std::string ConnectionStatusAsString(lldb::ConnectionStatus status)
Definition: Communication.cpp:420
lldb_private::Socket
Definition: Socket.h:42
lldb_private::eLazyBoolYes
@ eLazyBoolYes
Definition: lldb-private-enumerations.h:115
LLDB_LOGF
#define LLDB_LOGF(log,...)
Definition: Log.h:249
lldb_private::Args::AppendArguments
void AppendArguments(const Args &rhs)
Definition: Args.cpp:293
lldb_private::process_gdb_remote::GDBRemoteCommunication::m_listen_thread
HostThread m_listen_thread
Definition: GDBRemoteCommunication.h:247
lldb_private::Args::AppendArgument
void AppendArgument(llvm::StringRef arg_str, char quote_char='\0')
Appends a new argument to the end of the list argument list.
Definition: Args.cpp:318
lldb_private::process_gdb_remote::GDBRemoteCommunication::CompressionIsEnabled
bool CompressionIsEnabled()
Definition: GDBRemoteCommunication.h:206
lldb_private::process_gdb_remote::GDBRemoteCommunication
Definition: GDBRemoteCommunication.h:82
lldb_private::Args::Clear
void Clear()
Clear the arguments.
Definition: Args.cpp:374
lldb_private::process_gdb_remote::GDBRemoteCommunication::ScopedTimeout::m_saved_timeout
std::chrono::seconds m_saved_timeout
Definition: GDBRemoteCommunication.h:117
Reproducer.h
lldb_private::process_gdb_remote::GDBRemoteCommunication::eBroadcastBitGdbReadThreadGotNotify
@ eBroadcastBitGdbReadThreadGotNotify
Definition: GDBRemoteCommunication.h:86
lldb_private::ProcessInfo::GetProcessID
lldb::pid_t GetProcessID() const
Definition: ProcessInfo.h:67
lldb_private::FileSystem::Exists
bool Exists(const FileSpec &file_spec) const
Returns whether the given file exists.
Definition: common/FileSystem.cpp:170
lldb_private::Stream
Definition: Stream.h:28
lldb_private::Args
Definition: Args.h:33
lldb::pipe_t
int pipe_t
Definition: lldb-types.h:64
lldb::eConnectionStatusNoConnection
@ eConnectionStatusNoConnection
No connection.
Definition: lldb-enumerations.h:300
ThreadLauncher.h
lldb::eConnectionStatusEndOfFile
@ eConnectionStatusEndOfFile
End-of-file encountered.
Definition: lldb-enumerations.h:297
LLDB_LOGV
#define LLDB_LOGV(log,...)
Definition: Log.h:256
lldb_private::process_gdb_remote::GDBRemoteCommunication::WaitForPacketNoLock
PacketResult WaitForPacketNoLock(StringExtractorGDBRemote &response, Timeout< std::micro > timeout, bool sync_on_timeout)
Definition: GDBRemoteCommunication.cpp:265
lldb_private::StreamString::GetString
llvm::StringRef GetString() const
Definition: StreamString.cpp:51
lldb_private::process_gdb_remote::GDBRemoteCommunication::JoinListenThread
bool JoinListenThread()
Definition: GDBRemoteCommunication.cpp:881
lldb_private::ProcessLaunchInfo::AppendCloseFileAction
bool AppendCloseFileAction(int fd)
Definition: ProcessLaunchInfo.cpp:72
lldb_private::process_gdb_remote::GDBRemoteCommunication::PacketType::Invalid
@ Invalid
lldb_private::process_gdb_remote::GDBRemoteCommunication::DumpHistory
void DumpHistory(Stream &strm)
Definition: GDBRemoteCommunication.cpp:1224
lldb_private::Communication::SetConnection
void SetConnection(std::unique_ptr< Connection > connection)
Sets the connection that it to be used by this class.
Definition: Communication.cpp:413
lldb_private::Communication
Definition: Communication.h:84
lldb_private::process_gdb_remote::GDBRemoteCommunicationHistory::Dump
void Dump(Stream &strm) const
Definition: GDBRemoteCommunicationHistory.cpp:64
endif
LLDBWrapPython cpp endif() if(LLDB_ENABLE_LUA) get_target_property(lua_bindings_dir swig_wrapper_lua BINARY_DIR) set(lldb_lua_wrapper $
Definition: API/CMakeLists.txt:15
lldb_private::process_gdb_remote::GDBRemoteCommunication::PacketResult::ErrorReplyInvalid
@ ErrorReplyInvalid
lldb_private::ConnectionFileDescriptor::GetListeningPort
uint16_t GetListeningPort(const Timeout< std::micro > &timeout)
Definition: ConnectionFileDescriptorPosix.cpp:789
lldb_private::process_gdb_remote::GDBRemoteCommunication::SendRawPacketNoLock
PacketResult SendRawPacketNoLock(llvm::StringRef payload, bool skip_ack=false)
Definition: GDBRemoteCommunication.cpp:133
Platform.h
lldb_private::FileSpec
Definition: FileSpec.h:56
lldb_private::ProcessLaunchInfo::AppendSuppressFileAction
bool AppendSuppressFileAction(int fd, bool read, bool write)
Definition: ProcessLaunchInfo.cpp:100
lldb_private::process_gdb_remote::GDBRemoteCommunication::m_compression_type
CompressionType m_compression_type
Definition: GDBRemoteCommunication.h:184
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
lldb_private::process_gdb_remote::GDBRemoteCommunication::ListenThread
static lldb::thread_result_t ListenThread(lldb::thread_arg_t arg)
Definition: GDBRemoteCommunication.cpp:888
lldb_private::process_gdb_remote::GDBRemoteCommunication::PacketResult::ErrorReplyAck
@ ErrorReplyAck
else
else() list(APPEND LLVM_OPTIONAL_SOURCES $
Definition: Plugins/Platform/MacOSX/CMakeLists.txt:30
lldb_private::process_gdb_remote::GDBRemoteCommunication::StartDebugserverProcess
Status StartDebugserverProcess(const char *url, Platform *platform, ProcessLaunchInfo &launch_info, uint16_t *port, const Args *inferior_args, int pass_comm_fd)
Definition: GDBRemoteCommunication.cpp:903
lldb_private::ProcessLaunchInfo
Definition: ProcessLaunchInfo.h:31
Log.h
lldb_private::process_gdb_remote::GDBRemoteCommunication::PacketResult::ErrorNoSequenceLock
@ ErrorNoSequenceLock
lldb_private::process_gdb_remote::GDBRemoteCommunication::m_history
GDBRemoteCommunicationHistory m_history
Definition: GDBRemoteCommunication.h:178
lldb_private::process_gdb_remote::GDBRemoteCommunication::ScopedTimeout::~ScopedTimeout
~ScopedTimeout()
Definition: GDBRemoteCommunication.cpp:1277
lldb_private::StreamString::GetData
const char * GetData() const
Definition: StreamString.h:43
lldb_private::process_gdb_remote::GDBRemoteCommunication::m_echo_number
uint32_t m_echo_number
Definition: GDBRemoteCommunication.h:176
Socket.h
lldb_private::process_gdb_remote::GDBRemoteCommunication::PacketResult::ErrorSendFailed
@ ErrorSendFailed
StreamString.h
lldb_private::process_gdb_remote::CompressionType::LZMA
@ LZMA
lldb_private::process_gdb_remote::GDBRemoteCommunication::m_supports_qEcho
LazyBool m_supports_qEcho
Definition: GDBRemoteCommunication.h:177
lldb_private::process_gdb_remote::GDBRemoteCommunication::ScopedTimeout::m_gdb_comm
GDBRemoteCommunication & m_gdb_comm
Definition: GDBRemoteCommunication.h:116
lldb_private::StreamString
Definition: StreamString.h:23
StringExtractorGDBRemote::GetResponseType
ResponseType GetResponseType() const
Definition: StringExtractorGDBRemote.cpp:18
lldb_private::process_gdb_remote::GDBRemoteCommunication::SetPacketRecorder
void SetPacketRecorder(repro::PacketRecorder *recorder)
Definition: GDBRemoteCommunication.cpp:1226
lldb::eConnectionStatusTimedOut
@ eConnectionStatusTimedOut
Request timed out.
Definition: lldb-enumerations.h:299
lldb::ConnectionStatus
ConnectionStatus
Connection Status Types.
Definition: lldb-enumerations.h:295
Pipe.h
lldb_private::process_gdb_remote::GDBRemoteCommunication::m_condition_queue_not_empty
std::condition_variable m_condition_queue_not_empty
Definition: GDBRemoteCommunication.h:245
lldb::eConnectionStatusInterrupted
@ eConnectionStatusInterrupted
Interrupted read.
Definition: lldb-enumerations.h:303
ConnectionFileDescriptor.h
lldb_private::EventDataBytes
Definition: Event.h:56
lldb_private::Communication::StopReadThread
virtual bool StopReadThread(Status *error_ptr=nullptr)
Stops the read thread by cancelling it.
Definition: Communication.cpp:227
HostInfo.h
lldb_private::process_gdb_remote::GDBRemoteCommunicationHistory::SetRecorder
void SetRecorder(repro::PacketRecorder *recorder)
Definition: GDBRemoteCommunicationHistory.h:48
StringExtractor::GetChar
char GetChar(char fail_value='\0')
Definition: StringExtractor.cpp:45
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
lldb::thread_arg_t
void * thread_arg_t
Definition: lldb-types.h:61
lldb_private::Communication::Write
size_t Write(const void *src, size_t src_len, lldb::ConnectionStatus &status, Status *error_ptr)
The actual write function that attempts to write to the communications protocol.
Definition: Communication.cpp:173
lldb_private::Stream::PutChar
size_t PutChar(char ch)
Definition: Stream.cpp:104
lldb_private::process_gdb_remote
Definition: GDBRemoteClientBase.h:17
lldb_private::process_gdb_remote::GDBRemoteCommunication::SendNack
size_t SendNack()
Definition: GDBRemoteCommunication.cpp:110
lldb_private::Platform::LocateExecutable
virtual FileSpec LocateExecutable(const char *basename)
Find a support executable that may not live within in the standard locations related to LLDB.
Definition: Platform.h:737
lldb_private::process_gdb_remote::GDBRemoteCommunication::m_packet_queue_mutex
std::mutex m_packet_queue_mutex
Definition: GDBRemoteCommunication.h:243
Event.h
GDBR_LOG_PROCESS
#define GDBR_LOG_PROCESS
Definition: ProcessGDBRemoteLog.h:14
lldb_private::process_gdb_remote::GDBRemoteCommunication::PacketResult::Success
@ Success
lldb_private::process_gdb_remote::GDBRemoteCommunication::GetAck
PacketResult GetAck()
Definition: GDBRemoteCommunication.cpp:194
lldb_private::process_gdb_remote::GDBRemoteCommunicationHistory::AddPacket
void AddPacket(char packet_char, GDBRemotePacket::Type type, uint32_t bytes_transmitted)
Definition: GDBRemoteCommunicationHistory.cpp:29
lldb_private::Host::GetEnvironment
static Environment GetEnvironment()
Definition: freebsd/Host.cpp:244
lldb_private::FileSpec::Clear
void Clear()
Clears the object state.
Definition: FileSpec.cpp:261
DEBUGSERVER_BASENAME
#define DEBUGSERVER_BASENAME
Definition: GDBRemoteCommunication.cpp:45
StringExtractor::GetHexByteString
size_t GetHexByteString(std::string &str)
Definition: StringExtractor.cpp:300
StreamFile.h
lldb_private::process_gdb_remote::GDBRemoteCommunication::ScopedTimeout::ScopedTimeout
ScopedTimeout(GDBRemoteCommunication &gdb_comm, std::chrono::seconds timeout)
Definition: GDBRemoteCommunication.cpp:1265
lldb_private::GDBRemotePacket::ePacketTypeRecv
@ ePacketTypeRecv
Definition: GDBRemote.h:56
lldb_private::Broadcaster::BroadcastEvent
void BroadcastEvent(lldb::EventSP &event_sp)
Broadcast an event which has no associated data.
Definition: Broadcaster.h:262
lldb_private::Communication::Disconnect
lldb::ConnectionStatus Disconnect(Status *error_ptr=nullptr)
Disconnect the communications connection if one is currently connected.
Definition: Communication.cpp:92
lldb_private::process_gdb_remote::GDBRemoteCommunication::ConnectLocally
static llvm::Error ConnectLocally(GDBRemoteCommunication &client, GDBRemoteCommunication &server)
Definition: GDBRemoteCommunication.cpp:1232
lldb_private::HostThread::Join
Status Join(lldb::thread_result_t *result)
Definition: HostThread.cpp:20
StringExtractor::Clear
void Clear()
Definition: StringExtractor.h:41
lldb_private::process_gdb_remote::GDBRemoteCommunication::ReadPacket
PacketResult ReadPacket(StringExtractorGDBRemote &response, Timeout< std::micro > timeout, bool sync_on_timeout)
Definition: GDBRemoteCommunication.cpp:225
lldb_private::process_gdb_remote::GDBRemoteCommunication::PacketType::Standard
@ Standard
lldb_private::Status
Definition: Status.h:44
lldb_private::GDBRemotePacket::ePacketTypeSend
@ ePacketTypeSend
Definition: GDBRemote.h:56
lldb_private::Timeout< std::micro >
lldb_private::Communication::Read
size_t Read(void *dst, size_t dst_len, const Timeout< std::micro > &timeout, lldb::ConnectionStatus &status, Status *error_ptr)
Read bytes from the current connection.
Definition: Communication.cpp:125
uint32_t
lldb_private::process_gdb_remote::GDBRemoteCommunication::StartListenThread
Status StartListenThread(const char *hostname="127.0.0.1", uint16_t port=0)
Definition: GDBRemoteCommunication.cpp:860
lldb::thread_result_t
void * thread_result_t
Definition: lldb-types.h:62
lldb_private::ProcessInfo::GetEnvironment
Environment & GetEnvironment()
Definition: ProcessInfo.h:87
lldb_private::process_gdb_remote::GDBRemoteCommunication::m_listen_url
std::string m_listen_url
Definition: GDBRemoteCommunication.h:248
lldb::eConnectionStatusError
@ eConnectionStatusError
Check GetError() for details.
Definition: lldb-enumerations.h:298
lldb_private::process_gdb_remote::GDBRemoteCommunication::PacketType
PacketType
Definition: GDBRemoteCommunication.h:90
lldb_private::process_gdb_remote::CompressionType::None
@ None
lldb_private::process_gdb_remote::GDBRemoteCommunication::CheckForPacket
PacketType CheckForPacket(const uint8_t *src, size_t src_len, StringExtractorGDBRemote &packet)
Definition: GDBRemoteCommunication.cpp:641
lldb_private::process_gdb_remote::GDBRemoteCommunication::GetSendAcks
bool GetSendAcks()
Definition: GDBRemoteCommunication.h:139
lldb_private::process_gdb_remote::CompressionType::LZFSE
@ LZFSE
lldb_private::process_gdb_remote::GDBRemoteCommunication::ReadPacketWithOutputSupport
PacketResult ReadPacketWithOutputSupport(StringExtractorGDBRemote &response, Timeout< std::micro > timeout, bool sync_on_timeout, llvm::function_ref< void(llvm::StringRef)> output_callback)
Definition: GDBRemoteCommunication.cpp:208
lldb_private::Environment
Definition: Environment.h:18
lldb_private::process_gdb_remote::GDBRemoteCommunication::SendPacketNoLock
PacketResult SendPacketNoLock(llvm::StringRef payload)
Definition: GDBRemoteCommunication.cpp:121
lldb_private::process_gdb_remote::GDBRemoteCommunication::ScopedTimeout::m_timeout_modified
bool m_timeout_modified
Definition: GDBRemoteCommunication.h:121
lldb_private::Communication::IsConnected
bool IsConnected() const
Check if the connection is valid.
Definition: Communication.cpp:116
uint16_t
ProcessGDBRemoteLog.h
lldb_private::process_gdb_remote::CompressionType::ZlibDeflate
@ ZlibDeflate
TCPSocket.h
lldb_private::Platform
Definition: Platform.h:71
lldb_private::Stream::Printf
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:107
lldb_private::process_gdb_remote::ProcessGDBRemoteLog::GetLogIfAllCategoriesSet
static Log * GetLogIfAllCategoriesSet(uint32_t mask)
Definition: ProcessGDBRemoteLog.h:38
lldb_private::repro::PacketRecorder
Definition: GDBRemote.h:85
lldb_private::FileSystem::Instance
static FileSystem & Instance()
Definition: common/FileSystem.cpp:45
lldb::eConnectionStatusSuccess
@ eConnectionStatusSuccess
Success.
Definition: lldb-enumerations.h:296
lldb_private::process_gdb_remote::GDBRemoteCommunication::PacketResult::ErrorDisconnected
@ ErrorDisconnected
GDBRemoteCommunication.h
lldb_private::FileSpec::AppendPathComponent
void AppendPathComponent(llvm::StringRef component)
Definition: FileSpec.cpp:435
lldb_private::TCPSocket
Definition: TCPSocket.h:17
lldb_private::HostThread::IsJoinable
bool IsJoinable() const
Definition: HostThread.cpp:30
lldb_private::process_gdb_remote::GDBRemoteCommunication::PacketResult::ErrorReplyTimeout
@ ErrorReplyTimeout
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::eLazyBoolCalculate
@ eLazyBoolCalculate
Definition: lldb-private-enumerations.h:115
lldb_private::ConnectionFileDescriptor::Connect
lldb::ConnectionStatus Connect(llvm::StringRef s, Status *error_ptr) override
Connect using the connect string url.
Definition: ConnectionFileDescriptorPosix.cpp:125
lldb_private::process_gdb_remote::GDBRemoteCommunication::PacketResult::ErrorReplyFailed
@ ErrorReplyFailed
Error
llvm::Error Error
Definition: UdtRecordCompleter.cpp:29
lldb_private::ProcessInfo::GetExecutableFile
FileSpec & GetExecutableFile()
Definition: ProcessInfo.h:42
ConnectionFileDescriptorPosix.h
FileSpec.h
lldb_private::RegularExpression::Execute
bool Execute(llvm::StringRef string, llvm::SmallVectorImpl< llvm::StringRef > *matches=nullptr) const
Execute a regular expression match using the compiled regular expression that is already in this obje...
Definition: RegularExpression.cpp:23
lldb::eByteOrderBig
@ eByteOrderBig
Definition: lldb-enumerations.h:140
lldb_private::Stream::Write
size_t Write(const void *src, size_t src_len)
Output character bytes to the stream.
Definition: Stream.h:101
lldb_private::Status::ToError
llvm::Error ToError() const
Definition: Status.cpp:90
lldb::eConnectionStatusLostConnection
@ eConnectionStatusLostConnection
Lost connection while connected to a valid connection.
Definition: lldb-enumerations.h:301
lldb_private::process_gdb_remote::GDBRemoteCommunication::GetPacketTimeout
std::chrono::seconds GetPacketTimeout() const
Definition: GDBRemoteCommunication.h:152
StringExtractorGDBRemote
Definition: StringExtractorGDBRemote.h:21
lldb_private::Communication::GetConnection
lldb_private::Connection * GetConnection()
Definition: Communication.h:162
lldb_private::Log
Definition: Log.h:49
lldb_private::ProcessLaunchInfo::GetLaunchInSeparateProcessGroup
bool GetLaunchInSeparateProcessGroup() const
Definition: ProcessLaunchInfo.h:84
lldb_private::FileSpec::SetFile
void SetFile(llvm::StringRef path, Style style)
Change the file specified with a new path.
Definition: FileSpec.cpp:174
lldb_private::process_gdb_remote::GDBRemoteCommunicationHistory::DidDumpToLog
bool DidDumpToLog() const
Definition: GDBRemoteCommunicationHistory.h:46
lldb_private::Communication::m_read_thread_enabled
std::atomic< bool > m_read_thread_enabled
Definition: Communication.h:305
PATH_MAX
#define PATH_MAX
Definition: windows/PosixApi.h:25
lldb_private::FileSpec::GetPath
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
Definition: FileSpec.cpp:348
lldb_private::process_gdb_remote::CompressionType::LZ4
@ LZ4
lldb_private::TCPSocket::GetLocalPortNumber
uint16_t GetLocalPortNumber() const
Definition: TCPSocket.cpp:80
GDBR_LOG_PACKETS
#define GDBR_LOG_PACKETS
Definition: ProcessGDBRemoteLog.h:16
lldb_private::ProcessInfo::Dump
void Dump(Stream &s, Platform *platform) const
Definition: ProcessInfo.cpp:50
lldb_private::Args::GetArgumentCount
size_t GetArgumentCount() const
Gets the number of arguments left in this command object.
Definition: Args.h:118
lldb_private::ConnectionFileDescriptor
Definition: ConnectionFileDescriptorPosix.h:29
lldb
Definition: SBAddress.h:15
lldb_private::process_gdb_remote::GDBRemoteCommunication::ExpandRLE
static std::string ExpandRLE(std::string)
Expand GDB run-length encoding.
Definition: GDBRemoteCommunication.cpp:1366
lldb_private::Stream::PutHex8
size_t size_t PutHex8(uint8_t uvalue)
Append an uint8_t value in the hexadecimal format to the stream.
Definition: Stream.cpp:234
lldb_private::Communication::m_bytes
std::string m_bytes
A buffer to cache bytes read in the ReadThread function.
Definition: Communication.h:308
lldb_private::ThreadLauncher::LaunchThread
static llvm::Expected< HostThread > LaunchThread(llvm::StringRef name, lldb::thread_func_t thread_function, lldb::thread_arg_t thread_arg, size_t min_stack_byte_size=0)
Definition: ThreadLauncher.cpp:24
lldb_private::Communication::m_bytes_mutex
std::recursive_mutex m_bytes_mutex
A mutex to protect multi-threaded access to the cached bytes.
Definition: Communication.h:309
lldb_private::Status::AsCString
const char * AsCString(const char *default_error_str="unknown error") const
Get the error string associated with the current error.
Definition: Status.cpp:131
StringExtractorGDBRemote::IsNormalResponse
bool IsNormalResponse() const
Definition: StringExtractorGDBRemote.cpp:463
lldb_private::process_gdb_remote::GDBRemoteCommunication::PacketResult::ErrorSendAck
@ ErrorSendAck
lldb_private::TCPSocket::Listen
Status Listen(llvm::StringRef name, int backlog) override
Definition: TCPSocket.cpp:187