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 (std::count(supported_arch.begin(), supported_arch.end(),
339 arch->GetMachine())) {
340 const llvm::Triple &triple = arch->GetTriple();
341 switch (triple.getVendor()) {
342 case llvm::Triple::Apple:
343 create = true;
344 break;
345
346#if defined(__APPLE__)
347 // Only accept "unknown" for the vendor if the host is Apple and if
348 // "unknown" wasn't specified (it was just returned because it was NOT
349 // specified)
350 case llvm::Triple::UnknownVendor:
351 create = !arch->TripleVendorWasSpecified();
352 break;
353#endif
354 default:
355 break;
356 }
357
358 if (create) {
359 if (llvm::is_contained(supported_os, triple.getOS()))
360 create = true;
361#if defined(__APPLE__)
362 // Only accept "unknown" for the OS if the host is Apple and it
363 // "unknown" wasn't specified (it was just returned because it was NOT
364 // specified)
365 else if (triple.getOS() == llvm::Triple::UnknownOS)
366 create = !arch->TripleOSWasSpecified();
367#endif
368 else
369 create = false;
370 }
371 }
372 }
373 if (create) {
374 LLDB_LOGF(log, "%s::%s() creating platform", class_name, __FUNCTION__);
375
377 class_name, description, plugin_name, preferred_os, supported_triples,
378 sdk_name_primary, sdk_name_secondary, sdk_type, kind));
379 }
380
381 LLDB_LOGF(log, "%s::%s() aborting creation of platform", class_name,
382 __FUNCTION__);
383
384 return PlatformSP();
385}
386
388 const ModuleSpec &module_spec, lldb::ModuleSP &exe_module_sp,
389 const FileSpecList *module_search_paths_ptr) {
391 // Nothing special to do here, just use the actual file and architecture
392
393 ModuleSpec resolved_module_spec(module_spec);
394
395 // If we have "ls" as the exe_file, resolve the executable loation based on
396 // the current path variables
397 // TODO: resolve bare executables in the Platform SDK
398 // if (!resolved_exe_file.Exists())
399 // resolved_exe_file.ResolveExecutableLocation ();
400
401 // Resolve any executable within a bundle on MacOSX
402 // TODO: verify that this handles shallow bundles, if not then implement one
403 // ourselves
404 Host::ResolveExecutableInBundle(resolved_module_spec.GetFileSpec());
405
406 if (FileSystem::Instance().Exists(resolved_module_spec.GetFileSpec())) {
407 if (resolved_module_spec.GetArchitecture().IsValid()) {
408 error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
409 NULL, NULL, NULL);
410
411 if (exe_module_sp && exe_module_sp->GetObjectFile())
412 return error;
413 exe_module_sp.reset();
414 }
415 // No valid architecture was specified or the exact ARM slice wasn't found
416 // so ask the platform for the architectures that we should be using (in
417 // the correct order) and see if we can find a match that way
418 StreamString arch_names;
419 llvm::ListSeparator LS;
420 ArchSpec platform_arch;
421 for (const ArchSpec &arch : GetSupportedArchitectures({})) {
422 resolved_module_spec.GetArchitecture() = arch;
423
424 // Only match x86 with x86 and x86_64 with x86_64...
425 if (!module_spec.GetArchitecture().IsValid() ||
426 module_spec.GetArchitecture().GetCore() ==
427 resolved_module_spec.GetArchitecture().GetCore()) {
428 error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
429 NULL, NULL, NULL);
430 // Did we find an executable using one of the
431 if (error.Success()) {
432 if (exe_module_sp && exe_module_sp->GetObjectFile())
433 break;
434 else
435 error.SetErrorToGenericError();
436 }
437
438 arch_names << LS << platform_arch.GetArchitectureName();
439 }
440 }
441
442 if (error.Fail() || !exe_module_sp) {
443 if (FileSystem::Instance().Readable(resolved_module_spec.GetFileSpec())) {
444 error.SetErrorStringWithFormatv(
445 "'{0}' doesn't contain any '{1}' platform architectures: {2}",
446 resolved_module_spec.GetFileSpec(), GetPluginName(),
447 arch_names.GetString());
448 } else {
449 error.SetErrorStringWithFormat(
450 "'%s' is not readable",
451 resolved_module_spec.GetFileSpec().GetPath().c_str());
452 }
453 }
454 } else {
455 error.SetErrorStringWithFormat("'%s' does not exist",
456 module_spec.GetFileSpec().GetPath().c_str());
457 }
458
459 return error;
460}
461
463 const UUID *uuid_ptr,
464 FileSpec &local_file) {
466 char platform_file_path[PATH_MAX];
467 if (platform_file.GetPath(platform_file_path, sizeof(platform_file_path))) {
468 char resolved_path[PATH_MAX];
469
470 llvm::StringRef sdk = GetSDKFilepath();
471 if (!sdk.empty()) {
472 ::snprintf(resolved_path, sizeof(resolved_path), "%s/%s",
473 sdk.str().c_str(), platform_file_path);
474
475 // First try in the SDK and see if the file is in there
476 local_file.SetFile(resolved_path, FileSpec::Style::native);
477 FileSystem::Instance().Resolve(local_file);
478 if (FileSystem::Instance().Exists(local_file))
479 return error;
480
481 // Else fall back to the actual path itself
482 local_file.SetFile(platform_file_path, FileSpec::Style::native);
483 FileSystem::Instance().Resolve(local_file);
484 if (FileSystem::Instance().Exists(local_file))
485 return error;
486 }
487 error.SetErrorStringWithFormatv(
488 "unable to locate a platform file for '{0}' in platform '{1}'",
489 platform_file_path, GetPluginName());
490 } else {
491 error.SetErrorString("invalid platform file argument");
492 }
493 return error;
494}
495
497 const ModuleSpec &module_spec, Process *process, ModuleSP &module_sp,
498 const FileSpecList *module_search_paths_ptr,
499 llvm::SmallVectorImpl<lldb::ModuleSP> *old_modules, bool *did_create_ptr) {
500 // For iOS/tvOS/watchOS, the SDK files are all cached locally on the
501 // host system. So first we ask for the file in the cached SDK, then
502 // we attempt to get a shared module for the right architecture with
503 // the right UUID.
505 ModuleSpec platform_module_spec(module_spec);
506 const FileSpec &platform_file = module_spec.GetFileSpec();
507 error = GetSymbolFile(platform_file, module_spec.GetUUIDPtr(),
508 platform_module_spec.GetFileSpec());
509 if (error.Success()) {
510 error = ResolveExecutable(platform_module_spec, module_sp,
511 module_search_paths_ptr);
512 } else {
513 const bool always_create = false;
514 error = ModuleList::GetSharedModule(module_spec, module_sp,
515 module_search_paths_ptr, old_modules,
516 did_create_ptr, always_create);
517 }
518 if (module_sp)
519 module_sp->SetPlatformFileSpec(platform_file);
520
521 return error;
522}
523
525 const ProcessInstanceInfoMatch &match_info,
526 ProcessInstanceInfoList &process_infos) {
527 ProcessInstanceInfoList all_osx_process_infos;
528 // First we get all OSX processes
529 const uint32_t n = Host::FindProcesses(match_info, all_osx_process_infos);
530
531 // Now we filter them down to only the matching triples.
532 for (uint32_t i = 0; i < n; ++i) {
533 const ProcessInstanceInfo &proc_info = all_osx_process_infos[i];
534 const llvm::Triple &triple = proc_info.GetArchitecture().GetTriple();
535 if (triple.getOS() == m_os_type &&
536 triple.getEnvironment() == llvm::Triple::Simulator) {
537 process_infos.push_back(proc_info);
538 }
539 }
540 return process_infos.size();
541}
542
543/// Whether to skip creating a simulator platform.
544static bool shouldSkipSimulatorPlatform(bool force, const ArchSpec *arch) {
545 // If the arch is known not to specify a simulator environment, skip creating
546 // the simulator platform (we can create it later if there's a matching arch).
547 // This avoids very slow xcrun queries for non-simulator archs (the slowness
548 // is due to xcrun not caching negative queries.
549 return !force && arch && arch->IsValid() &&
551}
552
553static const char *g_ios_plugin_name = "ios-simulator";
554static const char *g_ios_description = "iPhone simulator platform plug-in.";
555
556/// IPhone Simulator Plugin.
558 static void Initialize() {
561 }
562
563 static void Terminate() {
565 }
566
567 static PlatformSP CreateInstance(bool force, const ArchSpec *arch) {
568 if (shouldSkipSimulatorPlatform(force, arch))
569 return nullptr;
570
572 "PlatformiOSSimulator", g_ios_description,
574 {llvm::Triple::aarch64, llvm::Triple::x86_64, llvm::Triple::x86},
575 llvm::Triple::IOS,
576 {// Deprecated, but still support Darwin for historical reasons.
577 llvm::Triple::Darwin, llvm::Triple::MacOSX,
578 // IOS is not used for simulator triples, but accept it just in
579 // case.
580 llvm::Triple::IOS},
581 {
582#ifdef __APPLE__
583#if __arm64__
584 "arm64e-apple-ios-simulator", "arm64-apple-ios-simulator",
585 "x86_64-apple-ios-simulator", "x86_64h-apple-ios-simulator",
586#else
587 "x86_64h-apple-ios-simulator", "x86_64-apple-ios-simulator",
588 "i386-apple-ios-simulator",
589#endif
590#endif
591 },
592 "iPhoneSimulator.Internal.sdk", "iPhoneSimulator.sdk",
593 XcodeSDK::Type::iPhoneSimulator,
595 }
596};
597
598static const char *g_tvos_plugin_name = "tvos-simulator";
599static const char *g_tvos_description = "tvOS simulator platform plug-in.";
600
601/// Apple TV Simulator Plugin.
603 static void Initialize() {
606 }
607
608 static void Terminate() {
610 }
611
612 static PlatformSP CreateInstance(bool force, const ArchSpec *arch) {
613 if (shouldSkipSimulatorPlatform(force, arch))
614 return nullptr;
616 "PlatformAppleTVSimulator", g_tvos_description,
618 {llvm::Triple::aarch64, llvm::Triple::x86_64}, llvm::Triple::TvOS,
619 {llvm::Triple::TvOS},
620 {
621#ifdef __APPLE__
622#if __arm64__
623 "arm64e-apple-tvos-simulator", "arm64-apple-tvos-simulator",
624 "x86_64h-apple-tvos-simulator", "x86_64-apple-tvos-simulator",
625#else
626 "x86_64h-apple-tvos-simulator", "x86_64-apple-tvos-simulator",
627#endif
628#endif
629 },
630 "AppleTVSimulator.Internal.sdk", "AppleTVSimulator.sdk",
631 XcodeSDK::Type::AppleTVSimulator,
633 arch);
634 }
635};
636
637
638static const char *g_watchos_plugin_name = "watchos-simulator";
639static const char *g_watchos_description =
640 "Apple Watch simulator platform plug-in.";
641
642/// Apple Watch Simulator Plugin.
644 static void Initialize() {
647 }
648
649 static void Terminate() {
652 }
653
654 static PlatformSP CreateInstance(bool force, const ArchSpec *arch) {
655 if (shouldSkipSimulatorPlatform(force, arch))
656 return nullptr;
658 "PlatformAppleWatchSimulator", g_watchos_description,
660 {llvm::Triple::aarch64, llvm::Triple::x86_64, llvm::Triple::x86},
661 llvm::Triple::WatchOS, {llvm::Triple::WatchOS},
662 {
663#ifdef __APPLE__
664#if __arm64__
665 "arm64e-apple-watchos-simulator", "arm64-apple-watchos-simulator",
666#else
667 "x86_64-apple-watchos-simulator", "x86_64h-apple-watchos-simulator",
668 "i386-apple-watchos-simulator",
669#endif
670#endif
671 },
672 "WatchSimulator.Internal.sdk", "WatchSimulator.sdk",
673 XcodeSDK::Type::WatchSimulator,
675 arch);
676 }
677};
678
679
680static unsigned g_initialize_count = 0;
681
682// Static Functions
684 if (g_initialize_count++ == 0) {
689 }
690}
691
693 if (g_initialize_count > 0)
694 if (--g_initialize_count == 0) {
699 }
700}
701
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOGF(log,...)
Definition: Log.h:349
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_tvos_plugin_name
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:79
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:1539
A file collection class.
Definition: FileSpecList.h:24
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:777
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:336
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:181
void SetErrorString(llvm::StringRef err_str)
Set the current error string to err_str.
Definition: Status.cpp:241
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:107
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:86
A class that represents a running process on the host machine.
Definition: SBAttachInfo.h:14
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition: Log.h:314
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:367
std::shared_ptr< lldb_private::Process > ProcessSP
Definition: lldb-forward.h:368
std::shared_ptr< lldb_private::Module > ModuleSP
Definition: lldb-forward.h:354
Apple TV Simulator Plugin.
static PlatformSP CreateInstance(bool force, const ArchSpec *arch)
Apple Watch Simulator Plugin.
static PlatformSP CreateInstance(bool force, const ArchSpec *arch)
IPhone Simulator Plugin.
static PlatformSP CreateInstance(bool force, const ArchSpec *arch)
#define PATH_MAX