LLDB mainline
PlatformRemoteMacOSX.cpp
Go to the documentation of this file.
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
14
16#include "lldb/Core/Module.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"
27#include "lldb/Utility/Log.h"
29
30using namespace lldb;
31using namespace lldb_private;
32
33/// Default Constructor
35
36// Static Variables
37static uint32_t g_initialize_count = 0;
38
39// Static Functions
47
55
57 const ArchSpec *arch) {
59 if (log) {
60 const char *arch_name;
61 if (arch && arch->GetArchitectureName())
62 arch_name = arch->GetArchitectureName();
63 else
64 arch_name = "<null>";
65
66 const char *triple_cstr =
67 arch ? arch->GetTriple().getTriple().c_str() : "<null>";
68
69 LLDB_LOGF(log, "PlatformRemoteMacOSX::%s(force=%s, arch={%s,%s})",
70 __FUNCTION__, force ? "true" : "false", arch_name, triple_cstr);
71 }
72
73 bool create = force;
74 if (!create && arch && arch->IsValid()) {
75 const llvm::Triple &triple = arch->GetTriple();
76 switch (triple.getVendor()) {
77 case llvm::Triple::Apple:
78 create = true;
79 break;
80
81#if defined(__APPLE__)
82 // Only accept "unknown" for vendor if the host is Apple and it "unknown"
83 // wasn't specified (it was just returned because it was NOT specified)
84 case llvm::Triple::UnknownVendor:
85 create = !arch->TripleVendorWasSpecified();
86 break;
87#endif
88 default:
89 break;
90 }
91
92 if (create) {
93 switch (triple.getOS()) {
94 case llvm::Triple::Darwin: // Deprecated, but still support Darwin for
95 // historical reasons
96 case llvm::Triple::MacOSX:
97 break;
98#if defined(__APPLE__)
99 // Only accept "vendor" for vendor if the host is Apple and it "unknown"
100 // wasn't specified (it was just returned because it was NOT specified)
101 case llvm::Triple::UnknownOS:
102 create = !arch->TripleOSWasSpecified();
103 break;
104#endif
105 default:
106 create = false;
107 break;
108 }
109 }
110 }
111
112 if (create) {
113 LLDB_LOGF(log, "PlatformRemoteMacOSX::%s() creating platform",
114 __FUNCTION__);
115 return std::make_shared<PlatformRemoteMacOSX>();
116 }
117
118 LLDB_LOGF(log, "PlatformRemoteMacOSX::%s() aborting creation of platform",
119 __FUNCTION__);
120
121 return PlatformSP();
122}
123
124std::vector<ArchSpec>
126 // macOS for ARM64 support both native and translated x86_64 processes
127 std::vector<ArchSpec> result;
128 ARMGetSupportedArchitectures(result, llvm::Triple::MacOSX);
129
130 // We can't use x86GetSupportedArchitectures() because it uses
131 // the system architecture for some of its return values and also
132 // has a 32bits variant.
133 result.push_back(ArchSpec("x86_64-apple-macosx"));
134 result.push_back(ArchSpec("x86_64-apple-ios-macabi"));
135 result.push_back(ArchSpec("arm64-apple-ios"));
136 result.push_back(ArchSpec("arm64e-apple-ios"));
137 return result;
138}
139
141 return "Remote Mac OS X user platform plug-in.";
142}
143
145 return "macOS DeviceSupport";
146}
147
149 return "MacOSX.platform";
150}
#define LLDB_LOGF(log,...)
Definition Log.h:376
static uint32_t g_initialize_count
An architecture specification class.
Definition ArchSpec.h:32
bool IsValid() const
Tests if this ArchSpec is valid.
Definition ArchSpec.h:367
llvm::Triple & GetTriple()
Architecture triple accessor.
Definition ArchSpec.h:457
bool TripleVendorWasSpecified() const
Definition ArchSpec.h:372
bool TripleOSWasSpecified() const
Definition ArchSpec.h:376
const char * GetArchitectureName() const
Returns a static string representing the current architecture.
Definition ArchSpec.cpp:548
void ARMGetSupportedArchitectures(std::vector< ArchSpec > &archs, std::optional< llvm::Triple::OSType > os={})
The architecture selection rules for arm processors These cpu subtypes have distinct names (e....
static llvm::StringRef GetPluginNameStatic()
llvm::StringRef GetDeviceSupportDirectoryName() override
static lldb::PlatformSP CreateInstance(bool force, const ArchSpec *arch)
std::vector< ArchSpec > GetSupportedArchitectures(const ArchSpec &process_host_arch) override
Get the platform's supported architectures in the order in which they should be searched.
llvm::StringRef GetPlatformName() override
static llvm::StringRef GetDescriptionStatic()
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
static bool UnregisterPlugin(ABICreateInstance create_callback)
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition Log.h:332
std::shared_ptr< lldb_private::Platform > PlatformSP