File indexing completed on 2026-05-10 08:42:49
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef LLDB_HOST_HOSTINFOBASE_H
0010 #define LLDB_HOST_HOSTINFOBASE_H
0011
0012 #include "lldb/Utility/ArchSpec.h"
0013 #include "lldb/Utility/FileSpec.h"
0014 #include "lldb/Utility/UUID.h"
0015 #include "lldb/Utility/UserIDResolver.h"
0016 #include "lldb/Utility/XcodeSDK.h"
0017 #include "lldb/lldb-enumerations.h"
0018 #include "llvm/ADT/StringRef.h"
0019 #include "llvm/Support/Errc.h"
0020
0021 #include <cstdint>
0022
0023 #include <optional>
0024 #include <string>
0025
0026 namespace lldb_private {
0027
0028 class FileSpec;
0029
0030 struct SharedCacheImageInfo {
0031 UUID uuid;
0032 lldb::DataBufferSP data_sp;
0033 };
0034
0035 namespace {
0036 struct HostInfoError : public llvm::ErrorInfo<HostInfoError> {
0037 static char ID;
0038 const std::string message_;
0039
0040 HostInfoError(const std::string message) : message_(std::move(message)) {}
0041
0042 void log(llvm::raw_ostream &OS) const override { OS << "HostInfoError"; }
0043
0044 std::error_code convertToErrorCode() const override {
0045 return llvm::inconvertibleErrorCode();
0046 }
0047 };
0048
0049 char HostInfoError::ID = 0;
0050 }
0051
0052 class HostInfoBase {
0053 private:
0054
0055 HostInfoBase() = default;
0056 ~HostInfoBase() = default;
0057
0058 public:
0059
0060
0061
0062
0063 using SharedLibraryDirectoryHelper = void(FileSpec &this_file);
0064
0065 static void Initialize(SharedLibraryDirectoryHelper *helper = nullptr);
0066 static void Terminate();
0067
0068
0069
0070
0071
0072 static llvm::Triple GetTargetTriple();
0073
0074 enum ArchitectureKind {
0075 eArchKindDefault,
0076
0077 eArchKind32,
0078
0079 eArchKind64
0080
0081 };
0082
0083 static const ArchSpec &
0084 GetArchitecture(ArchitectureKind arch_kind = eArchKindDefault);
0085
0086 static std::optional<ArchitectureKind>
0087 ParseArchitectureKind(llvm::StringRef kind);
0088
0089
0090
0091 static FileSpec GetShlibDir();
0092
0093
0094
0095 static FileSpec GetSupportExeDir();
0096
0097
0098
0099 static FileSpec GetHeaderDir();
0100
0101
0102
0103 static FileSpec GetSystemPluginDir();
0104
0105
0106
0107 static FileSpec GetUserPluginDir();
0108
0109
0110
0111
0112 static FileSpec GetProcessTempDir();
0113
0114
0115
0116
0117 static FileSpec GetGlobalTempDir();
0118
0119
0120
0121
0122 static ArchSpec GetAugmentedArchSpec(llvm::StringRef triple);
0123
0124 static bool ComputePathRelativeToLibrary(FileSpec &file_spec,
0125 llvm::StringRef dir);
0126
0127 static FileSpec GetXcodeContentsDirectory() { return {}; }
0128 static FileSpec GetXcodeDeveloperDirectory() { return {}; }
0129
0130 struct SDKOptions {
0131 std::optional<XcodeSDK> XcodeSDKSelection;
0132 };
0133
0134
0135 static llvm::Expected<llvm::StringRef> GetSDKRoot(SDKOptions options) {
0136 return llvm::make_error<HostInfoError>("cannot determine SDK root");
0137 }
0138
0139
0140 static llvm::Expected<llvm::StringRef> FindSDKTool(XcodeSDK sdk,
0141 llvm::StringRef tool) {
0142 return llvm::errorCodeToError(llvm::errc::no_such_file_or_directory);
0143 }
0144
0145
0146
0147 static SharedCacheImageInfo
0148 GetSharedCacheImageInfo(llvm::StringRef image_name) {
0149 return {};
0150 }
0151
0152
0153
0154
0155
0156
0157
0158 static llvm::StringRef GetDistributionId() { return llvm::StringRef(); }
0159
0160 protected:
0161 static bool ComputeSharedLibraryDirectory(FileSpec &file_spec);
0162 static bool ComputeSupportExeDirectory(FileSpec &file_spec);
0163 static bool ComputeProcessTempFileDirectory(FileSpec &file_spec);
0164 static bool ComputeGlobalTempFileDirectory(FileSpec &file_spec);
0165 static bool ComputeTempFileBaseDirectory(FileSpec &file_spec);
0166 static bool ComputeHeaderDirectory(FileSpec &file_spec);
0167 static bool ComputeSystemPluginsDirectory(FileSpec &file_spec);
0168 static bool ComputeUserPluginsDirectory(FileSpec &file_spec);
0169
0170 static void ComputeHostArchitectureSupport(ArchSpec &arch_32,
0171 ArchSpec &arch_64);
0172 };
0173 }
0174
0175 #endif