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