LLDB  mainline
HostInfoBase.h
Go to the documentation of this file.
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"
15 #include "lldb/Utility/XcodeSDK.h"
16 #include "lldb/lldb-enumerations.h"
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.
32 
33 public:
34  static void Initialize();
35  static void Terminate();
36 
37  /// Gets the host target triple.
38  ///
39  /// \return
40  /// The host target triple.
41  static llvm::Triple GetTargetTriple();
42 
44  eArchKindDefault, // The overall default architecture that applications will
45  // run on this host
46  eArchKind32, // If this host supports 32 bit programs, return the default 32
47  // bit arch
48  eArchKind64 // If this host supports 64 bit programs, return the default 64
49  // bit arch
50  };
51 
52  static const ArchSpec &
54 
55  static llvm::Optional<ArchitectureKind> ParseArchitectureKind(llvm::StringRef kind);
56 
57  /// Returns the directory containing the lldb shared library. Only the
58  /// directory member of the FileSpec is filled in.
59  static FileSpec GetShlibDir();
60 
61  /// Returns the directory containing the support executables (debugserver,
62  /// ...). Only the directory member of the FileSpec is filled in.
63  static FileSpec GetSupportExeDir();
64 
65  /// Returns the directory containing the lldb headers. Only the directory
66  /// member of the FileSpec is filled in.
67  static FileSpec GetHeaderDir();
68 
69  /// Returns the directory containing the system plugins. Only the directory
70  /// member of the FileSpec is filled in.
72 
73  /// Returns the directory containing the user plugins. Only the directory
74  /// member of the FileSpec is filled in.
75  static FileSpec GetUserPluginDir();
76 
77  /// Returns the proces temporary directory. This directory will be cleaned up
78  /// when this process exits. Only the directory member of the FileSpec is
79  /// filled in.
80  static FileSpec GetProcessTempDir();
81 
82  /// Returns the global temporary directory. This directory will **not** be
83  /// cleaned up when this process exits. Only the directory member of the
84  /// FileSpec is filled in.
85  static FileSpec GetGlobalTempDir();
86 
87  /// If the triple does not specify the vendor, os, and environment parts, we
88  /// "augment" these using information from the host and return the resulting
89  /// ArchSpec object.
90  static ArchSpec GetAugmentedArchSpec(llvm::StringRef triple);
91 
92  static bool ComputePathRelativeToLibrary(FileSpec &file_spec,
93  llvm::StringRef dir);
94 
95  static FileSpec GetXcodeContentsDirectory() { return {}; }
96  static FileSpec GetXcodeDeveloperDirectory() { return {}; }
97 
98  /// Return the directory containing a specific Xcode SDK.
99  static llvm::StringRef GetXcodeSDKPath(XcodeSDK sdk) { return {}; }
100 
101 protected:
102  static bool ComputeSharedLibraryDirectory(FileSpec &file_spec);
103  static bool ComputeSupportExeDirectory(FileSpec &file_spec);
104  static bool ComputeProcessTempFileDirectory(FileSpec &file_spec);
105  static bool ComputeGlobalTempFileDirectory(FileSpec &file_spec);
106  static bool ComputeTempFileBaseDirectory(FileSpec &file_spec);
107  static bool ComputeHeaderDirectory(FileSpec &file_spec);
108  static bool ComputeSystemPluginsDirectory(FileSpec &file_spec);
109  static bool ComputeUserPluginsDirectory(FileSpec &file_spec);
110 
111  static void ComputeHostArchitectureSupport(ArchSpec &arch_32,
112  ArchSpec &arch_64);
113 };
114 }
115 
116 #endif
static bool ComputeTempFileBaseDirectory(FileSpec &file_spec)
static FileSpec GetProcessTempDir()
Returns the proces temporary directory.
A class that represents a running process on the host machine.
static bool ComputeProcessTempFileDirectory(FileSpec &file_spec)
static void ComputeHostArchitectureSupport(ArchSpec &arch_32, ArchSpec &arch_64)
static bool ComputeSharedLibraryDirectory(FileSpec &file_spec)
A file utility class.
Definition: FileSpec.h:56
An architecture specification class.
Definition: ArchSpec.h:33
static bool ComputeUserPluginsDirectory(FileSpec &file_spec)
static bool ComputePathRelativeToLibrary(FileSpec &file_spec, llvm::StringRef dir)
static bool ComputeSystemPluginsDirectory(FileSpec &file_spec)
static FileSpec GetGlobalTempDir()
Returns the global temporary directory.
static FileSpec GetShlibDir()
Returns the directory containing the lldb shared library.
static FileSpec GetXcodeDeveloperDirectory()
Definition: HostInfoBase.h:96
static llvm::StringRef GetXcodeSDKPath(XcodeSDK sdk)
Return the directory containing a specific Xcode SDK.
Definition: HostInfoBase.h:99
static bool ComputeSupportExeDirectory(FileSpec &file_spec)
static FileSpec GetSupportExeDir()
Returns the directory containing the support executables (debugserver, ...).
static bool ComputeHeaderDirectory(FileSpec &file_spec)
static FileSpec GetHeaderDir()
Returns the directory containing the lldb headers.
static bool ComputeGlobalTempFileDirectory(FileSpec &file_spec)
An abstraction for Xcode-style SDKs that works like ArchSpec.
Definition: XcodeSDK.h:24
static FileSpec GetXcodeContentsDirectory()
Definition: HostInfoBase.h:95
static FileSpec GetSystemPluginDir()
Returns the directory containing the system plugins.
static ArchSpec GetAugmentedArchSpec(llvm::StringRef triple)
If the triple does not specify the vendor, os, and environment parts, we "augment" these using inform...
static llvm::Triple GetTargetTriple()
Gets the host target triple.
static FileSpec GetUserPluginDir()
Returns the directory containing the user plugins.
static llvm::Optional< ArchitectureKind > ParseArchitectureKind(llvm::StringRef kind)
static const ArchSpec & GetArchitecture(ArchitectureKind arch_kind=eArchKindDefault)