[NFC][AArch64] Explicitly define undefined bits for instructions (#122129)
[llvm-project.git] / lldb / source / Plugins / Platform / MacOSX / PlatformRemoteAppleXR.cpp
blobc7e734a5a098d7a0dd84826227a127af16f64314
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 //===----------------------------------------------------------------------===//
9 #include <string>
10 #include <vector>
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"
24 using namespace lldb;
25 using namespace lldb_private;
27 // Static Variables
28 static uint32_t g_xr_initialize_count = 0;
30 // Static Functions
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);
54 if (log) {
55 const char *arch_name;
56 if (arch && arch->GetArchitectureName())
57 arch_name = arch->GetArchitectureName();
58 else
59 arch_name = "<null>";
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);
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;
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;
90 #endif
91 default:
92 break;
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;
100 default:
101 create = false;
102 break;
105 } break;
106 default:
107 break;
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;
116 #endif
118 if (create) {
119 LLDB_LOGF(log, "PlatformRemoteAppleXR::%s() creating platform",
120 __FUNCTION__);
122 return lldb::PlatformSP(new PlatformRemoteAppleXR());
125 LLDB_LOGF(log, "PlatformRemoteAppleXR::%s() aborting creation of platform",
126 __FUNCTION__);
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"));
148 return result;
151 llvm::StringRef PlatformRemoteAppleXR::GetDeviceSupportDirectoryName() {
152 return "XROS DeviceSupport";
155 llvm::StringRef PlatformRemoteAppleXR::GetPlatformName() {
156 return "XROS.platform";