Coverage Report

Created: 2022-01-18 06:27

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