diff options
| author | David Spickett <david.spickett@linaro.org> | 2022-09-28 14:00:02 +0000 |
|---|---|---|
| committer | David Spickett <david.spickett@linaro.org> | 2022-10-11 13:59:05 +0000 |
| commit | c7ddbd62d811524726e6f8e293ab1576c5b289f3 (patch) | |
| tree | c4212e690b17d74e9de78cc47f9c38d8dd86c8d0 /lldb/source/Host/common/NativeRegisterContext.cpp | |
| parent | 7ec604a317c765552e28626dc85d610f8ca20dc0 (diff) | |
[LLDB] Change RegisterValue::GetAsMemoryData to const RegisterInfo&
Most of the paths to this never passed nullptr intentionally. Those
that possibly could have were assuming it was not null elsehwere,
so would have crashed.
I've added asserts in those cases.
At least one case was relying on GetAsMemoryData to return an error
when it was given nullptr. So I've hoisted that error setting code
out into the caller.
Depends on D134963
Reviewed By: clayborg
Differential Revision: https://reviews.llvm.org/D134965
Diffstat (limited to 'lldb/source/Host/common/NativeRegisterContext.cpp')
| -rw-r--r-- | lldb/source/Host/common/NativeRegisterContext.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lldb/source/Host/common/NativeRegisterContext.cpp b/lldb/source/Host/common/NativeRegisterContext.cpp index 7e4ffe8dfa18..0110a8ac9e2d 100644 --- a/lldb/source/Host/common/NativeRegisterContext.cpp +++ b/lldb/source/Host/common/NativeRegisterContext.cpp @@ -385,18 +385,20 @@ Status NativeRegisterContext::ReadRegisterValueFromMemory( Status NativeRegisterContext::WriteRegisterValueToMemory( const RegisterInfo *reg_info, lldb::addr_t dst_addr, size_t dst_len, const RegisterValue ®_value) { - - uint8_t dst[RegisterValue::kMaxRegisterByteSize]; - Status error; + if (reg_info == nullptr) { + error.SetErrorString("Invalid register info argument."); + return error; + } + uint8_t dst[RegisterValue::kMaxRegisterByteSize]; NativeProcessProtocol &process = m_thread.GetProcess(); // 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. const size_t bytes_copied = reg_value.GetAsMemoryData( - reg_info, dst, dst_len, process.GetByteOrder(), error); + *reg_info, dst, dst_len, process.GetByteOrder(), error); if (error.Success()) { if (bytes_copied == 0) { |
