[Lldb-commits] [lldb] r199539 - Added distribution info to ArchSpec and qHostInfo message.

Todd Fiala tfiala at google.com
Fri Jan 17 19:02:39 PST 2014


Author: tfiala
Date: Fri Jan 17 21:02:39 2014
New Revision: 199539

URL: http://llvm.org/viewvc/llvm-project?rev=199539&view=rev
Log:
Added distribution info to ArchSpec and qHostInfo message.

ArchSpec now contains an optional distribution_id, with getters and
setters. Host::GetArchitecture () sets it on non-Apple platforms using
Host::GetDistributionId (). The distribution_id is ignored during
ArchSpec comparisons.

The gdb remote qHostInfo message transmits it, if set, via the
distribution_id={id-value} key/value pair. Updated gdb remote docs to
reflect this change.

As before, GetDistributionId () returns nothing on non-Linux platforms
at this time. On Linux, it is returned only if the lsb_platform
command is installed (in /bin or /usr/bin), and only if the
distributor id key is returned by 'lsb_platform -i'. This id is
lowercased, and whitespace is replaced with underscores.


Modified:
    lldb/trunk/docs/lldb-gdb-remote.txt
    lldb/trunk/include/lldb/Core/ArchSpec.h
    lldb/trunk/source/Core/ArchSpec.cpp
    lldb/trunk/source/Host/common/Host.cpp
    lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
    lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp

Modified: lldb/trunk/docs/lldb-gdb-remote.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/docs/lldb-gdb-remote.txt?rev=199539&r1=199538&r2=199539&view=diff
==============================================================================
--- lldb/trunk/docs/lldb-gdb-remote.txt (original)
+++ lldb/trunk/docs/lldb-gdb-remote.txt Fri Jan 17 21:02:39 2014
@@ -536,6 +536,7 @@ os_kernel: a string describing the kerne
 os_version: a version string that represents the current OS version (10.8.2)
 watchpoint_exceptions_received: one of "before" or "after" to specify if a watchpoint is triggered before or after the pc when it stops
 default_packet_timeout: an unsigned number that specifies the default timeout in seconds
+distribution_id: optional. For linux, specifies distribution id (e.g. ubuntu, fedora, etc.)
 
 //----------------------------------------------------------------------
 // "qGDBServerVersion"

Modified: lldb/trunk/include/lldb/Core/ArchSpec.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ArchSpec.h?rev=199539&r1=199538&r2=199539&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ArchSpec.h (original)
+++ lldb/trunk/include/lldb/Core/ArchSpec.h Fri Jan 17 21:02:39 2014
@@ -13,6 +13,7 @@
 #if defined(__cplusplus)
 
 #include "lldb/lldb-private.h"
+#include "lldb/Core/ConstString.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/Triple.h"
 
@@ -203,6 +204,30 @@ public:
     GetMachine () const;
 
     //------------------------------------------------------------------
+    /// Returns the distribution id of the architecture.
+    ///
+    /// This will be something like "ubuntu", "fedora", etc. on Linux.
+    ///
+    /// @return A ConstString ref containing the distribution id,
+    ///         potentially empty.
+    //------------------------------------------------------------------
+    const ConstString&
+    GetDistributionId () const;
+
+    //------------------------------------------------------------------
+    /// Set the distribution id of the architecture.
+    ///
+    /// This will be something like "ubuntu", "fedora", etc. on Linux.
+    /// This should be the same value returned by
+    /// Host::GetDistributionId ().
+    ///
+    /// @return A ConstString ref containing the distribution id,
+    ///         potentially empty.
+    //------------------------------------------------------------------
+    void
+    SetDistributionId (const char* distribution_id);
+
+    //------------------------------------------------------------------
     /// Tests if this ArchSpec is valid.
     ///
     /// @return True if the current architecture is valid, false
@@ -400,6 +425,8 @@ protected:
     Core m_core;
     lldb::ByteOrder m_byte_order;
 
+    ConstString m_distribution_id;
+
     // Called when m_def or m_entry are changed.  Fills in all remaining
     // members with default values.
     void

