[Lldb-commits] [lldb] 5d64574 - [lldb] Delete Value::Vector class

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Wed Nov 4 01:22:06 PST 2020


Author: Pavel Labath
Date: 2020-11-04T10:21:56+01:00
New Revision: 5d64574301836c4c17127794121d49a62d24f803

URL: https://github.com/llvm/llvm-project/commit/5d64574301836c4c17127794121d49a62d24f803
DIFF: https://github.com/llvm/llvm-project/commit/5d64574301836c4c17127794121d49a62d24f803.diff

LOG: [lldb] Delete Value::Vector class

This class and it's surroundings contain a lot of shady code, but as far
as I can tell all of that code is unreachable (there is no code actually
setting the value to eValueTypeVector).

According to history this class was introduced in 2012 in
r167033/0665a0f09. At that time, the code seemed to serve some purpose,
and it had two entry points (in Value::SetContext and
ClangExpressionDeclMap::LookupDecl). The first entry point was deleted
in D17897 and the second one in r179842/44342735.

The stated purpose of the patch introducing this class was to fix
TestRegisters.py, and "expr $xmm0" in particular. Both of these things
function perfectly well these days without this class.

Added: 
    

Modified: 
    lldb/include/lldb/Core/Value.h
    lldb/source/Core/Value.cpp
    lldb/source/Core/ValueObject.cpp
    lldb/source/Core/ValueObjectVariable.cpp
    lldb/source/Expression/DWARFExpression.cpp
    lldb/source/Target/ABI.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/include/lldb/Core/Value.h b/lldb/include/lldb/Core/Value.h
index 641a64a3bbbe..0ff773e59911 100644
--- a/lldb/include/lldb/Core/Value.h
+++ b/lldb/include/lldb/Core/Value.h
@@ -43,8 +43,6 @@ class Value {
     // 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
@@ -62,66 +60,8 @@ class Value {
     eContextTypeVariable      // lldb_private::Variable *
   };
 
-  const static size_t 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(vector.bytes, vector.length, vector.byte_order);
-      return *this;
-    }
-
-    void Clear() { length = 0; }
-
-    bool SetBytes(const void *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.
-    llvm::APInt rhs = llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128,
-                                  ((type128 *)bytes)->x);
-    Scalar GetAsScalar() const {
-      Scalar scalar;
-      if (IsValid()) {
-        if (length == 1)
-          scalar = *(const uint8_t *)bytes;
-        else if (length == 2)
-          scalar = *(const uint16_t *)bytes;
-        else if (length == 4)
-          scalar = *(const uint32_t *)bytes;
-        else if (length == 8)
-          scalar = *(const uint64_t *)bytes;
-        else if (length >= 16)
-          scalar = rhs;
-      }
-      return scalar;
-    }
-  };
-
   Value();
   Value(const Scalar &scalar);
-  Value(const Vector &vector);
   Value(const void *bytes, int len);
   Value(const Value &rhs);
 
@@ -153,8 +93,7 @@ class Value {
     m_context = p;
     if (m_context_type == eContextTypeRegisterInfo) {
       RegisterInfo *reg_info = GetRegisterInfo();
-      if (reg_info->encoding == lldb::eEncodingVector &&
-          m_vector.byte_order != lldb::eByteOrderInvalid)
+      if (reg_info->encoding == lldb::eEncodingVector)
         SetValueType(eValueTypeScalar);
     }
   }
