LLDB  mainline
PlatformRemoteGDBServer.cpp
Go to the documentation of this file.
1 //===-- PlatformRemoteGDBServer.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 #include "lldb/Host/Config.h"
11 
13 #include "lldb/Core/Debugger.h"
14 #include "lldb/Core/Module.h"
15 #include "lldb/Core/ModuleList.h"
16 #include "lldb/Core/ModuleSpec.h"
18 #include "lldb/Core/StreamFile.h"
20 #include "lldb/Host/Host.h"
21 #include "lldb/Host/HostInfo.h"
22 #include "lldb/Host/PosixApi.h"
23 #include "lldb/Target/Process.h"
24 #include "lldb/Target/Target.h"
25 #include "lldb/Utility/FileSpec.h"
26 #include "lldb/Utility/Log.h"
28 #include "lldb/Utility/Status.h"
30 #include "lldb/Utility/UriParser.h"
31 
34 
35 using namespace lldb;
36 using namespace lldb_private;
37 using namespace lldb_private::platform_gdb_server;
38 
40 
41 static bool g_initialized = false;
42 
43 void PlatformRemoteGDBServer::Initialize() {
44  Platform::Initialize();
45 
46  if (!g_initialized) {
47  g_initialized = true;
48  PluginManager::RegisterPlugin(
49  PlatformRemoteGDBServer::GetPluginNameStatic(),
50  PlatformRemoteGDBServer::GetDescriptionStatic(),
51  PlatformRemoteGDBServer::CreateInstance);
52  }
53 }
54 
55 void PlatformRemoteGDBServer::Terminate() {
56  if (g_initialized) {
57  g_initialized = false;
58  PluginManager::UnregisterPlugin(PlatformRemoteGDBServer::CreateInstance);
59  }
60 
61  Platform::Terminate();
62 }
63 
64 PlatformSP PlatformRemoteGDBServer::CreateInstance(bool force,
65  const ArchSpec *arch) {
66  bool create = force;
67  if (!create) {
68  create = !arch->TripleVendorWasSpecified() && !arch->TripleOSWasSpecified();
69  }
70  if (create)
71  return PlatformSP(new PlatformRemoteGDBServer());
72  return PlatformSP();
73 }
74 
75 ConstString PlatformRemoteGDBServer::GetPluginNameStatic() {
76  static ConstString g_name("remote-gdb-server");
77  return g_name;
78 }
79 
80 const char *PlatformRemoteGDBServer::GetDescriptionStatic() {
81  return "A platform that uses the GDB remote protocol as the communication "
82  "transport.";
83 }
84 
85 const char *PlatformRemoteGDBServer::GetDescription() {
86  if (m_platform_description.empty()) {
87  if (IsConnected()) {
88  // Send the get description packet
89  }
90  }
91 
92  if (!m_platform_description.empty())
93  return m_platform_description.c_str();
94  return GetDescriptionStatic();
95 }
96 
97 Status PlatformRemoteGDBServer::ResolveExecutable(
98  const ModuleSpec &module_spec, lldb::ModuleSP &exe_module_sp,
99  const FileSpecList *module_search_paths_ptr) {
100  // copied from PlatformRemoteiOS
101 
102  Status error;
103  // Nothing special to do here, just use the actual file and architecture
104 
105  ModuleSpec resolved_module_spec(module_spec);
106 
107  // Resolve any executable within an apk on Android?
108  // Host::ResolveExecutableInBundle (resolved_module_spec.GetFileSpec());
109 
110  if (FileSystem::Instance().Exists(resolved_module_spec.GetFileSpec()) ||
111  module_spec.GetUUID().IsValid()) {
112  if (resolved_module_spec.GetArchitecture().IsValid() ||
113  resolved_module_spec.GetUUID().IsValid()) {
114  error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
115  module_search_paths_ptr, nullptr,
116  nullptr);
117 
118  if (exe_module_sp && exe_module_sp->GetObjectFile())
119  return error;
120  exe_module_sp.reset();
121  }
122  // No valid architecture was specified or the exact arch wasn't found so
123  // ask the platform for the architectures that we should be using (in the
124  // correct order) and see if we can find a match that way
125  StreamString arch_names;
126  for (uint32_t idx = 0; GetSupportedArchitectureAtIndex(
127  idx, resolved_module_spec.GetArchitecture());
128  ++idx) {
129  error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
130  module_search_paths_ptr, nullptr,
131  nullptr);
132  // Did we find an executable using one of the
133  if (error.Success()) {
134  if (exe_module_sp && exe_module_sp->GetObjectFile())
135  break;
136  else
137  error.SetErrorToGenericError();
138  }
139 
140  if (idx > 0)
141  arch_names.PutCString(", ");
142  arch_names.PutCString(
143  resolved_module_spec.GetArchitecture().GetArchitectureName());
144  }
145 
146  if (error.Fail() || !exe_module_sp) {
147  if (FileSystem::Instance().Readable(resolved_module_spec.GetFileSpec())) {
148  error.SetErrorStringWithFormatv(
149  "'{0}' doesn't contain any '{1}' platform architectures: {2}",
150  resolved_module_spec.GetFileSpec(), GetPluginName(),
151  arch_names.GetData());
152  } else {
153  error.SetErrorStringWithFormat(
154  "'%s' is not readable",
155  resolved_module_spec.GetFileSpec().GetPath().c_str());
156  }
157  }
158  } else {
159  error.SetErrorStringWithFormat(
160  "'%s' does not exist",
161  resolved_module_spec.GetFileSpec().GetPath().c_str());
162  }
163 
164  return error;
165 }
166 
167 bool PlatformRemoteGDBServer::GetModuleSpec(const FileSpec &module_file_spec,
168  const ArchSpec &arch,
169  ModuleSpec &module_spec) {
171 
172  const auto module_path = module_file_spec.GetPath(false);
173 
174  if (!m_gdb_client.GetModuleInfo(module_file_spec, arch, module_spec)) {
175  LLDB_LOGF(
176  log,
177  "PlatformRemoteGDBServer::%s - failed to get module info for %s:%s",
178  __FUNCTION__, module_path.c_str(),
179  arch.GetTriple().getTriple().c_str());
180  return false;
181  }
182 
183  if (log) {
184  StreamString stream;
185  module_spec.Dump(stream);
186  LLDB_LOGF(log,
187  "PlatformRemoteGDBServer::%s - got module info for (%s:%s) : %s",
188  __FUNCTION__, module_path.c_str(),
189  arch.GetTriple().getTriple().c_str(), stream.GetData());
190  }
191 
192  return true;
193 }
194 
195 Status PlatformRemoteGDBServer::GetFileWithUUID(const FileSpec &platform_file,
196  const UUID *uuid_ptr,
197  FileSpec &local_file) {
198  // Default to the local case
199  local_file = platform_file;
200  return Status();
201 }
202 
203 /// Default Constructor
204 PlatformRemoteGDBServer::PlatformRemoteGDBServer()
205  : Platform(false), // This is a remote platform
206  m_gdb_client() {
209 }
210 
211 /// Destructor.
212 ///
213 /// The destructor is virtual since this class is designed to be
214 /// inherited from by the plug-in instance.
216 
218  ArchSpec &arch) {
220 
221  if (idx == 0) {
222  arch = remote_arch;
223  return arch.IsValid();
224  } else if (idx == 1 && remote_arch.IsValid() &&
225  remote_arch.GetTriple().isArch64Bit()) {
226  arch.SetTriple(remote_arch.GetTriple().get32BitArchVariant());
227  return arch.IsValid();
228  }
229  return false;
230 }
231 
233  Target &target, BreakpointSite *bp_site) {
234  // This isn't needed if the z/Z packets are supported in the GDB remote
235  // server. But we might need a packet to detect this.
236  return 0;
237 }
238 
241  return !m_os_version.empty();
242 }
243 
245  return m_gdb_client.GetOSBuildString(s);
246 }
247 
250 }
251 
252 // Remote Platform subclasses need to override this function
255 }
256 
258  if (IsConnected()) {
260  FileSpec working_dir;
261  if (m_gdb_client.GetWorkingDir(working_dir) && log)
262  LLDB_LOGF(log,
263  "PlatformRemoteGDBServer::GetRemoteWorkingDirectory() -> '%s'",
264  working_dir.GetCString());
265  return working_dir;
266  } else {
268  }
269 }
270 
272  const FileSpec &working_dir) {
273  if (IsConnected()) {
274  // Clear the working directory it case it doesn't get set correctly. This
275  // will for use to re-read it
277  LLDB_LOGF(log, "PlatformRemoteGDBServer::SetRemoteWorkingDirectory('%s')",
278  working_dir.GetCString());
279  return m_gdb_client.SetWorkingDir(working_dir) == 0;
280  } else
281  return Platform::SetRemoteWorkingDirectory(working_dir);
282 }
283 
285  return m_gdb_client.IsConnected();
286 }
287 
289  Status error;
290  if (IsConnected()) {
291  error.SetErrorStringWithFormat("the platform is already connected to '%s', "
292  "execute 'platform disconnect' to close the "
293  "current connection",
294  GetHostname());
295  return error;
296  }
297 
298  if (args.GetArgumentCount() != 1) {
299  error.SetErrorString(
300  "\"platform connect\" takes a single argument: <connect-url>");
301  return error;
302  }
303 
304  const char *url = args.GetArgumentAtIndex(0);
305  if (!url)
306  return Status("URL is null.");
307 
308  llvm::Optional<uint16_t> port;
309  llvm::StringRef scheme, hostname, pathname;
310  if (!UriParser::Parse(url, scheme, hostname, port, pathname))
311  return Status("Invalid URL: %s", url);
312 
313  // We're going to reuse the hostname when we connect to the debugserver.
314  m_platform_scheme = std::string(scheme);
315  m_platform_hostname = std::string(hostname);
316 
317  m_gdb_client.SetConnection(std::make_unique<ConnectionFileDescriptor>());
318  if (repro::Reproducer::Instance().IsReplaying()) {
320  if (error.Success())
322  } else {
323  if (repro::Generator *g = repro::Reproducer::Instance().GetGenerator()) {
324  repro::GDBRemoteProvider &provider =
325  g->GetOrCreate<repro::GDBRemoteProvider>();
327  }
328  m_gdb_client.Connect(url, &error);
329  }
330 
331  if (error.Fail())
332  return error;
333 
336  // If a working directory was set prior to connecting, send it down
337  // now.
338  if (m_working_dir)
340  } else {
342  if (error.Success())
343  error.SetErrorString("handshake failed");
344  }
345  return error;
346 }
347 
349  Status error;
351  m_remote_signals_sp.reset();
352  return error;
353 }
354 
357  if (m_name.empty())
358  return nullptr;
359  return m_name.c_str();
360 }
361 
362 llvm::Optional<std::string>
364  std::string name;
365  if (m_gdb_client.GetUserName(uid, name))
366  return std::move(name);
367  return llvm::None;
368 }
369 
370 llvm::Optional<std::string>
372  std::string name;
373  if (m_gdb_client.GetGroupName(gid, name))
374  return std::move(name);
375  return llvm::None;
376 }
377 
379  const ProcessInstanceInfoMatch &match_info,
380  ProcessInstanceInfoList &process_infos) {
381  return m_gdb_client.FindProcesses(match_info, process_infos);
382 }
383 
385  lldb::pid_t pid, ProcessInstanceInfo &process_info) {
386  return m_gdb_client.GetProcessInfo(pid, process_info);
387 }
388 
391  Status error;
392 
393  LLDB_LOGF(log, "PlatformRemoteGDBServer::%s() called", __FUNCTION__);
394 
395  auto num_file_actions = launch_info.GetNumFileActions();
396  for (decltype(num_file_actions) i = 0; i < num_file_actions; ++i) {
397  const auto file_action = launch_info.GetFileActionAtIndex(i);
398  if (file_action->GetAction() != FileAction::eFileActionOpen)
399  continue;
400  switch (file_action->GetFD()) {
401  case STDIN_FILENO:
402  m_gdb_client.SetSTDIN(file_action->GetFileSpec());
403  break;
404  case STDOUT_FILENO:
405  m_gdb_client.SetSTDOUT(file_action->GetFileSpec());
406  break;
407  case STDERR_FILENO:
408  m_gdb_client.SetSTDERR(file_action->GetFileSpec());
409  break;
410  }
411  }
412 
414  launch_info.GetFlags().Test(eLaunchFlagDisableASLR));
416  launch_info.GetFlags().Test(eLaunchFlagDetachOnError));
417 
418  FileSpec working_dir = launch_info.GetWorkingDirectory();
419  if (working_dir) {
420  m_gdb_client.SetWorkingDir(working_dir);
421  }
422 
423  // Send the environment and the program + arguments after we connect
425 
426  ArchSpec arch_spec = launch_info.GetArchitecture();
427  const char *arch_triple = arch_spec.GetTriple().str().c_str();
428 
429  m_gdb_client.SendLaunchArchPacket(arch_triple);
430  LLDB_LOGF(
431  log,
432  "PlatformRemoteGDBServer::%s() set launch architecture triple to '%s'",
433  __FUNCTION__, arch_triple ? arch_triple : "<NULL>");
434 
435  int arg_packet_err;
436  {
437  // Scope for the scoped timeout object
439  m_gdb_client, std::chrono::seconds(5));
440  arg_packet_err = m_gdb_client.SendArgumentsPacket(launch_info);
441  }
442 
443  if (arg_packet_err == 0) {
444  std::string error_str;
445  if (m_gdb_client.GetLaunchSuccess(error_str)) {
446  const auto pid = m_gdb_client.GetCurrentProcessID(false);
447  if (pid != LLDB_INVALID_PROCESS_ID) {
448  launch_info.SetProcessID(pid);
449  LLDB_LOGF(log,
450  "PlatformRemoteGDBServer::%s() pid %" PRIu64
451  " launched successfully",
452  __FUNCTION__, pid);
453  } else {
454  LLDB_LOGF(log,
455  "PlatformRemoteGDBServer::%s() launch succeeded but we "
456  "didn't get a valid process id back!",
457  __FUNCTION__);
458  error.SetErrorString("failed to get PID");
459  }
460  } else {
461  error.SetErrorString(error_str.c_str());
462  LLDB_LOGF(log, "PlatformRemoteGDBServer::%s() launch failed: %s",
463  __FUNCTION__, error.AsCString());
464  }
465  } else {
466  error.SetErrorStringWithFormat("'A' packet returned an error: %i",
467  arg_packet_err);
468  }
469  return error;
470 }
471 
473  if (!KillSpawnedProcess(pid))
474  return Status("failed to kill remote spawned process");
475  return Status();
476 }
477 
478 lldb::ProcessSP
480  Debugger &debugger, Target &target,
481  Status &error) {
482  lldb::ProcessSP process_sp;
483  if (IsRemote()) {
484  if (IsConnected()) {
485  lldb::pid_t debugserver_pid = LLDB_INVALID_PROCESS_ID;
486  std::string connect_url;
487  if (!LaunchGDBServer(debugserver_pid, connect_url)) {
488  error.SetErrorStringWithFormat("unable to launch a GDB server on '%s'",
489  GetHostname());
490  } else {
491  // The darwin always currently uses the GDB remote debugger plug-in
492  // so even when debugging locally we are debugging remotely!
493  process_sp = target.CreateProcess(launch_info.GetListener(),
494  "gdb-remote", nullptr, true);
495 
496  if (process_sp) {
497  error = process_sp->ConnectRemote(connect_url.c_str());
498  // Retry the connect remote one time...
499  if (error.Fail())
500  error = process_sp->ConnectRemote(connect_url.c_str());
501  if (error.Success())
502  error = process_sp->Launch(launch_info);
503  else if (debugserver_pid != LLDB_INVALID_PROCESS_ID) {
504  printf("error: connect remote failed (%s)\n", error.AsCString());
505  KillSpawnedProcess(debugserver_pid);
506  }
507  }
508  }
509  } else {
510  error.SetErrorString("not connected to remote gdb server");
511  }
512  }
513  return process_sp;
514 }
515 
517  std::string &connect_url) {
518  ArchSpec remote_arch = GetRemoteSystemArchitecture();
519  llvm::Triple &remote_triple = remote_arch.GetTriple();
520 
521  uint16_t port = 0;
522  std::string socket_name;
523  bool launch_result = false;
524  if (remote_triple.getVendor() == llvm::Triple::Apple &&
525  remote_triple.getOS() == llvm::Triple::IOS) {
526  // When remote debugging to iOS, we use a USB mux that always talks to
527  // localhost, so we will need the remote debugserver to accept connections
528  // only from localhost, no matter what our current hostname is
529  launch_result =
530  m_gdb_client.LaunchGDBServer("127.0.0.1", pid, port, socket_name);
531  } else {
532  // All other hosts should use their actual hostname
533  launch_result =
534  m_gdb_client.LaunchGDBServer(nullptr, pid, port, socket_name);
535  }
536 
537  if (!launch_result)
538  return false;
539 
540  connect_url =
542  (socket_name.empty()) ? nullptr : socket_name.c_str());
543  return true;
544 }
545 
547  return m_gdb_client.KillSpawnedProcess(pid);
548 }
549 
551  ProcessAttachInfo &attach_info, Debugger &debugger,
552  Target *target, // Can be NULL, if NULL create a new target, else use
553  // existing one
554  Status &error) {
555  lldb::ProcessSP process_sp;
556  if (IsRemote()) {
557  if (IsConnected()) {
558  lldb::pid_t debugserver_pid = LLDB_INVALID_PROCESS_ID;
559  std::string connect_url;
560  if (!LaunchGDBServer(debugserver_pid, connect_url)) {
561  error.SetErrorStringWithFormat("unable to launch a GDB server on '%s'",
562  GetHostname());
563  } else {
564  if (target == nullptr) {
565  TargetSP new_target_sp;
566 
567  error = debugger.GetTargetList().CreateTarget(
568  debugger, "", "", eLoadDependentsNo, nullptr, new_target_sp);
569  target = new_target_sp.get();
570  } else
571  error.Clear();
572 
573  if (target && error.Success()) {
574  // The darwin always currently uses the GDB remote debugger plug-in
575  // so even when debugging locally we are debugging remotely!
576  process_sp =
577  target->CreateProcess(attach_info.GetListenerForProcess(debugger),
578  "gdb-remote", nullptr, true);
579  if (process_sp) {
580  error = process_sp->ConnectRemote(connect_url.c_str());
581  if (error.Success()) {
582  ListenerSP listener_sp = attach_info.GetHijackListener();
583  if (listener_sp)
584  process_sp->HijackProcessEvents(listener_sp);
585  error = process_sp->Attach(attach_info);
586  }
587 
588  if (error.Fail() && debugserver_pid != LLDB_INVALID_PROCESS_ID) {
589  KillSpawnedProcess(debugserver_pid);
590  }
591  }
592  }
593  }
594  } else {
595  error.SetErrorString("not connected to remote gdb server");
596  }
597  }
598  return process_sp;
599 }
600 
602  uint32_t mode) {
603  Status error = m_gdb_client.MakeDirectory(file_spec, mode);
605  LLDB_LOGF(log,
606  "PlatformRemoteGDBServer::MakeDirectory(path='%s', mode=%o) "
607  "error = %u (%s)",
608  file_spec.GetCString(), mode, error.GetError(), error.AsCString());
609  return error;
610 }
611 
613  uint32_t &file_permissions) {
614  Status error = m_gdb_client.GetFilePermissions(file_spec, file_permissions);
616  LLDB_LOGF(log,
617  "PlatformRemoteGDBServer::GetFilePermissions(path='%s', "
618  "file_permissions=%o) error = %u (%s)",
619  file_spec.GetCString(), file_permissions, error.GetError(),
620  error.AsCString());
621  return error;
622 }
623 
625  uint32_t file_permissions) {
626  Status error = m_gdb_client.SetFilePermissions(file_spec, file_permissions);
628  LLDB_LOGF(log,
629  "PlatformRemoteGDBServer::SetFilePermissions(path='%s', "
630  "file_permissions=%o) error = %u (%s)",
631  file_spec.GetCString(), file_permissions, error.GetError(),
632  error.AsCString());
633  return error;
634 }
635 
637  File::OpenOptions flags,
638  uint32_t mode,
639  Status &error) {
640  return m_gdb_client.OpenFile(file_spec, flags, mode, error);
641 }
642 
644  return m_gdb_client.CloseFile(fd, error);
645 }
646 
649  return m_gdb_client.GetFileSize(file_spec);
650 }
651 
653  CompletionRequest &request, bool only_dir) {
655 }
656 
658  void *dst, uint64_t dst_len,
659  Status &error) {
660  return m_gdb_client.ReadFile(fd, offset, dst, dst_len, error);
661 }
662 
664  const void *src, uint64_t src_len,
665  Status &error) {
666  return m_gdb_client.WriteFile(fd, offset, src, src_len, error);
667 }
668 
670  const FileSpec &destination,
671  uint32_t uid, uint32_t gid) {
672  return Platform::PutFile(source, destination, uid, gid);
673 }
674 
676  const FileSpec &src, // The name of the link is in src
677  const FileSpec &dst) // The symlink points to dst
678 {
681  LLDB_LOGF(log,
682  "PlatformRemoteGDBServer::CreateSymlink(src='%s', dst='%s') "
683  "error = %u (%s)",
684  src.GetCString(), dst.GetCString(), error.GetError(),
685  error.AsCString());
686  return error;
687 }
688 
690  Status error = m_gdb_client.Unlink(file_spec);
692  LLDB_LOGF(log, "PlatformRemoteGDBServer::Unlink(path='%s') error = %u (%s)",
693  file_spec.GetCString(), error.GetError(), error.AsCString());
694  return error;
695 }
696 
698  return m_gdb_client.GetFileExists(file_spec);
699 }
700 
702  llvm::StringRef shell, llvm::StringRef command,
703  const FileSpec &
704  working_dir, // Pass empty FileSpec to use the current working directory
705  int *status_ptr, // Pass NULL if you don't want the process exit status
706  int *signo_ptr, // Pass NULL if you don't want the signal that caused the
707  // process to exit
709  *command_output, // Pass NULL if you don't want the command output
710  const Timeout<std::micro> &timeout) {
711  return m_gdb_client.RunShellCommand(command, working_dir, status_ptr,
712  signo_ptr, command_output, timeout);
713 }
714 
716  m_trap_handlers.push_back(ConstString("_sigtramp"));
717 }
718 
720  if (!IsConnected())
722 
724  return m_remote_signals_sp;
725 
726  // If packet not implemented or JSON failed to parse, we'll guess the signal
727  // set based on the remote architecture.
729 
730  StringExtractorGDBRemote response;
731  auto result =
732  m_gdb_client.SendPacketAndWaitForResponse("jSignalsInfo", response);
733 
734  if (result != decltype(result)::Success ||
735  response.GetResponseType() != response.eResponse)
736  return m_remote_signals_sp;
737 
738  auto object_sp =
740  if (!object_sp || !object_sp->IsValid())
741  return m_remote_signals_sp;
742 
743  auto array_sp = object_sp->GetAsArray();
744  if (!array_sp || !array_sp->IsValid())
745  return m_remote_signals_sp;
746 
747  auto remote_signals_sp = std::make_shared<lldb_private::GDBRemoteSignals>();
748 
749  bool done = array_sp->ForEach(
750  [&remote_signals_sp](StructuredData::Object *object) -> bool {
751  if (!object || !object->IsValid())
752  return false;
753 
754  auto dict = object->GetAsDictionary();
755  if (!dict || !dict->IsValid())
756  return false;
757 
758  // Signal number and signal name are required.
759  int signo;
760  if (!dict->GetValueForKeyAsInteger("signo", signo))
761  return false;
762 
763  llvm::StringRef name;
764  if (!dict->GetValueForKeyAsString("name", name))
765  return false;
766 
767  // We can live without short_name, description, etc.
768  bool suppress{false};
769  auto object_sp = dict->GetValueForKey("suppress");
770  if (object_sp && object_sp->IsValid())
771  suppress = object_sp->GetBooleanValue();
772 
773  bool stop{false};
774  object_sp = dict->GetValueForKey("stop");
775  if (object_sp && object_sp->IsValid())
776  stop = object_sp->GetBooleanValue();
777 
778  bool notify{false};
779  object_sp = dict->GetValueForKey("notify");
780  if (object_sp && object_sp->IsValid())
781  notify = object_sp->GetBooleanValue();
782 
783  std::string description{""};
784  object_sp = dict->GetValueForKey("description");
785  if (object_sp && object_sp->IsValid())
786  description = std::string(object_sp->GetStringValue());
787 
788  remote_signals_sp->AddSignal(signo, name.str().c_str(), suppress, stop,
789  notify, description.c_str());
790  return true;
791  });
792 
793  if (done)
794  m_remote_signals_sp = std::move(remote_signals_sp);
795 
796  return m_remote_signals_sp;
797 }
798 
800  const std::string &platform_scheme, const std::string &platform_hostname,
801  uint16_t port, const char *socket_name) {
802  const char *override_scheme =
803  getenv("LLDB_PLATFORM_REMOTE_GDB_SERVER_SCHEME");
804  const char *override_hostname =
805  getenv("LLDB_PLATFORM_REMOTE_GDB_SERVER_HOSTNAME");
806  const char *port_offset_c_str =
807  getenv("LLDB_PLATFORM_REMOTE_GDB_SERVER_PORT_OFFSET");
808  int port_offset = port_offset_c_str ? ::atoi(port_offset_c_str) : 0;
809 
810  return MakeUrl(override_scheme ? override_scheme : platform_scheme.c_str(),
811  override_hostname ? override_hostname
812  : platform_hostname.c_str(),
813  port + port_offset, socket_name);
814 }
815 
817  const char *hostname,
818  uint16_t port, const char *path) {
819  StreamString result;
820  result.Printf("%s://[%s]", scheme, hostname);
821  if (port != 0)
822  result.Printf(":%u", port);
823  if (path)
824  result.Write(path, strlen(path));
825  return std::string(result.GetString());
826 }
827 
829  Status &error) {
830  std::vector<std::string> connection_urls;
831  GetPendingGdbServerList(connection_urls);
832 
833  for (size_t i = 0; i < connection_urls.size(); ++i) {
834  ConnectProcess(connection_urls[i].c_str(), "gdb-remote", debugger, nullptr, error);
835  if (error.Fail())
836  return i; // We already connected to i process succsessfully
837  }
838  return connection_urls.size();
839 }
840 
842  std::vector<std::string> &connection_urls) {
843  std::vector<std::pair<uint16_t, std::string>> remote_servers;
844  m_gdb_client.QueryGDBServer(remote_servers);
845  for (const auto &gdbserver : remote_servers) {
846  const char *socket_name_cstr =
847  gdbserver.second.empty() ? nullptr : gdbserver.second.c_str();
848  connection_urls.emplace_back(
850  gdbserver.first, socket_name_cstr));
851  }
852  return connection_urls.size();
853 }
lldb_private::ProcessInstanceInfo
Definition: ProcessInfo.h:108
lldb_private::UUID
Definition: UUID.h:23
lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::WriteFile
uint64_t WriteFile(lldb::user_id_t fd, uint64_t offset, const void *src, uint64_t src_len, Status &error)
Definition: GDBRemoteCommunicationClient.cpp:3227
lldb_private::platform_gdb_server::PlatformRemoteGDBServer::m_gdb_client
process_gdb_remote::GDBRemoteCommunicationClient m_gdb_client
Definition: PlatformRemoteGDBServer.h:161
g_initialized
static bool g_initialized
Definition: PlatformRemoteGDBServer.cpp:41
lldb_private::ArchSpec
Definition: ArchSpec.h:33
lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::SetSTDIN
int SetSTDIN(const FileSpec &file_spec)
Sets the path to use for stdin/out/err for a process that will be launched with the 'A' packet.
Definition: GDBRemoteCommunicationClient.cpp:1846
lldb_private::platform_gdb_server::PlatformRemoteGDBServer::MakeDirectory
Status MakeDirectory(const FileSpec &file_spec, uint32_t file_permissions) override
Definition: PlatformRemoteGDBServer.cpp:601
lldb_private::platform_gdb_server::PlatformRemoteGDBServer::CalculateTrapHandlerSymbolNames
void CalculateTrapHandlerSymbolNames() override
Ask the Platform subclass to fill in the list of trap handler names.
Definition: PlatformRemoteGDBServer.cpp:715
lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::FindProcesses
uint32_t FindProcesses(const ProcessInstanceInfoMatch &process_match_info, ProcessInstanceInfoList &process_infos)
Definition: GDBRemoteCommunicationClient.cpp:2228
lldb_private::platform_gdb_server::PlatformRemoteGDBServer::IsConnected
bool IsConnected() const override
Definition: PlatformRemoteGDBServer.cpp:284
lldb_private::ArchSpec::TripleVendorWasSpecified
bool TripleVendorWasSpecified() const
Definition: ArchSpec.h:347
lldb_private::platform_gdb_server::PlatformRemoteGDBServer::GetHostname
const char * GetHostname() override
Definition: PlatformRemoteGDBServer.cpp:355
lldb_private::platform_gdb_server::PlatformRemoteGDBServer::DoGetGroupName
llvm::Optional< std::string > DoGetGroupName(UserIDResolver::id_t uid) override
Definition: PlatformRemoteGDBServer.cpp:371
LLDB_INVALID_PROCESS_ID
#define LLDB_INVALID_PROCESS_ID
Definition: lldb-defines.h:93
lldb_private::process_gdb_remote::GDBRemoteCommunication::SetPacketTimeout
std::chrono::seconds SetPacketTimeout(std::chrono::seconds packet_timeout)
Definition: GDBRemoteCommunication.h:146
ModuleSpec.h
lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::GetUserName
bool GetUserName(uint32_t uid, std::string &name)
Definition: GDBRemoteCommunicationClient.cpp:2323
lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::SetWorkingDir
int SetWorkingDir(const FileSpec &working_dir)
Sets the working directory to path for a process that will be launched with the 'A' packet for non pl...
Definition: GDBRemoteCommunicationClient.cpp:1922
Host.h
StringExtractor::GetStringRef
llvm::StringRef GetStringRef() const
Definition: StringExtractor.h:48
lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::QueryGDBServer
size_t QueryGDBServer(std::vector< std::pair< uint16_t, std::string >> &connection_urls)
Definition: GDBRemoteCommunicationClient.cpp:2598
lldb_private::Platform::PutFile
virtual Status PutFile(const FileSpec &source, const FileSpec &destination, uint32_t uid=UINT32_MAX, uint32_t gid=UINT32_MAX)
Definition: Platform.cpp:1202
lldb_private::File::OpenOptions
OpenOptions
Definition: File.h:49
lldb_private::UUID::IsValid
bool IsValid() const
Definition: UUID.h:79
lldb_private::ModuleSpec::Dump
void Dump(Stream &strm) const
Definition: ModuleSpec.h:167
LLDB_LOGF
#define LLDB_LOGF(log,...)
Definition: Log.h:249
lldb_private::platform_gdb_server::PlatformRemoteGDBServer::GetFileSize
lldb::user_id_t GetFileSize(const FileSpec &file_spec) override
Definition: PlatformRemoteGDBServer.cpp:648
lldb_private::platform_gdb_server::PlatformRemoteGDBServer::DisconnectRemote
Status DisconnectRemote() override
Definition: PlatformRemoteGDBServer.cpp:348
Module.h
BreakpointLocation.h
LIBLLDB_LOG_PLATFORM
#define LIBLLDB_LOG_PLATFORM
Definition: Logging.h:39
PlatformRemoteGDBServer.h
lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::GetSystemArchitecture
ArchSpec GetSystemArchitecture()
Definition: GDBRemoteCommunicationClient.cpp:1006
lldb_private::ProcessInstanceInfoMatch
Definition: ProcessInfo.h:163
lldb_private::platform_gdb_server::PlatformRemoteGDBServer::m_platform_scheme
std::string m_platform_scheme
Definition: PlatformRemoteGDBServer.h:166
lldb_private::Platform::m_os_version
llvm::VersionTuple m_os_version
Definition: Platform.h:884
lldb_private::platform_gdb_server::PlatformRemoteGDBServer::CloseFile
bool CloseFile(lldb::user_id_t fd, Status &error) override
Definition: PlatformRemoteGDBServer.cpp:643
lldb_private::Platform::m_trap_handlers
std::vector< ConstString > m_trap_handlers
Definition: Platform.h:900
lldb_private::Flags::Test
bool Test(ValueType bit) const
Test a single flag bit.
Definition: Flags.h:96
lldb_private::ProcessLaunchInfo::GetFlags
Flags & GetFlags()
Definition: ProcessLaunchInfo.h:64
lldb_private::ProcessInfo::SetProcessID
void SetProcessID(lldb::pid_t pid)
Definition: ProcessInfo.h:69
lldb_private::Args
Definition: Args.h:33
lldb_private::ArchSpec::GetTriple
llvm::Triple & GetTriple()
Architecture triple accessor.
Definition: ArchSpec.h:444
lldb_private::platform_gdb_server
Definition: PlatformRemoteGDBServer.h:21
lldb_private::UriParser::Parse
static bool Parse(llvm::StringRef uri, llvm::StringRef &scheme, llvm::StringRef &hostname, llvm::Optional< uint16_t > &port, llvm::StringRef &path)
Definition: UriParser.cpp:19
lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::MakeDirectory
Status MakeDirectory(const FileSpec &file_spec, uint32_t mode)
Definition: GDBRemoteCommunicationClient.cpp:2947
Debugger.h
lldb_private::Target
Definition: Target.h:451
lldb_private::Target::CreateProcess
const lldb::ProcessSP & CreateProcess(lldb::ListenerSP listener_sp, llvm::StringRef plugin_name, const FileSpec *crash_file, bool can_connect)
Definition: Target.cpp:199
LLDB_PLUGIN_DEFINE_ADV
LLDB_PLUGIN_DEFINE_ADV(ObjectContainerUniversalMachO, ObjectContainerMachOArchive) void ObjectContainerUniversalMachO
Definition: ObjectContainerUniversalMachO.cpp:23
lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::GetWorkingDir
bool GetWorkingDir(FileSpec &working_dir)
Gets the current working directory of a remote platform GDB server.
Definition: GDBRemoteCommunicationClient.cpp:1906
lldb_private::StreamString::GetString
llvm::StringRef GetString() const
Definition: StreamString.cpp:51
lldb_private::repro::GDBRemoteProvider::GetNewPacketRecorder
PacketRecorder * GetNewPacketRecorder()
Definition: GDBRemote.cpp:125
lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::GetGroupName
bool GetGroupName(uint32_t gid, std::string &name)
Definition: GDBRemoteCommunicationClient.cpp:2350
Process.h
lldb_private::ProcessAttachInfo::GetListenerForProcess
lldb::ListenerSP GetListenerForProcess(Debugger &debugger)
Definition: Process.cpp:2759
lldb_private::process_gdb_remote::GDBRemoteCommunicationReplayServer::Connect
Status Connect(process_gdb_remote::GDBRemoteCommunicationClient &client)
Definition: GDBRemoteCommunicationReplayServer.cpp:291
lldb_private::FileSpec::GetCString
const char * GetCString(bool denormalize=true) const
Definition: FileSpec.cpp:364
lldb_private::platform_gdb_server::PlatformRemoteGDBServer::PutFile
Status PutFile(const FileSpec &source, const FileSpec &destination, uint32_t uid=UINT32_MAX, uint32_t gid=UINT32_MAX) override
Definition: PlatformRemoteGDBServer.cpp:669
Target.h
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::ModuleSpec::GetUUID
UUID & GetUUID()
Definition: ModuleSpec.h:104
lldb_private::FileSpec
Definition: FileSpec.h:56
lldb_private::platform_gdb_server::PlatformRemoteGDBServer::GetRemoteOSBuildString
bool GetRemoteOSBuildString(std::string &s) override
Definition: PlatformRemoteGDBServer.cpp:244
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
lldb_private::platform_gdb_server::PlatformRemoteGDBServer::GetFileExists
bool GetFileExists(const FileSpec &file_spec) override
Definition: PlatformRemoteGDBServer.cpp:697
ProcessInfo.h
lldb_private::platform_gdb_server::PlatformRemoteGDBServer::GetPendingGdbServerList
virtual size_t GetPendingGdbServerList(std::vector< std::string > &connection_urls)
Definition: PlatformRemoteGDBServer.cpp:841
lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::GetHostInfo
bool GetHostInfo(bool force=false)
Definition: GDBRemoteCommunicationClient.cpp:1185
ProcessGDBRemote.h
ModuleList.h
lldb_private::BreakpointSite
Definition: BreakpointSite.h:35
object
lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::KillSpawnedProcess
bool KillSpawnedProcess(lldb::pid_t pid)
Definition: GDBRemoteCommunicationClient.cpp:2637
lldb_private::ProcessLaunchInfo
Definition: ProcessLaunchInfo.h:31
Log.h
lldb_private::Platform::GetRemoteWorkingDirectory
virtual FileSpec GetRemoteWorkingDirectory()
Definition: Platform.h:258
lldb_private::platform_gdb_server::PlatformRemoteGDBServer::GetRemoteWorkingDirectory
FileSpec GetRemoteWorkingDirectory() override
Definition: PlatformRemoteGDBServer.cpp:257
lldb_private::platform_gdb_server::PlatformRemoteGDBServer::SetFilePermissions
Status SetFilePermissions(const FileSpec &file_spec, uint32_t file_permissions) override
Definition: PlatformRemoteGDBServer.cpp:624
lldb_private::eLoadDependentsNo
@ eLoadDependentsNo
Definition: Target.h:64
lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::SetSTDERR
int SetSTDERR(const FileSpec &file_spec)
Definition: GDBRemoteCommunicationClient.cpp:1886
lldb_private::ArchSpec::SetTriple
bool SetTriple(const llvm::Triple &triple)
Architecture triple setter.
Definition: ArchSpec.cpp:739
lldb_private::platform_gdb_server::PlatformRemoteGDBServer::LaunchGDBServer
virtual bool LaunchGDBServer(lldb::pid_t &pid, std::string &connect_url)
Definition: PlatformRemoteGDBServer.cpp:516
lldb_private::platform_gdb_server::PlatformRemoteGDBServer::KillSpawnedProcess
virtual bool KillSpawnedProcess(lldb::pid_t pid)
Definition: PlatformRemoteGDBServer.cpp:546
lldb_private::StreamString::GetData
const char * GetData() const
Definition: StreamString.h:43
lldb_private::platform_gdb_server::PlatformRemoteGDBServer::GetRemoteOSVersion
bool GetRemoteOSVersion() override
Definition: PlatformRemoteGDBServer.cpp:239
lldb_private::Platform::SetRemoteWorkingDirectory
virtual bool SetRemoteWorkingDirectory(const FileSpec &working_dir)
Definition: Platform.cpp:806
lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::Unlink
Status Unlink(const FileSpec &file_spec)
Definition: GDBRemoteCommunicationClient.cpp:3293
StreamString.h
lldb_private::platform_gdb_server::PlatformRemoteGDBServer::AutoCompleteDiskFileOrDirectory
void AutoCompleteDiskFileOrDirectory(CompletionRequest &request, bool only_dir) override
Definition: PlatformRemoteGDBServer.cpp:652
lldb_private::platform_gdb_server::PlatformRemoteGDBServer::GetProcessInfo
bool GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &proc_info) override
Definition: PlatformRemoteGDBServer.cpp:384
lldb_private::platform_gdb_server::PlatformRemoteGDBServer::GetRemoteSystemArchitecture
ArchSpec GetRemoteSystemArchitecture() override
Definition: PlatformRemoteGDBServer.cpp:253
StringExtractorGDBRemote::eResponse
@ eResponse
Definition: StringExtractorGDBRemote.h:181
lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::GetFileExists
bool GetFileExists(const FileSpec &file_spec)
Definition: GDBRemoteCommunicationClient.cpp:3325
lldb_private::ConstString
Definition: ConstString.h:40
lldb_private::StreamString
Definition: StreamString.h:23
StringExtractorGDBRemote::GetResponseType
ResponseType GetResponseType() const
Definition: StringExtractorGDBRemote.cpp:18
lldb_private::process_gdb_remote::GDBRemoteCommunication::SetPacketRecorder
void SetPacketRecorder(repro::PacketRecorder *recorder)
Definition: GDBRemoteCommunication.cpp:1226
lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::SetFilePermissions
Status SetFilePermissions(const FileSpec &file_spec, uint32_t file_permissions)
Definition: GDBRemoteCommunicationClient.cpp:2968
lldb_private::platform_gdb_server::PlatformRemoteGDBServer::CreateSymlink
Status CreateSymlink(const FileSpec &src, const FileSpec &dst) override
Definition: PlatformRemoteGDBServer.cpp:675
lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::SetDetachOnError
int SetDetachOnError(bool enable)
Sets the DetachOnError flag to enable for the process controlled by the stub.
Definition: GDBRemoteCommunicationClient.cpp:1959
lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::CloseFile
bool CloseFile(lldb::user_id_t fd, Status &error)
Definition: GDBRemoteCommunicationClient.cpp:3039
lldb_private::GetLogIfAllCategoriesSet
Log * GetLogIfAllCategoriesSet(uint32_t mask)
Definition: Logging.cpp:58
lldb_private::Platform::m_working_dir
FileSpec m_working_dir
Definition: Platform.h:880
lldb_private::TargetList::CreateTarget
Status CreateTarget(Debugger &debugger, llvm::StringRef user_exe_path, llvm::StringRef triple_str, LoadDependentFiles get_dependent_modules, const OptionGroupPlatform *platform_options, lldb::TargetSP &target_sp)
Create a new Target.
lldb_private::ProcessLaunchInfo::GetFileActionAtIndex
const FileAction * GetFileActionAtIndex(size_t idx) const
Definition: ProcessLaunchInfo.cpp:110
if
if(CMAKE_SYSTEM_NAME MATCHES "Windows") add_definitions(-DEXPORT_LIBLLDB) endif() get_property(LLDB_ALL_PLUGINS GLOBAL PROPERTY LLDB_PLUGINS) if(LLDB_BUILD_FRAMEWORK) set(option_install_prefix INSTALL_PREFIX $
Definition: API/CMakeLists.txt:1
lldb_private::ProcessLaunchInfo::GetListener
lldb::ListenerSP GetListener() const
Definition: ProcessLaunchInfo.h:128
lldb_private::platform_gdb_server::PlatformRemoteGDBServer::GetSoftwareBreakpointTrapOpcode
size_t GetSoftwareBreakpointTrapOpcode(Target &target, BreakpointSite *bp_site) override
Definition: PlatformRemoteGDBServer.cpp:232
lldb_private::ArchSpec::TripleOSWasSpecified
bool TripleOSWasSpecified() const
Definition: ArchSpec.h:351
ConnectionFileDescriptor.h
lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::CreateSymlink
Status CreateSymlink(const FileSpec &src, const FileSpec &dst)
Definition: GDBRemoteCommunicationClient.cpp:3259
lldb_private::platform_gdb_server::PlatformRemoteGDBServer::SetRemoteWorkingDirectory
bool SetRemoteWorkingDirectory(const FileSpec &working_dir) override
Definition: PlatformRemoteGDBServer.cpp:271
lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::ReadFile
uint64_t ReadFile(lldb::user_id_t fd, uint64_t offset, void *dst, uint64_t dst_len, Status &error)
Definition: GDBRemoteCommunicationClient.cpp:3187
lldb_private::platform_gdb_server::PlatformRemoteGDBServer::ConnectRemote
Status ConnectRemote(Args &args) override
Definition: PlatformRemoteGDBServer.cpp:288
lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::GetProcessInfo
bool GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &process_info)
Definition: GDBRemoteCommunicationClient.cpp:2073
lldb_private::Debugger
Definition: Debugger.h:70
lldb_private::process_gdb_remote::GDBRemoteCommunicationReplayServer::StartAsyncThread
bool StartAsyncThread()
Definition: GDBRemoteCommunicationReplayServer.cpp:209
HostInfo.h
lldb_private::ProcessLaunchInfo::GetNumFileActions
size_t GetNumFileActions() const
Definition: ProcessLaunchInfo.h:58
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
lldb_private::ProcessLaunchInfo::GetWorkingDirectory
const FileSpec & GetWorkingDirectory() const
Definition: ProcessLaunchInfo.cpp:124
lldb_private::ArchSpec::IsValid
bool IsValid() const
Tests if this ArchSpec is valid.
Definition: ArchSpec.h:342
lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::GetFilePermissions
Status GetFilePermissions(const FileSpec &file_spec, uint32_t &file_permissions)
Definition: GDBRemoteCommunicationClient.cpp:3139
lldb_private::platform_gdb_server::PlatformRemoteGDBServer::~PlatformRemoteGDBServer
~PlatformRemoteGDBServer() override
Destructor.
lldb_private::Platform::GetRemoteUnixSignals
virtual const lldb::UnixSignalsSP & GetRemoteUnixSignals()
Definition: Platform.cpp:1694
lldb_private::platform_gdb_server::PlatformRemoteGDBServer::GetRemoteOSKernelDescription
bool GetRemoteOSKernelDescription(std::string &s) override
Definition: PlatformRemoteGDBServer.cpp:248
lldb_private::platform_gdb_server::PlatformRemoteGDBServer::FindProcesses
uint32_t FindProcesses(const ProcessInstanceInfoMatch &match_info, ProcessInstanceInfoList &process_infos) override
Attach to an existing process by process name.
Definition: PlatformRemoteGDBServer.cpp:378
lldb_private::platform_gdb_server::PlatformRemoteGDBServer::OpenFile
lldb::user_id_t OpenFile(const FileSpec &file_spec, File::OpenOptions flags, uint32_t mode, Status &error) override
Definition: PlatformRemoteGDBServer.cpp:636
lldb_private::platform_gdb_server::PlatformRemoteGDBServer::Unlink
Status Unlink(const FileSpec &path) override
Definition: PlatformRemoteGDBServer.cpp:689
lldb_private::ProcessAttachInfo
Definition: Process.h:113
lldb_private::Debugger::GetTargetList
TargetList & GetTargetList()
Get accessor for the target list.
Definition: Debugger.h:223
lldb_private::FileAction::eFileActionOpen
@ eFileActionOpen
Definition: FileAction.h:23
lldb_private::Platform::IsRemote
bool IsRemote() const
Definition: Platform.h:441
lldb_private::process_gdb_remote::GDBRemoteCommunication::ScopedTimeout
Definition: GDBRemoteCommunication.h:109
StreamFile.h
lldb_private::platform_gdb_server::PlatformRemoteGDBServer::WriteFile
uint64_t WriteFile(lldb::user_id_t fd, uint64_t offset, const void *data, uint64_t len, Status &error) override
Definition: PlatformRemoteGDBServer.cpp:663
lldb_private::platform_gdb_server::PlatformRemoteGDBServer::m_platform_hostname
std::string m_platform_hostname
Definition: PlatformRemoteGDBServer.h:167
lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::OpenFile
lldb::user_id_t OpenFile(const FileSpec &file_spec, File::OpenOptions flags, mode_t mode, Status &error)
Definition: GDBRemoteCommunicationClient.cpp:3018
lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::SendEnvironment
int SendEnvironment(const Environment &env)
Definition: GDBRemoteCommunicationClient.cpp:842
lldb_private::ModuleSpec::GetFileSpec
FileSpec & GetFileSpec()
Definition: ModuleSpec.h:58
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::ModuleSpec
Definition: ModuleSpec.h:26
lldb_private::Status
Definition: Status.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
lldb_private::Timeout< std::micro >
lldb_private::ArchSpec::GetArchitectureName
const char * GetArchitectureName() const
Returns a static string representing the current architecture.
Definition: ArchSpec.cpp:538
lldb_private::platform_gdb_server::PlatformRemoteGDBServer::RunShellCommand
Status RunShellCommand(llvm::StringRef shell, llvm::StringRef command, const FileSpec &working_dir, int *status_ptr, int *signo_ptr, std::string *command_output, const lldb_private::Timeout< std::micro > &timeout) override
Definition: PlatformRemoteGDBServer.cpp:701
uint32_t
lldb_private::ProcessInfo::GetEnvironment
Environment & GetEnvironment()
Definition: ProcessInfo.h:87
lldb::pid_t
uint64_t pid_t
Definition: lldb-types.h:85
lldb_private::platform_gdb_server::PlatformRemoteGDBServer::m_gdb_replay_server
process_gdb_remote::GDBRemoteCommunicationReplayServer m_gdb_replay_server
Definition: PlatformRemoteGDBServer.h:162
lldb_private::Platform::m_name
std::string m_name
Definition: Platform.h:883
GDBRemoteSignals.h
lldb_private::platform_gdb_server::PlatformRemoteGDBServer::KillProcess
Status KillProcess(const lldb::pid_t pid) override
Kill process on a platform.
Definition: PlatformRemoteGDBServer.cpp:472
lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::GetFileSize
lldb::user_id_t GetFileSize(const FileSpec &file_spec)
Definition: GDBRemoteCommunicationClient.cpp:3087
lldb_private::Communication::IsConnected
bool IsConnected() const
Check if the connection is valid.
Definition: Communication.cpp:116
lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::LaunchGDBServer
bool LaunchGDBServer(const char *remote_accept_hostname, lldb::pid_t &pid, uint16_t &port, std::string &socket_name)
Definition: GDBRemoteCommunicationClient.cpp:2553
uint16_t
lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::SendArgumentsPacket
int SendArgumentsPacket(const ProcessLaunchInfo &launch_info)
Sends a GDB remote protocol 'A' packet that delivers program arguments to the remote server.
Definition: GDBRemoteCommunicationClient.cpp:762
lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::RunShellCommand
Status RunShellCommand(llvm::StringRef command, const FileSpec &working_dir, int *status_ptr, int *signo_ptr, std::string *command_output, const Timeout< std::micro > &timeout)
Definition: GDBRemoteCommunicationClient.cpp:2894
lldb_private::platform_gdb_server::PlatformRemoteGDBServer::GetRemoteUnixSignals
const lldb::UnixSignalsSP & GetRemoteUnixSignals() override
Definition: PlatformRemoteGDBServer.cpp:719
lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::GetOSBuildString
bool GetOSBuildString(std::string &s)
Definition: GDBRemoteCommunicationClient.cpp:973
PluginManager.h
lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::GetCurrentProcessID
lldb::pid_t GetCurrentProcessID(bool allow_lazy=true)
Definition: GDBRemoteCommunicationClient.cpp:689
lldb_private::ModuleSpec::GetArchitecture
ArchSpec & GetArchitecture()
Definition: ModuleSpec.h:94
lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::SetSTDOUT
int SetSTDOUT(const FileSpec &file_spec)
Definition: GDBRemoteCommunicationClient.cpp:1866
lldb_private::Platform
Definition: Platform.h:71
lldb_private::Stream::Printf
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:107
lldb_private::platform_gdb_server::PlatformRemoteGDBServer::MakeGdbServerUrl
std::string MakeGdbServerUrl(const std::string &platform_scheme, const std::string &platform_hostname, uint16_t port, const char *socket_name)
Definition: PlatformRemoteGDBServer.cpp:799
lldb_private::platform_gdb_server::PlatformRemoteGDBServer::ConnectToWaitingProcesses
size_t ConnectToWaitingProcesses(lldb_private::Debugger &debugger, lldb_private::Status &error) override
Connect to all processes waiting for a debugger to attach.
Definition: PlatformRemoteGDBServer.cpp:828
lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::SetDisableASLR
int SetDisableASLR(bool enable)
Sets the disable ASLR flag to enable for a process that will be launched with the 'A' packet.
Definition: GDBRemoteCommunicationClient.cpp:1942
lldb_private::process_gdb_remote::GDBRemoteClientBase::SendPacketAndWaitForResponse
PacketResult SendPacketAndWaitForResponse(llvm::StringRef payload, StringExtractorGDBRemote &response, std::chrono::seconds interrupt_timeout=std::chrono::seconds(0))
Definition: GDBRemoteClientBase.cpp:182
Status.h
lldb::user_id_t
uint64_t user_id_t
Definition: lldb-types.h:84
lldb_private::platform_gdb_server::PlatformRemoteGDBServer::GetFilePermissions
Status GetFilePermissions(const FileSpec &file_spec, uint32_t &file_permissions) override
Definition: PlatformRemoteGDBServer.cpp:612
lldb_private::ProcessInfo::GetArchitecture
ArchSpec & GetArchitecture()
Definition: ProcessInfo.h:61
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::LineStatus::Success
@ Success
PosixApi.h
lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::HandshakeWithServer
bool HandshakeWithServer(Status *error_ptr)
Definition: GDBRemoteCommunicationClient.cpp:81
FileSpec.h
lldb_private::repro::GDBRemoteProvider
Definition: GDBRemote.h:96
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::platform_gdb_server::PlatformRemoteGDBServer
Definition: PlatformRemoteGDBServer.h:23
StringExtractorGDBRemote
Definition: StringExtractorGDBRemote.h:21
lldb_private::StructuredData::ParseJSON
static ObjectSP ParseJSON(const std::string &json_text)
Definition: StructuredData.cpp:25
lldb_private::Log
Definition: Log.h:49
lldb_private::Stream::PutCString
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition: Stream.cpp:63
lldb_private::platform_gdb_server::PlatformRemoteGDBServer::LaunchProcess
Status LaunchProcess(ProcessLaunchInfo &launch_info) override
Launch a new process on a platform, not necessarily for debugging, it could be just for running the p...
Definition: PlatformRemoteGDBServer.cpp:389
lldb_private::platform_gdb_server::PlatformRemoteGDBServer::DebugProcess
lldb::ProcessSP DebugProcess(ProcessLaunchInfo &launch_info, Debugger &debugger, Target &target, Status &error) override
Subclasses do not need to implement this function as it uses the Platform::LaunchProcess() followed b...
Definition: PlatformRemoteGDBServer.cpp:479
UriParser.h
lldb_private::GetLogIfAnyCategoriesSet
Log * GetLogIfAnyCategoriesSet(uint32_t mask)
Definition: Logging.cpp:62
lldb_private::platform_gdb_server::PlatformRemoteGDBServer::MakeUrl
virtual std::string MakeUrl(const char *scheme, const char *hostname, uint16_t port, const char *path)
Definition: PlatformRemoteGDBServer.cpp:816
lldb_private::platform_gdb_server::PlatformRemoteGDBServer::DoGetUserName
llvm::Optional< std::string > DoGetUserName(UserIDResolver::id_t uid) override
Definition: PlatformRemoteGDBServer.cpp:363
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::GDBRemoteCommunicationClient::GetOSKernelDescription
bool GetOSKernelDescription(std::string &s)
Definition: GDBRemoteCommunicationClient.cpp:984
lldb_private::ProcessAttachInfo::GetHijackListener
lldb::ListenerSP GetHijackListener() const
Definition: Process.h:179
lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::GetHostname
bool GetHostname(std::string &s)
Definition: GDBRemoteCommunicationClient.cpp:995
lldb_private::repro::Reproducer::Instance
static Reproducer & Instance()
Definition: Reproducer.cpp:23
lldb_private::repro::Generator
The generator is responsible for the logic needed to generate a reproducer.
Definition: Reproducer.h:91
lldb_private::Args::GetArgumentCount
size_t GetArgumentCount() const
Gets the number of arguments left in this command object.
Definition: Args.h:118
lldb_private::ProcessInstanceInfoList
std::vector< ProcessInstanceInfo > ProcessInstanceInfoList
Definition: Host.h:30
lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::GetOSVersion
llvm::VersionTuple GetOSVersion()
Definition: GDBRemoteCommunicationClient.cpp:963
lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::GetLaunchSuccess
bool GetLaunchSuccess(std::string &error_str)
Definition: GDBRemoteCommunicationClient.cpp:738
lldb_private::StructuredData::Object
Definition: StructuredData.h:70
lldb
Definition: SBAddress.h:15
lldb_private::platform_gdb_server::PlatformRemoteGDBServer::ReadFile
uint64_t ReadFile(lldb::user_id_t fd, uint64_t offset, void *data_ptr, uint64_t len, Status &error) override
Definition: PlatformRemoteGDBServer.cpp:657
lldb_private::process_gdb_remote::ProcessGDBRemote::GetPacketTimeout
static std::chrono::seconds GetPacketTimeout()
Definition: ProcessGDBRemote.cpp:211
lldb_private::Platform::ConnectProcess
virtual lldb::ProcessSP ConnectProcess(llvm::StringRef connect_url, llvm::StringRef plugin_name, Debugger &debugger, Target *target, Status &error)
Definition: Platform.cpp:1773
lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::SendLaunchArchPacket
int SendLaunchArchPacket(const char *arch)
Definition: GDBRemoteCommunicationClient.cpp:918
lldb_private::platform_gdb_server::PlatformRemoteGDBServer::Attach
lldb::ProcessSP Attach(ProcessAttachInfo &attach_info, Debugger &debugger, Target *target, Status &error) override
Attach to an existing process using a process ID.
Definition: PlatformRemoteGDBServer.cpp:550
lldb_private::CompletionRequest
Definition: CompletionRequest.h:100
lldb_private::process_gdb_remote::GDBRemoteCommunicationClient::AutoCompleteDiskFileOrDirectory
void AutoCompleteDiskFileOrDirectory(CompletionRequest &request, bool only_dir)
Definition: GDBRemoteCommunicationClient.cpp:3113
lldb_private::platform_gdb_server::PlatformRemoteGDBServer::m_remote_signals_sp
lldb::UnixSignalsSP m_remote_signals_sp
Definition: PlatformRemoteGDBServer.h:169
lldb_private::platform_gdb_server::PlatformRemoteGDBServer::GetSupportedArchitectureAtIndex
bool GetSupportedArchitectureAtIndex(uint32_t idx, ArchSpec &arch) override
Get the platform's supported architectures in the order in which they should be searched.
Definition: PlatformRemoteGDBServer.cpp:217
lldb_private::UnixSignals::Create
static lldb::UnixSignalsSP Create(const ArchSpec &arch)
Definition: UnixSignals.cpp:29
lldb_private::Communication::Connect
lldb::ConnectionStatus Connect(const char *url, Status *error_ptr)
Connect using the current connection by passing url to its connect function.
Definition: Communication.cpp:78