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