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 
12 #include "PlatformRemoteAppleTV.h"
13 
15 #include "lldb/Core/Module.h"
16 #include "lldb/Core/ModuleList.h"
17 #include "lldb/Core/ModuleSpec.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"
28 
29 using namespace lldb;
30 using namespace lldb_private;
31 
32 /// Default Constructor
33 PlatformRemoteAppleTV::PlatformRemoteAppleTV()
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 }
PlatformRemoteAppleTV.h
lldb_private::PlatformRemoteAppleTV::GetPlatformName
llvm::StringRef GetPlatformName() override
Definition: PlatformRemoteAppleTV.cpp:161
lldb_private::ArchSpec
Definition: ArchSpec.h:33
lldb_private::ArchSpec::TripleVendorWasSpecified
bool TripleVendorWasSpecified() const
Definition: ArchSpec.h:358
lldb_private::ArchSpec::GetMachine
llvm::Triple::ArchType GetMachine() const
Returns a machine family for the current architecture.
Definition: ArchSpec.cpp:668
ModuleSpec.h
Host.h
lldb_private::PlatformRemoteAppleTV::GetDeviceSupportDirectoryName
llvm::StringRef GetDeviceSupportDirectoryName() override
Definition: PlatformRemoteAppleTV.cpp:157
lldb_private::ArchSpec::GetCore
Core GetCore() const
Definition: ArchSpec.h:434
LLDB_LOGF
#define LLDB_LOGF(log,...)
Definition: Log.h:343
Module.h
BreakpointLocation.h
lldb_private::ArchSpec::eCore_arm_arm64
@ eCore_arm_arm64
Definition: ArchSpec.h:142
lldb_private::PlatformRemoteAppleTV::GetSupportedArchitectures
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.
Definition: PlatformRemoteAppleTV.cpp:136
lldb_private::PlatformRemoteAppleTV::CreateInstance
static lldb::PlatformSP CreateInstance(bool force, const lldb_private::ArchSpec *arch)
Definition: PlatformRemoteAppleTV.cpp:60
lldb_private::ArchSpec::GetTriple
llvm::Triple & GetTriple()
Architecture triple accessor.
Definition: ArchSpec.h:455
lldb_private::PlatformRemoteAppleTV::GetPluginNameStatic
static llvm::StringRef GetPluginNameStatic()
Definition: PlatformRemoteAppleTV.h:36
Process.h
lldb_private::ArchSpec::Core
Core
Definition: ArchSpec.h:112
lldb_private::PlatformDarwin::Initialize
static void Initialize()
Definition: PlatformDarwin.cpp:83
Target.h
lldb_private::Platform::GetSystemArchitecture
const ArchSpec & GetSystemArchitecture()
Definition: Platform.cpp:885
ModuleList.h
lldb_private::PluginManager::UnregisterPlugin
static bool UnregisterPlugin(ABICreateInstance create_callback)
Definition: PluginManager.cpp:293
lldb_private::PlatformRemoteAppleTV::PlatformRemoteAppleTV
PlatformRemoteAppleTV()
Default Constructor.
Definition: PlatformRemoteAppleTV.cpp:33
Log.h
lldb_private::PlatformDarwin::Terminate
static void Terminate()
Definition: PlatformDarwin.cpp:94
lldb_private::PlatformRemoteAppleTV::Terminate
static void Terminate()
Definition: PlatformRemoteAppleTV.cpp:50
StreamString.h
g_initialize_count
static uint32_t g_initialize_count
Definition: PlatformRemoteAppleTV.cpp:37
lldb_private::ArchSpec::eCore_arm_armv7
@ eCore_arm_armv7
Definition: ArchSpec.h:121
lldb_private::PlatformRemoteDarwinDevice
Definition: PlatformRemoteDarwinDevice.h:36
lldb_private::PlatformRemoteAppleTV::GetDescriptionStatic
static llvm::StringRef GetDescriptionStatic()
Definition: PlatformRemoteAppleTV.cpp:132
lldb_private::ArchSpec::IsValid
bool IsValid() const
Tests if this ArchSpec is valid.
Definition: ArchSpec.h:353
lldb_private::PlatformRemoteAppleTV::Initialize
static void Initialize()
Definition: PlatformRemoteAppleTV.cpp:40
lldb_private::ArchSpec::GetArchitectureName
const char * GetArchitectureName() const
Returns a static string representing the current architecture.
Definition: ArchSpec.cpp:539
uint32_t
lldb_private::ArchSpec::eCore_arm_armv7s
@ eCore_arm_armv7s
Definition: ArchSpec.h:124
ArchSpec.h
PluginManager.h
Status.h
lldb_private::PluginManager::RegisterPlugin
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
Definition: PluginManager.cpp:287
lldb_private::LLDBLog::Platform
@ Platform
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
FileSpec.h
lldb_private::Log
Definition: Log.h:115
lldb_private::GetLog
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition: Log.h:308
lldb
Definition: SBAddress.h:15
LLDBLog.h