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