From 53c038a58127e337ba3c8332eb5a87880602c7d2 Mon Sep 17 00:00:00 2001 From: Oleksiy Vyalov Date: Tue, 9 Dec 2014 02:13:05 +0000 Subject: [PATCH] Add Linux support for HostInfo::GetOSBuildString and HostInfo::GetOSKernelDescription. llvm-svn: 223737 --- lldb/include/lldb/Host/linux/HostInfoLinux.h | 2 ++ lldb/source/Host/linux/HostInfoLinux.cpp | 29 +++++++++++++++++++ .../GDBRemoteCommunicationServer.cpp | 2 -- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/lldb/include/lldb/Host/linux/HostInfoLinux.h b/lldb/include/lldb/Host/linux/HostInfoLinux.h index f04be59a14c5..e951a4c41482 100644 --- a/lldb/include/lldb/Host/linux/HostInfoLinux.h +++ b/lldb/include/lldb/Host/linux/HostInfoLinux.h @@ -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(); diff --git a/lldb/source/Host/linux/HostInfoLinux.cpp b/lldb/source/Host/linux/HostInfoLinux.cpp index c18975ca160b..bace2586aad1 100644 --- a/lldb/source/Host/linux/HostInfoLinux.cpp +++ b/lldb/source/Host/linux/HostInfoLinux.cpp @@ -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() { diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp index 2e0cdd410e55..d00af89863c9 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp @@ -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__)