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.hasValue() && 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.hasValue()) {
231  FileSpec("/Library/Developer/PrivateFrameworks/CoreSimulator.framework/"
232  "CoreSimulator");
234  }
235  return m_core_simulator_framework_path.getValue();
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.hasValue()) {
256  std::string developer_dir = HostInfo::GetXcodeDeveloperDirectory().GetPath();
258  developer_dir.c_str())
259  .GetFanciest(dev_id);
260  }
261 
262  if (m_device.hasValue())
263  return m_device.getValue();
264  else
266 }
267 #endif
268 
270  const ArchSpec &process_host_arch) {
271  std::vector<ArchSpec> result(m_supported_triples.size());
272  llvm::transform(m_supported_triples, result.begin(),
273  [](llvm::StringRef triple) { return ArchSpec(triple); });
274  return result;
275 }
276 
277 static llvm::StringRef GetXcodeSDKDir(std::string preferred,
278  std::string secondary) {
279  llvm::StringRef sdk;
280  sdk = HostInfo::GetXcodeSDKPath(XcodeSDK(std::move(preferred)));
281  if (sdk.empty())
282  sdk = HostInfo::GetXcodeSDKPath(XcodeSDK(std::move(secondary)));
283  return sdk;
284 }
285 
287  const char *class_name, const char *description, ConstString plugin_name,
288  llvm::SmallVector<llvm::Triple::ArchType, 4> supported_arch,
289  llvm::Triple::OSType preferred_os,
290  llvm::SmallVector<llvm::Triple::OSType, 4> supported_os,
291  llvm::SmallVector<llvm::StringRef, 4> supported_triples,
292  std::string sdk_name_preferred, std::string sdk_name_secondary,
295  const ArchSpec *arch) {
296  Log *log = GetLog(LLDBLog::Platform);
297  if (log) {
298  const char *arch_name;
299  if (arch && arch->GetArchitectureName())
300  arch_name = arch->GetArchitectureName();
301  else
302  arch_name = "<null>";
303 
304  const char *triple_cstr =
305  arch ? arch->GetTriple().getTriple().c_str() : "<null>";
306 
307  LLDB_LOGF(log, "%s::%s(force=%s, arch={%s,%s})", class_name, __FUNCTION__,
308  force ? "true" : "false", arch_name, triple_cstr);
309  }
310 
311  bool create = force;
312  if (!create && arch && arch->IsValid()) {
313  if (std::count(supported_arch.begin(), supported_arch.end(),
314  arch->GetMachine())) {
315  const llvm::Triple &triple = arch->GetTriple();
316  switch (triple.getVendor()) {
317  case llvm::Triple::Apple:
318  create = true;
319  break;
320 
321 #if defined(__APPLE__)
322  // Only accept "unknown" for the vendor if the host is Apple and if
323  // "unknown" wasn't specified (it was just returned because it was NOT
324  // specified)
325  case llvm::Triple::UnknownVendor:
326  create = !arch->TripleVendorWasSpecified();
327  break;
328 #endif
329  default:
330  break;
331  }
332 
333  if (create) {
334  if (std::count(supported_os.begin(), supported_os.end(), triple.getOS()))
335  create = true;
336 #if defined(__APPLE__)
337  // Only accept "unknown" for the OS if the host is Apple and it
338  // "unknown" wasn't specified (it was just returned because it was NOT
339  // specified)
340  else if (triple.getOS() == llvm::Triple::UnknownOS)
341  create = !arch->TripleOSWasSpecified();
342 #endif
343  else
344  create = false;
345  }
346  }
347  }
348  if (create) {
349  LLDB_LOGF(log, "%s::%s() creating platform", class_name, __FUNCTION__);
350 
351  llvm::StringRef sdk =
352  GetXcodeSDKDir(sdk_name_preferred, sdk_name_secondary);
353  return PlatformSP(new PlatformAppleSimulator(
354  class_name, description, plugin_name, preferred_os, supported_triples,
355  sdk, sdk_type, kind));
356  }
357 
358  LLDB_LOGF(log, "%s::%s() aborting creation of platform", class_name,
359  __FUNCTION__);
360 
361  return PlatformSP();
362 }
363 
365  const ModuleSpec &module_spec, lldb::ModuleSP &exe_module_sp,
366  const FileSpecList *module_search_paths_ptr) {
367  Status error;
368  // Nothing special to do here, just use the actual file and architecture
369 
370  ModuleSpec resolved_module_spec(module_spec);
371 
372  // If we have "ls" as the exe_file, resolve the executable loation based on
373  // the current path variables
374  // TODO: resolve bare executables in the Platform SDK
375  // if (!resolved_exe_file.Exists())
376  // resolved_exe_file.ResolveExecutableLocation ();
377 
378  // Resolve any executable within a bundle on MacOSX
379  // TODO: verify that this handles shallow bundles, if not then implement one
380  // ourselves
381  Host::ResolveExecutableInBundle(resolved_module_spec.GetFileSpec());
382 
383  if (FileSystem::Instance().Exists(resolved_module_spec.GetFileSpec())) {
384  if (resolved_module_spec.GetArchitecture().IsValid()) {
385  error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
386  NULL, NULL, NULL);
387 
388  if (exe_module_sp && exe_module_sp->GetObjectFile())
389  return error;
390  exe_module_sp.reset();
391  }
392  // No valid architecture was specified or the exact ARM slice wasn't found
393  // so ask the platform for the architectures that we should be using (in
394  // the correct order) and see if we can find a match that way
395  StreamString arch_names;
396  llvm::ListSeparator LS;
397  ArchSpec platform_arch;
398  for (const ArchSpec &arch : GetSupportedArchitectures({})) {
399  resolved_module_spec.GetArchitecture() = arch;
400 
401  // Only match x86 with x86 and x86_64 with x86_64...
402  if (!module_spec.GetArchitecture().IsValid() ||
403  module_spec.GetArchitecture().GetCore() ==
404  resolved_module_spec.GetArchitecture().GetCore()) {
405  error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
406  NULL, NULL, NULL);
407  // Did we find an executable using one of the
408  if (error.Success()) {
409  if (exe_module_sp && exe_module_sp->GetObjectFile())
410  break;
411  else
412  error.SetErrorToGenericError();
413  }
414 
415  arch_names << LS << platform_arch.GetArchitectureName();
416  }
417  }
418 
419  if (error.Fail() || !exe_module_sp) {
420  if (FileSystem::Instance().Readable(resolved_module_spec.GetFileSpec())) {
421  error.SetErrorStringWithFormatv(
422  "'{0}' doesn't contain any '{1}' platform architectures: {2}",
423  resolved_module_spec.GetFileSpec(), GetPluginName(),
424  arch_names.GetString());
425  } else {
426  error.SetErrorStringWithFormat(
427  "'%s' is not readable",
428  resolved_module_spec.GetFileSpec().GetPath().c_str());
429  }
430  }
431  } else {
432  error.SetErrorStringWithFormat("'%s' does not exist",
433  module_spec.GetFileSpec().GetPath().c_str());
434  }
435 
436  return error;
437 }
438 
440  const UUID *uuid_ptr,
441  FileSpec &local_file) {
442  Status error;
443  char platform_file_path[PATH_MAX];
444  if (platform_file.GetPath(platform_file_path, sizeof(platform_file_path))) {
445  char resolved_path[PATH_MAX];
446 
447  if (!m_sdk.empty()) {
448  ::snprintf(resolved_path, sizeof(resolved_path), "%s/%s",
449  m_sdk.str().c_str(), platform_file_path);
450 
451  // First try in the SDK and see if the file is in there
452  local_file.SetFile(resolved_path, FileSpec::Style::native);
453  FileSystem::Instance().Resolve(local_file);
454  if (FileSystem::Instance().Exists(local_file))
455  return error;
456 
457  // Else fall back to the actual path itself
458  local_file.SetFile(platform_file_path, FileSpec::Style::native);
459  FileSystem::Instance().Resolve(local_file);
460  if (FileSystem::Instance().Exists(local_file))
461  return error;
462  }
463  error.SetErrorStringWithFormatv(
464  "unable to locate a platform file for '{0}' in platform '{1}'",
465  platform_file_path, GetPluginName());
466  } else {
467  error.SetErrorString("invalid platform file argument");
468  }
469  return error;
470 }
471 
473  const ModuleSpec &module_spec, Process *process, ModuleSP &module_sp,
474  const FileSpecList *module_search_paths_ptr,
475  llvm::SmallVectorImpl<lldb::ModuleSP> *old_modules, bool *did_create_ptr) {
476  // For iOS/tvOS/watchOS, the SDK files are all cached locally on the
477  // host system. So first we ask for the file in the cached SDK, then
478  // we attempt to get a shared module for the right architecture with
479  // the right UUID.
480  Status error;
481  ModuleSpec platform_module_spec(module_spec);
482  const FileSpec &platform_file = module_spec.GetFileSpec();
483  error = GetSymbolFile(platform_file, module_spec.GetUUIDPtr(),
484  platform_module_spec.GetFileSpec());
485  if (error.Success()) {
486  error = ResolveExecutable(platform_module_spec, module_sp,
487  module_search_paths_ptr);
488  } else {
489  const bool always_create = false;
490  error = ModuleList::GetSharedModule(module_spec, module_sp,
491  module_search_paths_ptr, old_modules,
492  did_create_ptr, always_create);
493  }
494  if (module_sp)
495  module_sp->SetPlatformFileSpec(platform_file);
496 
497  return error;
498 }
499 
501  const ProcessInstanceInfoMatch &match_info,
502  ProcessInstanceInfoList &process_infos) {
503  ProcessInstanceInfoList all_osx_process_infos;
504  // First we get all OSX processes
505  const uint32_t n = Host::FindProcesses(match_info, all_osx_process_infos);
506 
507  // Now we filter them down to only the matching triples.
508  for (uint32_t i = 0; i < n; ++i) {
509  const ProcessInstanceInfo &proc_info = all_osx_process_infos[i];
510  const llvm::Triple &triple = proc_info.GetArchitecture().GetTriple();
511  if (triple.getOS() == m_os_type &&
512  triple.getEnvironment() == llvm::Triple::Simulator) {
513  process_infos.push_back(proc_info);
514  }
515  }
516  return process_infos.size();
517 }
518 
519 /// Whether to skip creating a simulator platform.
520 static bool shouldSkipSimulatorPlatform(bool force, const ArchSpec *arch) {
521  // If the arch is known not to specify a simulator environment, skip creating
522  // the simulator platform (we can create it later if there's a matching arch).
523  // This avoids very slow xcrun queries for non-simulator archs (the slowness
524  // is due to xcrun not caching negative queries (rdar://74882205)).
525  return !force && arch && arch->IsValid() &&
527 }
528 
529 static const char *g_ios_plugin_name = "ios-simulator";
530 static const char *g_ios_description = "iPhone simulator platform plug-in.";
531 
532 /// IPhone Simulator Plugin.
534  static void Initialize() {
537  }
538 
539  static void Terminate() {
541  }
542 
543  static PlatformSP CreateInstance(bool force, const ArchSpec *arch) {
544  if (shouldSkipSimulatorPlatform(force, arch))
545  return nullptr;
546 
548  "PlatformiOSSimulator", g_ios_description,
550  {llvm::Triple::aarch64, llvm::Triple::x86_64, llvm::Triple::x86},
551  llvm::Triple::IOS,
552  {// Deprecated, but still support Darwin for historical reasons.
553  llvm::Triple::Darwin, llvm::Triple::MacOSX,
554  // IOS is not used for simulator triples, but accept it just in
555  // case.
556  llvm::Triple::IOS},
557  {
558 #ifdef __APPLE__
559 #if __arm64__
560  "arm64e-apple-ios-simulator", "arm64-apple-ios-simulator",
561  "x86_64-apple-ios-simulator", "x86_64h-apple-ios-simulator",
562 #else
563  "x86_64h-apple-ios-simulator", "x86_64-apple-ios-simulator",
564  "i386-apple-ios-simulator",
565 #endif
566 #endif
567  },
568  "iPhoneSimulator.Internal.sdk", "iPhoneSimulator.sdk",
569  XcodeSDK::Type::iPhoneSimulator,
571  }
572 };
573 
574 static const char *g_tvos_plugin_name = "tvos-simulator";
575 static const char *g_tvos_description = "tvOS simulator platform plug-in.";
576 
577 /// Apple TV Simulator Plugin.
579  static void Initialize() {
582  }
583 
584  static void Terminate() {
586  }
587 
588  static PlatformSP CreateInstance(bool force, const ArchSpec *arch) {
589  if (shouldSkipSimulatorPlatform(force, arch))
590  return nullptr;
592  "PlatformAppleTVSimulator", g_tvos_description,
594  {llvm::Triple::aarch64, llvm::Triple::x86_64}, llvm::Triple::TvOS,
595  {llvm::Triple::TvOS},
596  {
597 #ifdef __APPLE__
598 #if __arm64__
599  "arm64e-apple-tvos-simulator", "arm64-apple-tvos-simulator",
600  "x86_64h-apple-tvos-simulator", "x86_64-apple-tvos-simulator",
601 #else
602  "x86_64h-apple-tvos-simulator", "x86_64-apple-tvos-simulator",
603 #endif
604 #endif
605  },
606  "AppleTVSimulator.Internal.sdk", "AppleTVSimulator.sdk",
607  XcodeSDK::Type::AppleTVSimulator,
609  arch);
610  }
611 };
612 
613 
614 static const char *g_watchos_plugin_name = "watchos-simulator";
615 static const char *g_watchos_description =
616  "Apple Watch simulator platform plug-in.";
617 
618 /// Apple Watch Simulator Plugin.
620  static void Initialize() {
623  }
624 
625  static void Terminate() {
628  }
629 
630  static PlatformSP CreateInstance(bool force, const ArchSpec *arch) {
631  if (shouldSkipSimulatorPlatform(force, arch))
632  return nullptr;
634  "PlatformAppleWatchSimulator", g_watchos_description,
636  {llvm::Triple::aarch64, llvm::Triple::x86_64, llvm::Triple::x86},
637  llvm::Triple::WatchOS, {llvm::Triple::WatchOS},
638  {
639 #ifdef __APPLE__
640 #if __arm64__
641  "arm64e-apple-watchos-simulator", "arm64-apple-watchos-simulator",
642 #else
643  "x86_64-apple-watchos-simulator", "x86_64h-apple-watchos-simulator",
644  "i386-apple-watchos-simulator",
645 #endif
646 #endif
647  },
648  "WatchSimulator.Internal.sdk", "WatchSimulator.sdk",
649  XcodeSDK::Type::WatchSimulator,
651  arch);
652  }
653 };
654 
655 
656 static unsigned g_initialize_count = 0;
657 
658 // Static Functions
660  if (g_initialize_count++ == 0) {
665  }
666 }
667 
669  if (g_initialize_count > 0)
670  if (--g_initialize_count == 0) {
675  }
676 }
677 
lldb_private::ProcessInstanceInfo
Definition: ProcessInfo.h:108
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:329
PlatformAppleWatchSimulator::Initialize
static void Initialize()
Definition: PlatformAppleSimulator.cpp:620
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:615
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:33
lldb_private::ArchSpec::TripleVendorWasSpecified
bool TripleVendorWasSpecified() const
Definition: ArchSpec.h:358
lldb_private::ModuleSpec::GetUUIDPtr
UUID * GetUUIDPtr()
Definition: ModuleSpec.h:93
lldb_private::PlatformAppleSimulator::Initialize
static void Initialize()
Definition: PlatformAppleSimulator.cpp:659
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:668
GetXcodeSDKDir
static llvm::StringRef GetXcodeSDKDir(std::string preferred, std::string secondary)
Definition: PlatformAppleSimulator.cpp:277
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:269
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:533
lldb_private::PlatformAppleSimulator::m_sdk
llvm::StringRef m_sdk
Definition: PlatformAppleSimulator.h:122
lldb_private::ArchSpec::GetCore
Core GetCore() const
Definition: ArchSpec.h:434
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:575
PlatformiOSSimulator::CreateInstance
static PlatformSP CreateInstance(bool force, const ArchSpec *arch)
Definition: PlatformAppleSimulator.cpp:543
lldb_private::PseudoTerminal::invalid_fd
@ invalid_fd
Invalid file descriptor value.
Definition: PseudoTerminal.h:27
LLDB_LOGF
#define LLDB_LOGF(log,...)
Definition: Log.h:343
lldb_private::Process
Definition: Process.h:338
g_initialize_count
static unsigned g_initialize_count
Definition: PlatformAppleSimulator.cpp:656
Module.h
PlatformAppleTVSimulator::Terminate
static void Terminate()
Definition: PlatformAppleSimulator.cpp:584
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:163
g_ios_plugin_name
static const char * g_ios_plugin_name
Definition: PlatformAppleSimulator.cpp:529
lldb_private::ProcessInfo::GetProcessID
lldb::pid_t GetProcessID() const
Definition: ProcessInfo.h:67
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:520
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:69
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:455
PlatformAppleTVSimulator
Apple TV Simulator Plugin.
Definition: PlatformAppleSimulator.cpp:578
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:473
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:56
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:579
lldb_private::PlatformAppleSimulator::DisconnectRemote
Status DisconnectRemote() override
Definition: PlatformAppleSimulator.cpp:170
StreamString.h
lldb_private::ConstString
Definition: ConstString.h:40
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:614
lldb_private::ArchSpec::TripleOSWasSpecified
bool TripleOSWasSpecified() const
Definition: ArchSpec.h:362
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:353
lldb_private::PlatformAppleSimulator::Terminate
static void Terminate()
Definition: PlatformAppleSimulator.cpp:668
lldb_private::PlatformAppleSimulator::m_device
llvm::Optional< CoreSimulatorSupport::Device > m_device
Definition: PlatformAppleSimulator.h:115
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:364
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:588
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:259
lldb_private::ArchSpec::GetArchitectureName
const char * GetArchitectureName() const
Returns a static string representing the current architecture.
Definition: ArchSpec.cpp:539
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:615
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:539
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:286
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:61
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:364
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:500
PlatformAppleWatchSimulator
Apple Watch Simulator Plugin.
Definition: PlatformAppleSimulator.cpp:619
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:630
g_ios_description
static const char * g_ios_description
Definition: PlatformAppleSimulator.cpp:530
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:574
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:472
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:308
lldb_private::FileSpec::GetPath
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
Definition: FileSpec.cpp:347
lldb_private::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:118
lldb_private::ProcessInstanceInfoList
std::vector< ProcessInstanceInfo > ProcessInstanceInfoList
Definition: Host.h:31
PlatformAppleWatchSimulator::Terminate
static void Terminate()
Definition: PlatformAppleSimulator.cpp:625
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:777
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:439
PlatformiOSSimulator::Initialize
static void Initialize()
Definition: PlatformAppleSimulator.cpp:534
CoreSimulatorSupport::DeviceSet
Definition: PlatformiOSSimulatorCoreSimulatorSupport.h:195