Coverage Report

Created: 2022-01-15 10:30

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