[NFC][AArch64] Explicitly define undefined bits for instructions (#122129)
[llvm-project.git] / lldb / source / Plugins / Platform / MacOSX / PlatformRemoteAppleBridge.cpp
blob2aa4ad56bb84ad810f9a8531c2f2f4a842a879c8
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 //===----------------------------------------------------------------------===//
9 #include <string>
10 #include <vector>
12 #include "PlatformRemoteAppleBridge.h"
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"
28 using namespace lldb;
29 using namespace lldb_private;
31 /// Default Constructor
32 PlatformRemoteAppleBridge::PlatformRemoteAppleBridge()
33 : PlatformRemoteDarwinDevice () {}
35 // Static Variables
36 static uint32_t g_initialize_count = 0;
38 // Static Functions
39 void PlatformRemoteAppleBridge::Initialize() {
40 PlatformDarwin::Initialize();
42 if (g_initialize_count++ == 0) {
43 PluginManager::RegisterPlugin(PlatformRemoteAppleBridge::GetPluginNameStatic(),
44 PlatformRemoteAppleBridge::GetDescriptionStatic(),
45 PlatformRemoteAppleBridge::CreateInstance);
49 void PlatformRemoteAppleBridge::Terminate() {
50 if (g_initialize_count > 0) {
51 if (--g_initialize_count == 0) {
52 PluginManager::UnregisterPlugin(PlatformRemoteAppleBridge::CreateInstance);
56 PlatformDarwin::Terminate();
59 PlatformSP PlatformRemoteAppleBridge::CreateInstance(bool force,
60 const ArchSpec *arch) {
61 Log *log = GetLog(LLDBLog::Platform);
62 if (log) {
63 const char *arch_name;
64 if (arch && arch->GetArchitectureName())
65 arch_name = arch->GetArchitectureName();
66 else
67 arch_name = "<null>";
69 const char *triple_cstr =
70 arch ? arch->GetTriple().getTriple().c_str() : "<null>";
72 LLDB_LOGF(log, "PlatformRemoteAppleBridge::%s(force=%s, arch={%s,%s})",
73 __FUNCTION__, force ? "true" : "false", arch_name, triple_cstr);
76 bool create = force;
77 if (!create && arch && arch->IsValid()) {
78 switch (arch->GetMachine()) {
79 case llvm::Triple::aarch64: {
80 const llvm::Triple &triple = arch->GetTriple();
81 llvm::Triple::VendorType vendor = triple.getVendor();
82 switch (vendor) {
83 case llvm::Triple::Apple:
84 create = true;
85 break;
87 #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 case llvm::Triple::UnknownVendor:
92 create = !arch->TripleVendorWasSpecified();
93 break;
95 #endif
96 default:
97 break;
99 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 switch (triple.getOS()) {
106 case llvm::Triple::BridgeOS:
107 break;
108 default:
109 create = false;
110 break;
112 #ifdef _MSC_VER
113 #pragma warning(pop)
114 #endif
116 } break;
117 default:
118 break;
122 if (create) {
123 LLDB_LOGF(log, "PlatformRemoteAppleBridge::%s() creating platform",
124 __FUNCTION__);
126 return lldb::PlatformSP(new PlatformRemoteAppleBridge());
129 LLDB_LOGF(log,
130 "PlatformRemoteAppleBridge::%s() aborting creation of platform",
131 __FUNCTION__);
133 return lldb::PlatformSP();
136 llvm::StringRef PlatformRemoteAppleBridge::GetDescriptionStatic() {
137 return "Remote BridgeOS platform plug-in.";
140 std::vector<ArchSpec> PlatformRemoteAppleBridge::GetSupportedArchitectures(
141 const ArchSpec &process_host_arch) {
142 return {ArchSpec("arm64-apple-bridgeos")};
145 llvm::StringRef PlatformRemoteAppleBridge::GetDeviceSupportDirectoryName() {
146 return "BridgeOS DeviceSupport";
149 llvm::StringRef PlatformRemoteAppleBridge::GetPlatformName() {
150 return "BridgeOS.platform";