Modified: lldb/trunk/source/Core/ArchSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ArchSpec.cpp?rev=199539&r1=199538&r2=199539&view=diff
==============================================================================
--- lldb/trunk/source/Core/ArchSpec.cpp (original)
+++ lldb/trunk/source/Core/ArchSpec.cpp Fri Jan 17 21:02:39 2014
@@ -349,14 +349,16 @@ FindArchDefinitionEntry (const ArchDefin
 ArchSpec::ArchSpec() :
     m_triple (),
     m_core (kCore_invalid),
-    m_byte_order (eByteOrderInvalid)
+    m_byte_order (eByteOrderInvalid),
+    m_distribution_id ()
 {
 }
 
 ArchSpec::ArchSpec (const char *triple_cstr, Platform *platform) :
     m_triple (),
     m_core (kCore_invalid),
-    m_byte_order (eByteOrderInvalid)
+    m_byte_order (eByteOrderInvalid),
+    m_distribution_id ()
 {
     if (triple_cstr)
         SetTriple(triple_cstr, platform);
@@ -366,7 +368,8 @@ ArchSpec::ArchSpec (const char *triple_c
 ArchSpec::ArchSpec (const char *triple_cstr) :
     m_triple (),
     m_core (kCore_invalid),
-    m_byte_order (eByteOrderInvalid)
+    m_byte_order (eByteOrderInvalid),
+    m_distribution_id ()
 {
     if (triple_cstr)
         SetTriple(triple_cstr);
@@ -375,7 +378,8 @@ ArchSpec::ArchSpec (const char *triple_c
 ArchSpec::ArchSpec(const llvm::Triple &triple) :
     m_triple (),
     m_core (kCore_invalid),
-    m_byte_order (eByteOrderInvalid)
+    m_byte_order (eByteOrderInvalid),
+    m_distribution_id ()
 {
     SetTriple(triple);
 }
@@ -383,7 +387,8 @@ ArchSpec::ArchSpec(const llvm::Triple &t
 ArchSpec::ArchSpec (ArchitectureType arch_type, uint32_t cpu, uint32_t subtype) :
     m_triple (),
     m_core (kCore_invalid),
-    m_byte_order (eByteOrderInvalid)
+    m_byte_order (eByteOrderInvalid),
+    m_distribution_id ()
 {
     SetArchitecture (arch_type, cpu, subtype);
 }
@@ -403,6 +408,7 @@ ArchSpec::operator= (const ArchSpec& rhs
         m_triple = rhs.m_triple;
         m_core = rhs.m_core;
         m_byte_order = rhs.m_byte_order;
+        m_distribution_id = rhs.m_distribution_id;
     }
     return *this;
 }
@@ -413,6 +419,7 @@ ArchSpec::Clear()
     m_triple = llvm::Triple();
     m_core = kCore_invalid;
     m_byte_order = eByteOrderInvalid;
+    m_distribution_id.Clear ();
 }
 
 //===----------------------------------------------------------------------===//
@@ -468,6 +475,18 @@ ArchSpec::GetMachine () const
     return llvm::Triple::UnknownArch;
 }
 
+const ConstString&
+ArchSpec::GetDistributionId () const
+{
+    return m_distribution_id;
+}
+
+void
+ArchSpec::SetDistributionId (const char* distribution_id)
+{
+    m_distribution_id.SetCString (distribution_id);
+}
+
 uint32_t
 ArchSpec::GetAddressByteSize() const
 {
@@ -763,6 +782,8 @@ ArchSpec::IsCompatibleMatch (const ArchS
 bool
 ArchSpec::IsEqualTo (const ArchSpec& rhs, bool exact_match) const
 {
+    // explicitly ignoring m_distribution_id in this method.
+
     if (GetByteOrder() != rhs.GetByteOrder())
         return false;
         

Modified: lldb/trunk/source/Host/common/Host.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Host.cpp?rev=199539&r1=199538&r2=199539&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/Host.cpp (original)
+++ lldb/trunk/source/Host/common/Host.cpp Fri Jan 17 21:02:39 2014
@@ -370,23 +370,29 @@ Host::GetArchitecture (SystemDefaultArch
         if (triple.getOS() == llvm::Triple::Linux && triple.getVendor() == llvm::Triple::UnknownVendor)
             triple.setVendorName ("");
 
+        const char* distribution_id = GetDistributionId ().AsCString();
+
         switch (triple.getArch())
         {
         default:
             g_host_arch_32.SetTriple(triple);
+            g_host_arch_32.SetDistributionId (distribution_id);
             g_supports_32 = true;
             break;
 
         case llvm::Triple::x86_64:
             g_host_arch_64.SetTriple(triple);
+            g_host_arch_64.SetDistributionId (distribution_id);
             g_supports_64 = true;
             g_host_arch_32.SetTriple(triple.get32BitArchVariant());
+            g_host_arch_32.SetDistributionId (distribution_id);
             g_supports_32 = true;
             break;
 
         case llvm::Triple::sparcv9:
         case llvm::Triple::ppc64:
             g_host_arch_64.SetTriple(triple);
+            g_host_arch_64.SetDistributionId (distribution_id);
             g_supports_64 = true;
             break;
         }

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp?rev=199539&r1=199538&r2=199539&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Fri Jan 17 21:02:39 2014
@@ -1254,6 +1254,7 @@ GDBRemoteCommunicationClient::GetHostInf
                 std::string os_name;
                 std::string vendor_name;
                 std::string triple;
+                std::string distribution_id;
                 uint32_t pointer_byte_size = 0;
                 StringExtractor extractor;
                 ByteOrder byte_order = eByteOrderInvalid;
@@ -1287,6 +1288,13 @@ GDBRemoteCommunicationClient::GetHostInf
                         extractor.GetHexByteString (triple);
                         ++num_keys_decoded;
                     }
+                    else if (name.compare ("distribution_id") == 0)
+                    {
+                        extractor.GetStringRef ().swap (value);
+                        extractor.SetFilePos (0);
+                        extractor.GetHexByteString (distribution_id);
+                        ++num_keys_decoded;
+                    }
                     else if (name.compare("os_build") == 0)
                     {
                         extractor.GetStringRef().swap(value);
@@ -1461,7 +1469,9 @@ GDBRemoteCommunicationClient::GetHostInf
                     {
                         assert (byte_order == m_host_arch.GetByteOrder());
                     }
-                }       
+                }
+                if (!distribution_id.empty ())
+                    m_host_arch.SetDistributionId (distribution_id.c_str ());
             }
         }
     }

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp?rev=199539&r1=199538&r2=199539&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp Fri Jan 17 21:02:39 2014
@@ -313,6 +313,14 @@ GDBRemoteCommunicationServer::Handle_qHo
     response.PutCStringAsRawHex8(host_triple.getTriple().c_str());
     response.Printf (";ptrsize:%u;",host_arch.GetAddressByteSize());
 
+    const char* distribution_id = host_arch.GetDistributionId ().AsCString ();
+    if (distribution_id)
+    {
+        response.PutCString("distribution_id:");
+        response.PutCStringAsRawHex8(distribution_id);
+        response.PutCString(";");
+    }
+
     uint32_t cpu = host_arch.GetMachOCPUType();
     uint32_t sub = host_arch.GetMachOCPUSubType();
     if (cpu != LLDB_INVALID_CPUTYPE)





More information about the lldb-commits mailing list