forked from OSchip/llvm-project
[LLDB] Change RegisterValue::SetFromMemoryData to const RegisterInfo&
All callers were either assuming their pointer was not null before calling this, or checking beforehand. Reviewed By: clayborg Differential Revision: https://reviews.llvm.org/D135668
This commit is contained in:
parent
e75c87f22c
commit
812ad2167b
|
@ -99,7 +99,7 @@ public:
|
|||
uint32_t dst_len, lldb::ByteOrder dst_byte_order,
|
||||
Status &error) const;
|
||||
|
||||
uint32_t SetFromMemoryData(const RegisterInfo *reg_info, const void *src,
|
||||
uint32_t SetFromMemoryData(const RegisterInfo ®_info, const void *src,
|
||||
uint32_t src_len, lldb::ByteOrder src_byte_order,
|
||||
Status &error);
|
||||
|
||||
|
|
|
@ -376,7 +376,7 @@ Status NativeRegisterContext::ReadRegisterValueFromMemory(
|
|||
// TODO: we might need to add a parameter to this function in case the byte
|
||||
// order of the memory data doesn't match the process. For now we are
|
||||
// assuming they are the same.
|
||||
reg_value.SetFromMemoryData(reg_info, src, src_len, process.GetByteOrder(),
|
||||
reg_value.SetFromMemoryData(*reg_info, src, src_len, process.GetByteOrder(),
|
||||
error);
|
||||
|
||||
return error;
|
||||
|
|
|
@ -867,9 +867,8 @@ bool EmulateInstructionARM64::EmulateLDPSTP(const uint32_t opcode) {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (data_Rt.SetFromMemoryData(&(*reg_info_Rt), buffer,
|
||||
reg_info_Rt->byte_size, eByteOrderLittle,
|
||||
error) == 0)
|
||||
if (data_Rt.SetFromMemoryData(*reg_info_Rt, buffer, reg_info_Rt->byte_size,
|
||||
eByteOrderLittle, error) == 0)
|
||||
return false;
|
||||
|
||||
if (!vector && is_signed && !data_Rt.SignExtend(datasize))
|
||||
|
@ -884,7 +883,7 @@ bool EmulateInstructionARM64::EmulateLDPSTP(const uint32_t opcode) {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (data_Rt2.SetFromMemoryData(&(*reg_info_Rt2), buffer,
|
||||
if (data_Rt2.SetFromMemoryData(*reg_info_Rt2, buffer,
|
||||
reg_info_Rt2->byte_size, eByteOrderLittle,
|
||||
error) == 0)
|
||||
return false;
|
||||
|
@ -1017,9 +1016,8 @@ bool EmulateInstructionARM64::EmulateLDRSTRImm(const uint32_t opcode) {
|
|||
if (!ReadMemory(context, address, buffer, reg_info_Rt->byte_size))
|
||||
return false;
|
||||
|
||||
if (data_Rt.SetFromMemoryData(&(*reg_info_Rt), buffer,
|
||||
reg_info_Rt->byte_size, eByteOrderLittle,
|
||||
error) == 0)
|
||||
if (data_Rt.SetFromMemoryData(*reg_info_Rt, buffer, reg_info_Rt->byte_size,
|
||||
eByteOrderLittle, error) == 0)
|
||||
return false;
|
||||
|
||||
if (!WriteRegister(context, *reg_info_Rt, data_Rt))
|
||||
|
|
|
@ -284,7 +284,7 @@ NativeRegisterContextLinux_arm64::ReadRegister(const RegisterInfo *reg_info,
|
|||
return Status("failed - register wasn't recognized to be a GPR or an FPR, "
|
||||
"write strategy unknown");
|
||||
|
||||
reg_value.SetFromMemoryData(reg_info, src, reg_info->byte_size,
|
||||
reg_value.SetFromMemoryData(*reg_info, src, reg_info->byte_size,
|
||||
eByteOrderLittle, error);
|
||||
|
||||
return error;
|
||||
|
|
|
@ -147,7 +147,7 @@ bool RegisterContextCorePOSIX_arm64::ReadRegister(const RegisterInfo *reg_info,
|
|||
// SVE is disabled take legacy route for FPU register access
|
||||
offset -= GetGPRSize();
|
||||
if (offset < m_fpr_data.GetByteSize()) {
|
||||
value.SetFromMemoryData(reg_info, m_fpr_data.GetDataStart() + offset,
|
||||
value.SetFromMemoryData(*reg_info, m_fpr_data.GetDataStart() + offset,
|
||||
reg_info->byte_size, lldb::eByteOrderLittle,
|
||||
error);
|
||||
return error.Success();
|
||||
|
@ -180,7 +180,7 @@ bool RegisterContextCorePOSIX_arm64::ReadRegister(const RegisterInfo *reg_info,
|
|||
|
||||
assert(sve_reg_num != LLDB_INVALID_REGNUM);
|
||||
assert(offset < m_sve_data.GetByteSize());
|
||||
value.SetFromMemoryData(reg_info, GetSVEBuffer(offset),
|
||||
value.SetFromMemoryData(*reg_info, GetSVEBuffer(offset),
|
||||
reg_info->byte_size, lldb::eByteOrderLittle,
|
||||
error);
|
||||
}
|
||||
|
@ -204,13 +204,13 @@ bool RegisterContextCorePOSIX_arm64::ReadRegister(const RegisterInfo *reg_info,
|
|||
assert(offset < m_sve_data.GetByteSize());
|
||||
src = GetSVEBuffer(offset);
|
||||
}
|
||||
value.SetFromMemoryData(reg_info, src, byte_size, lldb::eByteOrderLittle,
|
||||
value.SetFromMemoryData(*reg_info, src, byte_size, lldb::eByteOrderLittle,
|
||||
error);
|
||||
} break;
|
||||
case SVEState::Full:
|
||||
offset = CalculateSVEOffset(reg_info);
|
||||
assert(offset < m_sve_data.GetByteSize());
|
||||
value.SetFromMemoryData(reg_info, GetSVEBuffer(offset),
|
||||
value.SetFromMemoryData(*reg_info, GetSVEBuffer(offset),
|
||||
reg_info->byte_size, lldb::eByteOrderLittle,
|
||||
error);
|
||||
break;
|
||||
|
@ -221,7 +221,7 @@ bool RegisterContextCorePOSIX_arm64::ReadRegister(const RegisterInfo *reg_info,
|
|||
} else if (IsPAuth(reg)) {
|
||||
offset = reg_info->byte_offset - m_register_info_up->GetPAuthOffset();
|
||||
assert(offset < m_pac_data.GetByteSize());
|
||||
value.SetFromMemoryData(reg_info, m_pac_data.GetDataStart() + offset,
|
||||
value.SetFromMemoryData(*reg_info, m_pac_data.GetDataStart() + offset,
|
||||
reg_info->byte_size, lldb::eByteOrderLittle, error);
|
||||
} else
|
||||
return false;
|
||||
|
|
|
@ -73,7 +73,7 @@ bool RegisterContextCorePOSIX_x86_64::ReadRegister(const RegisterInfo *reg_info,
|
|||
}
|
||||
|
||||
Status error;
|
||||
value.SetFromMemoryData(reg_info, src + offset, reg_info->byte_size,
|
||||
value.SetFromMemoryData(*reg_info, src + offset, reg_info->byte_size,
|
||||
lldb::eByteOrderLittle, error);
|
||||
|
||||
return error.Success();
|
||||
|
|
|
@ -107,7 +107,7 @@ bool GDBRemoteRegisterContext::ReadRegister(const RegisterInfo *reg_info,
|
|||
|
||||
Status error;
|
||||
return value.SetFromMemoryData(
|
||||
reg_info, combined_data.data(), combined_data.size(),
|
||||
*reg_info, combined_data.data(), combined_data.size(),
|
||||
m_reg_data.GetByteOrder(), error) == combined_data.size();
|
||||
} else {
|
||||
const bool partial_data_ok = false;
|
||||
|
|
|
@ -521,7 +521,7 @@ bool RegisterContextMinidump_ARM::ReadRegister(const RegisterInfo *reg_info,
|
|||
RegisterValue ®_value) {
|
||||
Status error;
|
||||
reg_value.SetFromMemoryData(
|
||||
reg_info, (const uint8_t *)&m_regs + reg_info->byte_offset,
|
||||
*reg_info, (const uint8_t *)&m_regs + reg_info->byte_offset,
|
||||
reg_info->byte_size, lldb::eByteOrderLittle, error);
|
||||
return error.Success();
|
||||
}
|
||||
|
|
|
@ -806,7 +806,7 @@ bool RegisterContextMinidump_ARM64::ReadRegister(const RegisterInfo *reg_info,
|
|||
RegisterValue ®_value) {
|
||||
Status error;
|
||||
reg_value.SetFromMemoryData(
|
||||
reg_info, (const uint8_t *)&m_regs + reg_info->byte_offset,
|
||||
*reg_info, (const uint8_t *)&m_regs + reg_info->byte_offset,
|
||||
reg_info->byte_size, lldb::eByteOrderLittle, error);
|
||||
return error.Success();
|
||||
}
|
||||
|
|
|
@ -357,7 +357,7 @@ Status RegisterContext::ReadRegisterValueFromMemory(
|
|||
// TODO: we might need to add a parameter to this function in case the byte
|
||||
// order of the memory data doesn't match the process. For now we are
|
||||
// assuming they are the same.
|
||||
reg_value.SetFromMemoryData(reg_info, src, src_len,
|
||||
reg_value.SetFromMemoryData(*reg_info, src, src_len,
|
||||
process_sp->GetByteOrder(), error);
|
||||
} else
|
||||
error.SetErrorString("invalid process");
|
||||
|
|
|
@ -76,15 +76,10 @@ uint32_t RegisterValue::GetAsMemoryData(const RegisterInfo ®_info, void *dst,
|
|||
return bytes_copied;
|
||||
}
|
||||
|
||||
uint32_t RegisterValue::SetFromMemoryData(const RegisterInfo *reg_info,
|
||||
uint32_t RegisterValue::SetFromMemoryData(const RegisterInfo ®_info,
|
||||
const void *src, uint32_t src_len,
|
||||
lldb::ByteOrder src_byte_order,
|
||||
Status &error) {
|
||||
if (reg_info == nullptr) {
|
||||
error.SetErrorString("invalid register info argument.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Moving from addr into a register
|
||||
//
|
||||
// Case 1: src_len == dst_len
|
||||
|
@ -107,12 +102,12 @@ uint32_t RegisterValue::SetFromMemoryData(const RegisterInfo *reg_info,
|
|||
return 0;
|
||||
}
|
||||
|
||||
const uint32_t dst_len = reg_info->byte_size;
|
||||
const uint32_t dst_len = reg_info.byte_size;
|
||||
|
||||
if (src_len > dst_len) {
|
||||
error.SetErrorStringWithFormat(
|
||||
"%u bytes is too big to store in register %s (%u bytes)", src_len,
|
||||
reg_info->name, dst_len);
|
||||
reg_info.name, dst_len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -120,7 +115,7 @@ uint32_t RegisterValue::SetFromMemoryData(const RegisterInfo *reg_info,
|
|||
// register value
|
||||
DataExtractor src_data(src, src_len, src_byte_order, 4);
|
||||
|
||||
error = SetValueFromData(reg_info, src_data, 0, true);
|
||||
error = SetValueFromData(®_info, src_data, 0, true);
|
||||
if (error.Fail())
|
||||
return 0;
|
||||
|
||||
|
|
|
@ -215,7 +215,7 @@ Expected<RegisterValue> parseRegisterValue(const RegisterInfo &Info,
|
|||
RegisterValue Value;
|
||||
Status ST;
|
||||
Value.SetFromMemoryData(
|
||||
&Info, Bytes.data(), Bytes.size(),
|
||||
Info, Bytes.data(), Bytes.size(),
|
||||
Endian == support::little ? eByteOrderLittle : eByteOrderBig, ST);
|
||||
if (ST.Fail())
|
||||
return ST.ToError();
|
||||
|
|
Loading…
Reference in New Issue