aboutsummaryrefslogtreecommitdiff
path: root/include/lldb/Host/HostInfoBase.h
blob: 74ac79b690b9974e33e0df077bfc3cc7b7523c72 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
//===-- HostInfoBase.h ------------------------------------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#ifndef lldb_Host_HostInfoBase_h_
#define lldb_Host_HostInfoBase_h_

#include "lldb/Core/ArchSpec.h"
#include "lldb/Host/FileSpec.h"
#include "lldb/lldb-enumerations.h"

#include "llvm/ADT/StringRef.h"

#include <stdint.h>

#include <string>

namespace lldb_private {

class FileSpec;

class HostInfoBase {
private:
  // Static class, unconstructable.
  HostInfoBase() {}
  ~HostInfoBase() {}

public:
  static void Initialize();
  static void Terminate();

  //------------------------------------------------------------------
  /// Returns the number of CPUs on this current host.
  ///
  /// @return
  ///     Number of CPUs on this current host, or zero if the number
  ///     of CPUs can't be determined on this host.
  //------------------------------------------------------------------
  static uint32_t GetNumberCPUS();

  //------------------------------------------------------------------
  /// Returns the maximum length of a thread name on this platform.
  ///
  /// @return
  ///     Maximum length of a thread name on this platform.
  //------------------------------------------------------------------
  static uint32_t GetMaxThreadNameLength();

  //------------------------------------------------------------------
  /// Gets the host vendor string.
  ///
  /// @return
  ///     A const string object containing the host vendor name.
  //------------------------------------------------------------------
  static llvm::StringRef GetVendorString();

  //------------------------------------------------------------------
  /// Gets the host Operating System (OS) string.
  ///
  /// @return
  ///     A const string object containing the host OS name.
  //------------------------------------------------------------------
  static llvm::StringRef GetOSString();

  //------------------------------------------------------------------
  /// Gets the host target triple as a const string.
  ///
  /// @return
  ///     A const string object containing the host target triple.
  //------------------------------------------------------------------
  static llvm::StringRef GetTargetTriple();

  //------------------------------------------------------------------
  /// Gets the host architecture.
  ///
  /// @return
  ///     A const architecture object that represents the host
  ///     architecture.
  //------------------------------------------------------------------
  enum ArchitectureKind {
    eArchKindDefault, // The overall default architecture that applications will
                      // run on this host
    eArchKind32, // If this host supports 32 bit programs, return the default 32
                 // bit arch
    eArchKind64  // If this host supports 64 bit programs, return the default 64
                 // bit arch
  };

  static const ArchSpec &
  GetArchitecture(ArchitectureKind arch_kind = eArchKindDefault);

  //------------------------------------------------------------------
  /// Find a resource files that are related to LLDB.
  ///
  /// Operating systems have different ways of storing shared
  /// libraries and related resources. This function abstracts the
  /// access to these paths.
  ///
  /// @param[in] path_type
  ///     The type of LLDB resource path you are looking for. If the
  ///     enumeration ends with "Dir", then only the \a file_spec's
  ///     directory member gets filled in.
  ///
  /// @param[in] file_spec
  ///     A file spec that gets filled in with the appropriate path.
  ///
  /// @return
  ///     \b true if \a resource_path was resolved, \a false otherwise.
  //------------------------------------------------------------------
  static bool GetLLDBPath(lldb::PathType type, FileSpec &file_spec);

protected:
  static bool ComputeSharedLibraryDirectory(FileSpec &file_spec);
  static bool ComputeSupportExeDirectory(FileSpec &file_spec);
  static bool ComputeProcessTempFileDirectory(FileSpec &file_spec);
  static bool ComputeGlobalTempFileDirectory(FileSpec &file_spec);
  static bool ComputeTempFileBaseDirectory(FileSpec &file_spec);
  static bool ComputeHeaderDirectory(FileSpec &file_spec);
  static bool ComputeSystemPluginsDirectory(FileSpec &file_spec);
  static bool ComputeClangDirectory(FileSpec &file_spec);
  static bool ComputeUserPluginsDirectory(FileSpec &file_spec);

  static void ComputeHostArchitectureSupport(ArchSpec &arch_32,
                                             ArchSpec &arch_64);
};
}

#endif