1 //===-- PlatformRemoteAppleTV.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 "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"
30 using namespace lldb_private
;
32 /// Default Constructor
33 PlatformRemoteAppleTV::PlatformRemoteAppleTV()
34 : PlatformRemoteDarwinDevice () {}
37 static uint32_t g_initialize_count
= 0;
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
);
64 const char *arch_name
;
65 if (arch
&& arch
->GetArchitectureName())
66 arch_name
= arch
->GetArchitectureName();
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
);
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();
86 case llvm::Triple::Apple
:
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
94 case llvm::Triple::UnknownVendor
:
95 create
= !arch
->TripleVendorWasSpecified();
103 switch (triple
.getOS()) {
104 case llvm::Triple::TvOS
: // This is the right triple value for Apple TV
120 LLDB_LOGF(log
, "PlatformRemoteAppleTV::%s() creating platform",
123 return lldb::PlatformSP(new PlatformRemoteAppleTV());
126 LLDB_LOGF(log
, "PlatformRemoteAppleTV::%s() aborting creation of platform",
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
) {
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";