LLDB  mainline
GDBRemoteCommunicationServerPlatform.cpp
Go to the documentation of this file.
1 //===-- GDBRemoteCommunicationServerPlatform.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 <cerrno>
12 
13 #include <chrono>
14 #include <csignal>
15 #include <cstring>
16 #include <mutex>
17 #include <sstream>
18 #include <thread>
19 
20 #include "llvm/Support/FileSystem.h"
21 #include "llvm/Support/JSON.h"
22 #include "llvm/Support/Threading.h"
23 
24 #include "lldb/Host/Config.h"
26 #include "lldb/Host/FileAction.h"
27 #include "lldb/Host/Host.h"
28 #include "lldb/Host/HostInfo.h"
30 #include "lldb/Target/Platform.h"
32 #include "lldb/Utility/GDBRemote.h"
33 #include "lldb/Utility/LLDBLog.h"
34 #include "lldb/Utility/Log.h"
38 #include "lldb/Utility/UriParser.h"
39 
41 
42 using namespace lldb;
43 using namespace lldb_private::process_gdb_remote;
44 using namespace lldb_private;
45 
46 GDBRemoteCommunicationServerPlatform::PortMap::PortMap(uint16_t min_port,
47  uint16_t max_port) {
48  for (; min_port < max_port; ++min_port)
49  m_port_map[min_port] = LLDB_INVALID_PROCESS_ID;
50 }
51 
52 void GDBRemoteCommunicationServerPlatform::PortMap::AllowPort(uint16_t port) {
53  // Do not modify existing mappings
54  m_port_map.insert({port, LLDB_INVALID_PROCESS_ID});
55 }
56 
57 llvm::Expected<uint16_t>
58 GDBRemoteCommunicationServerPlatform::PortMap::GetNextAvailablePort() {
59  if (m_port_map.empty())
60  return 0; // Bind to port zero and get a port, we didn't have any
61  // limitations
62 
63  for (auto &pair : m_port_map) {
64  if (pair.second == LLDB_INVALID_PROCESS_ID) {
65  pair.second = ~(lldb::pid_t)LLDB_INVALID_PROCESS_ID;
66  return pair.first;
67  }
68  }
69  return llvm::createStringError(llvm::inconvertibleErrorCode(),
70  "No free port found in port map");
71 }
72 
73 bool GDBRemoteCommunicationServerPlatform::PortMap::AssociatePortWithProcess(
74  uint16_t port, lldb::pid_t pid) {
75  auto pos = m_port_map.find(port);
76  if (pos != m_port_map.end()) {
77  pos->second = pid;
78  return true;
79  }
80  return false;
81 }
82 
83 bool GDBRemoteCommunicationServerPlatform::PortMap::FreePort(uint16_t port) {
84  std::map<uint16_t, lldb::pid_t>::iterator pos = m_port_map.find(port);
85  if (pos != m_port_map.end()) {
86  pos->second = LLDB_INVALID_PROCESS_ID;
87  return true;
88  }
89  return false;
90 }
91 
92 bool GDBRemoteCommunicationServerPlatform::PortMap::FreePortForProcess(
93  lldb::pid_t pid) {
94  if (!m_port_map.empty()) {
95  for (auto &pair : m_port_map) {
96  if (pair.second == pid) {
97  pair.second = LLDB_INVALID_PROCESS_ID;
98  return true;
99  }
100  }
101  }
102  return false;
103 }
104 
105 bool GDBRemoteCommunicationServerPlatform::PortMap::empty() const {
106  return m_port_map.empty();
107 }
108 
109 // GDBRemoteCommunicationServerPlatform constructor
110 GDBRemoteCommunicationServerPlatform::GDBRemoteCommunicationServerPlatform(
111  const Socket::SocketProtocol socket_protocol, const char *socket_scheme)
112  : GDBRemoteCommunicationServerCommon("gdb-remote.server",
113  "gdb-remote.server.rx_packet"),
114  m_socket_protocol(socket_protocol), m_socket_scheme(socket_scheme),
115  m_spawned_pids_mutex(), m_port_map(), m_port_offset(0) {
117  m_pending_gdb_server.port = 0;
118 
146 
149  bool &interrupt, bool &quit) {
150  error.SetErrorString("interrupt received");
151  interrupt = true;
152  return PacketResult::Success;
153  });
154 }
155 
156 // Destructor
158  default;
159 
161  const lldb_private::Args &args, std::string hostname, lldb::pid_t &pid,
162  llvm::Optional<uint16_t> &port, std::string &socket_name) {
163  if (!port) {
164  llvm::Expected<uint16_t> available_port = m_port_map.GetNextAvailablePort();
165  if (available_port)
166  port = *available_port;
167  else
168  return Status(available_port.takeError());
169  }
170 
171  // Spawn a new thread to accept the port that gets bound after binding to
172  // port 0 (zero).
173 
174  // ignore the hostname send from the remote end, just use the ip address that
175  // we're currently communicating with as the hostname
176 
177  // Spawn a debugserver and try to get the port it listens to.
178  ProcessLaunchInfo debugserver_launch_info;
179  if (hostname.empty())
180  hostname = "127.0.0.1";
181 
182  Log *log = GetLog(LLDBLog::Platform);
183  LLDB_LOGF(log, "Launching debugserver with: %s:%u...", hostname.c_str(),
184  *port);
185 
186  // Do not run in a new session so that it can not linger after the platform
187  // closes.
188  debugserver_launch_info.SetLaunchInSeparateProcessGroup(false);
189  debugserver_launch_info.SetMonitorProcessCallback(
191  this, std::placeholders::_1));
192 
193  std::ostringstream url;
194 // debugserver does not accept the URL scheme prefix.
195 #if !defined(__APPLE__)
196  url << m_socket_scheme << "://";
197 #endif
198  uint16_t *port_ptr = port.getPointer();
200  std::string platform_uri = GetConnection()->GetURI();
201  llvm::Optional<URI> parsed_uri = URI::Parse(platform_uri);
202  url << '[' << parsed_uri->hostname.str() << "]:" << *port;
203  } else {
204  socket_name = GetDomainSocketPath("gdbserver").GetPath();
205  url << socket_name;
206  port_ptr = nullptr;
207  }
208 
210  url.str().c_str(), nullptr, debugserver_launch_info, port_ptr, &args, -1);
211 
212  pid = debugserver_launch_info.GetProcessID();
213  if (pid != LLDB_INVALID_PROCESS_ID) {
214  std::lock_guard<std::recursive_mutex> guard(m_spawned_pids_mutex);
215  m_spawned_pids.insert(pid);
216  if (*port > 0)
218  } else {
219  if (*port > 0)
221  }
222  return error;
223 }
224 
227  StringExtractorGDBRemote &packet) {
228  // Spawn a local debugserver as a platform so we can then attach or launch a
229  // process...
230 
231  Log *log = GetLog(LLDBLog::Platform);
232  LLDB_LOGF(log, "GDBRemoteCommunicationServerPlatform::%s() called",
233  __FUNCTION__);
234 
235  ConnectionFileDescriptor file_conn;
236  std::string hostname;
237  packet.SetFilePos(::strlen("qLaunchGDBServer;"));
238  llvm::StringRef name;
239  llvm::StringRef value;
240  llvm::Optional<uint16_t> port;
241  while (packet.GetNameColonValue(name, value)) {
242  if (name.equals("host"))
243  hostname = std::string(value);
244  else if (name.equals("port")) {
245  // Make the Optional valid so we can use its value
246  port = 0;
247  value.getAsInteger(0, port.getValue());
248  }
249  }
250 
251  lldb::pid_t debugserver_pid = LLDB_INVALID_PROCESS_ID;
253  Status error =
254  LaunchGDBServer(Args(), hostname, debugserver_pid, port, socket_name);
255  if (error.Fail()) {
256  LLDB_LOGF(log,
257  "GDBRemoteCommunicationServerPlatform::%s() debugserver "
258  "launch failed: %s",
259  __FUNCTION__, error.AsCString());
260  return SendErrorResponse(9);
261  }
262 
263  LLDB_LOGF(log,
264  "GDBRemoteCommunicationServerPlatform::%s() debugserver "
265  "launched successfully as pid %" PRIu64,
266  __FUNCTION__, debugserver_pid);
267 
268  StreamGDBRemote response;
269  assert(port);
270  response.Printf("pid:%" PRIu64 ";port:%u;", debugserver_pid,
271  *port + m_port_offset);
272  if (!socket_name.empty()) {
273  response.PutCString("socket_name:");
275  response.PutChar(';');
276  }
277 
278  PacketResult packet_result = SendPacketNoLock(response.GetString());
279  if (packet_result != PacketResult::Success) {
280  if (debugserver_pid != LLDB_INVALID_PROCESS_ID)
281  Host::Kill(debugserver_pid, SIGINT);
282  }
283  return packet_result;
284 }
285 
288  StringExtractorGDBRemote &packet) {
289  namespace json = llvm::json;
290 
292  return SendErrorResponse(4);
293 
294  json::Object server{{"port", m_pending_gdb_server.port}};
295 
296  if (!m_pending_gdb_server.socket_name.empty())
297  server.try_emplace("socket_name", m_pending_gdb_server.socket_name);
298 
299  json::Array server_list;
300  server_list.push_back(std::move(server));
301 
302  StreamGDBRemote response;
303  response.AsRawOstream() << std::move(server_list);
304 
305  StreamGDBRemote escaped_response;
306  escaped_response.PutEscapedBytes(response.GetString().data(),
307  response.GetSize());
308  return SendPacketNoLock(escaped_response.GetString());
309 }
310 
313  StringExtractorGDBRemote &packet) {
314  packet.SetFilePos(::strlen("qKillSpawnedProcess:"));
315 
317 
318  // verify that we know anything about this pid. Scope for locker
319  {
320  std::lock_guard<std::recursive_mutex> guard(m_spawned_pids_mutex);
321  if (m_spawned_pids.find(pid) == m_spawned_pids.end()) {
322  // not a pid we know about
323  return SendErrorResponse(10);
324  }
325  }
326 
327  // go ahead and attempt to kill the spawned process
328  if (KillSpawnedProcess(pid))
329  return SendOKResponse();
330  else
331  return SendErrorResponse(11);
332 }
333 
335  // make sure we know about this process
336  {
337  std::lock_guard<std::recursive_mutex> guard(m_spawned_pids_mutex);
338  if (m_spawned_pids.find(pid) == m_spawned_pids.end())
339  return false;
340  }
341 
342  // first try a SIGTERM (standard kill)
343  Host::Kill(pid, SIGTERM);
344 
345  // check if that worked
346  for (size_t i = 0; i < 10; ++i) {
347  {
348  std::lock_guard<std::recursive_mutex> guard(m_spawned_pids_mutex);
349  if (m_spawned_pids.find(pid) == m_spawned_pids.end()) {
350  // it is now killed
351  return true;
352  }
353  }
354  std::this_thread::sleep_for(std::chrono::milliseconds(10));
355  }
356 
357  {
358  std::lock_guard<std::recursive_mutex> guard(m_spawned_pids_mutex);
359  if (m_spawned_pids.find(pid) == m_spawned_pids.end())
360  return true;
361  }
362 
363  // the launched process still lives. Now try killing it again, this time
364  // with an unblockable signal.
366 
367  for (size_t i = 0; i < 10; ++i) {
368  {
369  std::lock_guard<std::recursive_mutex> guard(m_spawned_pids_mutex);
370  if (m_spawned_pids.find(pid) == m_spawned_pids.end()) {
371  // it is now killed
372  return true;
373  }
374  }
375  std::this_thread::sleep_for(std::chrono::milliseconds(10));
376  }
377 
378  // check one more time after the final sleep
379  {
380  std::lock_guard<std::recursive_mutex> guard(m_spawned_pids_mutex);
381  if (m_spawned_pids.find(pid) == m_spawned_pids.end())
382  return true;
383  }
384 
385  // no luck - the process still lives
386  return false;
387 }
388 
391  StringExtractorGDBRemote &packet) {
394 
396  return SendErrorResponse(1);
397 
398  ProcessInstanceInfo proc_info;
399  if (!Host::GetProcessInfo(pid, proc_info))
400  return SendErrorResponse(1);
401 
402  StreamString response;
403  CreateProcessInfoResponse_DebugServerStyle(proc_info, response);
404  return SendPacketNoLock(response.GetString());
405 }
406 
409  StringExtractorGDBRemote &packet) {
410  packet.SetFilePos(::strlen("qPathComplete:"));
411  const bool only_dir = (packet.GetHexMaxU32(false, 0) == 1);
412  if (packet.GetChar() != ',')
413  return SendErrorResponse(85);
414  std::string path;
415  packet.GetHexByteString(path);
416 
417  StringList matches;
419  if (only_dir)
420  CommandCompletions::DiskDirectories(path, matches, resolver);
421  else
422  CommandCompletions::DiskFiles(path, matches, resolver);
423 
424  StreamString response;
425  response.PutChar('M');
426  llvm::StringRef separator;
427  std::sort(matches.begin(), matches.end());
428  for (const auto &match : matches) {
429  response << separator;
430  separator = ",";
431  // encode result strings into hex bytes to avoid unexpected error caused by
432  // special characters like '$'.
433  response.PutStringAsRawHex8(match.c_str());
434  }
435 
436  return SendPacketNoLock(response.GetString());
437 }
438 
441  StringExtractorGDBRemote &packet) {
442 
443  llvm::SmallString<64> cwd;
444  if (std::error_code ec = llvm::sys::fs::current_path(cwd))
445  return SendErrorResponse(ec.value());
446 
447  StreamString response;
448  response.PutBytesAsRawHex8(cwd.data(), cwd.size());
449  return SendPacketNoLock(response.GetString());
450 }
451 
454  StringExtractorGDBRemote &packet) {
455  packet.SetFilePos(::strlen("QSetWorkingDir:"));
456  std::string path;
457  packet.GetHexByteString(path);
458 
459  if (std::error_code ec = llvm::sys::fs::set_current_path(path))
460  return SendErrorResponse(ec.value());
461  return SendOKResponse();
462 }
463 
466  StringExtractorGDBRemote &packet) {
467  // NOTE: lldb should now be using qProcessInfo for process IDs. This path
468  // here
469  // should not be used. It is reporting process id instead of thread id. The
470  // correct answer doesn't seem to make much sense for lldb-platform.
471  // CONSIDER: flip to "unsupported".
473 
474  StreamString response;
475  response.Printf("QC%" PRIx64, pid);
476 
477  // If we launch a process and this GDB server is acting as a platform, then
478  // we need to clear the process launch state so we can start launching
479  // another process. In order to launch a process a bunch or packets need to
480  // be sent: environment packets, working directory, disable ASLR, and many
481  // more settings. When we launch a process we then need to know when to clear
482  // this information. Currently we are selecting the 'qC' packet as that
483  // packet which seems to make the most sense.
484  if (pid != LLDB_INVALID_PROCESS_ID) {
486  }
487 
488  return SendPacketNoLock(response.GetString());
489 }
490 
493  StringExtractorGDBRemote &packet) {
494  StructuredData::Array signal_array;
495 
496  lldb::UnixSignalsSP signals = UnixSignals::CreateForHost();
497  for (auto signo = signals->GetFirstSignalNumber();
499  signo = signals->GetNextSignalNumber(signo)) {
500  auto dictionary = std::make_shared<StructuredData::Dictionary>();
501 
502  dictionary->AddIntegerItem("signo", signo);
503  dictionary->AddStringItem("name", signals->GetSignalAsCString(signo));
504 
505  bool suppress, stop, notify;
506  signals->GetSignalInfo(signo, suppress, stop, notify);
507  dictionary->AddBooleanItem("suppress", suppress);
508  dictionary->AddBooleanItem("stop", stop);
509  dictionary->AddBooleanItem("notify", notify);
510 
511  signal_array.Push(dictionary);
512  }
513 
514  StreamString response;
515  signal_array.Dump(response);
516  return SendPacketNoLock(response.GetString());
517 }
518 
520  lldb::pid_t pid) {
521  std::lock_guard<std::recursive_mutex> guard(m_spawned_pids_mutex);
523  m_spawned_pids.erase(pid);
524 }
525 
528  return Status("%s: no process command line specified to launch",
529  __FUNCTION__);
530 
531  // specify the process monitor if not already set. This should generally be
532  // what happens since we need to reap started processes.
536  std::placeholders::_1));
537 
539  if (!error.Success()) {
540  fprintf(stderr, "%s: failed to launch executable %s", __FUNCTION__,
542  return error;
543  }
544 
545  printf("Launched '%s' as process %" PRIu64 "...\n",
548 
549  // add to list of spawned processes. On an lldb-gdbserver, we would expect
550  // there to be only one.
551  const auto pid = m_process_launch_info.GetProcessID();
552  if (pid != LLDB_INVALID_PROCESS_ID) {
553  // add to spawned pids
554  std::lock_guard<std::recursive_mutex> guard(m_spawned_pids_mutex);
555  m_spawned_pids.insert(pid);
556  }
557 
558  return error;
559 }
560 
562  m_port_map = port_map;
563 }
564 
566  static FileSpec g_domainsocket_dir;
567  static llvm::once_flag g_once_flag;
568 
569  llvm::call_once(g_once_flag, []() {
570  const char *domainsocket_dir_env =
571  ::getenv("LLDB_DEBUGSERVER_DOMAINSOCKET_DIR");
572  if (domainsocket_dir_env != nullptr)
573  g_domainsocket_dir = FileSpec(domainsocket_dir_env);
574  else
575  g_domainsocket_dir = HostInfo::GetProcessTempDir();
576  });
577 
578  return g_domainsocket_dir;
579 }
580 
581 FileSpec
583  llvm::SmallString<128> socket_path;
584  llvm::SmallString<128> socket_name(
585  (llvm::StringRef(prefix) + ".%%%%%%").str());
586 
587  FileSpec socket_path_spec(GetDomainSocketDir());
588  socket_path_spec.AppendPathComponent(socket_name.c_str());
589 
590  llvm::sys::fs::createUniqueFile(socket_path_spec.GetCString(), socket_path);
591  return FileSpec(socket_path.c_str());
592 }
593 
595  m_port_offset = port_offset;
596 }
597 
599  lldb::pid_t pid, uint16_t port, const std::string &socket_name) {
601  m_pending_gdb_server.port = port;
602  m_pending_gdb_server.socket_name = socket_name;
603 }
lldb_private::ProcessInfo::GetArguments
Args & GetArguments()
Definition: ProcessInfo.h:75
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerPlatform::Handle_qProcessInfo
PacketResult Handle_qProcessInfo(StringExtractorGDBRemote &packet)
Definition: GDBRemoteCommunicationServerPlatform.cpp:390
lldb_private::ProcessInstanceInfo
Definition: ProcessInfo.h:108
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerPlatform::Handle_qGetWorkingDir
PacketResult Handle_qGetWorkingDir(StringExtractorGDBRemote &packet)
Definition: GDBRemoteCommunicationServerPlatform.cpp:440
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerPlatform::Handle_jSignalsInfo
PacketResult Handle_jSignalsInfo(StringExtractorGDBRemote &packet)
Definition: GDBRemoteCommunicationServerPlatform.cpp:492
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerPlatform::m_socket_protocol
const Socket::SocketProtocol m_socket_protocol
Definition: GDBRemoteCommunicationServerPlatform.h:100
lldb_private::process_gdb_remote::GDBRemoteCommunicationServer::SendErrorResponse
PacketResult SendErrorResponse(const Status &error)
Definition: GDBRemoteCommunicationServer.cpp:106
lldb_private::StandardTildeExpressionResolver
Definition: TildeExpressionResolver.h:56
lldb_private::Host::LaunchProcess
static Status LaunchProcess(ProcessLaunchInfo &launch_info)
Launch the process specified in launch_info.
Definition: common/Host.cpp:547
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerPlatform::LaunchProcess
Status LaunchProcess() override
Launch a process with the current launch settings.
Definition: GDBRemoteCommunicationServerPlatform.cpp:526
lldb_private::StringList::begin
iterator begin()
Definition: StringList.h:63
LLDB_INVALID_PROCESS_ID
#define LLDB_INVALID_PROCESS_ID
Definition: lldb-defines.h:81
StringExtractor::SetFilePos
void SetFilePos(uint32_t idx)
Definition: StringExtractor.h:39
lldb_private::process_gdb_remote::GDBRemoteCommunicationServer::RegisterPacketHandler
void RegisterPacketHandler(StringExtractorGDBRemote::ServerPacketType packet_type, PacketHandler handler)
Definition: GDBRemoteCommunicationServer.cpp:38
lldb_private::StructuredData::Array
Definition: StructuredData.h:165
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerPlatform::Handle_qQueryGDBServer
PacketResult Handle_qQueryGDBServer(StringExtractorGDBRemote &packet)
Definition: GDBRemoteCommunicationServerPlatform.cpp:287
StructuredData.h
lldb_private::URI::Parse
static llvm::Optional< URI > Parse(llvm::StringRef uri)
Definition: UriParser.cpp:27
lldb_private::Socket::SocketProtocol
SocketProtocol
Definition: Socket.h:43
Host.h
lldb_private::Connection::GetURI
virtual std::string GetURI()=0
Returns a URI that describes this connection object.
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerPlatform::PortMap::AssociatePortWithProcess
bool AssociatePortWithProcess(uint16_t port, lldb::pid_t pid)
Definition: GDBRemoteCommunicationServerPlatform.cpp:73
StringExtractorGDBRemote::eServerPacketType_qQueryGDBServer
@ eServerPacketType_qQueryGDBServer
Definition: StringExtractorGDBRemote.h:60
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerPlatform::GetDomainSocketPath
static FileSpec GetDomainSocketPath(const char *prefix)
Definition: GDBRemoteCommunicationServerPlatform.cpp:582
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerPlatform::PortMap
Definition: GDBRemoteCommunicationServerPlatform.h:28
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerPlatform::~GDBRemoteCommunicationServerPlatform
~GDBRemoteCommunicationServerPlatform() override
lldb_private::process_gdb_remote::GDBRemoteCommunication::PacketResult
PacketResult
Definition: GDBRemoteCommunication.h:91
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerPlatform::SetPortMap
void SetPortMap(PortMap &&port_map)
Definition: GDBRemoteCommunicationServerPlatform.cpp:561
LLDB_LOGF
#define LLDB_LOGF(log,...)
Definition: Log.h:270
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerPlatform::m_pending_gdb_server
struct lldb_private::process_gdb_remote::GDBRemoteCommunicationServerPlatform::@75 m_pending_gdb_server
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerPlatform::m_port_map
PortMap m_port_map
Definition: GDBRemoteCommunicationServerPlatform.h:105
StringExtractorGDBRemote::eServerPacketType_qC
@ eServerPacketType_qC
Definition: StringExtractorGDBRemote.h:55
StringExtractorGDBRemote::eServerPacketType_qProcessInfo
@ eServerPacketType_qProcessInfo
Definition: StringExtractorGDBRemote.h:116
lldb_private::ProcessInfo::GetProcessID
lldb::pid_t GetProcessID() const
Definition: ProcessInfo.h:67
StringExtractor::GetHexMaxU32
uint32_t GetHexMaxU32(bool little_endian, uint32_t fail_value)
Definition: StringExtractor.cpp:153
StringExtractorGDBRemote.h
lldb_private::Args
Definition: Args.h:33
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerPlatform::Handle_qLaunchGDBServer
PacketResult Handle_qLaunchGDBServer(StringExtractorGDBRemote &packet)
Definition: GDBRemoteCommunicationServerPlatform.cpp:226
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon
Definition: GDBRemoteCommunicationServerCommon.h:26
lldb_private::Stream::PutStringAsRawHex8
size_t PutStringAsRawHex8(llvm::StringRef s)
Definition: Stream.cpp:383
lldb_private::StreamString::GetString
llvm::StringRef GetString() const
Definition: StreamString.cpp:51
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerPlatform::LaunchGDBServer
Status LaunchGDBServer(const lldb_private::Args &args, std::string hostname, lldb::pid_t &pid, llvm::Optional< uint16_t > &port, std::string &socket_name)
Definition: GDBRemoteCommunicationServerPlatform.cpp:160
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerPlatform::SetPortOffset
void SetPortOffset(uint16_t port_offset)
Definition: GDBRemoteCommunicationServerPlatform.cpp:594
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerPlatform::m_spawned_pids
std::set< lldb::pid_t > m_spawned_pids
Definition: GDBRemoteCommunicationServerPlatform.h:103
lldb_private::FileSpec::GetCString
const char * GetCString(bool denormalize=true) const
Definition: FileSpec.cpp:363
lldb_private::StringList::end
iterator end()
Definition: StringList.h:64
llvm::json
Definition: TraceJSONStructs.cpp:19
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerPlatform::PortMap::GetNextAvailablePort
llvm::Expected< uint16_t > GetNextAvailablePort()
Definition: GDBRemoteCommunicationServerPlatform.cpp:58
Platform.h
lldb_private::FileSpec
Definition: FileSpec.h:56
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
LLDB_INVALID_SIGNAL_NUMBER
#define LLDB_INVALID_SIGNAL_NUMBER
Definition: lldb-defines.h:84
lldb_private::StreamString::GetSize
size_t GetSize() const
Definition: StreamString.cpp:38
lldb_private::ProcessLaunchInfo::Clear
void Clear()
Definition: ProcessLaunchInfo.cpp:164
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:880
lldb_private::StructuredData::Object::Dump
void Dump(lldb_private::Stream &s, bool pretty_print=true) const
Definition: StructuredData.h:156
SIGKILL
#define SIGKILL
Definition: windows/PosixApi.h:31
lldb_private::ProcessLaunchInfo
Definition: ProcessLaunchInfo.h:31
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerPlatform::PortMap::FreePortForProcess
bool FreePortForProcess(lldb::pid_t pid)
Definition: GDBRemoteCommunicationServerPlatform.cpp:92
Log.h
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerPlatform::PortMap::FreePort
bool FreePort(uint16_t port)
Definition: GDBRemoteCommunicationServerPlatform.cpp:83
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerPlatform::Handle_qC
PacketResult Handle_qC(StringExtractorGDBRemote &packet)
Definition: GDBRemoteCommunicationServerPlatform.cpp:465
UnixSignals.h
StringExtractorGDBRemote::eServerPacketType_qPathComplete
@ eServerPacketType_qPathComplete
Definition: StringExtractorGDBRemote.h:79
StreamString.h
StringExtractorGDBRemote::eServerPacketType_jSignalsInfo
@ eServerPacketType_jSignalsInfo
Definition: StringExtractorGDBRemote.h:130
lldb_private::UnixSignals::CreateForHost
static lldb::UnixSignalsSP CreateForHost()
Definition: UnixSignals.cpp:54
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::RegisterMemberFunctionHandler
void RegisterMemberFunctionHandler(StringExtractorGDBRemote::ServerPacketType packet_type, PacketResult(T::*handler)(StringExtractorGDBRemote &packet))
Definition: GDBRemoteCommunicationServerCommon.h:118
StringExtractorGDBRemote::eServerPacketType_qKillSpawnedProcess
@ eServerPacketType_qKillSpawnedProcess
Definition: StringExtractorGDBRemote.h:61
lldb_private::StringList
Definition: StringList.h:26
lldb_private::StreamString
Definition: StreamString.h:23
GDBRemote.h
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerPlatform::Handle_qPathComplete
PacketResult Handle_qPathComplete(StringExtractorGDBRemote &packet)
Definition: GDBRemoteCommunicationServerPlatform.cpp:408
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerPlatform::Handle_QSetWorkingDir
PacketResult Handle_QSetWorkingDir(StringExtractorGDBRemote &packet)
Definition: GDBRemoteCommunicationServerPlatform.cpp:453
ConnectionFileDescriptor.h
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerPlatform::m_spawned_pids_mutex
std::recursive_mutex m_spawned_pids_mutex
Definition: GDBRemoteCommunicationServerPlatform.h:102
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerPlatform::m_socket_scheme
const std::string m_socket_scheme
Definition: GDBRemoteCommunicationServerPlatform.h:101
lldb_private::StructuredData::Array::Push
void Push(const ObjectSP &item)
Definition: StructuredData.h:274
HostInfo.h
lldb_private::CommandCompletions::DiskDirectories
static void DiskDirectories(CommandInterpreter &interpreter, CompletionRequest &request, SearchFilter *searcher)
Definition: CommandCompletions.cpp:484
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerPlatform::pid
lldb::pid_t pid
Definition: GDBRemoteCommunicationServerPlatform.h:108
StringExtractor::GetChar
char GetChar(char fail_value='\0')
Definition: StringExtractor.cpp:43
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
StringExtractor::GetNameColonValue
bool GetNameColonValue(llvm::StringRef &name, llvm::StringRef &value)
Definition: StringExtractor.cpp:333
lldb_private::Stream::PutChar
size_t PutChar(char ch)
Definition: Stream.cpp:104
lldb_private::process_gdb_remote
Definition: GDBRemoteClientBase.h:17
lldb_private::CommandCompletions::DiskFiles
static void DiskFiles(CommandInterpreter &interpreter, CompletionRequest &request, SearchFilter *searcher)
Definition: CommandCompletions.cpp:472
StringExtractorGDBRemote::eServerPacketType_qLaunchGDBServer
@ eServerPacketType_qLaunchGDBServer
Definition: StringExtractorGDBRemote.h:59
StringExtractorGDBRemote::eServerPacketType_QSetWorkingDir
@ eServerPacketType_QSetWorkingDir
Definition: StringExtractorGDBRemote.h:77
lldb_private::ProcessLaunchInfo::SetLaunchInSeparateProcessGroup
void SetLaunchInSeparateProcessGroup(bool separate)
Definition: ProcessLaunchInfo.cpp:150
lldb_private::process_gdb_remote::GDBRemoteCommunication::PacketResult::Success
@ Success
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerPlatform::DebugserverProcessReaped
void DebugserverProcessReaped(lldb::pid_t pid)
Definition: GDBRemoteCommunicationServerPlatform.cpp:519
StringExtractor::GetHexByteString
size_t GetHexByteString(std::string &str)
Definition: StringExtractor.cpp:298
StringExtractor::GetU64
uint64_t GetU64(uint64_t fail_value, int base=0)
Definition: StringExtractor.cpp:123
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerPlatform::socket_name
std::string socket_name
Definition: GDBRemoteCommunicationServerPlatform.h:110
GDBRemoteCommunicationServerPlatform.h
lldb_private::Stream::PutBytesAsRawHex8
size_t PutBytesAsRawHex8(const void *src, size_t src_len, lldb::ByteOrder src_byte_order=lldb::eByteOrderInvalid, lldb::ByteOrder dst_byte_order=lldb::eByteOrderInvalid)
Definition: Stream.cpp:356
lldb_private::Status
Definition: Status.h:44
lldb_private::Socket::ProtocolTcp
@ ProtocolTcp
Definition: Socket.h:44
lldb_private::Args::GetArgumentAtIndex
const char * GetArgumentAtIndex(size_t idx) const
Gets the NULL terminated C string argument pointer for the argument at index idx.
Definition: Args.cpp:259
TildeExpressionResolver.h
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerPlatform::Handle_qKillSpawnedProcess
PacketResult Handle_qKillSpawnedProcess(StringExtractorGDBRemote &packet)
Definition: GDBRemoteCommunicationServerPlatform.cpp:312
lldb::pid_t
uint64_t pid_t
Definition: lldb-types.h:85
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerPlatform::GetDomainSocketDir
static const FileSpec & GetDomainSocketDir()
Definition: GDBRemoteCommunicationServerPlatform.cpp:565
StringExtractorGDBRemote::eServerPacketType_interrupt
@ eServerPacketType_interrupt
Definition: StringExtractorGDBRemote.h:51
lldb_private::Host::GetProcessInfo
static bool GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &proc_info)
Definition: freebsd/Host.cpp:230
lldb_private::StreamGDBRemote
Definition: GDBRemote.h:27
lldb_private::Stream::AsRawOstream
llvm::raw_ostream & AsRawOstream()
Returns a raw_ostream that forwards the data to this Stream object.
Definition: Stream.h:357
lldb_private::process_gdb_remote::GDBRemoteCommunication::SendPacketNoLock
PacketResult SendPacketNoLock(llvm::StringRef payload)
Definition: GDBRemoteCommunication.cpp:116
uint16_t
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerPlatform::SetPendingGdbServer
void SetPendingGdbServer(lldb::pid_t pid, uint16_t port, const std::string &socket_name)
Definition: GDBRemoteCommunicationServerPlatform.cpp:598
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerPlatform::port
uint16_t port
Definition: GDBRemoteCommunicationServerPlatform.h:109
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerPlatform::m_port_offset
uint16_t m_port_offset
Definition: GDBRemoteCommunicationServerPlatform.h:106
lldb_private::process_gdb_remote::GDBRemoteCommunicationServer::SendOKResponse
PacketResult SendOKResponse()
Definition: GDBRemoteCommunicationServer.cpp:149
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::GDBRemoteCommunicationServerCommon::CreateProcessInfoResponse_DebugServerStyle
static void CreateProcessInfoResponse_DebugServerStyle(const ProcessInstanceInfo &proc_info, StreamString &response)
Definition: GDBRemoteCommunicationServerCommon.cpp:1237
lldb_private::LLDBLog::Platform
@ Platform
lldb_private::FileSpec::AppendPathComponent
void AppendPathComponent(llvm::StringRef component)
Definition: FileSpec.cpp:434
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::StreamGDBRemote::PutEscapedBytes
int PutEscapedBytes(const void *s, size_t src_len)
Output a block of data to the stream performing GDB-remote escaping.
Definition: GDBRemote.cpp:29
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::m_process_launch_info
ProcessLaunchInfo m_process_launch_info
Definition: GDBRemoteCommunicationServerCommon.h:34
StringExtractorGDBRemote::eServerPacketType_qGetWorkingDir
@ eServerPacketType_qGetWorkingDir
Definition: StringExtractorGDBRemote.h:67
StringExtractorGDBRemote
Definition: StringExtractorGDBRemote.h:21
lldb_private::Communication::GetConnection
lldb_private::Connection * GetConnection()
Definition: Communication.h:162
lldb_private::Log
Definition: Log.h:48
lldb_private::Stream::PutCString
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition: Stream.cpp:63
UriParser.h
lldb_private::GetLog
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition: Log.h:235
FileAction.h
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:347
lldb_private::Host::Kill
static void Kill(lldb::pid_t pid, int signo)
Definition: common/Host.cpp:568
lldb_private::process_gdb_remote::GDBRemoteCommunicationServerPlatform::KillSpawnedProcess
bool KillSpawnedProcess(lldb::pid_t pid)
Definition: GDBRemoteCommunicationServerPlatform.cpp:334
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
LLDBLog.h
CommandCompletions.h
lldb_private::ProcessLaunchInfo::SetMonitorProcessCallback
void SetMonitorProcessCallback(Host::MonitorChildProcessCallback callback)
Definition: ProcessLaunchInfo.h:102
lldb_private::ProcessLaunchInfo::GetMonitorProcessCallback
const Host::MonitorChildProcessCallback & GetMonitorProcessCallback() const
Definition: ProcessLaunchInfo.h:106