]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm-project/lldb/include/lldb/Host/HostInfoBase.h
MFC r355940:
[FreeBSD/FreeBSD.git] / contrib / llvm-project / lldb / include / lldb / Host / HostInfoBase.h
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/UserIDResolver.h"
15 #include "lldb/lldb-enumerations.h"
16 #include "llvm/ADT/StringRef.h"
17
18 #include <stdint.h>
19
20 #include <string>
21
22 namespace lldb_private {
23
24 class FileSpec;
25
26 class HostInfoBase {
27 private:
28   // Static class, unconstructable.
29   HostInfoBase() {}
30   ~HostInfoBase() {}
31
32 public:
33   static void Initialize();
34   static void Terminate();
35
36   /// Gets the host target triple as a const string.
37   ///
38   /// \return
39   ///     A const string object containing the host target triple.
40   static llvm::StringRef GetTargetTriple();
41
42   /// Gets the host architecture.
43   ///
44   /// \return
45   ///     A const architecture object that represents the host
46   ///     architecture.
47   enum ArchitectureKind {
48     eArchKindDefault, // The overall default architecture that applications will
49                       // run on this host
50     eArchKind32, // If this host supports 32 bit programs, return the default 32
51                  // bit arch
52     eArchKind64  // If this host supports 64 bit programs, return the default 64
53                  // bit arch
54   };
55
56   static const ArchSpec &
57   GetArchitecture(ArchitectureKind arch_kind = eArchKindDefault);
58
59   static llvm::Optional<ArchitectureKind> ParseArchitectureKind(llvm::StringRef kind);
60
61   /// Returns the directory containing the lldb shared library. Only the
62   /// directory member of the FileSpec is filled in.
63   static FileSpec GetShlibDir();
64
65   /// Returns the directory containing the support executables (debugserver,
66   /// ...). Only the directory member of the FileSpec is filled in.
67   static FileSpec GetSupportExeDir();
68
69   /// Returns the directory containing the lldb headers. Only the directory
70   /// member of the FileSpec is filled in.
71   static FileSpec GetHeaderDir();
72
73   /// Returns the directory containing the system plugins. Only the directory
74   /// member of the FileSpec is filled in.
75   static FileSpec GetSystemPluginDir();
76
77   /// Returns the directory containing the user plugins. Only the directory
78   /// member of the FileSpec is filled in.
79   static FileSpec GetUserPluginDir();
80
81   /// Returns the proces temporary directory. This directory will be cleaned up
82   /// when this process exits. Only the directory member of the FileSpec is
83   /// filled in.
84   static FileSpec GetProcessTempDir();
85
86   /// Returns the global temporary directory. This directory will **not** be
87   /// cleaned up when this process exits. Only the directory member of the
88   /// FileSpec is filled in.
89   static FileSpec GetGlobalTempDir();
90
91   /// If the triple does not specify the vendor, os, and environment parts, we
92   /// "augment" these using information from the host and return the resulting
93   /// ArchSpec object.
94   static ArchSpec GetAugmentedArchSpec(llvm::StringRef triple);
95
96   static bool ComputePathRelativeToLibrary(FileSpec &file_spec,
97                                            llvm::StringRef dir);
98
99 protected:
100   static bool ComputeSharedLibraryDirectory(FileSpec &file_spec);
101   static bool ComputeSupportExeDirectory(FileSpec &file_spec);
102   static bool ComputeProcessTempFileDirectory(FileSpec &file_spec);
103   static bool ComputeGlobalTempFileDirectory(FileSpec &file_spec);
104   static bool ComputeTempFileBaseDirectory(FileSpec &file_spec);
105   static bool ComputeHeaderDirectory(FileSpec &file_spec);
106   static bool ComputeSystemPluginsDirectory(FileSpec &file_spec);
107   static bool ComputeUserPluginsDirectory(FileSpec &file_spec);
108
109   static void ComputeHostArchitectureSupport(ArchSpec &arch_32,
110                                              ArchSpec &arch_64);
111 };
112 }
113
114 #endif