Fix the handling of FPR offsets in Linux arm/aarch64 register contexts

Differential revision: http://reviews.llvm.org/D12636

llvm-svn: 246959
This commit is contained in:
Tamas Berghammer 2015-09-07 10:11:23 +00:00
parent 25b9f7ebd3
commit c40e7b1769
5 changed files with 32 additions and 9 deletions

View File

@ -229,8 +229,9 @@ NativeRegisterContextLinux_arm::ReadRegister (const RegisterInfo *reg_info, Regi
}
// Get pointer to m_fpr variable and set the data from it.
assert (reg_info->byte_offset < sizeof m_fpr);
uint8_t *src = (uint8_t *)&m_fpr + reg_info->byte_offset;
uint32_t fpr_offset = CalculateFprOffset(reg_info);
assert (fpr_offset < sizeof m_fpr);
uint8_t *src = (uint8_t *)&m_fpr + fpr_offset;
switch (reg_info->byte_size)
{
case 2:
@ -267,8 +268,9 @@ NativeRegisterContextLinux_arm::WriteRegister (const RegisterInfo *reg_info, con
if (IsFPR(reg_index))
{
// Get pointer to m_fpr variable and set the data to it.
assert (reg_info->byte_offset < sizeof(m_fpr));
uint8_t *dst = (uint8_t *)&m_fpr + reg_info->byte_offset;
uint32_t fpr_offset = CalculateFprOffset(reg_info);
assert (fpr_offset < sizeof m_fpr);
uint8_t *dst = (uint8_t *)&m_fpr + fpr_offset;
switch (reg_info->byte_size)
{
case 2:
@ -844,4 +846,11 @@ NativeRegisterContextLinux_arm::WriteHardwareDebugRegs(int hwbType, int hwb_inde
return error;
}
uint32_t
NativeRegisterContextLinux_arm::CalculateFprOffset(const RegisterInfo* reg_info) const
{
return reg_info->byte_offset - GetRegisterInfoAtIndex(m_reg_info.first_fpr)->byte_offset;
}
#endif // defined(__arm__)

View File

@ -161,6 +161,9 @@ namespace process_linux {
Error
WriteHardwareDebugRegs(int hwbType, int hwb_index);
uint32_t
CalculateFprOffset(const RegisterInfo* reg_info) const;
};
} // namespace process_linux

View File

@ -249,8 +249,9 @@ NativeRegisterContextLinux_arm64::ReadRegister (const RegisterInfo *reg_info, Re
}
// Get pointer to m_fpr variable and set the data from it.
assert (reg_info->byte_offset < sizeof m_fpr);
uint8_t *src = (uint8_t *)&m_fpr + reg_info->byte_offset;
uint32_t fpr_offset = CalculateFprOffset(reg_info);
assert (fpr_offset < sizeof m_fpr);
uint8_t *src = (uint8_t *)&m_fpr + fpr_offset;
reg_value.SetFromMemoryData(reg_info, src, reg_info->byte_size, eByteOrderLittle, error);
return error;
@ -272,8 +273,9 @@ NativeRegisterContextLinux_arm64::WriteRegister (const RegisterInfo *reg_info, c
if (IsFPR(reg_index))
{
// Get pointer to m_fpr variable and set the data to it.
assert (reg_info->byte_offset < sizeof(m_fpr));
uint8_t *dst = (uint8_t *)&m_fpr + reg_info->byte_offset;
uint32_t fpr_offset = CalculateFprOffset(reg_info);
assert (fpr_offset < sizeof m_fpr);
uint8_t *dst = (uint8_t *)&m_fpr + fpr_offset;
switch (reg_info->byte_size)
{
case 2:
@ -980,4 +982,10 @@ NativeRegisterContextLinux_arm64::DoWriteFPR(void *buf, size_t buf_size)
return NativeProcessLinux::PtraceWrapper(PTRACE_SETREGSET, m_thread.GetID(), &regset, &ioVec, buf_size);
}
uint32_t
NativeRegisterContextLinux_arm64::CalculateFprOffset(const RegisterInfo* reg_info) const
{
return reg_info->byte_offset - GetRegisterInfoAtIndex(m_reg_info.first_fpr)->byte_offset;
}
#endif // defined (__arm64__) || defined (__aarch64__)

View File

@ -183,6 +183,9 @@ namespace process_linux {
Error
WriteHardwareDebugRegs(int hwbType);
uint32_t
CalculateFprOffset(const RegisterInfo* reg_info) const;
};
} // namespace process_linux

View File

@ -21,7 +21,7 @@
#define GPR_OFFSET_NAME(reg) (LLVM_EXTENSION offsetof (RegisterContextLinux_arm64::GPR, reg))
#define FPU_OFFSET(idx) ((idx) * 16 + sizeof (RegisterContextLinux_arm64::GPR))
#define FPU_OFFSET_NAME(reg) (LLVM_EXTENSION offsetof (RegisterContextLinux_arm64::FPU, reg))
#define FPU_OFFSET_NAME(reg) (LLVM_EXTENSION offsetof (RegisterContextLinux_arm64::FPU, reg) + sizeof (RegisterContextLinux_arm64::GPR))
#define EXC_OFFSET_NAME(reg) (LLVM_EXTENSION offsetof (RegisterContextLinux_arm64::EXC, reg) + sizeof (RegisterContextLinux_arm64::GPR) + sizeof (RegisterContextLinux_arm64::FPU))
#define DBG_OFFSET_NAME(reg) (LLVM_EXTENSION offsetof (RegisterContextLinux_arm64::DBG, reg) + sizeof (RegisterContextLinux_arm64::GPR) + sizeof (RegisterContextLinux_arm64::FPU) + sizeof (RegisterContextLinux_arm64::EXC))