Fix an out-of-bounds error in RegisterContextDarwin_arm64

Summary:
gcc diagnoses this as "array subscript 63 is above array bounds of
'RegisterContextDarwin_arm64::VReg [32]'".

The correct fix seems to be subtracting the fpu register base index, but
I have no way of verifying that this actually works.

Reviewers: jasonmolenda

Subscribers: javed.absar, kristof.beyls, lldb-commits

Differential Revision: https://reviews.llvm.org/D59495

llvm-svn: 357055
This commit is contained in:
Pavel Labath 2019-03-27 09:39:46 +00:00
parent 3f2e29b013
commit cf6c19c2d3
1 changed files with 3 additions and 2 deletions

View File

@ -429,7 +429,7 @@ bool RegisterContextDarwin_arm64::ReadRegister(const RegisterInfo *reg_info,
case fpu_v29:
case fpu_v30:
case fpu_v31:
value.SetBytes(fpu.v[reg].bytes.buffer, reg_info->byte_size,
value.SetBytes(fpu.v[reg - fpu_v0].bytes.buffer, reg_info->byte_size,
endian::InlHostByteOrder());
break;
@ -621,7 +621,8 @@ bool RegisterContextDarwin_arm64::WriteRegister(const RegisterInfo *reg_info,
case fpu_v29:
case fpu_v30:
case fpu_v31:
::memcpy(fpu.v[reg].bytes.buffer, value.GetBytes(), value.GetByteSize());
::memcpy(fpu.v[reg - fpu_v0].bytes.buffer, value.GetBytes(),
value.GetByteSize());
break;
case fpu_fpsr: