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/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. 30 HostInfoBase() {} 31 ~HostInfoBase() {} 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 43 enum ArchitectureKind { 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 & 53 GetArchitecture(ArchitectureKind arch_kind = eArchKindDefault); 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. 71 static FileSpec GetSystemPluginDir(); 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 117