/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteMacOSX.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | //===-- PlatformRemoteMacOSX.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 <memory> |
10 | | #include <string> |
11 | | #include <vector> |
12 | | |
13 | | #include "PlatformRemoteMacOSX.h" |
14 | | |
15 | | #include "lldb/Breakpoint/BreakpointLocation.h" |
16 | | #include "lldb/Core/Module.h" |
17 | | #include "lldb/Core/ModuleList.h" |
18 | | #include "lldb/Core/ModuleSpec.h" |
19 | | #include "lldb/Core/PluginManager.h" |
20 | | #include "lldb/Host/Host.h" |
21 | | #include "lldb/Host/HostInfo.h" |
22 | | #include "lldb/Target/Process.h" |
23 | | #include "lldb/Target/Target.h" |
24 | | #include "lldb/Utility/ArchSpec.h" |
25 | | #include "lldb/Utility/FileSpec.h" |
26 | | #include "lldb/Utility/LLDBLog.h" |
27 | | #include "lldb/Utility/Log.h" |
28 | | #include "lldb/Utility/StreamString.h" |
29 | | |
30 | | using namespace lldb; |
31 | | using namespace lldb_private; |
32 | | |
33 | | /// Default Constructor |
34 | 53 | PlatformRemoteMacOSX::PlatformRemoteMacOSX() : PlatformRemoteDarwinDevice() {} Unexecuted instantiation: lldb_private::PlatformRemoteMacOSX::PlatformRemoteMacOSX() lldb_private::PlatformRemoteMacOSX::PlatformRemoteMacOSX() Line | Count | Source | 34 | 53 | PlatformRemoteMacOSX::PlatformRemoteMacOSX() : PlatformRemoteDarwinDevice() {} |
|
35 | | |
36 | | // Static Variables |
37 | | static uint32_t g_initialize_count = 0; |
38 | | |
39 | | // Static Functions |
40 | 7.88k | void PlatformRemoteMacOSX::Initialize() { |
41 | 7.88k | PlatformDarwin::Initialize(); |
42 | | |
43 | 7.88k | if (g_initialize_count++ == 0) { |
44 | 3.94k | PluginManager::RegisterPlugin(PlatformRemoteMacOSX::GetPluginNameStatic(), |
45 | 3.94k | PlatformRemoteMacOSX::GetDescriptionStatic(), |
46 | 3.94k | PlatformRemoteMacOSX::CreateInstance); |
47 | 3.94k | } |
48 | 7.88k | } |
49 | | |
50 | 0 | void PlatformRemoteMacOSX::Terminate() { |
51 | 0 | if (g_initialize_count > 0) { |
52 | 0 | if (--g_initialize_count == 0) { |
53 | 0 | PluginManager::UnregisterPlugin(PlatformRemoteMacOSX::CreateInstance); |
54 | 0 | } |
55 | 0 | } |
56 | |
|
57 | 0 | PlatformDarwin::Terminate(); |
58 | 0 | } |
59 | | |
60 | | PlatformSP PlatformRemoteMacOSX::CreateInstance(bool force, |
61 | 248 | const ArchSpec *arch) { |
62 | 248 | Log *log = GetLog(LLDBLog::Platform); |
63 | 248 | 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, "PlatformRemoteMacOSX::%s(force=%s, arch={%s,%s})", |
74 | 0 | __FUNCTION__, force ? "true" : "false", arch_name, triple_cstr); |
75 | 0 | } |
76 | | |
77 | 248 | bool create = force; |
78 | 248 | if (!create && arch232 && arch->IsValid()232 ) { |
79 | 232 | const llvm::Triple &triple = arch->GetTriple(); |
80 | 232 | switch (triple.getVendor()) { |
81 | 22 | case llvm::Triple::Apple: |
82 | 22 | create = true; |
83 | 22 | break; |
84 | | |
85 | 0 | #if defined(__APPLE__) |
86 | | // Only accept "unknown" for vendor if the host is Apple and it "unknown" |
87 | | // wasn't specified (it was just returned because it was NOT specified) |
88 | 118 | case llvm::Triple::UnknownVendor: |
89 | 118 | create = !arch->TripleVendorWasSpecified(); |
90 | 118 | break; |
91 | 0 | #endif |
92 | 92 | default: |
93 | 92 | break; |
94 | 232 | } |
95 | | |
96 | 232 | if (create) { |
97 | 62 | switch (triple.getOS()) { |
98 | 0 | case llvm::Triple::Darwin: // Deprecated, but still support Darwin for |
99 | | // historical reasons |
100 | 13 | case llvm::Triple::MacOSX: |
101 | 13 | break; |
102 | 0 | #if defined(__APPLE__) |
103 | | // Only accept "vendor" for vendor if the host is Apple and it "unknown" |
104 | | // wasn't specified (it was just returned because it was NOT specified) |
105 | 24 | case llvm::Triple::UnknownOS: |
106 | 24 | create = !arch->TripleOSWasSpecified(); |
107 | 24 | break; |
108 | 0 | #endif |
109 | 25 | default: |
110 | 25 | create = false; |
111 | 25 | break; |
112 | 62 | } |
113 | 62 | } |
114 | 232 | } |
115 | | |
116 | 248 | if (create) { |
117 | 53 | LLDB_LOGF(log, "PlatformRemoteMacOSX::%s() creating platform", |
118 | 53 | __FUNCTION__); |
119 | 53 | return std::make_shared<PlatformRemoteMacOSX>(); |
120 | 53 | } |
121 | | |
122 | 195 | LLDB_LOGF(log, "PlatformRemoteMacOSX::%s() aborting creation of platform", |
123 | 195 | __FUNCTION__); |
124 | | |
125 | 195 | return PlatformSP(); |
126 | 248 | } |
127 | | |
128 | | std::vector<ArchSpec> |
129 | 76 | PlatformRemoteMacOSX::GetSupportedArchitectures(const ArchSpec &host_info) { |
130 | | // macOS for ARM64 support both native and translated x86_64 processes |
131 | 76 | std::vector<ArchSpec> result; |
132 | 76 | ARMGetSupportedArchitectures(result, llvm::Triple::MacOSX); |
133 | | |
134 | | // We can't use x86GetSupportedArchitectures() because it uses |
135 | | // the system architecture for some of its return values and also |
136 | | // has a 32bits variant. |
137 | 76 | result.push_back(ArchSpec("x86_64-apple-macosx")); |
138 | 76 | result.push_back(ArchSpec("x86_64-apple-ios-macabi")); |
139 | 76 | result.push_back(ArchSpec("arm64-apple-ios")); |
140 | 76 | result.push_back(ArchSpec("arm64e-apple-ios")); |
141 | 76 | return result; |
142 | 76 | } |
143 | | |
144 | 3.94k | llvm::StringRef PlatformRemoteMacOSX::GetDescriptionStatic() { |
145 | 3.94k | return "Remote Mac OS X user platform plug-in."; |
146 | 3.94k | } |
147 | | |
148 | 99 | llvm::StringRef PlatformRemoteMacOSX::GetDeviceSupportDirectoryName() { |
149 | 99 | return "macOS DeviceSupport"; |
150 | 99 | } |
151 | | |
152 | 99 | llvm::StringRef PlatformRemoteMacOSX::GetPlatformName() { |
153 | 99 | return "MacOSX.platform"; |
154 | 99 | } |