Add Linux support for HostInfo::GetOSBuildString and HostInfo::GetOSKernelDescription.

llvm-svn: 223737
This commit is contained in:
Oleksiy Vyalov 2014-12-09 02:13:05 +00:00
parent 6a2fabcc3f
commit 53c038a581
3 changed files with 31 additions and 2 deletions

View File

@ -34,6 +34,8 @@ class HostInfoLinux : public HostInfoPosix
static uint32_t GetMaxThreadNameLength();
static bool GetOSVersion(uint32_t &major, uint32_t &minor, uint32_t &update);
static bool GetOSBuildString(std::string &s);
static bool GetOSKernelDescription(std::string &s);
static llvm::StringRef GetDistributionId();
static FileSpec GetProgramFileSpec();

View File

@ -88,6 +88,35 @@ finished:
return success;
}
bool
HostInfoLinux::GetOSBuildString(std::string &s)
{
struct utsname un;
::memset(&un, 0, sizeof(utsname));
s.clear();
if (uname(&un) < 0)
return false;
s.assign(un.release);
return true;
}
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()
{

View File

@ -1274,7 +1274,6 @@ GDBRemoteCommunicationServer::Handle_qHostInfo (StringExtractorGDBRemote &packet
}
std::string s;
#if !defined(__linux__)
if (HostInfo::GetOSBuildString(s))
{
response.PutCString ("os_build:");
@ -1287,7 +1286,6 @@ GDBRemoteCommunicationServer::Handle_qHostInfo (StringExtractorGDBRemote &packet
response.PutCStringAsRawHex8(s.c_str());
response.PutChar(';');
}
#endif
#if defined(__APPLE__)