ObjectFileELF::GetModuleSpecifications on Linux should work now.
Which means "platform process list" should work and list the architecture.
We are now parsing the elf build-id if it exists, which should allow us to load stripped symbols (looking at that next).
llvm-svn: 182610
diff --git a/lldb/source/Core/UUID.cpp b/lldb/source/Core/UUID.cpp
index e84c13e..a512431 100644
--- a/lldb/source/Core/UUID.cpp
+++ b/lldb/source/Core/UUID.cpp
@@ -22,29 +22,30 @@
namespace lldb_private {
-UUID::UUID()
+UUID::UUID() : m_num_uuid_bytes(16)
{
::memset (m_uuid, 0, sizeof(m_uuid));
}
UUID::UUID(const UUID& rhs)
{
+ m_num_uuid_bytes = rhs.m_num_uuid_bytes;
::memcpy (m_uuid, rhs.m_uuid, sizeof (m_uuid));
}
UUID::UUID (const void *uuid_bytes, uint32_t num_uuid_bytes)
{
- if (uuid_bytes && num_uuid_bytes >= 16)
- ::memcpy (m_uuid, uuid_bytes, sizeof (m_uuid));
- else
- ::memset (m_uuid, 0, sizeof(m_uuid));
+ SetBytes (uuid_bytes, num_uuid_bytes);
}
const UUID&
UUID::operator=(const UUID& rhs)
{
if (this != &rhs)
+ {
+ m_num_uuid_bytes = rhs.m_num_uuid_bytes;
::memcpy (m_uuid, rhs.m_uuid, sizeof (m_uuid));
+ }
return *this;
}
@@ -55,6 +56,7 @@
void
UUID::Clear()
{
+ m_num_uuid_bytes = 16;
::memset (m_uuid, 0, sizeof(m_uuid));
}
@@ -70,12 +72,17 @@
std::string result;
char buf[64];
const uint8_t *u = (const uint8_t *)GetBytes();
- if (sizeof (buf) > snprintf (buf,
+ if (sizeof (buf) > (size_t)snprintf (buf,
sizeof (buf),
"%2.2X%2.2X%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X%2.2X%2.2X%2.2X%2.2X",
u[0],u[1],u[2],u[3],u[4],u[5],u[6],u[7],u[8],u[9],u[10],u[11],u[12],u[13],u[14],u[15]))
{
result.append (buf);
+ if (m_num_uuid_bytes == 20)
+ {
+ if (sizeof (buf) > (size_t)snprintf (buf, sizeof (buf), "-%2.2X%2.2X%2.2X%2.2X", u[16],u[17],u[18],u[19]))
+ result.append (buf);
+ }
}
return result;
}
@@ -86,21 +93,37 @@
const uint8_t *u = (const uint8_t *)GetBytes();
s->Printf ("%2.2X%2.2X%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X%2.2X%2.2X%2.2X%2.2X",
u[0],u[1],u[2],u[3],u[4],u[5],u[6],u[7],u[8],u[9],u[10],u[11],u[12],u[13],u[14],u[15]);
+ if (m_num_uuid_bytes == 20)
+ {
+ s->Printf ("-%2.2X%2.2X%2.2X%2.2X", u[16],u[17],u[18],u[19]);
+ }
}
void
-UUID::SetBytes (const void *uuid_bytes)
+UUID::SetBytes (const void *uuid_bytes, uint32_t num_uuid_bytes)
{
- if (uuid_bytes)
- ::memcpy (m_uuid, uuid_bytes, sizeof (m_uuid));
+ if (uuid_bytes && num_uuid_bytes >= 20)
+ {
+ m_num_uuid_bytes = 20;
+ ::memcpy (m_uuid, uuid_bytes, m_num_uuid_bytes);
+ }
+ else if (uuid_bytes && num_uuid_bytes >= 16)
+ {
+ m_num_uuid_bytes = 16;
+ ::memcpy (m_uuid, uuid_bytes, m_num_uuid_bytes);
+ m_uuid[16] = m_uuid[17] = m_uuid[18] = m_uuid[19] = 0;
+ }
else
+ {
+ m_num_uuid_bytes = 16;
::memset (m_uuid, 0, sizeof(m_uuid));
+ }
}
size_t
UUID::GetByteSize()
{
- return sizeof(UUID::ValueType);
+ return m_num_uuid_bytes;
}
bool
@@ -121,7 +144,11 @@
m_uuid[12] ||
m_uuid[13] ||
m_uuid[14] ||
- m_uuid[15];
+ m_uuid[15] ||
+ m_uuid[16] ||
+ m_uuid[17] ||
+ m_uuid[18] ||
+ m_uuid[19];
}
static inline int
@@ -134,7 +161,7 @@
}
size_t
-UUID::DecodeUUIDBytesFromCString (const char *p, ValueType &uuid_bytes, const char **end)
+UUID::DecodeUUIDBytesFromCString (const char *p, ValueType &uuid_bytes, const char **end, uint32_t num_uuid_bytes)
{
size_t uuid_byte_idx = 0;
if (p)
@@ -153,7 +180,7 @@
// Increment the byte that we are decoding within the UUID value
// and break out if we are done
- if (++uuid_byte_idx == 16)
+ if (++uuid_byte_idx == num_uuid_bytes)
break;
}
else if (*p == '-')
@@ -170,10 +197,13 @@
}
if (end)
*end = p;
+ // Clear trailing bytes to 0.
+ for (uint32_t i = uuid_byte_idx; i < sizeof(ValueType); i++)
+ uuid_bytes[i] = 0;
return uuid_byte_idx;
}
size_t
-UUID::SetFromCString (const char *cstr)
+UUID::SetFromCString (const char *cstr, uint32_t num_uuid_bytes)
{
if (cstr == NULL)
return 0;
@@ -184,11 +214,11 @@
while (isspace(*p))
++p;
- const size_t uuid_byte_idx = UUID::DecodeUUIDBytesFromCString (p, m_uuid, &p);
+ const size_t uuid_byte_idx = UUID::DecodeUUIDBytesFromCString (p, m_uuid, &p, num_uuid_bytes);
// If we successfully decoded a UUID, return the amount of characters that
// were consumed
- if (uuid_byte_idx == 16)
+ if (uuid_byte_idx == num_uuid_bytes)
return p - cstr;
// Else return zero to indicate we were not able to parse a UUID value
@@ -200,35 +230,35 @@
bool
lldb_private::operator == (const lldb_private::UUID &lhs, const lldb_private::UUID &rhs)
{
- return ::memcmp (lhs.GetBytes(), rhs.GetBytes(), lldb_private::UUID::GetByteSize()) == 0;
+ return ::memcmp (lhs.GetBytes(), rhs.GetBytes(), sizeof (lldb_private::UUID::ValueType)) == 0;
}
bool
lldb_private::operator != (const lldb_private::UUID &lhs, const lldb_private::UUID &rhs)
{
- return ::memcmp (lhs.GetBytes(), rhs.GetBytes(), lldb_private::UUID::GetByteSize()) != 0;
+ return ::memcmp (lhs.GetBytes(), rhs.GetBytes(), sizeof (lldb_private::UUID::ValueType)) != 0;
}
bool
lldb_private::operator < (const lldb_private::UUID &lhs, const lldb_private::UUID &rhs)
{
- return ::memcmp (lhs.GetBytes(), rhs.GetBytes(), lldb_private::UUID::GetByteSize()) < 0;
+ return ::memcmp (lhs.GetBytes(), rhs.GetBytes(), sizeof (lldb_private::UUID::ValueType)) < 0;
}
bool
lldb_private::operator <= (const lldb_private::UUID &lhs, const lldb_private::UUID &rhs)
{
- return ::memcmp (lhs.GetBytes(), rhs.GetBytes(), lldb_private::UUID::GetByteSize()) <= 0;
+ return ::memcmp (lhs.GetBytes(), rhs.GetBytes(), sizeof (lldb_private::UUID::ValueType)) <= 0;
}
bool
lldb_private::operator > (const lldb_private::UUID &lhs, const lldb_private::UUID &rhs)
{
- return ::memcmp (lhs.GetBytes(), rhs.GetBytes(), lldb_private::UUID::GetByteSize()) > 0;
+ return ::memcmp (lhs.GetBytes(), rhs.GetBytes(), sizeof (lldb_private::UUID::ValueType)) > 0;
}
bool
lldb_private::operator >= (const lldb_private::UUID &lhs, const lldb_private::UUID &rhs)
{
- return ::memcmp (lhs.GetBytes(), rhs.GetBytes(), lldb_private::UUID::GetByteSize()) >= 0;
+ return ::memcmp (lhs.GetBytes(), rhs.GetBytes(), sizeof (lldb_private::UUID::ValueType)) >= 0;
}