forked from OSchip/llvm-project
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
This commit is contained in:
parent
ed91da719e
commit
a9ddb0e14f
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
@ -202,6 +203,30 @@ public:
|
|||
llvm::Triple::ArchType
|
||||
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.
|
||||
///
|
||||
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 ());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue