[NFC][AArch64] Explicitly define undefined bits for instructions (#122129)
[llvm-project.git] / lldb / source / Plugins / Platform / MacOSX / PlatformRemoteAppleTV.cpp
blob5b729690eda13abbf933e2db70cd07817b124b01
1 //===-- PlatformRemoteAppleTV.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 "PlatformRemoteAppleTV.h"
14 #include "lldb/Breakpoint/BreakpointLocation.h"
15 #include "lldb/Core/Module.h"
16 #include "lldb/Core/ModuleList.h"
17 #include "lldb/Core/ModuleSpec.h"
18 #include "lldb/Core/PluginManager.h"
19 #include "lldb/Host/Host.h"
20 #include "lldb/Target/Process.h"
21 #include "lldb/Target/Target.h"
22 #include "lldb/Utility/ArchSpec.h"
23 #include "lldb/Utility/FileSpec.h"
24 #include "lldb/Utility/LLDBLog.h"
25 #include "lldb/Utility/Log.h"
26 #include "lldb/Utility/Status.h"
27 #include "lldb/Utility/StreamString.h"
29 using namespace lldb;
30 using namespace lldb_private;
32 /// Default Constructor
33 PlatformRemoteAppleTV::PlatformRemoteAppleTV()
34 : PlatformRemoteDarwinDevice () {}
36 // Static Variables
37 static uint32_t g_initialize_count = 0;
39 // Static Functions
40 void PlatformRemoteAppleTV::Initialize() {
41 PlatformDarwin::Initialize();
43 if (g_initialize_count++ == 0) {
44 PluginManager::RegisterPlugin(PlatformRemoteAppleTV::GetPluginNameStatic(),
45 PlatformRemoteAppleTV::GetDescriptionStatic(),
46 PlatformRemoteAppleTV::CreateInstance);
50 void PlatformRemoteAppleTV::Terminate() {
51 if (g_initialize_count > 0) {
52 if (--g_initialize_count == 0) {
53 PluginManager::UnregisterPlugin(PlatformRemoteAppleTV::CreateInstance);
57 PlatformDarwin::Terminate();
60 PlatformSP PlatformRemoteAppleTV::CreateInstance(bool force,
61 const ArchSpec *arch) {
62 Log *log = GetLog(LLDBLog::Platform);
63 if (log) {
64 const char *arch_name;
65 if (arch && arch->GetArchitectureName())
66 arch_name = arch->GetArchitectureName();
67 else
68 arch_name = "<null>";
70 const char *triple_cstr =
71 arch ? arch->GetTriple().getTriple().c_str() : "<null>";
73 LLDB_LOGF(log, "PlatformRemoteAppleTV::%s(force=%s, arch={%s,%s})",
74 __FUNCTION__, force ? "true" : "false", arch_name, triple_cstr);
77 bool create = force;
78 if (!create && arch && arch->IsValid()) {
79 switch (arch->GetMachine()) {
80 case llvm::Triple::arm:
81 case llvm::Triple::aarch64:
82 case llvm::Triple::thumb: {
83 const llvm::Triple &triple = arch->GetTriple();
84 llvm::Triple::VendorType vendor = triple.getVendor();
85 switch (vendor) {
86 case llvm::Triple::Apple:
87 create = true;
88 break;
90 #if defined(__APPLE__)
91 // Only accept "unknown" for the vendor if the host is Apple and
92 // "unknown" wasn't specified (it was just returned because it was NOT
93 // specified)
94 case llvm::Triple::UnknownVendor:
95 create = !arch->TripleVendorWasSpecified();
96 break;
98 #endif
99 default:
100 break;
102 if (create) {
103 switch (triple.getOS()) {
104 case llvm::Triple::TvOS: // This is the right triple value for Apple TV
105 // debugging
106 break;
108 default:
109 create = false;
110 break;
113 } break;
114 default:
115 break;
119 if (create) {
120 LLDB_LOGF(log, "PlatformRemoteAppleTV::%s() creating platform",
121 __FUNCTION__);
123 return lldb::PlatformSP(new PlatformRemoteAppleTV());
126 LLDB_LOGF(log, "PlatformRemoteAppleTV::%s() aborting creation of platform",
127 __FUNCTION__);
129 return lldb::PlatformSP();
132 llvm::StringRef PlatformRemoteAppleTV::GetDescriptionStatic() {
133 return "Remote Apple TV platform plug-in.";
136 std::vector<ArchSpec> PlatformRemoteAppleTV::GetSupportedArchitectures(
137 const ArchSpec &process_host_arch) {
138 ArchSpec system_arch(GetSystemArchitecture());
140 const ArchSpec::Core system_core = system_arch.GetCore();
141 switch (system_core) {
142 default:
143 case ArchSpec::eCore_arm_arm64:
144 return {ArchSpec("arm64-apple-tvos"), ArchSpec("armv7s-apple-tvos"),
145 ArchSpec("armv7-apple-tvos"), ArchSpec("thumbv7s-apple-tvos"),
146 ArchSpec("thumbv7-apple-tvos")};
148 case ArchSpec::eCore_arm_armv7s:
149 return {ArchSpec("armv7s-apple-tvos"), ArchSpec("armv7-apple-tvos"),
150 ArchSpec("thumbv7s-apple-tvos"), ArchSpec("thumbv7-apple-tvos")};
152 case ArchSpec::eCore_arm_armv7:
153 return {ArchSpec("armv7-apple-tvos"), ArchSpec("thumbv7-apple-tvos")};
157 llvm::StringRef PlatformRemoteAppleTV::GetDeviceSupportDirectoryName() {
158 return "tvOS DeviceSupport";
161 llvm::StringRef PlatformRemoteAppleTV::GetPlatformName() {
162 return "AppleTVOS.platform";