Add Linux support for HostInfo::GetOSBuildString and HostInfo::GetOSKernelDescription.
authorOleksiy Vyalov <ovyalov@google.com>
Tue, 9 Dec 2014 02:13:05 +0000 (02:13 +0000)
committerOleksiy Vyalov <ovyalov@google.com>
Tue, 9 Dec 2014 02:13:05 +0000 (02:13 +0000)
llvm-svn: 223737

lldb/include/lldb/Host/linux/HostInfoLinux.h
lldb/source/Host/linux/HostInfoLinux.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp

index f04be59..e951a4c 100644 (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();
 
index c18975c..bace258 100644 (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()
 {
index 2e0cdd4..d00af89 100644 (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__)