LLDB  mainline
PlatformRemoteiOS.cpp
Go to the documentation of this file.
1 //===-- PlatformRemoteiOS.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 "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 
29 
30 // Static Variables
32 
33 // Static Functions
34 void PlatformRemoteiOS::Initialize() {
36 
37  if (g_initialize_count++ == 0) {
38  PluginManager::RegisterPlugin(PlatformRemoteiOS::GetPluginNameStatic(),
41  }
42 }
43 
45  if (g_initialize_count > 0) {
46  if (--g_initialize_count == 0) {
47  PluginManager::UnregisterPlugin(PlatformRemoteiOS::CreateInstance);
48  }
49  }
50 
52 }
53 
54 PlatformSP PlatformRemoteiOS::CreateInstance(bool force, const ArchSpec *arch) {
56  if (log) {
57  const char *arch_name;
58  if (arch && arch->GetArchitectureName())
59  arch_name = arch->GetArchitectureName();
60  else
61  arch_name = "<null>";
62 
63  const char *triple_cstr =
64  arch ? arch->GetTriple().getTriple().c_str() : "<null>";
65 
66  LLDB_LOGF(log, "PlatformRemoteiOS::%s(force=%s, arch={%s,%s})",
67  __FUNCTION__, force ? "true" : "false", arch_name, triple_cstr);
68  }
69 
70  bool create = force;
71  if (!create && arch && arch->IsValid()) {
72  switch (arch->GetMachine()) {
73  case llvm::Triple::arm:
74  case llvm::Triple::aarch64:
75  case llvm::Triple::thumb: {
76  const llvm::Triple &triple = arch->GetTriple();
77  llvm::Triple::VendorType vendor = triple.getVendor();
78  switch (vendor) {
79  case llvm::Triple::Apple:
80  create = true;
81  break;
82 
83 #if defined(__APPLE__)
84  // Only accept "unknown" for the vendor if the host is Apple and
85  // "unknown" wasn't specified (it was just returned because it was NOT
86  // specified)
87  case llvm::Triple::UnknownVendor:
88  create = !arch->TripleVendorWasSpecified();
89  break;
90 
91 #endif
92  default:
93  break;
94  }
95  if (create) {
96  switch (triple.getOS()) {
97  case llvm::Triple::Darwin: // Deprecated, but still support Darwin for
98  // historical reasons
99  case llvm::Triple::IOS: // This is the right triple value for iOS
100  // debugging
101  break;
102 
103  default:
104  create = false;
105  break;
106  }
107  }
108  } break;
109  default:
110  break;
111  }
112  }
113 
114  if (create) {
115  if (log)
116  LLDB_LOGF(log, "PlatformRemoteiOS::%s() creating platform", __FUNCTION__);
117 
118  return lldb::PlatformSP(new PlatformRemoteiOS());
119  }
120 
121  if (log)
122  LLDB_LOGF(log, "PlatformRemoteiOS::%s() aborting creation of platform",
123  __FUNCTION__);
124 
125  return lldb::PlatformSP();
126 }
127 
129  static ConstString g_name("remote-ios");
130  return g_name;
131 }
132 
134  return "Remote iOS platform plug-in.";
135 }
136 
137 /// Default Constructor
140 
142  ArchSpec &arch) {
143  return ARMGetSupportedArchitectureAtIndex(idx, arch);
144 }
145 
147  return "iOS DeviceSupport";
148 }
149 
151  return "iPhoneOS.platform";
152 }
lldb_private::ArchSpec
Definition: ArchSpec.h:33
lldb_private::ArchSpec::TripleVendorWasSpecified
bool TripleVendorWasSpecified() const
Definition: ArchSpec.h:347
lldb_private::ArchSpec::GetMachine
llvm::Triple::ArchType GetMachine() const
Returns a machine family for the current architecture.
Definition: ArchSpec.cpp:667
ModuleSpec.h
Host.h
LLDB_LOGF
#define LLDB_LOGF(log,...)
Definition: Log.h:249
Module.h
BreakpointLocation.h
LIBLLDB_LOG_PLATFORM
#define LIBLLDB_LOG_PLATFORM
Definition: Logging.h:39
PlatformDarwin::ARMGetSupportedArchitectureAtIndex
bool ARMGetSupportedArchitectureAtIndex(uint32_t idx, lldb_private::ArchSpec &arch)
The architecture selection rules for arm processors These cpu subtypes have distinct names (e....
Definition: PlatformDarwin.cpp:561
lldb_private::ArchSpec::GetTriple
llvm::Triple & GetTriple()
Architecture triple accessor.
Definition: ArchSpec.h:444
PlatformRemoteDarwinDevice
Definition: PlatformRemoteDarwinDevice.h:19
Process.h
Target.h
PlatformRemoteiOS::GetDescriptionStatic
static const char * GetDescriptionStatic()
Definition: PlatformRemoteiOS.cpp:133
ModuleList.h
PlatformRemoteiOS::GetPluginNameStatic
static lldb_private::ConstString GetPluginNameStatic()
Definition: PlatformRemoteiOS.cpp:128
Log.h
StreamString.h
lldb_private::ConstString
Definition: ConstString.h:40
PlatformRemoteiOS::GetPlatformName
llvm::StringRef GetPlatformName() override
Definition: PlatformRemoteiOS.cpp:150
lldb_private::Platform::Terminate
static void Terminate()
Definition: Platform.cpp:149
lldb_private::GetLogIfAllCategoriesSet
Log * GetLogIfAllCategoriesSet(uint32_t mask)
Definition: Logging.cpp:58
lldb_private::ArchSpec::IsValid
bool IsValid() const
Tests if this ArchSpec is valid.
Definition: ArchSpec.h:342
lldb_private::Platform::Initialize
static void Initialize()
Definition: Platform.cpp:147
PlatformRemoteiOS.h
PlatformRemoteiOS
Definition: PlatformRemoteiOS.h:19
lldb_private::ArchSpec::GetArchitectureName
const char * GetArchitectureName() const
Returns a static string representing the current architecture.
Definition: ArchSpec.cpp:538
uint32_t
PlatformRemoteiOS::PlatformRemoteiOS
PlatformRemoteiOS()
Default Constructor.
Definition: PlatformRemoteiOS.cpp:138
PlatformRemoteiOS::GetDeviceSupportDirectoryName
llvm::StringRef GetDeviceSupportDirectoryName() override
Definition: PlatformRemoteiOS.cpp:146
PlatformRemoteiOS::CreateInstance
static lldb::PlatformSP CreateInstance(bool force, const lldb_private::ArchSpec *arch)
Definition: PlatformRemoteiOS.cpp:54
PlatformRemoteiOS::GetSupportedArchitectureAtIndex
bool GetSupportedArchitectureAtIndex(uint32_t idx, lldb_private::ArchSpec &arch) override
Get the platform's supported architectures in the order in which they should be searched.
Definition: PlatformRemoteiOS.cpp:141
ArchSpec.h
PluginManager.h
Status.h
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
FileSpec.h
LLDB_PLUGIN_DEFINE
#define LLDB_PLUGIN_DEFINE(PluginName)
Definition: PluginManager.h:31
lldb_private::Log
Definition: Log.h:49
PlatformRemoteiOS::Terminate
static void Terminate()
Definition: PlatformRemoteiOS.cpp:44
lldb
Definition: SBAddress.h:15
g_initialize_count
static uint32_t g_initialize_count
Definition: PlatformRemoteiOS.cpp:31