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