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 @@ -99,7 +99,7 @@ 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); diff --git a/lldb/source/Host/common/NativeRegisterContext.cpp b/lldb/source/Host/common/NativeRegisterContext.cpp --- a/lldb/source/Host/common/NativeRegisterContext.cpp +++ b/lldb/source/Host/common/NativeRegisterContext.cpp @@ -376,7 +376,7 @@ // 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; diff --git a/lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp b/lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp --- a/lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp +++ b/lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp @@ -867,7 +867,7 @@ return false; } - if (data_Rt.SetFromMemoryData(&(*reg_info_Rt), buffer, + if (data_Rt.SetFromMemoryData(*reg_info_Rt, buffer, reg_info_Rt->byte_size, eByteOrderLittle, error) == 0) return false; @@ -884,7 +884,7 @@ 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,7 +1017,7 @@ if (!ReadMemory(context, address, buffer, reg_info_Rt->byte_size)) return false; - if (data_Rt.SetFromMemoryData(&(*reg_info_Rt), buffer, + if (data_Rt.SetFromMemoryData(*reg_info_Rt, buffer, reg_info_Rt->byte_size, eByteOrderLittle, error) == 0) return false; diff --git a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp --- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp @@ -284,7 +284,7 @@ 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; diff --git a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp --- a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp +++ b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp @@ -147,7 +147,7 @@ // 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 @@ 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 @@ 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 @@ } 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; diff --git a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp --- a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp +++ b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp @@ -73,7 +73,7 @@ } 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(); 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 @@ -107,7 +107,7 @@ 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; diff --git a/lldb/source/Plugins/Process/minidump/RegisterContextMinidump_ARM.cpp b/lldb/source/Plugins/Process/minidump/RegisterContextMinidump_ARM.cpp --- a/lldb/source/Plugins/Process/minidump/RegisterContextMinidump_ARM.cpp +++ b/lldb/source/Plugins/Process/minidump/RegisterContextMinidump_ARM.cpp @@ -521,7 +521,7 @@ 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(); } diff --git a/lldb/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.cpp b/lldb/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.cpp --- a/lldb/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.cpp +++ b/lldb/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.cpp @@ -806,7 +806,7 @@ 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(); } diff --git a/lldb/source/Target/RegisterContext.cpp b/lldb/source/Target/RegisterContext.cpp --- a/lldb/source/Target/RegisterContext.cpp +++ b/lldb/source/Target/RegisterContext.cpp @@ -357,7 +357,7 @@ // 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"); 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 @@ -76,15 +76,10 @@ 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 @@ 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 @@ // 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; diff --git a/lldb/unittests/tools/lldb-server/tests/MessageObjects.cpp b/lldb/unittests/tools/lldb-server/tests/MessageObjects.cpp --- a/lldb/unittests/tools/lldb-server/tests/MessageObjects.cpp +++ b/lldb/unittests/tools/lldb-server/tests/MessageObjects.cpp @@ -215,7 +215,7 @@ 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();