Coverage Report

Created: 2022-01-18 06:27

/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/include/lldb/Host/HostInfoBase.h
Line
Count
Source (jump to first uncovered line)
1
//===-- HostInfoBase.h ------------------------------------------*- C++ -*-===//
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
#ifndef LLDB_HOST_HOSTINFOBASE_H
10
#define LLDB_HOST_HOSTINFOBASE_H
11
12
#include "lldb/Utility/ArchSpec.h"
13
#include "lldb/Utility/FileSpec.h"
14
#include "lldb/Utility/UUID.h"
15
#include "lldb/Utility/UserIDResolver.h"
16
#include "lldb/Utility/XcodeSDK.h"
17
#include "lldb/lldb-enumerations.h"
18
#include "llvm/ADT/StringRef.h"
19
20
#include <cstdint>
21
22
#include <string>
23
24
namespace lldb_private {
25
26
class FileSpec;
27
28
struct SharedCacheImageInfo {
29
  UUID uuid;
30
  lldb::DataBufferSP data_sp;
31
};
32
33
class HostInfoBase {
34
private:
35
  // Static class, unconstructable.
36
  HostInfoBase() = default;
37
  ~HostInfoBase() = default;
38
39
public:
40
  /// A helper function for determining the liblldb location. It receives a
41
  /// FileSpec with the location of file containing _this_ code. It can
42
  /// (optionally) replace it with a file spec pointing to a more canonical
43
  /// copy.
44
  using SharedLibraryDirectoryHelper = void(FileSpec &this_file);
45
46
  static void Initialize(SharedLibraryDirectoryHelper *helper = nullptr);
47
  static void Terminate();
48
49
  /// Gets the host target triple.
50
  ///
51
  /// \return
52
  ///     The host target triple.
53
  static llvm::Triple GetTargetTriple();
54
55
  enum ArchitectureKind {
56
    eArchKindDefault, // The overall default architecture that applications will
57
                      // run on this host
58
    eArchKind32, // If this host supports 32 bit programs, return the default 32
59
                 // bit arch
60
    eArchKind64  // If this host supports 64 bit programs, return the default 64
61
                 // bit arch
62
  };
63
64
  static const ArchSpec &
65
  GetArchitecture(ArchitectureKind arch_kind = eArchKindDefault);
66
67
  static llvm::Optional<ArchitectureKind> ParseArchitectureKind(llvm::StringRef kind);
68
69
  /// Returns the directory containing the lldb shared library. Only the
70
  /// directory member of the FileSpec is filled in.
71
  static FileSpec GetShlibDir();
72
73
  /// Returns the directory containing the support executables (debugserver,
74
  /// ...). Only the directory member of the FileSpec is filled in.
75
  static FileSpec GetSupportExeDir();
76
77
  /// Returns the directory containing the lldb headers. Only the directory
78
  /// member of the FileSpec is filled in.
79
  static FileSpec GetHeaderDir();
80
81
  /// Returns the directory containing the system plugins. Only the directory
82
  /// member of the FileSpec is filled in.
83
  static FileSpec GetSystemPluginDir();
84
85
  /// Returns the directory containing the user plugins. Only the directory
86
  /// member of the FileSpec is filled in.
87
  static FileSpec GetUserPluginDir();
88
89
  /// Returns the proces temporary directory. This directory will be cleaned up
90
  /// when this process exits. Only the directory member of the FileSpec is
91
  /// filled in.
92
  static FileSpec GetProcessTempDir();
93
94
  /// Returns the global temporary directory. This directory will **not** be
95
  /// cleaned up when this process exits. Only the directory member of the
96
  /// FileSpec is filled in.
97
  static FileSpec GetGlobalTempDir();
98
99
  /// If the triple does not specify the vendor, os, and environment parts, we
100
  /// "augment" these using information from the host and return the resulting
101
  /// ArchSpec object.
102
  static ArchSpec GetAugmentedArchSpec(llvm::StringRef triple);
103
104
  static bool ComputePathRelativeToLibrary(FileSpec &file_spec,
105
                                           llvm::StringRef dir);
106
107
0
  static FileSpec GetXcodeContentsDirectory() { return {}; }
108
0
  static FileSpec GetXcodeDeveloperDirectory() { return {}; }
109
  
110
  /// Return the directory containing a specific Xcode SDK.
111
0
  static llvm::StringRef GetXcodeSDKPath(XcodeSDK sdk) { return {}; }
112
113
  /// Return information about module \p image_name if it is loaded in
114
  /// the current process's address space.
115
  static SharedCacheImageInfo
116
0
  GetSharedCacheImageInfo(llvm::StringRef image_name) {
117
0
    return {};
118
0
  }
119
120
protected:
121
  static bool ComputeSharedLibraryDirectory(FileSpec &file_spec);
122
  static bool ComputeSupportExeDirectory(FileSpec &file_spec);
123
  static bool ComputeProcessTempFileDirectory(FileSpec &file_spec);
124
  static bool ComputeGlobalTempFileDirectory(FileSpec &file_spec);
125
  static bool ComputeTempFileBaseDirectory(FileSpec &file_spec);
126
  static bool ComputeHeaderDirectory(FileSpec &file_spec);
127
  static bool ComputeSystemPluginsDirectory(FileSpec &file_spec);
128
  static bool ComputeUserPluginsDirectory(FileSpec &file_spec);
129
130
  static void ComputeHostArchitectureSupport(ArchSpec &arch_32,
131
                                             ArchSpec &arch_64);
132
};
133
}
134
135
#endif