/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleBridge.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | //===-- PlatformRemoteAppleBridge.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 "PlatformRemoteAppleBridge.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/StreamString.h" |
27 | | |
28 | | using namespace lldb; |
29 | | using namespace lldb_private; |
30 | | |
31 | | /// Default Constructor |
32 | | PlatformRemoteAppleBridge::PlatformRemoteAppleBridge() |
33 | 4 | : PlatformRemoteDarwinDevice () {} |
34 | | |
35 | | // Static Variables |
36 | | static uint32_t g_initialize_count = 0; |
37 | | |
38 | | // Static Functions |
39 | 3.94k | void PlatformRemoteAppleBridge::Initialize() { |
40 | 3.94k | PlatformDarwin::Initialize(); |
41 | | |
42 | 3.94k | if (g_initialize_count++ == 0) { |
43 | 3.94k | PluginManager::RegisterPlugin(PlatformRemoteAppleBridge::GetPluginNameStatic(), |
44 | 3.94k | PlatformRemoteAppleBridge::GetDescriptionStatic(), |
45 | 3.94k | PlatformRemoteAppleBridge::CreateInstance); |
46 | 3.94k | } |
47 | 3.94k | } |
48 | | |
49 | 3.93k | void PlatformRemoteAppleBridge::Terminate() { |
50 | 3.93k | if (g_initialize_count > 0) { |
51 | 3.93k | if (--g_initialize_count == 0) { |
52 | 3.93k | PluginManager::UnregisterPlugin(PlatformRemoteAppleBridge::CreateInstance); |
53 | 3.93k | } |
54 | 3.93k | } |
55 | | |
56 | 3.93k | PlatformDarwin::Terminate(); |
57 | 3.93k | } |
58 | | |
59 | | PlatformSP PlatformRemoteAppleBridge::CreateInstance(bool force, |
60 | 206 | const ArchSpec *arch) { |
61 | 206 | Log *log = GetLog(LLDBLog::Platform); |
62 | 206 | if (log) { |
63 | 0 | const char *arch_name; |
64 | 0 | if (arch && arch->GetArchitectureName()) |
65 | 0 | arch_name = arch->GetArchitectureName(); |
66 | 0 | else |
67 | 0 | arch_name = "<null>"; |
68 | |
|
69 | 0 | const char *triple_cstr = |
70 | 0 | arch ? arch->GetTriple().getTriple().c_str() : "<null>"; |
71 | |
|
72 | 0 | LLDB_LOGF(log, "PlatformRemoteAppleBridge::%s(force=%s, arch={%s,%s})", |
73 | 0 | __FUNCTION__, force ? "true" : "false", arch_name, triple_cstr); |
74 | 0 | } |
75 | | |
76 | 206 | bool create = force; |
77 | 206 | if (!create && arch202 && arch->IsValid()202 ) { |
78 | 202 | switch (arch->GetMachine()) { |
79 | 74 | case llvm::Triple::aarch64: { |
80 | 74 | const llvm::Triple &triple = arch->GetTriple(); |
81 | 74 | llvm::Triple::VendorType vendor = triple.getVendor(); |
82 | 74 | switch (vendor) { |
83 | 1 | case llvm::Triple::Apple: |
84 | 1 | create = true; |
85 | 1 | break; |
86 | | |
87 | 0 | #if defined(__APPLE__) |
88 | | // Only accept "unknown" for the vendor if the host is Apple and |
89 | | // it "unknown" wasn't specified (it was just returned because it |
90 | | // was NOT specified) |
91 | 73 | case llvm::Triple::UnknownVendor: |
92 | 73 | create = !arch->TripleVendorWasSpecified(); |
93 | 73 | break; |
94 | | |
95 | 0 | #endif |
96 | 0 | default: |
97 | 0 | break; |
98 | 74 | } |
99 | 74 | if (create) { |
100 | | // Suppress warning "switch statement contains 'default' but no 'case' labels". |
101 | | #ifdef _MSC_VER |
102 | | #pragma warning(push) |
103 | | #pragma warning(disable : 4065) |
104 | | #endif |
105 | 24 | switch (triple.getOS()) { |
106 | | // NEED_BRIDGEOS_TRIPLE case llvm::Triple::BridgeOS: |
107 | | // break; |
108 | | |
109 | 24 | default: |
110 | 24 | create = false; |
111 | 24 | break; |
112 | 24 | } |
113 | | #ifdef _MSC_VER |
114 | | #pragma warning(pop) |
115 | | #endif |
116 | 24 | } |
117 | 74 | } break; |
118 | 128 | default: |
119 | 128 | break; |
120 | 202 | } |
121 | 202 | } |
122 | | |
123 | 206 | if (create) { |
124 | 4 | LLDB_LOGF(log, "PlatformRemoteAppleBridge::%s() creating platform", |
125 | 4 | __FUNCTION__); |
126 | | |
127 | 4 | return lldb::PlatformSP(new PlatformRemoteAppleBridge()); |
128 | 4 | } |
129 | | |
130 | 202 | LLDB_LOGF(log, |
131 | 202 | "PlatformRemoteAppleBridge::%s() aborting creation of platform", |
132 | 202 | __FUNCTION__); |
133 | | |
134 | 202 | return lldb::PlatformSP(); |
135 | 206 | } |
136 | | |
137 | 3.94k | llvm::StringRef PlatformRemoteAppleBridge::GetDescriptionStatic() { |
138 | 3.94k | return "Remote BridgeOS platform plug-in."; |
139 | 3.94k | } |
140 | | |
141 | | std::vector<ArchSpec> PlatformRemoteAppleBridge::GetSupportedArchitectures( |
142 | 0 | const ArchSpec &process_host_arch) { |
143 | 0 | return {ArchSpec("arm64-apple-bridgeos")}; |
144 | 0 | } |
145 | | |
146 | 0 | llvm::StringRef PlatformRemoteAppleBridge::GetDeviceSupportDirectoryName() { |
147 | 0 | return "BridgeOS DeviceSupport"; |
148 | 0 | } |
149 | | |
150 | 0 | llvm::StringRef PlatformRemoteAppleBridge::GetPlatformName() { |
151 | 0 | return "BridgeOS.platform"; |
152 | 0 | } |