/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | //===-- PlatformRemoteAppleWatch.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 "PlatformRemoteAppleWatch.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 | | // Static Variables |
33 | | static uint32_t g_initialize_count = 0; |
34 | | |
35 | | // Static Functions |
36 | 3.97k | void PlatformRemoteAppleWatch::Initialize() { |
37 | 3.97k | PlatformDarwin::Initialize(); |
38 | | |
39 | 3.97k | if (g_initialize_count++ == 0) { |
40 | 3.97k | PluginManager::RegisterPlugin( |
41 | 3.97k | PlatformRemoteAppleWatch::GetPluginNameStatic(), |
42 | 3.97k | PlatformRemoteAppleWatch::GetDescriptionStatic(), |
43 | 3.97k | PlatformRemoteAppleWatch::CreateInstance); |
44 | 3.97k | } |
45 | 3.97k | } |
46 | | |
47 | 3.96k | void PlatformRemoteAppleWatch::Terminate() { |
48 | 3.96k | if (g_initialize_count > 0) { |
49 | 3.96k | if (--g_initialize_count == 0) { |
50 | 3.96k | PluginManager::UnregisterPlugin(PlatformRemoteAppleWatch::CreateInstance); |
51 | 3.96k | } |
52 | 3.96k | } |
53 | | |
54 | 3.96k | PlatformDarwin::Terminate(); |
55 | 3.96k | } |
56 | | |
57 | | PlatformSP PlatformRemoteAppleWatch::CreateInstance(bool force, |
58 | 210 | const ArchSpec *arch) { |
59 | 210 | Log *log = GetLog(LLDBLog::Platform); |
60 | 210 | if (log) { |
61 | 0 | const char *arch_name; |
62 | 0 | if (arch && arch->GetArchitectureName()) |
63 | 0 | arch_name = arch->GetArchitectureName(); |
64 | 0 | else |
65 | 0 | arch_name = "<null>"; |
66 | |
|
67 | 0 | const char *triple_cstr = |
68 | 0 | arch ? arch->GetTriple().getTriple().c_str() : "<null>"; |
69 | |
|
70 | 0 | LLDB_LOGF(log, "PlatformRemoteAppleWatch::%s(force=%s, arch={%s,%s})", |
71 | 0 | __FUNCTION__, force ? "true" : "false", arch_name, triple_cstr); |
72 | 0 | } |
73 | | |
74 | 210 | bool create = force; |
75 | 210 | if (!create && arch205 && arch->IsValid()205 ) { |
76 | 205 | switch (arch->GetMachine()) { |
77 | 12 | case llvm::Triple::arm: |
78 | 88 | case llvm::Triple::aarch64: |
79 | 89 | case llvm::Triple::aarch64_32: |
80 | 89 | case llvm::Triple::thumb: { |
81 | 89 | const llvm::Triple &triple = arch->GetTriple(); |
82 | 89 | llvm::Triple::VendorType vendor = triple.getVendor(); |
83 | 89 | switch (vendor) { |
84 | 2 | case llvm::Triple::Apple: |
85 | 2 | create = true; |
86 | 2 | break; |
87 | | |
88 | 0 | #if defined(__APPLE__) |
89 | | // Only accept "unknown" for the vendor if the host is Apple and |
90 | | // "unknown" wasn't specified (it was just returned because it was NOT |
91 | | // specified) |
92 | 81 | case llvm::Triple::UnknownVendor: |
93 | 81 | create = !arch->TripleVendorWasSpecified(); |
94 | 81 | break; |
95 | | |
96 | 0 | #endif |
97 | 6 | default: |
98 | 6 | break; |
99 | 89 | } |
100 | 89 | if (create) { |
101 | 25 | switch (triple.getOS()) { |
102 | 1 | case llvm::Triple::WatchOS: // This is the right triple value for Apple |
103 | | // Watch debugging |
104 | 1 | break; |
105 | | |
106 | 24 | default: |
107 | 24 | create = false; |
108 | 24 | break; |
109 | 25 | } |
110 | 25 | } |
111 | 89 | } break; |
112 | 116 | default: |
113 | 116 | break; |
114 | 205 | } |
115 | 205 | } |
116 | | |
117 | | #if defined(__APPLE__) && \ |
118 | | (defined(__arm__) || defined(__arm64__) || defined(__aarch64__)) |
119 | | // If lldb is running on a watch, this isn't a RemoteWatch environment; it's |
120 | | // a local system environment. |
121 | | if (force == false) { |
122 | | create = false; |
123 | | } |
124 | | #endif |
125 | | |
126 | 210 | if (create) { |
127 | 6 | LLDB_LOGF(log, "PlatformRemoteAppleWatch::%s() creating platform", |
128 | 6 | __FUNCTION__); |
129 | | |
130 | 6 | return lldb::PlatformSP(new PlatformRemoteAppleWatch()); |
131 | 6 | } |
132 | | |
133 | 204 | LLDB_LOGF(log, "PlatformRemoteAppleWatch::%s() aborting creation of platform", |
134 | 204 | __FUNCTION__); |
135 | | |
136 | 204 | return lldb::PlatformSP(); |
137 | 210 | } |
138 | | |
139 | 3.97k | llvm::StringRef PlatformRemoteAppleWatch::GetDescriptionStatic() { |
140 | 3.97k | return "Remote Apple Watch platform plug-in."; |
141 | 3.97k | } |
142 | | |
143 | | /// Default Constructor |
144 | | PlatformRemoteAppleWatch::PlatformRemoteAppleWatch() |
145 | 6 | : PlatformRemoteDarwinDevice() {} |
146 | | |
147 | | std::vector<ArchSpec> |
148 | 8 | PlatformRemoteAppleWatch::GetSupportedArchitectures(const ArchSpec &host_info) { |
149 | 8 | ArchSpec system_arch(GetSystemArchitecture()); |
150 | | |
151 | 8 | const ArchSpec::Core system_core = system_arch.GetCore(); |
152 | 8 | switch (system_core) { |
153 | 8 | default: |
154 | 8 | case ArchSpec::eCore_arm_arm64: |
155 | 8 | return { |
156 | 8 | ArchSpec("arm64-apple-watchos"), ArchSpec("armv7k-apple-watchos"), |
157 | 8 | ArchSpec("armv7s-apple-watchos"), ArchSpec("armv7-apple-watchos"), |
158 | 8 | ArchSpec("thumbv7k-apple-watchos"), ArchSpec("thumbv7-apple-watchos"), |
159 | 8 | ArchSpec("thumbv7s-apple-watchos"), ArchSpec("arm64_32-apple-watchos")}; |
160 | | |
161 | 0 | case ArchSpec::eCore_arm_armv7k: |
162 | 0 | return { |
163 | 0 | ArchSpec("armv7k-apple-watchos"), ArchSpec("armv7s-apple-watchos"), |
164 | 0 | ArchSpec("armv7-apple-watchos"), ArchSpec("thumbv7k-apple-watchos"), |
165 | 0 | ArchSpec("thumbv7-apple-watchos"), ArchSpec("thumbv7s-apple-watchos"), |
166 | 0 | ArchSpec("arm64_32-apple-watchos")}; |
167 | | |
168 | 0 | case ArchSpec::eCore_arm_armv7s: |
169 | 0 | return { |
170 | 0 | ArchSpec("armv7s-apple-watchos"), ArchSpec("armv7k-apple-watchos"), |
171 | 0 | ArchSpec("armv7-apple-watchos"), ArchSpec("thumbv7k-apple-watchos"), |
172 | 0 | ArchSpec("thumbv7-apple-watchos"), ArchSpec("thumbv7s-apple-watchos"), |
173 | 0 | ArchSpec("arm64_32-apple-watchos")}; |
174 | | |
175 | 0 | case ArchSpec::eCore_arm_armv7: |
176 | 0 | return {ArchSpec("armv7-apple-watchos"), ArchSpec("armv7k-apple-watchos"), |
177 | 0 | ArchSpec("thumbv7k-apple-watchos"), |
178 | 0 | ArchSpec("thumbv7-apple-watchos"), |
179 | 0 | ArchSpec("arm64_32-apple-watchos")}; |
180 | 8 | } |
181 | 8 | } |
182 | | |
183 | 4 | llvm::StringRef PlatformRemoteAppleWatch::GetDeviceSupportDirectoryName() { |
184 | 4 | return "watchOS DeviceSupport"; |
185 | 4 | } |
186 | | |
187 | 4 | llvm::StringRef PlatformRemoteAppleWatch::GetPlatformName() { |
188 | 4 | return "WatchOS.platform"; |
189 | 4 | } |