summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTodd Fiala <tfiala@google.com>2014-01-18 03:02:39 +0000
committerTodd Fiala <tfiala@google.com>2014-01-18 03:02:39 +0000
commita9ddb0e14fa6ef559efb36654e1cc9e3c9e6c0d9 (patch)
treeee6e54765addf9701ad9f49a6799d037b178eaa7
parented91da719e53e2dd6d665347188e541b45931672 (diff)
downloadbcm5719-llvm-a9ddb0e14fa6ef559efb36654e1cc9e3c9e6c0d9.tar.gz
bcm5719-llvm-a9ddb0e14fa6ef559efb36654e1cc9e3c9e6c0d9.zip
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. llvm-svn: 199539
-rw-r--r--lldb/docs/lldb-gdb-remote.txt1
-rw-r--r--lldb/include/lldb/Core/ArchSpec.h27
-rw-r--r--lldb/source/Core/ArchSpec.cpp31
-rw-r--r--lldb/source/Host/common/Host.cpp6
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp12
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp8
6 files changed, 79 insertions, 6 deletions
diff --git a/lldb/docs/lldb-gdb-remote.txt b/lldb/docs/lldb-gdb-remote.txt
index 9a51383a71a..9fdd9206fcb 100644
--- a/lldb/docs/lldb-gdb-remote.txt
+++ b/lldb/docs/lldb-gdb-remote.txt
@@ -536,6 +536,7 @@ os_kernel: a string describing the kernel version
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"
diff --git a/lldb/include/lldb/Core/ArchSpec.h b/lldb/include/lldb/Core/ArchSpec.h
index 7f2fd77a093..554670ea8e0 100644
--- a/lldb/include/lldb/Core/ArchSpec.h
+++ b/lldb/include/lldb/Core/ArchSpec.h
@@ -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
diff --git a/lldb/source/Core/ArchSpec.cpp b/lldb/source/Core/ArchSpec.cpp
index f2eb3751a4b..f39367e65e5 100644
--- a/lldb/source/Core/ArchSpec.cpp
+++ b/lldb/source/Core/ArchSpec.cpp
@@ -349,14 +349,16 @@ FindArchDefinitionEntry (const ArchDefinition *def, ArchSpec::Core core)
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_cstr, Platform *platform) :
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_cstr) :
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 &triple) :
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 ArchSpec& rhs) const
bool
ArchSpec::IsEqualTo (const ArchSpec& rhs, bool exact_match) const
{
+ // explicitly ignoring m_distribution_id in this method.
+
if (GetByteOrder() != rhs.GetByteOrder())
return false;
diff --git a/lldb/source/Host/common/Host.cpp b/lldb/source/Host/common/Host.cpp
index 5c4bf39e620..7cefd41731c 100644
--- a/lldb/source/Host/common/Host.cpp
+++ b/lldb/source/Host/common/Host.cpp
@@ -370,23 +370,29 @@ Host::GetArchitecture (SystemDefaultArchitecture arch_kind)
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;
}
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
index df313572d60..aae3aaafa33 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -1254,6 +1254,7 @@ GDBRemoteCommunicationClient::GetHostInfo (bool force)
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::GetHostInfo (bool force)
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::GetHostInfo (bool force)
{
assert (byte_order == m_host_arch.GetByteOrder());
}
- }
+ }
+ if (!distribution_id.empty ())
+ m_host_arch.SetDistributionId (distribution_id.c_str ());
}
}
}
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp
index 9579e7cc2a5..bed8852b7a0 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp
@@ -313,6 +313,14 @@ GDBRemoteCommunicationServer::Handle_qHostInfo (StringExtractorGDBRemote &packet
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)
OpenPOWER on IntegriCloud