diff --git a/lldb/include/lldb/Utility/RegisterValue.h b/lldb/include/lldb/Utility/RegisterValue.h --- a/lldb/include/lldb/Utility/RegisterValue.h +++ b/lldb/include/lldb/Utility/RegisterValue.h @@ -238,7 +238,7 @@ Status SetValueFromString(const RegisterInfo *reg_info, const char *value_str) = delete; - Status SetValueFromData(const RegisterInfo *reg_info, DataExtractor &data, + Status SetValueFromData(const RegisterInfo ®_info, DataExtractor &data, lldb::offset_t offset, bool partial_data_ok); const void *GetBytes() const; diff --git a/lldb/source/Core/ValueObjectRegister.cpp b/lldb/source/Core/ValueObjectRegister.cpp --- a/lldb/source/Core/ValueObjectRegister.cpp +++ b/lldb/source/Core/ValueObjectRegister.cpp @@ -282,7 +282,7 @@ } bool ValueObjectRegister::SetData(DataExtractor &data, Status &error) { - error = m_reg_value.SetValueFromData(&m_reg_info, data, 0, false); + error = m_reg_value.SetValueFromData(m_reg_info, data, 0, false); if (!error.Success()) return false; diff --git a/lldb/source/Core/ValueObjectVariable.cpp b/lldb/source/Core/ValueObjectVariable.cpp --- a/lldb/source/Core/ValueObjectVariable.cpp +++ b/lldb/source/Core/ValueObjectVariable.cpp @@ -398,7 +398,7 @@ error.SetErrorString("unable to retrieve register info"); return false; } - error = reg_value.SetValueFromData(reg_info, data, 0, true); + error = reg_value.SetValueFromData(*reg_info, data, 0, true); if (error.Fail()) return false; if (reg_ctx->WriteRegister(reg_info, reg_value)) { diff --git a/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp b/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp --- a/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp +++ b/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp @@ -304,7 +304,7 @@ if (byte_size <= 16) { if (byte_size <= RegisterValue::GetMaxByteSize()) { RegisterValue reg_value; - error = reg_value.SetValueFromData(v0_info, data, 0, true); + error = reg_value.SetValueFromData(*v0_info, data, 0, true); if (error.Success()) { if (!reg_ctx->WriteRegister(v0_info, reg_value)) error.SetErrorString("failed to write register v0"); @@ -331,7 +331,7 @@ if (v0_info) { if (byte_size <= v0_info->byte_size) { RegisterValue reg_value; - error = reg_value.SetValueFromData(v0_info, data, 0, true); + error = reg_value.SetValueFromData(*v0_info, data, 0, true); if (error.Success()) { if (!reg_ctx->WriteRegister(v0_info, reg_value)) error.SetErrorString("failed to write register v0"); diff --git a/lldb/source/Plugins/ABI/AArch64/ABISysV_arm64.cpp b/lldb/source/Plugins/ABI/AArch64/ABISysV_arm64.cpp --- a/lldb/source/Plugins/ABI/AArch64/ABISysV_arm64.cpp +++ b/lldb/source/Plugins/ABI/AArch64/ABISysV_arm64.cpp @@ -277,7 +277,7 @@ if (byte_size <= 16) { if (byte_size <= RegisterValue::GetMaxByteSize()) { RegisterValue reg_value; - error = reg_value.SetValueFromData(v0_info, data, 0, true); + error = reg_value.SetValueFromData(*v0_info, data, 0, true); if (error.Success()) { if (!reg_ctx->WriteRegister(v0_info, reg_value)) error.SetErrorString("failed to write register v0"); @@ -304,7 +304,7 @@ if (v0_info) { if (byte_size <= v0_info->byte_size) { RegisterValue reg_value; - error = reg_value.SetValueFromData(v0_info, data, 0, true); + error = reg_value.SetValueFromData(*v0_info, data, 0, true); if (error.Success()) { if (!reg_ctx->WriteRegister(v0_info, reg_value)) error.SetErrorString("failed to write register v0"); diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextMemory.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextMemory.cpp --- a/lldb/source/Plugins/Process/Utility/RegisterContextMemory.cpp +++ b/lldb/source/Plugins/Process/Utility/RegisterContextMemory.cpp @@ -81,7 +81,7 @@ } const bool partial_data_ok = false; return reg_value - .SetValueFromData(reg_info, m_reg_data, reg_info->byte_offset, + .SetValueFromData(*reg_info, m_reg_data, reg_info->byte_offset, partial_data_ok) .Success(); } diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp @@ -112,7 +112,7 @@ } else { const bool partial_data_ok = false; Status error(value.SetValueFromData( - reg_info, m_reg_data, reg_info->byte_offset, partial_data_ok)); + *reg_info, m_reg_data, reg_info->byte_offset, partial_data_ok)); return error.Success(); } } diff --git a/lldb/source/Utility/RegisterValue.cpp b/lldb/source/Utility/RegisterValue.cpp --- a/lldb/source/Utility/RegisterValue.cpp +++ b/lldb/source/Utility/RegisterValue.cpp @@ -115,7 +115,7 @@ // register value DataExtractor src_data(src, src_len, src_byte_order, 4); - error = SetValueFromData(®_info, src_data, 0, true); + error = SetValueFromData(reg_info, src_data, 0, true); if (error.Fail()) return 0; @@ -150,16 +150,20 @@ void RegisterValue::Clear() { m_type = eTypeInvalid; } RegisterValue::Type RegisterValue::SetType(const RegisterInfo *reg_info) { + assert(reg_info && "Expected non null reg_info."); // To change the type, we simply copy the data in again, using the new format RegisterValue copy; DataExtractor copy_data; - if (copy.CopyValue(*this) && copy.GetData(copy_data)) - SetValueFromData(reg_info, copy_data, 0, true); + if (copy.CopyValue(*this) && copy.GetData(copy_data)) { + Status error = SetValueFromData(*reg_info, copy_data, 0, true); + assert(error.Success() && "Expected SetValueFromData to succeed."); + UNUSED_IF_ASSERT_DISABLED(error); + } return m_type; } -Status RegisterValue::SetValueFromData(const RegisterInfo *reg_info, +Status RegisterValue::SetValueFromData(const RegisterInfo ®_info, DataExtractor &src, lldb::offset_t src_offset, bool partial_data_ok) { @@ -170,22 +174,22 @@ return error; } - if (reg_info->byte_size == 0) { + if (reg_info.byte_size == 0) { error.SetErrorString("invalid register info."); return error; } uint32_t src_len = src.GetByteSize() - src_offset; - if (!partial_data_ok && (src_len < reg_info->byte_size)) { + if (!partial_data_ok && (src_len < reg_info.byte_size)) { error.SetErrorString("not enough data."); return error; } // Cap the data length if there is more than enough bytes for this register // value - if (src_len > reg_info->byte_size) - src_len = reg_info->byte_size; + if (src_len > reg_info.byte_size) + src_len = reg_info.byte_size; // Zero out the value in case we get partial data... memset(buffer.bytes, 0, sizeof(buffer.bytes)); @@ -193,20 +197,20 @@ type128 int128; m_type = eTypeInvalid; - switch (reg_info->encoding) { + switch (reg_info.encoding) { case eEncodingInvalid: break; case eEncodingUint: case eEncodingSint: - if (reg_info->byte_size == 1) + if (reg_info.byte_size == 1) SetUInt8(src.GetMaxU32(&src_offset, src_len)); - else if (reg_info->byte_size <= 2) + else if (reg_info.byte_size <= 2) SetUInt16(src.GetMaxU32(&src_offset, src_len)); - else if (reg_info->byte_size <= 4) + else if (reg_info.byte_size <= 4) SetUInt32(src.GetMaxU32(&src_offset, src_len)); - else if (reg_info->byte_size <= 8) + else if (reg_info.byte_size <= 8) SetUInt64(src.GetMaxU64(&src_offset, src_len)); - else if (reg_info->byte_size <= 16) { + else if (reg_info.byte_size <= 16) { uint64_t data1 = src.GetU64(&src_offset); uint64_t data2 = src.GetU64(&src_offset); if (src.GetByteSize() == eByteOrderBig) { @@ -220,16 +224,16 @@ } break; case eEncodingIEEE754: - if (reg_info->byte_size == sizeof(float)) + if (reg_info.byte_size == sizeof(float)) SetFloat(src.GetFloat(&src_offset)); - else if (reg_info->byte_size == sizeof(double)) + else if (reg_info.byte_size == sizeof(double)) SetDouble(src.GetDouble(&src_offset)); - else if (reg_info->byte_size == sizeof(long double)) + else if (reg_info.byte_size == sizeof(long double)) SetLongDouble(src.GetLongDouble(&src_offset)); break; case eEncodingVector: { m_type = eTypeBytes; - buffer.length = reg_info->byte_size; + buffer.length = reg_info.byte_size; buffer.byte_order = src.GetByteOrder(); assert(buffer.length <= kMaxRegisterByteSize); if (buffer.length > kMaxRegisterByteSize) @@ -242,7 +246,7 @@ buffer.byte_order) == 0) // dst byte order { error.SetErrorStringWithFormat( - "failed to copy data for register write of %s", reg_info->name); + "failed to copy data for register write of %s", reg_info.name); return error; } } @@ -250,7 +254,7 @@ if (m_type == eTypeInvalid) error.SetErrorStringWithFormat( - "invalid register value type for register %s", reg_info->name); + "invalid register value type for register %s", reg_info.name); return error; }