[LLDB][MIPS] Make register read/write to set/get the size of register according to abi.

Summary:
For O32 abi register size should be 4 bytes.
For N32 and N64 abi register size should be 8 bytes.
This patch will make register read/write to set/get the size of register according to abi.

Reviewers: clayborg, tberghammer
Subscribers: lldb-commits, nitesh.jain, mohit.bhakkad, bhushan, jaydeep
Differential: http://reviews.llvm.org/D15884
llvm-svn: 256834
This commit is contained in:
Sagar Thakur
2016-01-05 14:03:45 +00:00
parent 7093cccf92
commit 307a3ba3b3

View File

@@ -1388,7 +1388,7 @@ NativeRegisterContextLinux_mips64::DoReadRegisterValue(uint32_t offset,
{
lldb_private::ArchSpec arch;
if (m_thread.GetProcess()->GetArchitecture(arch))
value.SetBytes((void *)(((unsigned char *)&regs) + offset + 4 * (arch.GetMachine() == llvm::Triple::mips)), arch.GetAddressByteSize(), arch.GetByteOrder());
value.SetBytes((void *)(((unsigned char *)&regs) + offset + 4 * (arch.GetMachine() == llvm::Triple::mips)), arch.GetFlags() & lldb_private::ArchSpec::eMIPSABI_O32 ? 4 : 8, arch.GetByteOrder());
else
error.SetErrorString("failed to get architecture");
}
@@ -1404,8 +1404,14 @@ NativeRegisterContextLinux_mips64::DoWriteRegisterValue(uint32_t offset,
Error error = NativeProcessLinux::PtraceWrapper(PTRACE_GETREGS, m_thread.GetID(), NULL, &regs, sizeof regs);
if (error.Success())
{
::memcpy((void *)(((unsigned char *)(&regs)) + offset), value.GetBytes(), 8);
error = NativeProcessLinux::PtraceWrapper(PTRACE_SETREGS, m_thread.GetID(), NULL, &regs, sizeof regs);
lldb_private::ArchSpec arch;
if (m_thread.GetProcess()->GetArchitecture(arch))
{
::memcpy((void *)(((unsigned char *)(&regs)) + offset), value.GetBytes(), arch.GetFlags() & lldb_private::ArchSpec::eMIPSABI_O32 ? 4 : 8);
error = NativeProcessLinux::PtraceWrapper(PTRACE_SETREGS, m_thread.GetID(), NULL, &regs, sizeof regs);
}
else
error.SetErrorString("failed to get architecture");
}
return error;
}