// C Includes
// C++ Includes
+#include <string>
#include <vector>
// Other libraries and framework includes
// Project includes
// m_value contains...
// ============================
eValueTypeScalar, // raw scalar value
+ eValueTypeVector, // byte array of m_vector.length with endianness of m_vector.byte_order
eValueTypeFileAddress, // file address value
eValueTypeLoadAddress, // load address value
eValueTypeHostAddress // host address value (for memory in the process that is using liblldb)
// ====================
eContextTypeInvalid, // undefined
eContextTypeClangType, // void * (an opaque clang::QualType * that can be fed to "static QualType QualType::getFromOpaquePtr(void *)")
- eContextTypeRegisterInfo, // RegisterInfo *
+ eContextTypeRegisterInfo, // RegisterInfo * (can be a scalar or a vector register)
eContextTypeLLDBType, // lldb_private::Type *
eContextTypeVariable // lldb_private::Variable *
};
+ enum
+ {
+ kMaxByteSize = 32u
+ };
+
+ struct Vector
+ {
+ // The byte array must be big enough to hold vector registers for any supported target.
+ uint8_t bytes[kMaxByteSize];
+ size_t length;
+ lldb::ByteOrder byte_order;
+
+ Vector() :
+ length(0),
+ byte_order(lldb::eByteOrderInvalid)
+ {
+ }
+
+ Vector(const Vector& vector)
+ { *this = vector;
+ }
+ const Vector&
+ operator=(const Vector& vector)
+ {
+ SetBytes((uint8_t *)vector.bytes, vector.length, vector.byte_order);
+ return *this;
+ }
+
+ bool
+ SetBytes(uint8_t *bytes, size_t length, lldb::ByteOrder byte_order)
+ {
+ this->length = length;
+ this->byte_order = byte_order;
+ if (length)
+ ::memcpy(this->bytes, bytes, length < kMaxByteSize ? length : kMaxByteSize);
+ return IsValid();
+ }
+
+ bool
+ IsValid() const
+ {
+ return (length > 0 && length < kMaxByteSize && byte_order != lldb::eByteOrderInvalid);
+ }
+ // Casts a vector, if valid, to an unsigned int of matching or largest supported size.
+ // Truncates to the beginning of the vector if required.
+ // Returns a default constructed Scalar if the Vector data is internally inconsistent.
+ Scalar
+ GetAsScalar() const
+ {
+ Scalar scalar;
+ if (IsValid())
+ if (length == 1) scalar = *(uint8_t *)bytes;
+ if (length == 2) scalar = *(uint16_t *)bytes;
+ if (length == 4) scalar = *(uint32_t *)bytes;
+ if (length == 8) scalar = *(uint64_t *)bytes;
+#if defined (ENABLE_128_BIT_SUPPORT)
+ if (length >= 16) scalar = *(__uint128_t *)bytes;
+#else
+ if (length >= 16) scalar = *(__uint64_t *)bytes;
+#endif
+ return scalar;
+ }
+ };
+
Value();
Value(const Scalar& scalar);
+ Value(const Vector& vector);
Value(const uint8_t *bytes, int len);
Value(const Value &rhs);
{
m_context_type = context_type;
m_context = p;
+ if (m_context_type == eContextTypeRegisterInfo) {
+ RegisterInfo *reg_info = GetRegisterInfo();
+ if (reg_info->encoding == lldb::eEncodingVector)
+ SetValueType(eValueTypeVector);
+ else
+ SetValueType(eValueTypeScalar);
+ }
}
RegisterInfo *
return m_value;
}
+ Vector &
+ GetVector()
+ {
+ return m_vector;
+ }
+
+ bool
+ SetVectorBytes(const Vector& vector)
+ {
+ m_vector = vector;
+ return m_vector.IsValid();
+ }
+
+ bool
+ SetVectorBytes(uint8_t *bytes, size_t length, lldb::ByteOrder byte_order)
+ {
+ return m_vector.SetBytes(bytes, length, byte_order);
+ }
+
+ bool
+ SetScalarFromVector()
+ {
+ if (m_vector.IsValid())
+ {
+ m_value = m_vector.GetAsScalar();
+ return true;
+ }
+ return false;
+ }
+
void
ResizeData(int len);
protected:
Scalar m_value;
+ Vector m_vector;
ValueType m_value_type;
void * m_context;
ContextType m_context_type;
break;
case Value::eValueTypeScalar:
+ case Value::eValueTypeVector:
if (m_value.GetContextType() == Value::eContextTypeRegisterInfo)
{
RegisterInfo *reg_info = m_value.GetRegisterInfo();
m_location_str = reg_info->name;
else if (reg_info->alt_name)
m_location_str = reg_info->alt_name;
- break;
+
+ m_location_str = (reg_info->encoding == lldb::eEncodingVector) ? "vector" : "scalar";
}
}
- m_location_str = "scalar";
break;
case Value::eValueTypeLoadAddress:
switch (m_value.GetValueType())
{
case Value::eValueTypeScalar:
+ case Value::eValueTypeVector:
if (scalar_is_load_address)
{
if(address_type)
switch (m_value.GetValueType())
{
case Value::eValueTypeScalar:
+ case Value::eValueTypeVector:
address = m_value.GetScalar().ULongLong(LLDB_INVALID_ADDRESS);
break;
break;
case Value::eValueTypeFileAddress:
case Value::eValueTypeScalar:
- break;
+ case Value::eValueTypeVector:
+ break;
}
}
else