Coverage Report

Created: 2023-09-30 09:22

/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp
Line
Count
Source (jump to first uncovered line)
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
11
#include "lldb/Breakpoint/BreakpointLocation.h"
12
#include "lldb/Core/Module.h"
13
#include "lldb/Core/ModuleList.h"
14
#include "lldb/Core/ModuleSpec.h"
15
#include "lldb/Core/PluginManager.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/LLDBLog.h"
22
#include "lldb/Utility/Log.h"
23
#include "lldb/Utility/Status.h"
24
#include "lldb/Utility/StreamString.h"
25
26
using namespace lldb;
27
using namespace lldb_private;
28
29
LLDB_PLUGIN_DEFINE(PlatformRemoteiOS)
30
31
// Static Variables
32
static uint32_t g_initialize_count = 0;
33
34
// Static Functions
35
3.94k
void PlatformRemoteiOS::Initialize() {
36
3.94k
  PlatformDarwin::Initialize();
37
38
3.94k
  if (g_initialize_count++ == 0) {
39
3.94k
    PluginManager::RegisterPlugin(PlatformRemoteiOS::GetPluginNameStatic(),
40
3.94k
                                  PlatformRemoteiOS::GetDescriptionStatic(),
41
3.94k
                                  PlatformRemoteiOS::CreateInstance);
42
3.94k
  }
43
3.94k
}
44
45
3.94k
void PlatformRemoteiOS::Terminate() {
46
3.94k
  if (g_initialize_count > 0) {
47
3.94k
    if (--g_initialize_count == 0) {
48
3.94k
      PluginManager::UnregisterPlugin(PlatformRemoteiOS::CreateInstance);
49
3.94k
    }
50
3.94k
  }
51
52
3.94k
  PlatformDarwin::Terminate();
53
3.94k
}
54
55
236
PlatformSP PlatformRemoteiOS::CreateInstance(bool force, const ArchSpec *arch) {
56
236
  Log *log = GetLog(LLDBLog::Platform);
57
236
  if (log) {
58
0
    const char *arch_name;
59
0
    if (arch && arch->GetArchitectureName())
60
0
      arch_name = arch->GetArchitectureName();
61
0
    else
62
0
      arch_name = "<null>";
63
64
0
    const char *triple_cstr =
65
0
        arch ? arch->GetTriple().getTriple().c_str() : "<null>";
66
67
0
    LLDB_LOGF(log, "PlatformRemoteiOS::%s(force=%s, arch={%s,%s})",
68
0
              __FUNCTION__, force ? "true" : "false", arch_name, triple_cstr);
69
0
  }
70
71
236
  bool create = force;
72
236
  if (!create && 
arch231
&&
arch->IsValid()231
) {
73
231
    switch (arch->GetMachine()) {
74
15
    case llvm::Triple::arm:
75
111
    case llvm::Triple::aarch64:
76
112
    case llvm::Triple::thumb: {
77
112
      const llvm::Triple &triple = arch->GetTriple();
78
112
      llvm::Triple::VendorType vendor = triple.getVendor();
79
112
      switch (vendor) {
80
14
      case llvm::Triple::Apple:
81
14
        create = true;
82
14
        break;
83
84
0
#if defined(__APPLE__)
85
      // Only accept "unknown" for the vendor if the host is Apple and
86
      // "unknown" wasn't specified (it was just returned because it was NOT
87
      // specified)
88
92
      case llvm::Triple::UnknownVendor:
89
92
        create = !arch->TripleVendorWasSpecified();
90
92
        break;
91
92
0
#endif
93
6
      default:
94
6
        break;
95
112
      }
96
112
      if (create) {
97
50
        switch (triple.getOS()) {
98
0
        case llvm::Triple::Darwin: // Deprecated, but still support Darwin for
99
                                   // historical reasons
100
1
        case llvm::Triple::IOS:    // This is the right triple value for iOS
101
                                   // debugging
102
1
          break;
103
104
49
        default:
105
49
          create = false;
106
49
          break;
107
50
        }
108
50
      }
109
112
    } break;
110
119
    default:
111
119
      break;
112
231
    }
113
231
  }
114
115
236
  if (create) {
116
6
    if (log)
117
0
      LLDB_LOGF(log, "PlatformRemoteiOS::%s() creating platform", __FUNCTION__);
118
119
6
    return lldb::PlatformSP(new PlatformRemoteiOS());
120
6
  }
121
122
230
  if (log)
123
0
    LLDB_LOGF(log, "PlatformRemoteiOS::%s() aborting creation of platform",
124
230
              __FUNCTION__);
125
126
230
  return lldb::PlatformSP();
127
236
}
128
129
3.94k
llvm::StringRef PlatformRemoteiOS::GetDescriptionStatic() {
130
3.94k
  return "Remote iOS platform plug-in.";
131
3.94k
}
132
133
/// Default Constructor
134
PlatformRemoteiOS::PlatformRemoteiOS()
135
6
    : PlatformRemoteDarwinDevice() {}
136
137
std::vector<ArchSpec> PlatformRemoteiOS::GetSupportedArchitectures(
138
7
    const ArchSpec &process_host_arch) {
139
7
  std::vector<ArchSpec> result;
140
7
  ARMGetSupportedArchitectures(result, llvm::Triple::IOS);
141
7
  return result;
142
7
}
143
144
0
bool PlatformRemoteiOS::CheckLocalSharedCache() const {
145
  // You can run iPhone and iPad apps on Mac with Apple Silicon. At the
146
  // platform level there's no way to distinguish them from remote iOS
147
  // applications. Make sure we still read from our own shared cache.
148
0
  return true;
149
0
}
150
151
0
llvm::StringRef PlatformRemoteiOS::GetDeviceSupportDirectoryName() {
152
0
  return "iOS DeviceSupport";
153
0
}
154
155
0
llvm::StringRef PlatformRemoteiOS::GetPlatformName() {
156
0
  return "iPhoneOS.platform";
157
0
}