LLDB  mainline
PlatformAppleSimulator.cpp
Go to the documentation of this file.
1 //===-- PlatformAppleSimulator.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 #if defined(__APPLE__)
12 #include <dlfcn.h>
13 #endif
14 
15 #include "lldb/Core/Module.h"
17 #include "lldb/Host/HostInfo.h"
19 #include "lldb/Target/Process.h"
21 #include "lldb/Utility/LLDBLog.h"
22 #include "lldb/Utility/Log.h"
23 #include "lldb/Utility/Status.h"
25 
26 #include "llvm/Support/Threading.h"
27 
28 #include <mutex>
29 #include <thread>
30 
31 using namespace lldb;
32 using namespace lldb_private;
33 
34 #if !defined(__APPLE__)
35 #define UNSUPPORTED_ERROR ("Apple simulators aren't supported on this platform")
36 #endif
37 
38 /// Default Constructor
39 PlatformAppleSimulator::PlatformAppleSimulator(
40  const char *class_name, const char *description, ConstString plugin_name,
41  llvm::Triple::OSType preferred_os,
42  llvm::SmallVector<llvm::StringRef, 4> supported_triples,
43  llvm::StringRef sdk, lldb_private::XcodeSDK::Type sdk_type,
45  : PlatformDarwin(true), m_class_name(class_name),
46  m_description(description), m_plugin_name(plugin_name), m_kind(kind),
47  m_os_type(preferred_os), m_supported_triples(supported_triples),
48  m_sdk(sdk), m_sdk_type(sdk_type) {}
49 
50 /// Destructor.
51 ///
52 /// The destructor is virtual since this class is designed to be
53 /// inherited from by the plug-in instance.
55 
57  lldb_private::ProcessLaunchInfo &launch_info) {
58 #if defined(__APPLE__)
60  CoreSimulatorSupport::Device device(GetSimulatorDevice());
61 
63  Status boot_err;
64  device.Boot(boot_err);
65  if (boot_err.Fail())
66  return boot_err;
67  }
68 
69  auto spawned = device.Spawn(launch_info);
70 
71  if (spawned) {
72  launch_info.SetProcessID(spawned.GetPID());
73  return Status();
74  } else
75  return spawned.GetError();
76 #else
77  Status err;
79  return err;
80 #endif
81 }
82 
84  Platform::GetStatus(strm);
85  if (!m_sdk.empty())
86  strm << " SDK Path: \"" << m_sdk << "\"\n";
87  else
88  strm << " SDK Path: error: unable to locate SDK\n";
89 
90 #if defined(__APPLE__)
91  // This will get called by subclasses, so just output status on the current
92  // simulator
94 
95  std::string developer_dir = HostInfo::GetXcodeDeveloperDirectory().GetPath();
98  developer_dir.c_str());
99  const size_t num_devices = devices.GetNumDevices();
100  if (num_devices) {
101  strm.Printf("Available devices:\n");
102  for (size_t i = 0; i < num_devices; ++i) {
104  strm << " " << device.GetUDID() << ": " << device.GetName() << "\n";
105  }
106 
107  if (m_device.has_value() && m_device->operator bool()) {
108  strm << "Current device: " << m_device->GetUDID() << ": "
109  << m_device->GetName();
111  strm << " state = booted";
112  }
113  strm << "\nType \"platform connect <ARG>\" where <ARG> is a device "
114  "UDID or a device name to disconnect and connect to a "
115  "different device.\n";
116 
117  } else {
118  strm << "No current device is selected, \"platform connect <ARG>\" "
119  "where <ARG> is a device UDID or a device name to connect to "
120  "a specific device.\n";
121  }
122 
123  } else {
124  strm << "No devices are available.\n";
125  }
126 #else
127  strm << UNSUPPORTED_ERROR;
128 #endif
129 }
130 
132 #if defined(__APPLE__)
133  Status error;
134  if (args.GetArgumentCount() == 1) {
135  if (m_device)
138  const char *arg_cstr = args.GetArgumentAtIndex(0);
139  if (arg_cstr) {
140  std::string arg_str(arg_cstr);
141  std::string developer_dir = HostInfo::GetXcodeDeveloperDirectory().GetPath();
144  developer_dir.c_str());
145  devices.ForEach(
146  [this, &arg_str](const CoreSimulatorSupport::Device &device) -> bool {
147  if (arg_str == device.GetUDID() || arg_str == device.GetName()) {
148  m_device = device;
149  return false; // Stop iterating
150  } else {
151  return true; // Keep iterating
152  }
153  });
154  if (!m_device)
155  error.SetErrorStringWithFormat(
156  "no device with UDID or name '%s' was found", arg_cstr);
157  }
158  } else {
159  error.SetErrorString("this command take a single UDID argument of the "
160  "device you want to connect to.");
161  }
162  return error;
163 #else
164  Status err;
166  return err;
167 #endif
168 }
169 
171 #if defined(__APPLE__)
172  m_device.reset();
173  return Status();
174 #else
175  Status err;
177  return err;
178 #endif
179 }
180 
181 lldb::ProcessSP
183  Debugger &debugger, Target &target,
184  Status &error) {
185 #if defined(__APPLE__)
186  ProcessSP process_sp;
187  // Make sure we stop at the entry point
188  launch_info.GetFlags().Set(eLaunchFlagDebug);
189  // We always launch the process we are going to debug in a separate process
190  // group, since then we can handle ^C interrupts ourselves w/o having to
191  // worry about the target getting them as well.
192  launch_info.SetLaunchInSeparateProcessGroup(true);
193 
194  error = LaunchProcess(launch_info);
195  if (error.Success()) {
196  if (launch_info.GetProcessID() != LLDB_INVALID_PROCESS_ID) {
197  ProcessAttachInfo attach_info(launch_info);
198  process_sp = Attach(attach_info, debugger, &target, error);
199  if (process_sp) {
200  launch_info.SetHijackListener(attach_info.GetHijackListener());
201 
202  // Since we attached to the process, it will think it needs to detach
203  // if the process object just goes away without an explicit call to
204  // Process::Kill() or Process::Detach(), so let it know to kill the
205  // process if this happens.
206  process_sp->SetShouldDetach(false);
207 
208  // If we didn't have any file actions, the pseudo terminal might have
209  // been used where the secondary side was given as the file to open for
210  // stdin/out/err after we have already opened the primary so we can
211  // read/write stdin/out/err.
212  int pty_fd = launch_info.GetPTY().ReleasePrimaryFileDescriptor();
213  if (pty_fd != PseudoTerminal::invalid_fd) {
214  process_sp->SetSTDIOFileDescriptor(pty_fd);
215  }
216  }
217  }
218  }
219 
220  return process_sp;
221 #else
222  return ProcessSP();
223 #endif
224 }
225 
227 #if defined(__APPLE__)
228  std::lock_guard<std::mutex> guard(m_core_sim_path_mutex);
229  if (!m_core_simulator_framework_path.has_value()) {
231  FileSpec("/Library/Developer/PrivateFrameworks/CoreSimulator.framework/"
232  "CoreSimulator");
234  }
235  return m_core_simulator_framework_path.value();
236 #else
237  return FileSpec();
238 #endif
239 }
240 
242 #if defined(__APPLE__)
243  static llvm::once_flag g_load_core_sim_flag;
244  llvm::call_once(g_load_core_sim_flag, [this] {
245  const std::string core_sim_path(GetCoreSimulatorPath().GetPath());
246  if (core_sim_path.size())
247  dlopen(core_sim_path.c_str(), RTLD_LAZY);
248  });
249 #endif
250 }
251 
252 #if defined(__APPLE__)
253 CoreSimulatorSupport::Device PlatformAppleSimulator::GetSimulatorDevice() {
254  if (!m_device.has_value()) {
256  std::string developer_dir =
257  HostInfo::GetXcodeDeveloperDirectory().GetPath();
259  developer_dir.c_str())
260  .GetFanciest(dev_id);
261  }
262 
263  if (m_device.has_value())
264  return m_device.value();
265  else
267 }
268 #endif
269 
271  const ArchSpec &process_host_arch) {
272  std::vector<ArchSpec> result(m_supported_triples.size());
273  llvm::transform(m_supported_triples, result.begin(),
274  [](llvm::StringRef triple) { return ArchSpec(triple); });
275  return result;
276 }
277 
278 static llvm::StringRef GetXcodeSDKDir(std::string preferred,
279  std::string secondary) {
280  llvm::StringRef sdk;
281  sdk = HostInfo::GetXcodeSDKPath(XcodeSDK(std::move(preferred)));
282  if (sdk.empty())
283  sdk = HostInfo::GetXcodeSDKPath(XcodeSDK(std::move(secondary)));
284  return sdk;
285 }
286 
288  const char *class_name, const char *description, ConstString plugin_name,
289  llvm::SmallVector<llvm::Triple::ArchType, 4> supported_arch,
290  llvm::Triple::OSType preferred_os,
291  llvm::SmallVector<llvm::Triple::OSType, 4> supported_os,
292  llvm::SmallVector<llvm::StringRef, 4> supported_triples,
293  std::string sdk_name_preferred, std::string sdk_name_secondary,
296  const ArchSpec *arch) {
297  Log *log = GetLog(LLDBLog::Platform);
298  if (log) {
299  const char *arch_name;
300  if (arch && arch->GetArchitectureName())
301  arch_name = arch->GetArchitectureName();
302  else
303  arch_name = "<null>";
304 
305  const char *triple_cstr =
306  arch ? arch->GetTriple().getTriple().c_str() : "<null>";
307 
308  LLDB_LOGF(log, "%s::%s(force=%s, arch={%s,%s})", class_name, __FUNCTION__,
309  force ? "true" : "false", arch_name, triple_cstr);
310  }
311 
312  bool create = force;
313  if (!create && arch && arch->IsValid()) {
314  if (std::count(supported_arch.begin(), supported_arch.end(),
315  arch->GetMachine())) {
316  const llvm::Triple &triple = arch->GetTriple();
317  switch (triple.getVendor()) {
318  case llvm::Triple::Apple:
319  create = true;
320  break;
321 
322 #if defined(__APPLE__)
323  // Only accept "unknown" for the vendor if the host is Apple and if
324  // "unknown" wasn't specified (it was just returned because it was NOT
325  // specified)
326  case llvm::Triple::UnknownVendor:
327  create = !arch->TripleVendorWasSpecified();
328  break;
329 #endif
330  default:
331  break;
332  }
333 
334  if (create) {
335  if (llvm::is_contained(supported_os, triple.getOS()))
336  create = true;
337 #if defined(__APPLE__)
338  // Only accept "unknown" for the OS if the host is Apple and it
339  // "unknown" wasn't specified (it was just returned because it was NOT
340  // specified)
341  else if (triple.getOS() == llvm::Triple::UnknownOS)
342  create = !arch->TripleOSWasSpecified();
343 #endif
344  else
345  create = false;
346  }
347  }
348  }
349  if (create) {
350  LLDB_LOGF(log, "%s::%s() creating platform", class_name, __FUNCTION__);
351 
352  llvm::StringRef sdk =
353  GetXcodeSDKDir(sdk_name_preferred, sdk_name_secondary);
354  return PlatformSP(new PlatformAppleSimulator(
355  class_name, description, plugin_name, preferred_os, supported_triples,
356  sdk, sdk_type, kind));
357  }
358 
359  LLDB_LOGF(log, "%s::%s() aborting creation of platform", class_name,
360  __FUNCTION__);
361 
362  return PlatformSP();
363 }
364 
366  const ModuleSpec &module_spec, lldb::ModuleSP &exe_module_sp,
367  const FileSpecList *module_search_paths_ptr) {
368  Status error;
369  // Nothing special to do here, just use the actual file and architecture
370 
371  ModuleSpec resolved_module_spec(module_spec);
372 
373  // If we have "ls" as the exe_file, resolve the executable loation based on
374  // the current path variables
375  // TODO: resolve bare executables in the Platform SDK
376  // if (!resolved_exe_file.Exists())
377  // resolved_exe_file.ResolveExecutableLocation ();
378 
379  // Resolve any executable within a bundle on MacOSX
380  // TODO: verify that this handles shallow bundles, if not then implement one
381  // ourselves
382  Host::ResolveExecutableInBundle(resolved_module_spec.GetFileSpec());
383 
384  if (FileSystem::Instance().Exists(resolved_module_spec.GetFileSpec())) {
385  if (resolved_module_spec.GetArchitecture().IsValid()) {
386  error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
387  NULL, NULL, NULL);
388 
389  if (exe_module_sp && exe_module_sp->GetObjectFile())
390  return error;
391  exe_module_sp.reset();
392  }
393  // No valid architecture was specified or the exact ARM slice wasn't found
394  // so ask the platform for the architectures that we should be using (in
395  // the correct order) and see if we can find a match that way
396  StreamString arch_names;
397  llvm::ListSeparator LS;
398  ArchSpec platform_arch;
399  for (const ArchSpec &arch : GetSupportedArchitectures({})) {
400  resolved_module_spec.GetArchitecture() = arch;
401 
402  // Only match x86 with x86 and x86_64 with x86_64...
403  if (!module_spec.GetArchitecture().IsValid() ||
404  module_spec.GetArchitecture().GetCore() ==
405  resolved_module_spec.GetArchitecture().GetCore()) {
406  error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
407  NULL, NULL, NULL);
408  // Did we find an executable using one of the
409  if (error.Success()) {
410  if (exe_module_sp && exe_module_sp->GetObjectFile())
411  break;
412  else
413  error.SetErrorToGenericError();
414  }
415 
416  arch_names << LS << platform_arch.GetArchitectureName();
417  }
418  }
419 
420  if (error.Fail() || !exe_module_sp) {
421  if (FileSystem::Instance().Readable(resolved_module_spec.GetFileSpec())) {
422  error.SetErrorStringWithFormatv(
423  "'{0}' doesn't contain any '{1}' platform architectures: {2}",
424  resolved_module_spec.GetFileSpec(), GetPluginName(),
425  arch_names.GetString());
426  } else {
427  error.SetErrorStringWithFormat(
428  "'%s' is not readable",
429  resolved_module_spec.GetFileSpec().GetPath().c_str());
430  }
431  }
432  } else {
433  error.SetErrorStringWithFormat("'%s' does not exist",
434  module_spec.GetFileSpec().GetPath().c_str());
435  }
436 
437  return error;
438 }
439 
441  const UUID *uuid_ptr,
442  FileSpec &local_file) {
443  Status error;
444  char platform_file_path[PATH_MAX];
445  if (platform_file.GetPath(platform_file_path, sizeof(platform_file_path))) {
446  char resolved_path[PATH_MAX];
447 
448  if (!m_sdk.empty()) {
449  ::snprintf(resolved_path, sizeof(resolved_path), "%s/%s",
450  m_sdk.str().c_str(), platform_file_path);
451 
452  // First try in the SDK and see if the file is in there
453  local_file.SetFile(resolved_path, FileSpec::Style::native);
454  FileSystem::Instance().Resolve(local_file);
455  if (FileSystem::Instance().Exists(local_file))
456  return error;
457 
458  // Else fall back to the actual path itself
459  local_file.SetFile(platform_file_path, FileSpec::Style::native);
460  FileSystem::Instance().Resolve(local_file);
461  if (FileSystem::Instance().Exists(local_file))
462  return error;
463  }
464  error.SetErrorStringWithFormatv(
465  "unable to locate a platform file for '{0}' in platform '{1}'",
466  platform_file_path, GetPluginName());
467  } else {
468  error.SetErrorString("invalid platform file argument");
469  }
470  return error;
471 }
472 
474  const ModuleSpec &module_spec, Process *process, ModuleSP &module_sp,
475  const FileSpecList *module_search_paths_ptr,
476  llvm::SmallVectorImpl<lldb::ModuleSP> *old_modules, bool *did_create_ptr) {
477  // For iOS/tvOS/watchOS, the SDK files are all cached locally on the
478  // host system. So first we ask for the file in the cached SDK, then
479  // we attempt to get a shared module for the right architecture with
480  // the right UUID.
481  Status error;
482  ModuleSpec platform_module_spec(module_spec);
483  const FileSpec &platform_file = module_spec.GetFileSpec();
484  error = GetSymbolFile(platform_file, module_spec.GetUUIDPtr(),
485  platform_module_spec.GetFileSpec());
486  if (error.Success()) {
487  error = ResolveExecutable(platform_module_spec, module_sp,
488  module_search_paths_ptr);
489  } else {
490  const bool always_create = false;
491  error = ModuleList::GetSharedModule(module_spec, module_sp,
492  module_search_paths_ptr, old_modules,
493  did_create_ptr, always_create);
494  }
495  if (module_sp)
496  module_sp->SetPlatformFileSpec(platform_file);
497 
498  return error;
499 }
500 
502  const ProcessInstanceInfoMatch &match_info,
503  ProcessInstanceInfoList &process_infos) {
504  ProcessInstanceInfoList all_osx_process_infos;
505  // First we get all OSX processes
506  const uint32_t n = Host::FindProcesses(match_info, all_osx_process_infos);
507 
508  // Now we filter them down to only the matching triples.
509  for (uint32_t i = 0; i < n; ++i) {
510  const ProcessInstanceInfo &proc_info = all_osx_process_infos[i];
511  const llvm::Triple &triple = proc_info.GetArchitecture().GetTriple();
512  if (triple.getOS() == m_os_type &&
513  triple.getEnvironment() == llvm::Triple::Simulator) {
514  process_infos.push_back(proc_info);
515  }
516  }
517  return process_infos.size();
518 }
519 
520 /// Whether to skip creating a simulator platform.
521 static bool shouldSkipSimulatorPlatform(bool force, const ArchSpec *arch) {
522  // If the arch is known not to specify a simulator environment, skip creating
523  // the simulator platform (we can create it later if there's a matching arch).
524  // This avoids very slow xcrun queries for non-simulator archs (the slowness
525  // is due to xcrun not caching negative queries (rdar://74882205)).
526  return !force && arch && arch->IsValid() &&
528 }
529 
530 static const char *g_ios_plugin_name = "ios-simulator";
531 static const char *g_ios_description = "iPhone simulator platform plug-in.";
532 
533 /// IPhone Simulator Plugin.
535  static void Initialize() {
538  }
539 
540  static void Terminate() {
542  }
543 
544  static PlatformSP CreateInstance(bool force, const ArchSpec *arch) {
545  if (shouldSkipSimulatorPlatform(force, arch))
546  return nullptr;
547 
549  "PlatformiOSSimulator", g_ios_description,
551  {llvm::Triple::aarch64, llvm::Triple::x86_64, llvm::Triple::x86},
552  llvm::Triple::IOS,
553  {// Deprecated, but still support Darwin for historical reasons.
554  llvm::Triple::Darwin, llvm::Triple::MacOSX,
555  // IOS is not used for simulator triples, but accept it just in
556  // case.
557  llvm::Triple::IOS},
558  {
559 #ifdef __APPLE__
560 #if __arm64__
561  "arm64e-apple-ios-simulator", "arm64-apple-ios-simulator",
562  "x86_64-apple-ios-simulator", "x86_64h-apple-ios-simulator",
563 #else
564  "x86_64h-apple-ios-simulator", "x86_64-apple-ios-simulator",
565  "i386-apple-ios-simulator",
566 #endif
567 #endif
568  },
569  "iPhoneSimulator.Internal.sdk", "iPhoneSimulator.sdk",
570  XcodeSDK::Type::iPhoneSimulator,
572  }
573 };
574 
575 static const char *g_tvos_plugin_name = "tvos-simulator";
576 static const char *g_tvos_description = "tvOS simulator platform plug-in.";
577 
578 /// Apple TV Simulator Plugin.
580  static void Initialize() {
583  }
584 
585  static void Terminate() {
587  }
588 
589  static PlatformSP CreateInstance(bool force, const ArchSpec *arch) {
590  if (shouldSkipSimulatorPlatform(force, arch))
591  return nullptr;
593  "PlatformAppleTVSimulator", g_tvos_description,
595  {llvm::Triple::aarch64, llvm::Triple::x86_64}, llvm::Triple::TvOS,
596  {llvm::Triple::TvOS},
597  {
598 #ifdef __APPLE__
599 #if __arm64__
600  "arm64e-apple-tvos-simulator", "arm64-apple-tvos-simulator",
601  "x86_64h-apple-tvos-simulator", "x86_64-apple-tvos-simulator",
602 #else
603  "x86_64h-apple-tvos-simulator", "x86_64-apple-tvos-simulator",
604 #endif
605 #endif
606  },
607  "AppleTVSimulator.Internal.sdk", "AppleTVSimulator.sdk",
608  XcodeSDK::Type::AppleTVSimulator,
610  arch);
611  }
612 };
613 
614 
615 static const char *g_watchos_plugin_name = "watchos-simulator";
616 static const char *g_watchos_description =
617  "Apple Watch simulator platform plug-in.";
618 
619 /// Apple Watch Simulator Plugin.
621  static void Initialize() {
624  }
625 
626  static void Terminate() {
629  }
630 
631  static PlatformSP CreateInstance(bool force, const ArchSpec *arch) {
632  if (shouldSkipSimulatorPlatform(force, arch))
633  return nullptr;
635  "PlatformAppleWatchSimulator", g_watchos_description,
637  {llvm::Triple::aarch64, llvm::Triple::x86_64, llvm::Triple::x86},
638  llvm::Triple::WatchOS, {llvm::Triple::WatchOS},
639  {
640 #ifdef __APPLE__
641 #if __arm64__
642  "arm64e-apple-watchos-simulator", "arm64-apple-watchos-simulator",
643 #else
644  "x86_64-apple-watchos-simulator", "x86_64h-apple-watchos-simulator",
645  "i386-apple-watchos-simulator",
646 #endif
647 #endif
648  },
649  "WatchSimulator.Internal.sdk", "WatchSimulator.sdk",
650  XcodeSDK::Type::WatchSimulator,
652  arch);
653  }
654 };
655 
656 
657 static unsigned g_initialize_count = 0;
658 
659 // Static Functions
661  if (g_initialize_count++ == 0) {
666  }
667 }
668 
670  if (g_initialize_count > 0)
671  if (--g_initialize_count == 0) {
676  }
677 }
678 
lldb_private::ProcessInstanceInfo
Definition: ProcessInfo.h:106
lldb_private::UUID
Definition: UUID.h:23
lldb_private::Host::ResolveExecutableInBundle
static bool ResolveExecutableInBundle(FileSpec &file)
When executable files may live within a directory, where the directory represents an executable bundl...
Definition: common/Host.cpp:328
PlatformAppleWatchSimulator::Initialize
static void Initialize()
Definition: PlatformAppleSimulator.cpp:621
CoreSimulatorSupport::Device::GetName
std::string GetName() const
Definition: PlatformiOSSimulatorCoreSimulatorSupport.mm:205
lldb_private::Host::FindProcesses
static uint32_t FindProcesses(const ProcessInstanceInfoMatch &match_info, ProcessInstanceInfoList &proc_infos)
Definition: common/Host.cpp:614
lldb_private::PlatformAppleSimulator::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: PlatformAppleSimulator.cpp:56
lldb_private::ArchSpec
Definition: ArchSpec.h:32
lldb_private::ArchSpec::TripleVendorWasSpecified
bool TripleVendorWasSpecified() const
Definition: ArchSpec.h:366
lldb_private::ModuleSpec::GetUUIDPtr
UUID * GetUUIDPtr()
Definition: ModuleSpec.h:93
lldb_private::PlatformAppleSimulator::Initialize
static void Initialize()
Definition: PlatformAppleSimulator.cpp:660
LLDB_INVALID_PROCESS_ID
#define LLDB_INVALID_PROCESS_ID
Definition: lldb-defines.h:81
lldb_private::ArchSpec::GetMachine
llvm::Triple::ArchType GetMachine() const
Returns a machine family for the current architecture.
Definition: ArchSpec.cpp:678
GetXcodeSDKDir
static llvm::StringRef GetXcodeSDKDir(std::string preferred, std::string secondary)
Definition: PlatformAppleSimulator.cpp:278
lldb_private::PlatformAppleSimulator::GetSupportedArchitectures
std::vector< ArchSpec > GetSupportedArchitectures(const ArchSpec &process_host_arch) override
Get the platform's supported architectures in the order in which they should be searched.
Definition: PlatformAppleSimulator.cpp:270
CoreSimulatorSupport::DeviceSet::ForEach
void ForEach(std::function< bool(const Device &)> f)
Definition: PlatformiOSSimulatorCoreSimulatorSupport.mm:590
UNSUPPORTED_ERROR
#define UNSUPPORTED_ERROR
Definition: PlatformAppleSimulator.cpp:35
PlatformiOSSimulator
IPhone Simulator Plugin.
Definition: PlatformAppleSimulator.cpp:534
lldb_private::PlatformAppleSimulator::m_sdk
llvm::StringRef m_sdk
Definition: PlatformAppleSimulator.h:122
lldb_private::ArchSpec::GetCore
Core GetCore() const
Definition: ArchSpec.h:442
CoreSimulatorSupport::Device::Spawn
Process Spawn(lldb_private::ProcessLaunchInfo &launch_info)
Definition: PlatformiOSSimulatorCoreSimulatorSupport.mm:448
g_tvos_description
static const char * g_tvos_description
Definition: PlatformAppleSimulator.cpp:576
PlatformiOSSimulator::CreateInstance
static PlatformSP CreateInstance(bool force, const ArchSpec *arch)
Definition: PlatformAppleSimulator.cpp:544
LLDB_LOGF
#define LLDB_LOGF(log,...)
Definition: Log.h:344
lldb_private::Process
Definition: Process.h:338
g_initialize_count
static unsigned g_initialize_count
Definition: PlatformAppleSimulator.cpp:657
Module.h
PlatformAppleTVSimulator::Terminate
static void Terminate()
Definition: PlatformAppleSimulator.cpp:585
lldb_private::XcodeSDK
An abstraction for Xcode-style SDKs that works like ArchSpec.
Definition: XcodeSDK.h:24
lldb_private::PlatformAppleSimulator::~PlatformAppleSimulator
~PlatformAppleSimulator() override
Destructor.
lldb_private::ProcessInstanceInfoMatch
Definition: ProcessInfo.h:160
g_ios_plugin_name
static const char * g_ios_plugin_name
Definition: PlatformAppleSimulator.cpp:530
lldb_private::ProcessInfo::GetProcessID
lldb::pid_t GetProcessID() const
Definition: ProcessInfo.h:66
lldb_private::PlatformAppleSimulator::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: PlatformAppleSimulator.cpp:182
shouldSkipSimulatorPlatform
static bool shouldSkipSimulatorPlatform(bool force, const ArchSpec *arch)
Whether to skip creating a simulator platform.
Definition: PlatformAppleSimulator.cpp:521
lldb_private::ProcessLaunchInfo::GetFlags
Flags & GetFlags()
Definition: ProcessLaunchInfo.h:64
CoreSimulatorSupport::DeviceSet::GetNumDevices
size_t GetNumDevices()
Definition: PlatformiOSSimulatorCoreSimulatorSupport.mm:567
lldb_private::ProcessInfo::SetProcessID
void SetProcessID(lldb::pid_t pid)
Definition: ProcessInfo.h:68
lldb_private::Stream
Definition: Stream.h:28
lldb_private::Args
Definition: Args.h:33
lldb_private::ArchSpec::GetTriple
llvm::Triple & GetTriple()
Architecture triple accessor.
Definition: ArchSpec.h:463
PlatformAppleTVSimulator
Apple TV Simulator Plugin.
Definition: PlatformAppleSimulator.cpp:579
lldb_private::PlatformAppleSimulator::m_core_sim_path_mutex
std::mutex m_core_sim_path_mutex
Definition: PlatformAppleSimulator.h:113
CoreSimulatorSupport::DeviceType::ProductFamilyID::appleWatch
@ appleWatch
lldb_private::Target
Definition: Target.h:469
lldb_private::ProcessLaunchInfo::SetHijackListener
void SetHijackListener(const lldb::ListenerSP &listener_sp)
Definition: ProcessLaunchInfo.h:133
lldb_private::StreamString::GetString
llvm::StringRef GetString() const
Definition: StreamString.cpp:51
Process.h
lldb_private::PlatformDarwin::Initialize
static void Initialize()
Definition: PlatformDarwin.cpp:83
CoreSimulatorSupport::Device::GetState
State GetState()
Definition: PlatformiOSSimulatorCoreSimulatorSupport.mm:107
lldb_private::FileSpec
Definition: FileSpec.h:55
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
CoreSimulatorSupport::DeviceType::ProductFamilyID::iPhone
@ iPhone
LLDBAssert.h
CoreSimulatorSupport::DeviceSet::GetFanciest
Device GetFanciest(DeviceType::ProductFamilyID dev_id)
Definition: PlatformiOSSimulatorCoreSimulatorSupport.mm:613
lldb_private::PluginManager::UnregisterPlugin
static bool UnregisterPlugin(ABICreateInstance create_callback)
Definition: PluginManager.cpp:293
lldb_private::ProcessLaunchInfo
Definition: ProcessLaunchInfo.h:31
Log.h
lldb_private::PlatformDarwin::Terminate
static void Terminate()
Definition: PlatformDarwin.cpp:94
lldb_private::Status::Fail
bool Fail() const
Test for error condition.
Definition: Status.cpp:181
PlatformAppleTVSimulator::Initialize
static void Initialize()
Definition: PlatformAppleSimulator.cpp:580
lldb_private::PlatformAppleSimulator::DisconnectRemote
Status DisconnectRemote() override
Definition: PlatformAppleSimulator.cpp:170
StreamString.h
lldb_private::ConstString
Definition: ConstString.h:39
CoreSimulatorSupport::DeviceSet::GetDeviceAtIndex
Device GetDeviceAtIndex(size_t idx)
Definition: PlatformiOSSimulatorCoreSimulatorSupport.mm:572
lldb_private::StreamString
Definition: StreamString.h:23
CoreSimulatorSupport::Device::GetUDID
std::string GetUDID() const
Definition: PlatformiOSSimulatorCoreSimulatorSupport.mm:212
g_watchos_plugin_name
static const char * g_watchos_plugin_name
Definition: PlatformAppleSimulator.cpp:615
lldb_private::ArchSpec::TripleOSWasSpecified
bool TripleOSWasSpecified() const
Definition: ArchSpec.h:370
lldb_private::PlatformAppleSimulator::m_kind
CoreSimulatorSupport::DeviceType::ProductFamilyID m_kind
Definition: PlatformAppleSimulator.h:116
lldb_private::Debugger
Definition: Debugger.h:74
lldb_private::PlatformAppleSimulator::GetStatus
void GetStatus(Stream &strm) override
Report the current status for this platform.
Definition: PlatformAppleSimulator.cpp:83
HostInfo.h
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
lldb_private::FileSystem::Resolve
void Resolve(llvm::SmallVectorImpl< char > &path)
Resolve path to make it canonical.
Definition: common/FileSystem.cpp:235
lldb_private::ArchSpec::IsValid
bool IsValid() const
Tests if this ArchSpec is valid.
Definition: ArchSpec.h:361
lldb_private::PlatformAppleSimulator::Terminate
static void Terminate()
Definition: PlatformAppleSimulator.cpp:669
lldb_private::PlatformAppleSimulator::m_device
llvm::Optional< CoreSimulatorSupport::Device > m_device
Definition: PlatformAppleSimulator.h:115
lldb_private::PseudoTerminal::invalid_fd
@ invalid_fd
Invalid file descriptor value.
Definition: PseudoTerminal.h:27
lldb_private::ProcessLaunchInfo::SetLaunchInSeparateProcessGroup
void SetLaunchInSeparateProcessGroup(bool separate)
Definition: ProcessLaunchInfo.cpp:150
lldb_private::PlatformAppleSimulator::LoadCoreSimulator
void LoadCoreSimulator()
Definition: PlatformAppleSimulator.cpp:241
lldb_private::ProcessLaunchInfo::GetPTY
PseudoTerminal & GetPTY()
Definition: ProcessLaunchInfo.h:122
lldb_private::ArchSpec::TripleEnvironmentWasSpecified
bool TripleEnvironmentWasSpecified() const
Definition: ArchSpec.h:372
lldb_private::ProcessAttachInfo
Definition: Process.h:113
lldb_private::PlatformAppleSimulator::PlatformAppleSimulator
PlatformAppleSimulator(const char *class_name, const char *description, ConstString plugin_name, llvm::Triple::OSType preferred_os, llvm::SmallVector< llvm::StringRef, 4 > supported_triples, llvm::StringRef sdk, XcodeSDK::Type sdk_type, CoreSimulatorSupport::DeviceType::ProductFamilyID kind)
Default Constructor.
Definition: PlatformAppleSimulator.cpp:39
CoreSimulatorSupport::DeviceType::ProductFamilyID::appleTV
@ appleTV
PlatformAppleTVSimulator::CreateInstance
static PlatformSP CreateInstance(bool force, const ArchSpec *arch)
Definition: PlatformAppleSimulator.cpp:589
lldb_private::ModuleSpec::GetFileSpec
FileSpec & GetFileSpec()
Definition: ModuleSpec.h:53
lldb_private::ModuleSpec
Definition: ModuleSpec.h:27
lldb_private::Status
Definition: Status.h:44
lldb_private::PseudoTerminal::ReleasePrimaryFileDescriptor
int ReleasePrimaryFileDescriptor()
Release the primary file descriptor.
Definition: PseudoTerminal.cpp:202
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:264
lldb_private::ArchSpec::GetArchitectureName
const char * GetArchitectureName() const
Returns a static string representing the current architecture.
Definition: ArchSpec.cpp:547
lldb_private::PlatformAppleSimulator::GetCoreSimulatorPath
FileSpec GetCoreSimulatorPath()
Definition: PlatformAppleSimulator.cpp:226
lldb_private::PlatformAppleSimulator::m_supported_triples
llvm::SmallVector< llvm::StringRef, 4 > m_supported_triples
Definition: PlatformAppleSimulator.h:121
uint32_t
g_watchos_description
static const char * g_watchos_description
Definition: PlatformAppleSimulator.cpp:616
PlatformAppleSimulator.h
CoreSimulatorSupport::DeviceSet::GetAvailableDevices
static DeviceSet GetAvailableDevices(const char *developer_dir)
Definition: PlatformiOSSimulatorCoreSimulatorSupport.mm:559
lldb_private::XcodeSDK::Type
Type
Different types of Xcode SDKs.
Definition: XcodeSDK.h:29
lldb_private::PlatformAppleSimulator::ConnectRemote
Status ConnectRemote(Args &args) override
Definition: PlatformAppleSimulator.cpp:131
CoreSimulatorSupport::DeviceType::ProductFamilyID
ProductFamilyID
Definition: PlatformiOSSimulatorCoreSimulatorSupport.h:72
CoreSimulatorSupport::Device::Boot
bool Boot(lldb_private::Status &err)
Definition: PlatformiOSSimulatorCoreSimulatorSupport.mm:342
CoreSimulatorSupport::Device
Definition: PlatformiOSSimulatorCoreSimulatorSupport.h:136
lldb_private::Status::SetErrorString
void SetErrorString(llvm::StringRef err_str)
Set the current error string to err_str.
Definition: Status.cpp:241
PlatformiOSSimulator::Terminate
static void Terminate()
Definition: PlatformAppleSimulator.cpp:540
CoreSimulatorSupport::Device::State::Booted
@ Booted
lldb_private::PlatformAppleSimulator::m_os_type
llvm::Triple::OSType m_os_type
Definition: PlatformAppleSimulator.h:120
lldb_private::PlatformAppleSimulator::CreateInstance
static lldb::PlatformSP CreateInstance(const char *class_name, const char *description, ConstString plugin_name, llvm::SmallVector< llvm::Triple::ArchType, 4 > supported_arch, llvm::Triple::OSType preferred_os, llvm::SmallVector< llvm::Triple::OSType, 4 > supported_os, llvm::SmallVector< llvm::StringRef, 4 > supported_triples, std::string sdk_name_preferred, std::string sdk_name_secondary, XcodeSDK::Type sdk_type, CoreSimulatorSupport::DeviceType::ProductFamilyID kind, bool force, const ArchSpec *arch)
Definition: PlatformAppleSimulator.cpp:287
PseudoTerminal.h
PluginManager.h
lldb_private::ModuleSpec::GetArchitecture
ArchSpec & GetArchitecture()
Definition: ModuleSpec.h:89
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::FileSystem::Instance
static FileSystem & Instance()
Definition: common/FileSystem.cpp:46
Status.h
lldb_private::PluginManager::RegisterPlugin
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
Definition: PluginManager.cpp:287
lldb_private::LLDBLog::Platform
@ Platform
lldb_private::PlatformAppleSimulator::GetPluginName
llvm::StringRef GetPluginName() override
Definition: PlatformAppleSimulator.h:69
lldb_private::ProcessInfo::GetArchitecture
ArchSpec & GetArchitecture()
Definition: ProcessInfo.h:60
lldb_private::PlatformAppleSimulator::ResolveExecutable
Status ResolveExecutable(const ModuleSpec &module_spec, lldb::ModuleSP &module_sp, const FileSpecList *module_search_paths_ptr) override
Find a platform plugin for a given process.
Definition: PlatformAppleSimulator.cpp:365
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::PlatformAppleSimulator::m_core_simulator_framework_path
llvm::Optional< FileSpec > m_core_simulator_framework_path
Definition: PlatformAppleSimulator.h:114
lldb_private::PlatformAppleSimulator::FindProcesses
uint32_t FindProcesses(const ProcessInstanceInfoMatch &match_info, ProcessInstanceInfoList &process_infos) override
Attach to an existing process by process name.
Definition: PlatformAppleSimulator.cpp:501
PlatformAppleWatchSimulator
Apple Watch Simulator Plugin.
Definition: PlatformAppleSimulator.cpp:620
lldb_private::Flags::Set
ValueType Set(ValueType mask)
Set one or more flags by logical OR'ing mask with the current flags.
Definition: Flags.h:73
PlatformAppleWatchSimulator::CreateInstance
static PlatformSP CreateInstance(bool force, const ArchSpec *arch)
Definition: PlatformAppleSimulator.cpp:631
g_ios_description
static const char * g_ios_description
Definition: PlatformAppleSimulator.cpp:531
lldb_private::Platform::GetStatus
virtual void GetStatus(Stream &strm)
Report the current status for this platform.
Definition: Platform.cpp:285
lldb_private::Log
Definition: Log.h:115
PlatformPOSIX::Attach
lldb::ProcessSP Attach(lldb_private::ProcessAttachInfo &attach_info, lldb_private::Debugger &debugger, lldb_private::Target *target, lldb_private::Status &error) override
Attach to an existing process using a process ID.
Definition: PlatformPOSIX.cpp:362
lldb_private::FileSpec::SetFile
void SetFile(llvm::StringRef path, Style style)
Change the file specified with a new path.
Definition: FileSpec.cpp:172
g_tvos_plugin_name
static const char * g_tvos_plugin_name
Definition: PlatformAppleSimulator.cpp:575
llvm::SmallVectorImpl
Definition: Disassembler.h:42
lldb_private::PlatformAppleSimulator::GetSharedModule
Status GetSharedModule(const ModuleSpec &module_spec, Process *process, lldb::ModuleSP &module_sp, const FileSpecList *module_search_paths_ptr, llvm::SmallVectorImpl< lldb::ModuleSP > *old_modules, bool *did_create_ptr) override
Definition: PlatformAppleSimulator.cpp:473
PATH_MAX
#define PATH_MAX
Definition: windows/PosixApi.h:25
lldb_private::GetLog
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition: Log.h:309
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:364
lldb_private::ProcessAttachInfo::GetHijackListener
lldb::ListenerSP GetHijackListener() const
Definition: Process.h:176
lldb_private::Args::GetArgumentCount
size_t GetArgumentCount() const
Gets the number of arguments left in this command object.
Definition: Args.h:116
lldb_private::ProcessInstanceInfoList
std::vector< ProcessInstanceInfo > ProcessInstanceInfoList
Definition: Host.h:31
PlatformAppleWatchSimulator::Terminate
static void Terminate()
Definition: PlatformAppleSimulator.cpp:626
lldb
Definition: SBAddress.h:15
lldb_private::ModuleList::GetSharedModule
static Status GetSharedModule(const ModuleSpec &module_spec, lldb::ModuleSP &module_sp, const FileSpecList *module_search_paths_ptr, llvm::SmallVectorImpl< lldb::ModuleSP > *old_modules, bool *did_create_ptr, bool always_create=false)
Definition: ModuleList.cpp:786
lldb_private::PlatformDarwin
Definition: PlatformDarwin.h:45
LLDBLog.h
lldb_private::PlatformAppleSimulator::GetSymbolFile
Status GetSymbolFile(const FileSpec &platform_file, const UUID *uuid_ptr, FileSpec &local_file)
Definition: PlatformAppleSimulator.cpp:440
PlatformiOSSimulator::Initialize
static void Initialize()
Definition: PlatformAppleSimulator.cpp:535
CoreSimulatorSupport::DeviceSet
Definition: PlatformiOSSimulatorCoreSimulatorSupport.h:195