public:
static llvm::VersionTuple GetOSVersion();
static llvm::Optional<std::string> GetOSBuildString();
- static bool GetOSKernelDescription(std::string &s);
static FileSpec GetProgramFileSpec();
};
}
static llvm::VersionTuple GetOSVersion();
static llvm::Optional<std::string> GetOSBuildString();
- static bool GetOSKernelDescription(std::string &s);
static llvm::StringRef GetDistributionId();
static FileSpec GetProgramFileSpec();
static llvm::VersionTuple GetOSVersion();
static llvm::VersionTuple GetMacCatalystVersion();
static llvm::Optional<std::string> GetOSBuildString();
- static bool GetOSKernelDescription(std::string &s);
static FileSpec GetProgramFileSpec();
static FileSpec GetXcodeContentsDirectory();
static FileSpec GetXcodeDeveloperDirectory();
public:
static llvm::VersionTuple GetOSVersion();
static llvm::Optional<std::string> GetOSBuildString();
- static bool GetOSKernelDescription(std::string &s);
static FileSpec GetProgramFileSpec();
};
}
public:
static llvm::VersionTuple GetOSVersion();
static llvm::Optional<std::string> GetOSBuildString();
- static bool GetOSKernelDescription(std::string &s);
static FileSpec GetProgramFileSpec();
};
}
public:
static size_t GetPageSize();
static bool GetHostname(std::string &s);
+ static llvm::Optional<std::string> GetOSKernelDescription();
static uint32_t GetUserID();
static uint32_t GetGroupID();
static llvm::VersionTuple GetOSVersion();
static llvm::Optional<std::string> GetOSBuildString();
- static bool GetOSKernelDescription(std::string &s);
+ static llvm::Optional<std::string> GetOSKernelDescription();
static bool GetHostname(std::string &s);
static FileSpec GetProgramFileSpec();
static FileSpec GetDefaultShell();
return llvm::None;
}
-bool HostInfoFreeBSD::GetOSKernelDescription(std::string &s) {
- struct utsname un;
-
- ::memset(&un, 0, sizeof(utsname));
- s.clear();
-
- if (uname(&un) < 0)
- return false;
-
- s.assign(un.version);
-
- return true;
-}
-
FileSpec HostInfoFreeBSD::GetProgramFileSpec() {
static FileSpec g_program_filespec;
if (!g_program_filespec) {
return std::string(un.release);
}
-bool HostInfoLinux::GetOSKernelDescription(std::string &s) {
- struct utsname un;
-
- ::memset(&un, 0, sizeof(utsname));
- s.clear();
-
- if (uname(&un) < 0)
- return false;
-
- s.assign(un.version);
- return true;
-}
-
llvm::StringRef HostInfoLinux::GetDistributionId() {
assert(g_fields && "Missing call to Initialize?");
// Try to run 'lbs_release -i', and use that response for the distribution
return llvm::None;
}
-bool HostInfoMacOSX::GetOSKernelDescription(std::string &s) {
- int mib[2] = {CTL_KERN, KERN_VERSION};
- char cstr[PATH_MAX];
- size_t cstr_len = sizeof(cstr);
- if (::sysctl(mib, 2, cstr, &cstr_len, NULL, 0) == 0) {
- s.assign(cstr, cstr_len);
- return true;
- }
- s.clear();
- return false;
-}
-
static void ParseOSVersion(llvm::VersionTuple &version, NSString *Key) {
@autoreleasepool {
NSDictionary *version_info =
return llvm::None;
}
-bool HostInfoNetBSD::GetOSKernelDescription(std::string &s) {
- struct utsname un;
-
- ::memset(&un, 0, sizeof(un));
- s.clear();
-
- if (::uname(&un) < 0)
- return false;
-
- s.assign(un.version);
-
- return true;
-}
-
FileSpec HostInfoNetBSD::GetProgramFileSpec() {
static FileSpec g_program_filespec;
return llvm::None;
}
-bool HostInfoOpenBSD::GetOSKernelDescription(std::string &s) {
- struct utsname un;
-
- ::memset(&un, 0, sizeof(utsname));
- s.clear();
-
- if (uname(&un) < 0)
- return false;
-
- s.assign(un.version);
-
- return true;
-}
-
FileSpec HostInfoOpenBSD::GetProgramFileSpec() {
static FileSpec g_program_filespec;
return g_program_filespec;
#include <mutex>
#include <pwd.h>
#include <sys/types.h>
+#include <sys/utsname.h>
#include <unistd.h>
using namespace lldb_private;
return false;
}
+llvm::Optional<std::string> HostInfoPosix::GetOSKernelDescription() {
+ struct utsname un;
+ if (uname(&un) < 0)
+ return llvm::None;
+
+ return std::string(un.version);
+}
+
#ifdef __ANDROID__
#include <android/api-level.h>
#endif
return "Windows NT " + version.getAsString();
}
-bool HostInfoWindows::GetOSKernelDescription(std::string &s) {
- llvm::Optional<std::string> build = GetOSBuildString();
- s = build.getValueOr("");
- return build.hasValue();
+llvm::Optional<std::string> HostInfoWindows::GetOSKernelDescription() {
+ return GetOSBuildString();
}
bool HostInfoWindows::GetHostname(std::string &s) {
response.PutStringAsRawHex8(*s);
response.PutChar(';');
}
- std::string s;
- if (HostInfo::GetOSKernelDescription(s)) {
+ if (llvm::Optional<std::string> s = HostInfo::GetOSKernelDescription()) {
response.PutCString("os_kernel:");
- response.PutStringAsRawHex8(s);
+ response.PutStringAsRawHex8(*s);
response.PutChar(';');
}
+ std::string s;
#if defined(__APPLE__)
#if defined(__arm__) || defined(__arm64__) || defined(__aarch64__)
}
bool Platform::GetOSKernelDescription(std::string &s) {
- if (IsHost())
- return HostInfo::GetOSKernelDescription(s);
+ if (IsHost()) {
+ llvm::Optional<std::string> desc = HostInfo::GetOSKernelDescription();
+ s = desc.getValueOr("");
+ return desc.hasValue();
+ }
return GetRemoteOSKernelDescription(s);
}