Coverage Report

Created: 2022-01-22 13:19

/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp
Line
Count
Source (jump to first uncovered line)
1
//===-- PlatformRemoteAppleTV.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
12
#include "PlatformRemoteAppleTV.h"
13
14
#include "lldb/Breakpoint/BreakpointLocation.h"
15
#include "lldb/Core/Module.h"
16
#include "lldb/Core/ModuleList.h"
17
#include "lldb/Core/ModuleSpec.h"
18
#include "lldb/Core/PluginManager.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/Log.h"
25
#include "lldb/Utility/Status.h"
26
#include "lldb/Utility/StreamString.h"
27
28
using namespace lldb;
29
using namespace lldb_private;
30
31
/// Default Constructor
32
PlatformRemoteAppleTV::PlatformRemoteAppleTV()
33
0
    : PlatformRemoteDarwinDevice () {}
34
35
// Static Variables
36
static uint32_t g_initialize_count = 0;
37
38
// Static Functions
39
3.44k
void PlatformRemoteAppleTV::Initialize() {
40
3.44k
  PlatformDarwin::Initialize();
41
42
3.44k
  if (g_initialize_count++ == 0) {
43
3.44k
    PluginManager::RegisterPlugin(PlatformRemoteAppleTV::GetPluginNameStatic(),
44
3.44k
                                  PlatformRemoteAppleTV::GetDescriptionStatic(),
45
3.44k
                                  PlatformRemoteAppleTV::CreateInstance);
46
3.44k
  }
47
3.44k
}
48
49
3.43k
void PlatformRemoteAppleTV::Terminate() {
50
3.43k
  if (g_initialize_count > 0) {
51
3.43k
    if (--g_initialize_count == 0) {
52
3.43k
      PluginManager::UnregisterPlugin(PlatformRemoteAppleTV::CreateInstance);
53
3.43k
    }
54
3.43k
  }
55
56
3.43k
  PlatformDarwin::Terminate();
57
3.43k
}
58
59
PlatformSP PlatformRemoteAppleTV::CreateInstance(bool force,
60
78
                                                 const ArchSpec *arch) {
61
78
  Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM));
62
78
  if (log) {
63
0
    const char *arch_name;
64
0
    if (arch && arch->GetArchitectureName())
65
0
      arch_name = arch->GetArchitectureName();
66
0
    else
67
0
      arch_name = "<null>";
68
69
0
    const char *triple_cstr =
70
0
        arch ? arch->GetTriple().getTriple().c_str() : "<null>";
71
72
0
    LLDB_LOGF(log, "PlatformRemoteAppleTV::%s(force=%s, arch={%s,%s})",
73
0
              __FUNCTION__, force ? "true" : "false", arch_name, triple_cstr);
74
0
  }
75
76
78
  bool create = force;
77
78
  if (!create && arch && arch->IsValid()) {
78
78
    switch (arch->GetMachine()) {
79
12
    case llvm::Triple::arm:
80
29
    case llvm::Triple::aarch64:
81
29
    case llvm::Triple::thumb: {
82
29
      const llvm::Triple &triple = arch->GetTriple();
83
29
      llvm::Triple::VendorType vendor = triple.getVendor();
84
29
      switch (vendor) {
85
0
      case llvm::Triple::Apple:
86
0
        create = true;
87
0
        break;
88
89
0
#if defined(__APPLE__)
90
      // Only accept "unknown" for the vendor if the host is Apple and
91
      // "unknown" wasn't specified (it was just returned because it was NOT
92
      // specified)
93
23
      case llvm::Triple::UnknownVendor:
94
23
        create = !arch->TripleVendorWasSpecified();
95
23
        break;
96
97
0
#endif
98
6
      default:
99
6
        break;
100
29
      }
101
29
      if (create) {
102
17
        switch (triple.getOS()) {
103
0
        case llvm::Triple::TvOS: // This is the right triple value for Apple TV
104
                                 // debugging
105
0
          break;
106
107
17
        default:
108
17
          create = false;
109
17
          break;
110
17
        }
111
17
      }
112
29
    } break;
113
49
    default:
114
49
      break;
115
78
    }
116
78
  }
117
118
78
  if (create) {
119
0
    LLDB_LOGF(log, "PlatformRemoteAppleTV::%s() creating platform",
120
0
              __FUNCTION__);
121
122
0
    return lldb::PlatformSP(new PlatformRemoteAppleTV());
123
0
  }
124
125
78
  LLDB_LOGF(log, "PlatformRemoteAppleTV::%s() aborting creation of platform",
126
78
            __FUNCTION__);
127
128
78
  return lldb::PlatformSP();
129
78
}
130
131
3.44k
llvm::StringRef PlatformRemoteAppleTV::GetDescriptionStatic() {
132
3.44k
  return "Remote Apple TV platform plug-in.";
133
3.44k
}
134
135
0
std::vector<ArchSpec> PlatformRemoteAppleTV::GetSupportedArchitectures() {
136
0
  ArchSpec system_arch(GetSystemArchitecture());
137
138
0
  const ArchSpec::Core system_core = system_arch.GetCore();
139
0
  switch (system_core) {
140
0
  default:
141
0
  case ArchSpec::eCore_arm_arm64:
142
0
    return {ArchSpec("arm64-apple-tvos"), ArchSpec("armv7s-apple-tvos"),
143
0
            ArchSpec("armv7-apple-tvos"), ArchSpec("thumbv7s-apple-tvos"),
144
0
            ArchSpec("thumbv7-apple-tvos")};
145
146
0
  case ArchSpec::eCore_arm_armv7s:
147
0
    return {ArchSpec("armv7s-apple-tvos"), ArchSpec("armv7-apple-tvos"),
148
0
            ArchSpec("thumbv7s-apple-tvos"), ArchSpec("thumbv7-apple-tvos")};
149
150
0
  case ArchSpec::eCore_arm_armv7:
151
0
    return {ArchSpec("armv7-apple-tvos"), ArchSpec("thumbv7-apple-tvos")};
152
0
  }
153
0
}
154
155
0
llvm::StringRef PlatformRemoteAppleTV::GetDeviceSupportDirectoryName() {
156
0
  return "tvOS DeviceSupport";
157
0
}
158
159
0
llvm::StringRef PlatformRemoteAppleTV::GetPlatformName() {
160
0
  return "AppleTVOS.platform";
161
0
}