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 UUID *uuid_ptr,
388 FileSpec &local_file) {
390 char platform_file_path[PATH_MAX];
391 if (platform_file.GetPath(platform_file_path, sizeof(platform_file_path))) {
392 char resolved_path[PATH_MAX];
393
394 llvm::StringRef sdk = GetSDKFilepath();
395 if (!sdk.empty()) {
396 ::snprintf(resolved_path, sizeof(resolved_path), "%s/%s",
397 sdk.str().c_str(), platform_file_path);
398
399 // First try in the SDK and see if the file is in there
400 local_file.SetFile(resolved_path, FileSpec::Style::native);
401 FileSystem::Instance().Resolve(local_file);
402 if (FileSystem::Instance().Exists(local_file))
403 return error;
404
405 // Else fall back to the actual path itself
406 local_file.SetFile(platform_file_path, FileSpec::Style::native);
407 FileSystem::Instance().Resolve(local_file);
408 if (FileSystem::Instance().Exists(local_file))
409 return error;
410 }
411 error.SetErrorStringWithFormatv(
412 "unable to locate a platform file for '{0}' in platform '{1}'",
413 platform_file_path, GetPluginName());
414 } else {
415 error.SetErrorString("invalid platform file argument");
416 }
417 return error;
418}
419
421 const ModuleSpec &module_spec, Process *process, ModuleSP &module_sp,
422 const FileSpecList *module_search_paths_ptr,
423 llvm::SmallVectorImpl<lldb::ModuleSP> *old_modules, bool *did_create_ptr) {
424 // For iOS/tvOS/watchOS, the SDK files are all cached locally on the
425 // host system. So first we ask for the file in the cached SDK, then
426 // we attempt to get a shared module for the right architecture with
427 // the right UUID.
429 ModuleSpec platform_module_spec(module_spec);
430 const FileSpec &platform_file = module_spec.GetFileSpec();
431 error = GetSymbolFile(platform_file, module_spec.GetUUIDPtr(),
432 platform_module_spec.GetFileSpec());
433 if (error.Success()) {
434 error = ResolveExecutable(platform_module_spec, module_sp,
435 module_search_paths_ptr);
436 } else {
437 const bool always_create = false;
438 error = ModuleList::GetSharedModule(module_spec, module_sp,
439 module_search_paths_ptr, old_modules,
440 did_create_ptr, always_create);
441 }
442 if (module_sp)
443 module_sp->SetPlatformFileSpec(platform_file);
444
445 return error;
446}
447
449 const ProcessInstanceInfoMatch &match_info,
450 ProcessInstanceInfoList &process_infos) {
451 ProcessInstanceInfoList all_osx_process_infos;
452 // First we get all OSX processes
453 const uint32_t n = Host::FindProcesses(match_info, all_osx_process_infos);
454
455 // Now we filter them down to only the matching triples.
456 for (uint32_t i = 0; i < n; ++i) {
457 const ProcessInstanceInfo &proc_info = all_osx_process_infos[i];
458 const llvm::Triple &triple = proc_info.GetArchitecture().GetTriple();
459 if (triple.getOS() == m_os_type &&
460 triple.getEnvironment() == llvm::Triple::Simulator) {
461 process_infos.push_back(proc_info);
462 }
463 }
464 return process_infos.size();
465}
466
467/// Whether to skip creating a simulator platform.
468static bool shouldSkipSimulatorPlatform(bool force, const ArchSpec *arch) {
469 // If the arch is known not to specify a simulator environment, skip creating
470 // the simulator platform (we can create it later if there's a matching arch).
471 // This avoids very slow xcrun queries for non-simulator archs (the slowness
472 // is due to xcrun not caching negative queries.
473 return !force && arch && arch->IsValid() &&
475}
476
477static const char *g_ios_plugin_name = "ios-simulator";
478static const char *g_ios_description = "iPhone simulator platform plug-in.";
479
480/// IPhone Simulator Plugin.
482 static void Initialize() {
485 }
486
487 static void Terminate() {
489 }
490
491 static PlatformSP CreateInstance(bool force, const ArchSpec *arch) {
492 if (shouldSkipSimulatorPlatform(force, arch))
493 return nullptr;
494
496 "PlatformiOSSimulator", g_ios_description,
498 {llvm::Triple::aarch64, llvm::Triple::x86_64, llvm::Triple::x86},
499 llvm::Triple::IOS,
500 {// Deprecated, but still support Darwin for historical reasons.
501 llvm::Triple::Darwin, llvm::Triple::MacOSX,
502 // IOS is not used for simulator triples, but accept it just in
503 // case.
504 llvm::Triple::IOS},
505 {
506#ifdef __APPLE__
507#if __arm64__
508 "arm64e-apple-ios-simulator", "arm64-apple-ios-simulator",
509 "x86_64-apple-ios-simulator", "x86_64h-apple-ios-simulator",
510#else
511 "x86_64h-apple-ios-simulator", "x86_64-apple-ios-simulator",
512 "i386-apple-ios-simulator",
513#endif
514#endif
515 },
516 "iPhoneSimulator.Internal.sdk", "iPhoneSimulator.sdk",
517 XcodeSDK::Type::iPhoneSimulator,
519 }
520};
521
522static const char *g_tvos_plugin_name = "tvos-simulator";
523static const char *g_tvos_description = "tvOS simulator platform plug-in.";
524
525/// Apple TV Simulator Plugin.
527 static void Initialize() {
530 }
531
532 static void Terminate() {
534 }
535
536 static PlatformSP CreateInstance(bool force, const ArchSpec *arch) {
537 if (shouldSkipSimulatorPlatform(force, arch))
538 return nullptr;
540 "PlatformAppleTVSimulator", g_tvos_description,
542 {llvm::Triple::aarch64, llvm::Triple::x86_64}, llvm::Triple::TvOS,
543 {llvm::Triple::TvOS},
544 {
545#ifdef __APPLE__
546#if __arm64__
547 "arm64e-apple-tvos-simulator", "arm64-apple-tvos-simulator",
548 "x86_64h-apple-tvos-simulator", "x86_64-apple-tvos-simulator",
549#else
550 "x86_64h-apple-tvos-simulator", "x86_64-apple-tvos-simulator",
551#endif
552#endif
553 },
554 "AppleTVSimulator.Internal.sdk", "AppleTVSimulator.sdk",
555 XcodeSDK::Type::AppleTVSimulator,
557 arch);
558 }
559};
560
561
562static const char *g_watchos_plugin_name = "watchos-simulator";
563static const char *g_watchos_description =
564 "Apple Watch simulator platform plug-in.";
565
566/// Apple Watch Simulator Plugin.
568 static void Initialize() {
571 }
572
573 static void Terminate() {
576 }
577
578 static PlatformSP CreateInstance(bool force, const ArchSpec *arch) {
579 if (shouldSkipSimulatorPlatform(force, arch))
580 return nullptr;
582 "PlatformAppleWatchSimulator", g_watchos_description,
584 {llvm::Triple::aarch64, llvm::Triple::x86_64, llvm::Triple::x86},
585 llvm::Triple::WatchOS, {llvm::Triple::WatchOS},
586 {
587#ifdef __APPLE__
588#if __arm64__
589 "arm64e-apple-watchos-simulator", "arm64-apple-watchos-simulator",
590#else
591 "x86_64-apple-watchos-simulator", "x86_64h-apple-watchos-simulator",
592 "i386-apple-watchos-simulator",
593#endif
594#endif
595 },
596 "WatchSimulator.Internal.sdk", "WatchSimulator.sdk",
597 XcodeSDK::Type::WatchSimulator,
599 arch);
600 }
601};
602
603static const char *g_xros_plugin_name = "xros-simulator";
604static const char *g_xros_description = "XROS simulator platform plug-in.";
605
606/// XRSimulator Plugin.
608 static void Initialize() {
611 }
612
613 static void Terminate() {
615 }
616
617 static PlatformSP CreateInstance(bool force, const ArchSpec *arch) {
619 "PlatformXRSimulator", g_xros_description,
621 {llvm::Triple::aarch64, llvm::Triple::x86_64, llvm::Triple::x86},
622 llvm::Triple::XROS, {llvm::Triple::XROS},
623 {
624#ifdef __APPLE__
625#if __arm64__
626 "arm64e-apple-xros-simulator", "arm64-apple-xros-simulator",
627#else
628 "x86_64-apple-xros-simulator", "x86_64h-apple-xros-simulator",
629#endif
630#endif
631 },
632 "XRSimulator.Internal.sdk", "XRSimulator.sdk",
633 XcodeSDK::Type::XRSimulator,
635 arch);
636 }
637};
638
639static unsigned g_initialize_count = 0;
640
641// Static Functions
643 if (g_initialize_count++ == 0) {
649 }
650}
651
653 if (g_initialize_count > 0)
654 if (--g_initialize_count == 0) {
660 }
661}
662
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
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:91
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 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
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.
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:248
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:110
lldb::ListenerSP GetHijackListener() const
Definition: ProcessInfo.h:108
lldb::pid_t GetProcessID() const
Definition: ProcessInfo.h:68
void SetProcessID(lldb::pid_t pid)
Definition: ProcessInfo.h:70
ArchSpec & GetArchitecture()
Definition: ProcessInfo.h:62
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.
virtual Status ResolveExecutable(const ModuleSpec &module_spec, lldb::ModuleSP &exe_module_sp, const FileSpecList *module_search_paths_ptr) override
Set the target's executable based off of the existing architecture information in target given a path...
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
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:386
std::shared_ptr< lldb_private::Process > ProcessSP
Definition: lldb-forward.h:387
std::shared_ptr< lldb_private::Module > ModuleSP
Definition: lldb-forward.h:371
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