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"
14 #include "lldb/Utility/UUID.h"
16 #include "lldb/Utility/XcodeSDK.h"
17 #include "lldb/lldb-enumerations.h"
18 #include "llvm/ADT/StringRef.h"
19 
20 #include <cstdint>
21 
22 #include <string>
23 
24 namespace lldb_private {
25 
26 class FileSpec;
27 
30  lldb::DataBufferSP data_sp;
31 };
32 
33 class HostInfoBase {
34 private:
35  // Static class, unconstructable.
38 
39 public:
40  /// A helper function for determining the liblldb location. It receives a
41  /// FileSpec with the location of file containing _this_ code. It can
42  /// (optionally) replace it with a file spec pointing to a more canonical
43  /// copy.
44  using SharedLibraryDirectoryHelper = void(FileSpec &this_file);
45 
46  static void Initialize(SharedLibraryDirectoryHelper *helper = nullptr);
47  static void Terminate();
48 
49  /// Gets the host target triple.
50  ///
51  /// \return
52  /// The host target triple.
53  static llvm::Triple GetTargetTriple();
54 
56  eArchKindDefault, // The overall default architecture that applications will
57  // run on this host
58  eArchKind32, // If this host supports 32 bit programs, return the default 32
59  // bit arch
60  eArchKind64 // If this host supports 64 bit programs, return the default 64
61  // bit arch
62  };
63 
64  static const ArchSpec &
66 
67  static llvm::Optional<ArchitectureKind> ParseArchitectureKind(llvm::StringRef kind);
68 
69  /// Returns the directory containing the lldb shared library. Only the
70  /// directory member of the FileSpec is filled in.
71  static FileSpec GetShlibDir();
72 
73  /// Returns the directory containing the support executables (debugserver,
74  /// ...). Only the directory member of the FileSpec is filled in.
75  static FileSpec GetSupportExeDir();
76 
77  /// Returns the directory containing the lldb headers. Only the directory
78  /// member of the FileSpec is filled in.
79  static FileSpec GetHeaderDir();
80 
81  /// Returns the directory containing the system plugins. Only the directory
82  /// member of the FileSpec is filled in.
84 
85  /// Returns the directory containing the user plugins. Only the directory
86  /// member of the FileSpec is filled in.
87  static FileSpec GetUserPluginDir();
88 
89  /// Returns the proces temporary directory. This directory will be cleaned up
90  /// when this process exits. Only the directory member of the FileSpec is
91  /// filled in.
92  static FileSpec GetProcessTempDir();
93 
94  /// Returns the global temporary directory. This directory will **not** be
95  /// cleaned up when this process exits. Only the directory member of the
96  /// FileSpec is filled in.
97  static FileSpec GetGlobalTempDir();
98 
99  /// If the triple does not specify the vendor, os, and environment parts, we
100  /// "augment" these using information from the host and return the resulting
101  /// ArchSpec object.
102  static ArchSpec GetAugmentedArchSpec(llvm::StringRef triple);
103 
104  static bool ComputePathRelativeToLibrary(FileSpec &file_spec,
105  llvm::StringRef dir);
106 
107  static FileSpec GetXcodeContentsDirectory() { return {}; }
108  static FileSpec GetXcodeDeveloperDirectory() { return {}; }
109 
110  /// Return the directory containing a specific Xcode SDK.
111  static llvm::StringRef GetXcodeSDKPath(XcodeSDK sdk) { return {}; }
112 
113  /// Return information about module \p image_name if it is loaded in
114  /// the current process's address space.
115  static SharedCacheImageInfo
116  GetSharedCacheImageInfo(llvm::StringRef image_name) {
117  return {};
118  }
119 
120 protected:
121  static bool ComputeSharedLibraryDirectory(FileSpec &file_spec);
122  static bool ComputeSupportExeDirectory(FileSpec &file_spec);
123  static bool ComputeProcessTempFileDirectory(FileSpec &file_spec);
124  static bool ComputeGlobalTempFileDirectory(FileSpec &file_spec);
125  static bool ComputeTempFileBaseDirectory(FileSpec &file_spec);
126  static bool ComputeHeaderDirectory(FileSpec &file_spec);
127  static bool ComputeSystemPluginsDirectory(FileSpec &file_spec);
128  static bool ComputeUserPluginsDirectory(FileSpec &file_spec);
129 
130  static void ComputeHostArchitectureSupport(ArchSpec &arch_32,
131  ArchSpec &arch_64);
132 };
133 }
134 
135 #endif
lldb_private::HostInfoBase::GetHeaderDir
static FileSpec GetHeaderDir()
Returns the directory containing the lldb headers.
Definition: HostInfoBase.cpp:143
lldb_private::UUID
Definition: UUID.h:23
lldb_private::ArchSpec
Definition: ArchSpec.h:33
UUID.h
lldb_private::HostInfoBase::ParseArchitectureKind
static llvm::Optional< ArchitectureKind > ParseArchitectureKind(llvm::StringRef kind)
Definition: HostInfoBase.cpp:115
lldb_private::HostInfoBase::ComputeUserPluginsDirectory
static bool ComputeUserPluginsDirectory(FileSpec &file_spec)
Definition: HostInfoBase.cpp:320
lldb_private::HostInfoBase::Initialize
static void Initialize(SharedLibraryDirectoryHelper *helper=nullptr)
Definition: HostInfoBase.cpp:79
lldb_private::HostInfoBase::GetProcessTempDir
static FileSpec GetProcessTempDir()
Returns the proces temporary directory.
Definition: HostInfoBase.cpp:174
lldb_private::XcodeSDK
An abstraction for Xcode-style SDKs that works like ArchSpec.
Definition: XcodeSDK.h:24
lldb_private::HostInfoBase::eArchKindDefault
@ eArchKindDefault
Definition: HostInfoBase.h:56
lldb_private::HostInfoBase::SharedLibraryDirectoryHelper
void(FileSpec &this_file) SharedLibraryDirectoryHelper
A helper function for determining the liblldb location.
Definition: HostInfoBase.h:44
lldb_private::HostInfoBase::ComputeHeaderDirectory
static bool ComputeHeaderDirectory(FileSpec &file_spec)
Definition: HostInfoBase.cpp:308
lldb_private::HostInfoBase::eArchKind32
@ eArchKind32
Definition: HostInfoBase.h:58
XcodeSDK.h
lldb_private::HostInfoBase::GetAugmentedArchSpec
static ArchSpec GetAugmentedArchSpec(llvm::StringRef triple)
If the triple does not specify the vendor, os, and environment parts, we "augment" these using inform...
Definition: HostInfoBase.cpp:196
lldb_private::HostInfoBase::ComputeGlobalTempFileDirectory
static bool ComputeGlobalTempFileDirectory(FileSpec &file_spec)
Definition: HostInfoBase.cpp:293
lldb_private::FileSpec
Definition: FileSpec.h:56
lldb_private::HostInfoBase::ComputeTempFileBaseDirectory
static bool ComputeTempFileBaseDirectory(FileSpec &file_spec)
Definition: HostInfoBase.cpp:285
lldb_private::HostInfoBase::GetUserPluginDir
static FileSpec GetUserPluginDir()
Returns the directory containing the user plugins.
Definition: HostInfoBase.cpp:164
lldb_private::HostInfoBase::GetSystemPluginDir
static FileSpec GetSystemPluginDir()
Returns the directory containing the system plugins.
Definition: HostInfoBase.cpp:153
lldb_private::HostInfoBase::GetShlibDir
static FileSpec GetShlibDir()
Returns the directory containing the lldb shared library.
Definition: HostInfoBase.cpp:123
lldb_private::HostInfoBase::GetSharedCacheImageInfo
static SharedCacheImageInfo GetSharedCacheImageInfo(llvm::StringRef image_name)
Return information about module image_name if it is loaded in the current process's address space.
Definition: HostInfoBase.h:116
lldb_private::HostInfoBase::ComputeProcessTempFileDirectory
static bool ComputeProcessTempFileDirectory(FileSpec &file_spec)
Definition: HostInfoBase.cpp:271
lldb_private::HostInfoBase::GetGlobalTempDir
static FileSpec GetGlobalTempDir()
Returns the global temporary directory.
Definition: HostInfoBase.cpp:185
lldb_private::HostInfoBase::GetArchitecture
static const ArchSpec & GetArchitecture(ArchitectureKind arch_kind=eArchKindDefault)
Definition: HostInfoBase.cpp:98
lldb_private::HostInfoBase::ComputePathRelativeToLibrary
static bool ComputePathRelativeToLibrary(FileSpec &file_spec, llvm::StringRef dir)
Definition: HostInfoBase.cpp:217
lldb-enumerations.h
lldb_private::HostInfoBase::ComputeSupportExeDirectory
static bool ComputeSupportExeDirectory(FileSpec &file_spec)
Definition: HostInfoBase.cpp:266
lldb_private::HostInfoBase::HostInfoBase
HostInfoBase()
Definition: HostInfoBase.h:36
lldb_private::HostInfoBase::ComputeSharedLibraryDirectory
static bool ComputeSharedLibraryDirectory(FileSpec &file_spec)
Definition: HostInfoBase.cpp:248
lldb_private::HostInfoBase::GetXcodeSDKPath
static llvm::StringRef GetXcodeSDKPath(XcodeSDK sdk)
Return the directory containing a specific Xcode SDK.
Definition: HostInfoBase.h:111
UserIDResolver.h
lldb_private::HostInfoBase::ComputeHostArchitectureSupport
static void ComputeHostArchitectureSupport(ArchSpec &arch_32, ArchSpec &arch_64)
Definition: HostInfoBase.cpp:326
lldb_private::SharedCacheImageInfo
Definition: HostInfoBase.h:28
lldb_private::HostInfoBase::eArchKind64
@ eArchKind64
Definition: HostInfoBase.h:60
lldb_private::HostInfoBase::GetSupportExeDir
static FileSpec GetSupportExeDir()
Returns the directory containing the support executables (debugserver, ...).
Definition: HostInfoBase.cpp:133
lldb_private::HostInfoBase
Definition: HostInfoBase.h:33
lldb_private::SharedCacheImageInfo::uuid
UUID uuid
Definition: HostInfoBase.h:29
lldb_private::SharedCacheImageInfo::data_sp
lldb::DataBufferSP data_sp
Definition: HostInfoBase.h:30
ArchSpec.h
lldb_private::HostInfoBase::ComputeSystemPluginsDirectory
static bool ComputeSystemPluginsDirectory(FileSpec &file_spec)
Definition: HostInfoBase.cpp:314
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
FileSpec.h
lldb_private::HostInfoBase::GetTargetTriple
static llvm::Triple GetTargetTriple()
Gets the host target triple.
Definition: HostInfoBase.cpp:90
lldb_private::HostInfoBase::GetXcodeContentsDirectory
static FileSpec GetXcodeContentsDirectory()
Definition: HostInfoBase.h:107
lldb_private::HostInfoBase::GetXcodeDeveloperDirectory
static FileSpec GetXcodeDeveloperDirectory()
Definition: HostInfoBase.h:108
lldb_private::HostInfoBase::ArchitectureKind
ArchitectureKind
Definition: HostInfoBase.h:55
lldb_private::HostInfoBase::~HostInfoBase
~HostInfoBase()
Definition: HostInfoBase.h:37
lldb_private::HostInfoBase::Terminate
static void Terminate()
Definition: HostInfoBase.cpp:84