LLDB  mainline
PlatformRemoteAppleBridge.cpp
Go to the documentation of this file.
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 
13 
15 #include "lldb/Core/Module.h"
16 #include "lldb/Core/ModuleList.h"
17 #include "lldb/Core/ModuleSpec.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"
27 
28 using namespace lldb;
29 using namespace lldb_private;
30 
31 /// Default Constructor
32 PlatformRemoteAppleBridge::PlatformRemoteAppleBridge()
34 
35 // Static Variables
37 
38 // Static Functions
41 
42  if (g_initialize_count++ == 0) {
46  }
47 }
48 
50  if (g_initialize_count > 0) {
51  if (--g_initialize_count == 0) {
53  }
54  }
55 
57 }
58 
60  const ArchSpec *arch) {
62  if (log) {
63  const char *arch_name;
64  if (arch && arch->GetArchitectureName())
65  arch_name = arch->GetArchitectureName();
66  else
67  arch_name = "<null>";
68 
69  const char *triple_cstr =
70  arch ? arch->GetTriple().getTriple().c_str() : "<null>";
71 
72  LLDB_LOGF(log, "PlatformRemoteAppleBridge::%s(force=%s, arch={%s,%s})",
73  __FUNCTION__, force ? "true" : "false", arch_name, triple_cstr);
74  }
75 
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;
86 
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;
94 
95 #endif
96  default:
97  break;
98  }
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  // NEED_BRIDGEOS_TRIPLE case llvm::Triple::BridgeOS:
107  // break;
108 
109  default:
110  create = false;
111  break;
112  }
113 #ifdef _MSC_VER
114 #pragma warning(pop)
115 #endif
116  }
117  } break;
118  default:
119  break;
120  }
121  }
122 
123  if (create) {
124  LLDB_LOGF(log, "PlatformRemoteAppleBridge::%s() creating platform",
125  __FUNCTION__);
126 
127  return lldb::PlatformSP(new PlatformRemoteAppleBridge());
128  }
129 
130  LLDB_LOGF(log,
131  "PlatformRemoteAppleBridge::%s() aborting creation of platform",
132  __FUNCTION__);
133 
134  return lldb::PlatformSP();
135 }
136 
138  return "Remote BridgeOS platform plug-in.";
139 }
140 
142  const ArchSpec &process_host_arch) {
143  return {ArchSpec("arm64-apple-bridgeos")};
144 }
145 
147  return "BridgeOS DeviceSupport";
148 }
149 
151  return "BridgeOS.platform";
152 }
lldb_private::ArchSpec
Definition: ArchSpec.h:32
lldb_private::ArchSpec::TripleVendorWasSpecified
bool TripleVendorWasSpecified() const
Definition: ArchSpec.h:357
lldb_private::PlatformRemoteAppleBridge::GetPluginNameStatic
static llvm::StringRef GetPluginNameStatic()
Definition: PlatformRemoteAppleBridge.h:33
lldb_private::ArchSpec::GetMachine
llvm::Triple::ArchType GetMachine() const
Returns a machine family for the current architecture.
Definition: ArchSpec.cpp:666
ModuleSpec.h
Host.h
lldb_private::PlatformRemoteAppleBridge::GetDescriptionStatic
static llvm::StringRef GetDescriptionStatic()
Definition: PlatformRemoteAppleBridge.cpp:137
lldb_private::PlatformRemoteAppleBridge::GetDeviceSupportDirectoryName
llvm::StringRef GetDeviceSupportDirectoryName() override
Definition: PlatformRemoteAppleBridge.cpp:146
LLDB_LOGF
#define LLDB_LOGF(log,...)
Definition: Log.h:344
lldb_private::PlatformRemoteAppleBridge::Initialize
static void Initialize()
Definition: PlatformRemoteAppleBridge.cpp:39
Module.h
BreakpointLocation.h
g_initialize_count
static uint32_t g_initialize_count
Definition: PlatformRemoteAppleBridge.cpp:36
lldb_private::ArchSpec::GetTriple
llvm::Triple & GetTriple()
Architecture triple accessor.
Definition: ArchSpec.h:454
lldb_private::PlatformRemoteAppleBridge::GetSupportedArchitectures
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.
Definition: PlatformRemoteAppleBridge.cpp:141
Process.h
lldb_private::PlatformDarwin::Initialize
static void Initialize()
Definition: PlatformDarwin.cpp:83
Target.h
ModuleList.h
lldb_private::PluginManager::UnregisterPlugin
static bool UnregisterPlugin(ABICreateInstance create_callback)
Definition: PluginManager.cpp:293
Log.h
lldb_private::PlatformDarwin::Terminate
static void Terminate()
Definition: PlatformDarwin.cpp:94
StreamString.h
lldb_private::PlatformRemoteDarwinDevice
Definition: PlatformRemoteDarwinDevice.h:36
lldb_private::PlatformRemoteAppleBridge::Terminate
static void Terminate()
Definition: PlatformRemoteAppleBridge.cpp:49
lldb_private::ArchSpec::IsValid
bool IsValid() const
Tests if this ArchSpec is valid.
Definition: ArchSpec.h:352
lldb_private::ArchSpec::GetArchitectureName
const char * GetArchitectureName() const
Returns a static string representing the current architecture.
Definition: ArchSpec.cpp:535
uint32_t
PlatformRemoteAppleBridge.h
ArchSpec.h
PluginManager.h
lldb_private::PluginManager::RegisterPlugin
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
Definition: PluginManager.cpp:287
lldb_private::LLDBLog::Platform
@ Platform
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
FileSpec.h
lldb_private::Log
Definition: Log.h:115
lldb_private::GetLog
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition: Log.h:309
lldb
Definition: SBAddress.h:15
LLDBLog.h
lldb_private::PlatformRemoteAppleBridge::CreateInstance
static lldb::PlatformSP CreateInstance(bool force, const ArchSpec *arch)
Definition: PlatformRemoteAppleBridge.cpp:59
lldb_private::PlatformRemoteAppleBridge::GetPlatformName
llvm::StringRef GetPlatformName() override
Definition: PlatformRemoteAppleBridge.cpp:150
lldb_private::PlatformRemoteAppleBridge::PlatformRemoteAppleBridge
PlatformRemoteAppleBridge()
Default Constructor.
Definition: PlatformRemoteAppleBridge.cpp:32