LLDB mainline
PlatformRemoteAppleXR.cpp
Go to the documentation of this file.
1//===-- PlatformRemoteAppleXR.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
9#include <string>
10#include <vector>
11
14#include "lldb/Core/Module.h"
17#include "lldb/Target/Process.h"
18#include "lldb/Target/Target.h"
22#include "lldb/Utility/Log.h"
23
24using namespace lldb;
25using namespace lldb_private;
26
27// Static Variables
28static uint32_t g_xr_initialize_count = 0;
29
30// Static Functions
33
34 if (g_xr_initialize_count++ == 0) {
38 }
39}
40
42 if (g_xr_initialize_count > 0) {
43 if (--g_xr_initialize_count == 0) {
45 }
46 }
47
49}
50
52 const ArchSpec *arch) {
54 if (log) {
55 const char *arch_name;
56 if (arch && arch->GetArchitectureName())
57 arch_name = arch->GetArchitectureName();
58 else
59 arch_name = "<null>";
60
61 const char *triple_cstr =
62 arch ? arch->GetTriple().getTriple().c_str() : "<null>";
63
64 LLDB_LOGF(log, "PlatformRemoteAppleXR::%s(force=%s, arch={%s,%s})",
65 __FUNCTION__, force ? "true" : "false", arch_name, triple_cstr);
66 }
67
68 bool create = force;
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();
77 switch (vendor) {
78 case llvm::Triple::Apple:
79 create = true;
80 break;
81
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
85 // specified)
86 case llvm::Triple::UnknownVendor:
87 create = !arch->TripleVendorWasSpecified();
88 break;
89
90#endif
91 default:
92 break;
93 }
94 if (create) {
95 switch (triple.getOS()) {
96 case llvm::Triple::XROS: // This is the right triple value for Apple
97 // XR debugging
98 break;
99
100 default:
101 create = false;
102 break;
103 }
104 }
105 } break;
106 default:
107 break;
108 }
109 }
110
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) {
114 create = false;
115 }
116#endif
117
118 if (create) {
119 LLDB_LOGF(log, "PlatformRemoteAppleXR::%s() creating platform",
120 __FUNCTION__);
121
123 }
124
125 LLDB_LOGF(log, "PlatformRemoteAppleXR::%s() aborting creation of platform",
126 __FUNCTION__);
127
128 return lldb::PlatformSP();
129}
130
132 return "remote-xros";
133}
134
136 return "Remote Apple XR platform plug-in.";
137}
138
139/// Default Constructor
141
142std::vector<lldb_private::ArchSpec>
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"));
148 return result;
149}
150
152 return "XROS DeviceSupport";
153}
154
156 return "XROS.platform";
157}
#define LLDB_LOGF(log,...)
Definition: Log.h:349
static uint32_t g_xr_initialize_count
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
llvm::Triple::ArchType GetMachine() const
Returns a machine family for the current architecture.
Definition: ArchSpec.cpp:683
bool TripleVendorWasSpecified() const
Definition: ArchSpec.h:353
const char * GetArchitectureName() const
Returns a static string representing the current architecture.
Definition: ArchSpec.cpp:552
std::vector< lldb_private::ArchSpec > GetSupportedArchitectures(const lldb_private::ArchSpec &process_host_arch) override
Get the platform's supported architectures in the order in which they should be searched.
llvm::StringRef GetPlatformName() override
llvm::StringRef GetDeviceSupportDirectoryName() override
static lldb::PlatformSP CreateInstance(bool force, const lldb_private::ArchSpec *arch)
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
static bool UnregisterPlugin(ABICreateInstance create_callback)
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
Definition: SBAddress.h:15
std::shared_ptr< lldb_private::Platform > PlatformSP
Definition: lldb-forward.h:380