@@ -167,30 +106,8 @@ class Value {
 
   const Scalar &GetScalar() const { return m_value; }
 
-  const Vector &GetVector() const { return m_vector; }
-
   Scalar &GetScalar() { 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;
-  }
-
   size_t ResizeData(size_t len);
 
   size_t AppendDataToHostBuffer(const Value &rhs);
@@ -225,7 +142,6 @@ class Value {
 
 protected:
   Scalar m_value;
-  Vector m_vector;
   CompilerType m_compiler_type;
   void *m_context;
   ValueType m_value_type;

diff  --git a/lldb/source/Core/Value.cpp b/lldb/source/Core/Value.cpp
index 64e9a507bcfa..8007df4f934e 100644
--- a/lldb/source/Core/Value.cpp
+++ b/lldb/source/Core/Value.cpp
@@ -39,27 +39,26 @@ using namespace lldb;
 using namespace lldb_private;
 
 Value::Value()
-    : m_value(), m_vector(), m_compiler_type(), m_context(nullptr),
+    : m_value(), m_compiler_type(), m_context(nullptr),
       m_value_type(eValueTypeScalar), m_context_type(eContextTypeInvalid),
       m_data_buffer() {}
 
 Value::Value(const Scalar &scalar)
-    : m_value(scalar), m_vector(), m_compiler_type(), m_context(nullptr),
+    : m_value(scalar), m_compiler_type(), m_context(nullptr),
       m_value_type(eValueTypeScalar), m_context_type(eContextTypeInvalid),
       m_data_buffer() {}
 
 Value::Value(const void *bytes, int len)
-    : m_value(), m_vector(), m_compiler_type(), m_context(nullptr),
+    : m_value(), m_compiler_type(), m_context(nullptr),
       m_value_type(eValueTypeHostAddress), m_context_type(eContextTypeInvalid),
       m_data_buffer() {
   SetBytes(bytes, len);
 }
 
 Value::Value(const Value &v)
-    : m_value(v.m_value), m_vector(v.m_vector),
-      m_compiler_type(v.m_compiler_type), m_context(v.m_context),
-      m_value_type(v.m_value_type), m_context_type(v.m_context_type),
-      m_data_buffer() {
+    : m_value(v.m_value), m_compiler_type(v.m_compiler_type),
+      m_context(v.m_context), m_value_type(v.m_value_type),
+      m_context_type(v.m_context_type), m_data_buffer() {
   const uintptr_t rhs_value =
       (uintptr_t)v.m_value.ULongLong(LLDB_INVALID_ADDRESS);
   if ((rhs_value != 0) &&
@@ -74,7 +73,6 @@ Value::Value(const Value &v)
 Value &Value::operator=(const Value &rhs) {
   if (this != &rhs) {
     m_value = rhs.m_value;
-    m_vector = rhs.m_vector;
     m_compiler_type = rhs.m_compiler_type;
     m_context = rhs.m_context;
     m_value_type = rhs.m_value_type;
@@ -159,17 +157,6 @@ size_t Value::AppendDataToHostBuffer(const Value &rhs) {
       }
     }
   } break;
-  case eValueTypeVector: {
-    const size_t vector_size = rhs.m_vector.length;
-    if (vector_size > 0) {
-      const size_t new_size = curr_size + vector_size;
-      if (ResizeData(new_size) == new_size) {
-        ::memcpy(m_data_buffer.GetBytes() + curr_size, rhs.m_vector.bytes,
-                 vector_size);
-        return vector_size;
-      }
-    }
-  } break;
   case eValueTypeFileAddress:
   case eValueTypeLoadAddress:
   case eValueTypeHostAddress: {
@@ -329,14 +316,6 @@ Status Value::GetValueAsData(ExecutionContext *exe_ctx, DataExtractor &data,
     return error;
 
   switch (m_value_type) {
-  case eValueTypeVector:
-    if (ast_type.IsValid())
-      data.SetAddressByteSize(ast_type.GetPointerByteSize());
-    else
-      data.SetAddressByteSize(sizeof(void *));
-    data.SetData(m_vector.bytes, m_vector.length, m_vector.byte_order);
-    break;
-
   case eValueTypeScalar: {
     data.SetByteOrder(endian::InlHostByteOrder());
     if (ast_type.IsValid())
@@ -634,7 +613,6 @@ Variable *Value::GetVariable() {
 
 void Value::Clear() {
   m_value.Clear();
-  m_vector.Clear();
   m_compiler_type.Clear();
   m_value_type = eValueTypeScalar;
   m_context = nullptr;
@@ -646,8 +624,6 @@ const char *Value::GetValueTypeAsCString(ValueType value_type) {
   switch (value_type) {
   case eValueTypeScalar:
     return "scalar";
-  case eValueTypeVector:
-    return "vector";
   case eValueTypeFileAddress:
     return "file address";
   case eValueTypeLoadAddress:

diff  --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp
index 78711c4e42ce..bcd76f5a74be 100644
--- a/lldb/source/Core/ValueObject.cpp
+++ b/lldb/source/Core/ValueObject.cpp
@@ -337,7 +337,6 @@ const char *ValueObject::GetLocationAsCStringImpl(const Value &value,
 
       switch (value_type) {
       case Value::eValueTypeScalar:
-      case Value::eValueTypeVector:
         if (value.GetContextType() == Value::eContextTypeRegisterInfo) {
           RegisterInfo *reg_info = value.GetRegisterInfo();
           if (reg_info) {
@@ -352,8 +351,7 @@ const char *ValueObject::GetLocationAsCStringImpl(const Value &value,
           }
         }
         if (m_location_str.empty())
-          m_location_str =
-              (value_type == Value::eValueTypeVector) ? "vector" : "scalar";
+          m_location_str = "scalar";
         break;
 
       case Value::eValueTypeLoadAddress:
@@ -892,7 +890,6 @@ bool ValueObject::SetData(DataExtractor &data, Status &error) {
     m_value.GetScalar() = (uintptr_t)m_data.GetDataStart();
   } break;
   case Value::eValueTypeFileAddress:
-  case Value::eValueTypeVector:
     break;
   }
 
@@ -1459,7 +1456,6 @@ addr_t ValueObject::GetAddressOf(bool scalar_is_load_address,
 
   switch (m_value.GetValueType()) {
   case Value::eValueTypeScalar:
-  case Value::eValueTypeVector:
     if (scalar_is_load_address) {
       if (address_type)
         *address_type = eAddressTypeLoad;
@@ -1494,7 +1490,6 @@ addr_t ValueObject::GetPointerValue(AddressType *address_type) {
 
   switch (m_value.GetValueType()) {
   case Value::eValueTypeScalar:
-  case Value::eValueTypeVector:
     address = m_value.GetScalar().ULongLong(LLDB_INVALID_ADDRESS);
     break;
 
@@ -1577,7 +1572,6 @@ bool ValueObject::SetValueFromCString(const char *value_str, Status &error) {
       } break;
       case Value::eValueTypeFileAddress:
       case Value::eValueTypeScalar:
-      case Value::eValueTypeVector:
         break;
       }
     } else {

diff  --git a/lldb/source/Core/ValueObjectVariable.cpp b/lldb/source/Core/ValueObjectVariable.cpp
index 43e888a68725..5acb23aaac5b 100644
--- a/lldb/source/Core/ValueObjectVariable.cpp
+++ b/lldb/source/Core/ValueObjectVariable.cpp
@@ -196,8 +196,6 @@ bool ValueObjectVariable::UpdateValue() {
       const bool process_is_alive = process && process->IsAlive();
 
       switch (value_type) {
-      case Value::eValueTypeVector:
-      // fall through
       case Value::eValueTypeScalar:
         // The variable value is in the Scalar value inside the m_value. We can
         // point our m_data right to it.
@@ -295,7 +293,6 @@ void ValueObjectVariable::DoUpdateChildrenAddressType(ValueObject &valobj) {
     break;
   case Value::eValueTypeLoadAddress:
   case Value::eValueTypeScalar:
-  case Value::eValueTypeVector:
     valobj.SetAddressTypeOfChildren(eAddressTypeLoad);
     break;
   }

diff  --git a/lldb/source/Expression/DWARFExpression.cpp b/lldb/source/Expression/DWARFExpression.cpp
index 755480ac5532..9240956defc8 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.cpp
@@ -2153,20 +2153,6 @@ bool DWARFExpression::Evaluate(
                                          ap_int.getNumWords()};
             curr_piece.GetScalar() = Scalar(llvm::APInt(bit_size, buf));
           } break;
-
-          case Value::eValueTypeVector: {
-            if (curr_piece_source_value.GetVector().length >= piece_byte_size)
-              curr_piece_source_value.GetVector().length = piece_byte_size;
-            else {
-              if (error_ptr)
-                error_ptr->SetErrorStringWithFormat(
-                    "unable to extract %" PRIu64 " bytes from a %" PRIu64
-                    " byte vector value.",
-                    piece_byte_size,
-                    (uint64_t)curr_piece_source_value.GetVector().length);
-              return false;
-            }
-          } break;
           }
 
           // Check if this is the first piece?
@@ -2235,15 +2221,6 @@ bool DWARFExpression::Evaluate(
                 piece_bit_size, piece_bit_offset);
           }
           return false;
-
-        case Value::eValueTypeVector:
-          if (error_ptr) {
-            error_ptr->SetErrorStringWithFormat(
-                "unable to extract DW_OP_bit_piece(bit_size = %" PRIu64
-                ", bit_offset = %" PRIu64 ") from a vector value.",
-                piece_bit_size, piece_bit_offset);
-          }
-          return false;
         }
       }
       break;

diff  --git a/lldb/source/Target/ABI.cpp b/lldb/source/Target/ABI.cpp
index d50afb9967e3..f6a531136dcb 100644
--- a/lldb/source/Target/ABI.cpp
+++ b/lldb/source/Target/ABI.cpp
@@ -125,7 +125,6 @@ ValueObjectSP ABI::GetReturnValueObject(Thread &thread, CompilerType &ast_type,
       // we don't do anything with these for now
       break;
     case Value::eValueTypeScalar:
-    case Value::eValueTypeVector:
       expr_variable_sp->m_flags |=
           ExpressionVariable::EVIsFreezeDried;
       expr_variable_sp->m_flags |=


        


More information about the lldb-commits mailing list