1 //===-- PlatformRemoteAppleXR.cpp -----------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
12 #include "PlatformRemoteAppleXR.h"
13 #include "lldb/Breakpoint/BreakpointLocation.h"
14 #include "lldb/Core/Module.h"
15 #include "lldb/Core/ModuleList.h"
16 #include "lldb/Core/PluginManager.h"
17 #include "lldb/Target/Process.h"
18 #include "lldb/Target/Target.h"
19 #include "lldb/Utility/ArchSpec.h"
20 #include "lldb/Utility/FileSpec.h"
21 #include "lldb/Utility/LLDBLog.h"
22 #include "lldb/Utility/Log.h"
25 using namespace lldb_private
;
28 static uint32_t g_xr_initialize_count
= 0;
31 void PlatformRemoteAppleXR::Initialize() {
32 PlatformDarwin::Initialize();
34 if (g_xr_initialize_count
++ == 0) {
35 PluginManager::RegisterPlugin(PlatformRemoteAppleXR::GetPluginNameStatic(),
36 PlatformRemoteAppleXR::GetDescriptionStatic(),
37 PlatformRemoteAppleXR::CreateInstance
);
41 void PlatformRemoteAppleXR::Terminate() {
42 if (g_xr_initialize_count
> 0) {
43 if (--g_xr_initialize_count
== 0) {
44 PluginManager::UnregisterPlugin(PlatformRemoteAppleXR::CreateInstance
);
48 PlatformDarwin::Terminate();
51 PlatformSP
PlatformRemoteAppleXR::CreateInstance(bool force
,
52 const ArchSpec
*arch
) {
53 Log
*log
= GetLog(LLDBLog::Platform
);
55 const char *arch_name
;
56 if (arch
&& arch
->GetArchitectureName())
57 arch_name
= arch
->GetArchitectureName();
61 const char *triple_cstr
=
62 arch
? arch
->GetTriple().getTriple().c_str() : "<null>";
64 LLDB_LOGF(log
, "PlatformRemoteAppleXR::%s(force=%s, arch={%s,%s})",
65 __FUNCTION__
, force
? "true" : "false", arch_name
, triple_cstr
);
69 if (!create
&& arch
&& arch
->IsValid()) {
70 switch (arch
->GetMachine()) {
71 case llvm::Triple::arm
:
72 case llvm::Triple::aarch64
:
73 case llvm::Triple::aarch64_32
:
74 case llvm::Triple::thumb
: {
75 const llvm::Triple
&triple
= arch
->GetTriple();
76 llvm::Triple::VendorType vendor
= triple
.getVendor();
78 case llvm::Triple::Apple
:
82 #if defined(__APPLE__)
83 // Only accept "unknown" for the vendor if the host is Apple and
84 // "unknown" wasn't specified (it was just returned because it was NOT
86 case llvm::Triple::UnknownVendor
:
87 create
= !arch
->TripleVendorWasSpecified();
95 switch (triple
.getOS()) {
96 case llvm::Triple::XROS
: // This is the right triple value for Apple
111 #if defined(TARGET_OS_XR) && TARGET_OS_XR == 1
112 // If lldb is running on a XR device, this isn't a RemoteXR.
113 if (force
== false) {
119 LLDB_LOGF(log
, "PlatformRemoteAppleXR::%s() creating platform",
122 return lldb::PlatformSP(new PlatformRemoteAppleXR());
125 LLDB_LOGF(log
, "PlatformRemoteAppleXR::%s() aborting creation of platform",
128 return lldb::PlatformSP();
131 llvm::StringRef
PlatformRemoteAppleXR::GetPluginNameStatic() {
132 return "remote-xros";
135 llvm::StringRef
PlatformRemoteAppleXR::GetDescriptionStatic() {
136 return "Remote Apple XR platform plug-in.";
139 /// Default Constructor
140 PlatformRemoteAppleXR::PlatformRemoteAppleXR() : PlatformRemoteDarwinDevice() {}
142 std::vector
<lldb_private::ArchSpec
>
143 PlatformRemoteAppleXR::GetSupportedArchitectures(
144 const ArchSpec
&process_host_arch
) {
145 std::vector
<ArchSpec
> result
;
146 result
.push_back(ArchSpec("arm64-apple-xros"));
147 result
.push_back(ArchSpec("arm64-apple-xros"));
151 llvm::StringRef
PlatformRemoteAppleXR::GetDeviceSupportDirectoryName() {
152 return "XROS DeviceSupport";
155 llvm::StringRef
PlatformRemoteAppleXR::GetPlatformName() {
156 return "XROS.platform";