/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp
Line | Count | Source (jump to first uncovered line) |
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 | | |
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" |
28 | | |
29 | | using namespace lldb; |
30 | | using namespace lldb_private; |
31 | | |
32 | | /// Default Constructor |
33 | | PlatformRemoteAppleTV::PlatformRemoteAppleTV() |
34 | 5 | : PlatformRemoteDarwinDevice () {} |
35 | | |
36 | | // Static Variables |
37 | | static uint32_t g_initialize_count = 0; |
38 | | |
39 | | // Static Functions |
40 | 3.94k | void PlatformRemoteAppleTV::Initialize() { |
41 | 3.94k | PlatformDarwin::Initialize(); |
42 | | |
43 | 3.94k | if (g_initialize_count++ == 0) { |
44 | 3.94k | PluginManager::RegisterPlugin(PlatformRemoteAppleTV::GetPluginNameStatic(), |
45 | 3.94k | PlatformRemoteAppleTV::GetDescriptionStatic(), |
46 | 3.94k | PlatformRemoteAppleTV::CreateInstance); |
47 | 3.94k | } |
48 | 3.94k | } |
49 | | |
50 | 3.94k | void PlatformRemoteAppleTV::Terminate() { |
51 | 3.94k | if (g_initialize_count > 0) { |
52 | 3.94k | if (--g_initialize_count == 0) { |
53 | 3.94k | PluginManager::UnregisterPlugin(PlatformRemoteAppleTV::CreateInstance); |
54 | 3.94k | } |
55 | 3.94k | } |
56 | | |
57 | 3.94k | PlatformDarwin::Terminate(); |
58 | 3.94k | } |
59 | | |
60 | | PlatformSP PlatformRemoteAppleTV::CreateInstance(bool force, |
61 | 208 | const ArchSpec *arch) { |
62 | 208 | Log *log = GetLog(LLDBLog::Platform); |
63 | 208 | if (log) { |
64 | 0 | const char *arch_name; |
65 | 0 | if (arch && arch->GetArchitectureName()) |
66 | 0 | arch_name = arch->GetArchitectureName(); |
67 | 0 | else |
68 | 0 | arch_name = "<null>"; |
69 | |
|
70 | 0 | const char *triple_cstr = |
71 | 0 | arch ? arch->GetTriple().getTriple().c_str() : "<null>"; |
72 | |
|
73 | 0 | LLDB_LOGF(log, "PlatformRemoteAppleTV::%s(force=%s, arch={%s,%s})", |
74 | 0 | __FUNCTION__, force ? "true" : "false", arch_name, triple_cstr); |
75 | 0 | } |
76 | | |
77 | 208 | bool create = force; |
78 | 208 | if (!create && arch203 && arch->IsValid()203 ) { |
79 | 203 | switch (arch->GetMachine()) { |
80 | 12 | case llvm::Triple::arm: |
81 | 86 | case llvm::Triple::aarch64: |
82 | 86 | case llvm::Triple::thumb: { |
83 | 86 | const llvm::Triple &triple = arch->GetTriple(); |
84 | 86 | llvm::Triple::VendorType vendor = triple.getVendor(); |
85 | 86 | switch (vendor) { |
86 | 1 | case llvm::Triple::Apple: |
87 | 1 | create = true; |
88 | 1 | break; |
89 | | |
90 | 0 | #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 | 79 | case llvm::Triple::UnknownVendor: |
95 | 79 | create = !arch->TripleVendorWasSpecified(); |
96 | 79 | break; |
97 | | |
98 | 0 | #endif |
99 | 6 | default: |
100 | 6 | break; |
101 | 86 | } |
102 | 86 | if (create) { |
103 | 24 | switch (triple.getOS()) { |
104 | 0 | case llvm::Triple::TvOS: // This is the right triple value for Apple TV |
105 | | // debugging |
106 | 0 | break; |
107 | | |
108 | 24 | default: |
109 | 24 | create = false; |
110 | 24 | break; |
111 | 24 | } |
112 | 24 | } |
113 | 86 | } break; |
114 | 117 | default: |
115 | 117 | break; |
116 | 203 | } |
117 | 203 | } |
118 | | |
119 | 208 | if (create) { |
120 | 5 | LLDB_LOGF(log, "PlatformRemoteAppleTV::%s() creating platform", |
121 | 5 | __FUNCTION__); |
122 | | |
123 | 5 | return lldb::PlatformSP(new PlatformRemoteAppleTV()); |
124 | 5 | } |
125 | | |
126 | 203 | LLDB_LOGF(log, "PlatformRemoteAppleTV::%s() aborting creation of platform", |
127 | 203 | __FUNCTION__); |
128 | | |
129 | 203 | return lldb::PlatformSP(); |
130 | 208 | } |
131 | | |
132 | 3.94k | llvm::StringRef PlatformRemoteAppleTV::GetDescriptionStatic() { |
133 | 3.94k | return "Remote Apple TV platform plug-in."; |
134 | 3.94k | } |
135 | | |
136 | | std::vector<ArchSpec> PlatformRemoteAppleTV::GetSupportedArchitectures( |
137 | 6 | const ArchSpec &process_host_arch) { |
138 | 6 | ArchSpec system_arch(GetSystemArchitecture()); |
139 | | |
140 | 6 | const ArchSpec::Core system_core = system_arch.GetCore(); |
141 | 6 | switch (system_core) { |
142 | 6 | default: |
143 | 6 | case ArchSpec::eCore_arm_arm64: |
144 | 6 | return {ArchSpec("arm64-apple-tvos"), ArchSpec("armv7s-apple-tvos"), |
145 | 6 | ArchSpec("armv7-apple-tvos"), ArchSpec("thumbv7s-apple-tvos"), |
146 | 6 | ArchSpec("thumbv7-apple-tvos")}; |
147 | | |
148 | 0 | case ArchSpec::eCore_arm_armv7s: |
149 | 0 | return {ArchSpec("armv7s-apple-tvos"), ArchSpec("armv7-apple-tvos"), |
150 | 0 | ArchSpec("thumbv7s-apple-tvos"), ArchSpec("thumbv7-apple-tvos")}; |
151 | | |
152 | 0 | case ArchSpec::eCore_arm_armv7: |
153 | 0 | return {ArchSpec("armv7-apple-tvos"), ArchSpec("thumbv7-apple-tvos")}; |
154 | 6 | } |
155 | 6 | } |
156 | | |
157 | 0 | llvm::StringRef PlatformRemoteAppleTV::GetDeviceSupportDirectoryName() { |
158 | 0 | return "tvOS DeviceSupport"; |
159 | 0 | } |
160 | | |
161 | 0 | llvm::StringRef PlatformRemoteAppleTV::GetPlatformName() { |
162 | 0 | return "AppleTVOS.platform"; |
163 | 0 | } |