[Lldb-commits] [lldb] r256834 - [LLDB][MIPS] Make register read/write to set/get the size of register according to abi.

Sagar Thakur via lldb-commits lldb-commits at lists.llvm.org
Tue Jan 5 06:03:46 PST 2016


Author: slthakur
Date: Tue Jan  5 08:03:45 2016
New Revision: 256834

URL: http://llvm.org/viewvc/llvm-project?rev=256834&view=rev
Log:
[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

Modified:
    lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp

Modified: lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp?rev=256834&r1=256833&r2=256834&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp Tue Jan  5 08:03:45 2016
@@ -1388,7 +1388,7 @@ NativeRegisterContextLinux_mips64::DoRea
     {
         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::DoWri
     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;
 }




More information about the lldb-commits mailing list