]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Host/HostInfoBase.h
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / 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/Utility/ArchSpec.h"
14 #include "lldb/Utility/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   /// Gets the host target triple as a const string.
39   ///
40   /// @return
41   ///     A const string object containing the host target triple.
42   //------------------------------------------------------------------
43   static llvm::StringRef GetTargetTriple();
44
45   //------------------------------------------------------------------
46   /// Gets the host architecture.
47   ///
48   /// @return
49   ///     A const architecture object that represents the host
50   ///     architecture.
51   //------------------------------------------------------------------
52   enum ArchitectureKind {
53     eArchKindDefault, // The overall default architecture that applications will
54                       // run on this host
55     eArchKind32, // If this host supports 32 bit programs, return the default 32
56                  // bit arch
57     eArchKind64  // If this host supports 64 bit programs, return the default 64
58                  // bit arch
59   };
60
61   static const ArchSpec &
62   GetArchitecture(ArchitectureKind arch_kind = eArchKindDefault);
63
64   static llvm::Optional<ArchitectureKind> ParseArchitectureKind(llvm::StringRef kind);
65
66   /// Returns the directory containing the lldb shared library. Only the
67   /// directory member of the FileSpec is filled in.
68   static FileSpec GetShlibDir();
69
70   /// Returns the directory containing the support executables (debugserver,
71   /// ...). Only the directory member of the FileSpec is filled in.
72   static FileSpec GetSupportExeDir();
73
74   /// Returns the directory containing the lldb headers. Only the directory
75   /// member of the FileSpec is filled in.
76   static FileSpec GetHeaderDir();
77
78   /// Returns the directory containing the system plugins. Only the directory
79   /// member of the FileSpec is filled in.
80   static FileSpec GetSystemPluginDir();
81
82   /// Returns the directory containing the user plugins. Only the directory
83   /// member of the FileSpec is filled in.
84   static FileSpec GetUserPluginDir();
85
86   /// Returns the proces temporary directory. This directory will be cleaned up
87   /// when this process exits. Only the directory member of the FileSpec is
88   /// filled in.
89   static FileSpec GetProcessTempDir();
90
91   /// Returns the global temporary directory. This directory will **not** be
92   /// cleaned up when this process exits. Only the directory member of the
93   /// FileSpec is filled in.
94   static FileSpec GetGlobalTempDir();
95
96   //---------------------------------------------------------------------------
97   /// If the triple does not specify the vendor, os, and environment parts, we
98   /// "augment" these using information from the host and return the resulting
99   /// ArchSpec object.
100   //---------------------------------------------------------------------------
101   static ArchSpec GetAugmentedArchSpec(llvm::StringRef triple);
102
103 protected:
104   static bool ComputeSharedLibraryDirectory(FileSpec &file_spec);
105   static bool ComputeSupportExeDirectory(FileSpec &file_spec);
106   static bool ComputeProcessTempFileDirectory(FileSpec &file_spec);
107   static bool ComputeGlobalTempFileDirectory(FileSpec &file_spec);
108   static bool ComputeTempFileBaseDirectory(FileSpec &file_spec);
109   static bool ComputeHeaderDirectory(FileSpec &file_spec);
110   static bool ComputeSystemPluginsDirectory(FileSpec &file_spec);
111   static bool ComputeUserPluginsDirectory(FileSpec &file_spec);
112
113   static void ComputeHostArchitectureSupport(ArchSpec &arch_32,
114                                              ArchSpec &arch_64);
115 };
116 }
117
118 #endif