LLDB  mainline
PlatformRemoteiOS.cpp
Go to the documentation of this file.
1 //===-- PlatformRemoteiOS.cpp -----------------------------------*- C++ -*-===//
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 "PlatformRemoteiOS.h"
10 
12 #include "lldb/Core/Module.h"
13 #include "lldb/Core/ModuleList.h"
14 #include "lldb/Core/ModuleSpec.h"
16 #include "lldb/Host/Host.h"
17 #include "lldb/Target/Process.h"
18 #include "lldb/Target/Target.h"
19 #include "lldb/Utility/ArchSpec.h"
20 #include "lldb/Utility/FileSpec.h"
21 #include "lldb/Utility/Log.h"
22 #include "lldb/Utility/Status.h"
24 
25 using namespace lldb;
26 using namespace lldb_private;
27 
28 // Static Variables
30 
31 // Static Functions
34 
35  if (g_initialize_count++ == 0) {
36  PluginManager::RegisterPlugin(PlatformRemoteiOS::GetPluginNameStatic(),
39  }
40 }
41 
43  if (g_initialize_count > 0) {
44  if (--g_initialize_count == 0) {
45  PluginManager::UnregisterPlugin(PlatformRemoteiOS::CreateInstance);
46  }
47  }
48 
50 }
51 
52 PlatformSP PlatformRemoteiOS::CreateInstance(bool force, const ArchSpec *arch) {
54  if (log) {
55  const char *arch_name;
56  if (arch && arch->GetArchitectureName())
57  arch_name = arch->GetArchitectureName();
58  else
59  arch_name = "<null>";
60 
61  const char *triple_cstr =
62  arch ? arch->GetTriple().getTriple().c_str() : "<null>";
63 
64  log->Printf("PlatformRemoteiOS::%s(force=%s, arch={%s,%s})", __FUNCTION__,
65  force ? "true" : "false", arch_name, triple_cstr);
66  }
67 
68  bool create = force;
69  if (!create && arch && arch->IsValid()) {
70  switch (arch->GetMachine()) {
71  case llvm::Triple::arm:
72  case llvm::Triple::aarch64:
73  case llvm::Triple::thumb: {
74  const llvm::Triple &triple = arch->GetTriple();
75  llvm::Triple::VendorType vendor = triple.getVendor();
76  switch (vendor) {
77  case llvm::Triple::Apple:
78  create = true;
79  break;
80 
81 #if defined(__APPLE__)
82  // Only accept "unknown" for the vendor if the host is Apple and
83  // "unknown" wasn't specified (it was just returned because it was NOT
84  // specified)
85  case llvm::Triple::UnknownVendor:
86  create = !arch->TripleVendorWasSpecified();
87  break;
88 
89 #endif
90  default:
91  break;
92  }
93  if (create) {
94  switch (triple.getOS()) {
95  case llvm::Triple::Darwin: // Deprecated, but still support Darwin for
96  // historical reasons
97  case llvm::Triple::IOS: // This is the right triple value for iOS
98  // debugging
99  break;
100 
101  default:
102  create = false;
103  break;
104  }
105  }
106  } break;
107  default:
108  break;
109  }
110  }
111 
112  if (create) {
113  if (log)
114  log->Printf("PlatformRemoteiOS::%s() creating platform", __FUNCTION__);
115 
116  return lldb::PlatformSP(new PlatformRemoteiOS());
117  }
118 
119  if (log)
120  log->Printf("PlatformRemoteiOS::%s() aborting creation of platform",
121  __FUNCTION__);
122 
123  return lldb::PlatformSP();
124 }
125 
127  static ConstString g_name("remote-ios");
128  return g_name;
129 }
130 
132  return "Remote iOS platform plug-in.";
133 }
134 
135 /// Default Constructor
138 
140  ArchSpec &arch) {
141  return ARMGetSupportedArchitectureAtIndex(idx, arch);
142 }
143 
144 
145 void PlatformRemoteiOS::GetDeviceSupportDirectoryNames (std::vector<std::string> &dirnames)
146 {
147  dirnames.clear();
148  dirnames.push_back("iOS DeviceSupport");
149 }
150 
152 {
153  return "iPhoneOS.platform";
154 }
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
bool ARMGetSupportedArchitectureAtIndex(uint32_t idx, lldb_private::ArchSpec &arch)
An architecture specification class.
Definition: ArchSpec.h:32
#define LIBLLDB_LOG_PLATFORM
Definition: Logging.h:39
static void Terminate()
Definition: Platform.cpp:142
bool IsValid() const
Tests if this ArchSpec is valid.
Definition: ArchSpec.h:329
static const char * GetDescriptionStatic()
llvm::Triple & GetTriple()
Architecture triple accessor.
Definition: ArchSpec.h:431
bool TripleVendorWasSpecified() const
Definition: ArchSpec.h:334
const char * GetArchitectureName() const
Returns a static string representing the current architecture.
Definition: ArchSpec.cpp:591
static lldb_private::ConstString GetPluginNameStatic()
Log * GetLogIfAllCategoriesSet(uint32_t mask)
Definition: Logging.cpp:57
static void Initialize()
Definition: Platform.cpp:140
PlatformRemoteiOS()
Default Constructor.
static void Initialize()
A uniqued constant string class.
Definition: ConstString.h:38
Definition: SBAddress.h:15
bool GetSupportedArchitectureAtIndex(uint32_t idx, lldb_private::ArchSpec &arch) override
Get the platform&#39;s supported architectures in the order in which they should be searched.
void GetDeviceSupportDirectoryNames(std::vector< std::string > &dirnames) override
static uint32_t g_initialize_count
std::string GetPlatformName() override
static void Terminate()
static lldb::PlatformSP CreateInstance(bool force, const lldb_private::ArchSpec *arch)
void Printf(const char *format,...) __attribute__((format(printf
Definition: Log.cpp:113
llvm::Triple::ArchType GetMachine() const
Returns a machine family for the current architecture.
Definition: ArchSpec.cpp:726