]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - include/lldb/Host/HostInfoBase.h
Vendor import of lldb trunk r290819:
[FreeBSD/FreeBSD.git] / include / lldb / Host / HostInfoBase.h
1 //===-- HostInfoBase.h ------------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef lldb_Host_HostInfoBase_h_
11 #define lldb_Host_HostInfoBase_h_
12
13 #include "lldb/Core/ArchSpec.h"
14 #include "lldb/Host/FileSpec.h"
15 #include "lldb/lldb-enumerations.h"
16
17 #include "llvm/ADT/StringRef.h"
18
19 #include <stdint.h>
20
21 #include <string>
22
23 namespace lldb_private {
24
25 class FileSpec;
26
27 class HostInfoBase {
28 private:
29   // Static class, unconstructable.
30   HostInfoBase() {}
31   ~HostInfoBase() {}
32
33 public:
34   static void Initialize();
35   static void Terminate();
36
37   //------------------------------------------------------------------
38   /// Returns the number of CPUs on this current host.
39   ///
40   /// @return
41   ///     Number of CPUs on this current host, or zero if the number
42   ///     of CPUs can't be determined on this host.
43   //------------------------------------------------------------------
44   static uint32_t GetNumberCPUS();
45
46   //------------------------------------------------------------------
47   /// Returns the maximum length of a thread name on this platform.
48   ///
49   /// @return
50   ///     Maximum length of a thread name on this platform.
51   //------------------------------------------------------------------
52   static uint32_t GetMaxThreadNameLength();
53
54   //------------------------------------------------------------------
55   /// Gets the host vendor string.
56   ///
57   /// @return
58   ///     A const string object containing the host vendor name.
59   //------------------------------------------------------------------
60   static llvm::StringRef GetVendorString();
61
62   //------------------------------------------------------------------
63   /// Gets the host Operating System (OS) string.
64   ///
65   /// @return
66   ///     A const string object containing the host OS name.
67   //------------------------------------------------------------------
68   static llvm::StringRef GetOSString();
69
70   //------------------------------------------------------------------
71   /// Gets the host target triple as a const string.
72   ///
73   /// @return
74   ///     A const string object containing the host target triple.
75   //------------------------------------------------------------------
76   static llvm::StringRef GetTargetTriple();
77
78   //------------------------------------------------------------------
79   /// Gets the host architecture.
80   ///
81   /// @return
82   ///     A const architecture object that represents the host
83   ///     architecture.
84   //------------------------------------------------------------------
85   enum ArchitectureKind {
86     eArchKindDefault, // The overall default architecture that applications will
87                       // run on this host
88     eArchKind32, // If this host supports 32 bit programs, return the default 32
89                  // bit arch
90     eArchKind64  // If this host supports 64 bit programs, return the default 64
91                  // bit arch
92   };
93
94   static const ArchSpec &
95   GetArchitecture(ArchitectureKind arch_kind = eArchKindDefault);
96
97   //------------------------------------------------------------------
98   /// Find a resource files that are related to LLDB.
99   ///
100   /// Operating systems have different ways of storing shared
101   /// libraries and related resources. This function abstracts the
102   /// access to these paths.
103   ///
104   /// @param[in] path_type
105   ///     The type of LLDB resource path you are looking for. If the
106   ///     enumeration ends with "Dir", then only the \a file_spec's
107   ///     directory member gets filled in.
108   ///
109   /// @param[in] file_spec
110   ///     A file spec that gets filled in with the appropriate path.
111   ///
112   /// @return
113   ///     \b true if \a resource_path was resolved, \a false otherwise.
114   //------------------------------------------------------------------
115   static bool GetLLDBPath(lldb::PathType type, FileSpec &file_spec);
116
117 protected:
118   static bool ComputeSharedLibraryDirectory(FileSpec &file_spec);
119   static bool ComputeSupportExeDirectory(FileSpec &file_spec);
120   static bool ComputeProcessTempFileDirectory(FileSpec &file_spec);
121   static bool ComputeGlobalTempFileDirectory(FileSpec &file_spec);
122   static bool ComputeTempFileBaseDirectory(FileSpec &file_spec);
123   static bool ComputeHeaderDirectory(FileSpec &file_spec);
124   static bool ComputeSystemPluginsDirectory(FileSpec &file_spec);
125   static bool ComputeClangDirectory(FileSpec &file_spec);
126   static bool ComputeUserPluginsDirectory(FileSpec &file_spec);
127
128   static void ComputeHostArchitectureSupport(ArchSpec &arch_32,
129                                              ArchSpec &arch_64);
130 };
131 }
132
133 #endif