LLDB mainline
PlatformRemoteAppleTV.cpp
Go to the documentation of this file.
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//===----------------------------------------------------------------------===//
8
9#include <string>
10#include <vector>
11
13
15#include "lldb/Core/Module.h"
19#include "lldb/Host/Host.h"
20#include "lldb/Target/Process.h"
21#include "lldb/Target/Target.h"
25#include "lldb/Utility/Log.h"
26#include "lldb/Utility/Status.h"
28
29using namespace lldb;
30using namespace lldb_private;
31
32/// Default Constructor
35
36// Static Variables
38
39// Static Functions
42
43 if (g_initialize_count++ == 0) {
47 }
48}
49
51 if (g_initialize_count > 0) {
52 if (--g_initialize_count == 0) {
54 }
55 }
56
58}
59
61 const ArchSpec *arch) {
63 if (log) {
64 const char *arch_name;
65 if (arch && arch->GetArchitectureName())
66 arch_name = arch->GetArchitectureName();
67 else
68 arch_name = "<null>";
69
70 const char *triple_cstr =
71 arch ? arch->GetTriple().getTriple().c_str() : "<null>";
72
73 LLDB_LOGF(log, "PlatformRemoteAppleTV::%s(force=%s, arch={%s,%s})",
74 __FUNCTION__, force ? "true" : "false", arch_name, triple_cstr);
75 }
76
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;
89
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;
97
98#endif
99 default:
100 break;
101 }
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;
107
108 default:
109 create = false;
110 break;
111 }
112 }
113 } break;
114 default:
115 break;
116 }
117 }
118
119 if (create) {
120 LLDB_LOGF(log, "PlatformRemoteAppleTV::%s() creating platform",
121 __FUNCTION__);
122
123 return lldb::PlatformSP(new PlatformRemoteAppleTV());
124 }
125
126 LLDB_LOGF(log, "PlatformRemoteAppleTV::%s() aborting creation of platform",
127 __FUNCTION__);
128
129 return lldb::PlatformSP();
130}
131
133 return "Remote Apple TV platform plug-in.";
134}
135
137 const ArchSpec &process_host_arch) {
138 ArchSpec system_arch(GetSystemArchitecture());
139
140 const ArchSpec::Core system_core = system_arch.GetCore();
141 switch (system_core) {
142 default:
144 return {ArchSpec("arm64-apple-tvos"), ArchSpec("armv7s-apple-tvos"),
145 ArchSpec("armv7-apple-tvos"), ArchSpec("thumbv7s-apple-tvos"),
146 ArchSpec("thumbv7-apple-tvos")};
147
149 return {ArchSpec("armv7s-apple-tvos"), ArchSpec("armv7-apple-tvos"),
150 ArchSpec("thumbv7s-apple-tvos"), ArchSpec("thumbv7-apple-tvos")};
151
153 return {ArchSpec("armv7-apple-tvos"), ArchSpec("thumbv7-apple-tvos")};
154 }
155}
156
158 return "tvOS DeviceSupport";
159}
160
162 return "AppleTVOS.platform";
163}
#define LLDB_LOGF(log,...)
Definition: Log.h:344
static uint32_t g_initialize_count
An architecture specification class.
Definition: ArchSpec.h:32
bool IsValid() const
Tests if this ArchSpec is valid.
Definition: ArchSpec.h:361
llvm::Triple & GetTriple()
Architecture triple accessor.
Definition: ArchSpec.h:463
llvm::Triple::ArchType GetMachine() const
Returns a machine family for the current architecture.
Definition: ArchSpec.cpp:678
bool TripleVendorWasSpecified() const
Definition: ArchSpec.h:366
Core GetCore() const
Definition: ArchSpec.h:442
const char * GetArchitectureName() const
Returns a static string representing the current architecture.
Definition: ArchSpec.cpp:547
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.
static llvm::StringRef GetPluginNameStatic()
static lldb::PlatformSP CreateInstance(bool force, const lldb_private::ArchSpec *arch)
llvm::StringRef GetPlatformName() override
llvm::StringRef GetDeviceSupportDirectoryName() override
const ArchSpec & GetSystemArchitecture()
Definition: Platform.cpp:887
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.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition: Log.h:309
Definition: SBAddress.h:15