[Lldb-commits] [lldb] r250696 - [LLDB][MIPS] Use the correct ptrace buffer for writing register value for o32 applications

Sagar Thakur via lldb-commits lldb-commits at lists.llvm.org
Mon Oct 19 04:21:21 PDT 2015


Author: slthakur
Date: Mon Oct 19 06:21:20 2015
New Revision: 250696

URL: http://llvm.org/viewvc/llvm-project?rev=250696&view=rev
Log:
[LLDB][MIPS] Use the correct ptrace buffer for writing register value for o32 applications

For o32 applications on mips we were getting segmentation fault while launching lldb-server because of overwritting stack when using elf_gregset_t in DoWriteRegisterValue.
We are now using the GPR_mips_linux buffer in DoWriteRegisterValue as done in DoReadRegisterValue also, which solves the above issue.


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=250696&r1=250695&r2=250696&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp Mon Oct 19 06:21:20 2015
@@ -927,7 +927,7 @@ GetWatchHi (struct pt_watch_regs *regs,
         return regs->mips32.watchhi[index];
     else if (regs->style == pt_watch_style_mips64)
         return regs->mips64.watchhi[index];
-    else
+    if(log)
         log->Printf("Invalid watch register style");
     return 0;
 }
@@ -940,7 +940,7 @@ SetWatchHi (struct pt_watch_regs *regs,
         regs->mips32.watchhi[index] = value;
     else if (regs->style == pt_watch_style_mips64)
         regs->mips64.watchhi[index] = value;
-    else
+    if(log)
         log->Printf("Invalid watch register style");
     return;
 }
@@ -953,7 +953,7 @@ GetWatchLo (struct pt_watch_regs *regs,
         return regs->mips32.watchlo[index];
     else if (regs->style == pt_watch_style_mips64)
         return regs->mips64.watchlo[index];
-    else
+    if(log)
         log->Printf("Invalid watch register style");
     return LLDB_INVALID_ADDRESS;
 }
@@ -966,7 +966,7 @@ SetWatchLo (struct pt_watch_regs *regs,
         regs->mips32.watchlo[index] = (uint32_t) value;
     else if (regs->style == pt_watch_style_mips64)
         regs->mips64.watchlo[index] = value;
-    else
+    if(log)
         log->Printf("Invalid watch register style");
     return;
 }
@@ -979,7 +979,7 @@ GetIRWMask (struct pt_watch_regs *regs,
         return regs->mips32.watch_masks[index] & IRW;
     else if (regs->style == pt_watch_style_mips64)
         return regs->mips64.watch_masks[index] & IRW;
-    else
+    if(log)
         log->Printf("Invalid watch register style");
     return 0;
 }
@@ -992,7 +992,7 @@ GetRegMask (struct pt_watch_regs *regs,
         return regs->mips32.watch_masks[index] & ~IRW;
     else if (regs->style == pt_watch_style_mips64)
         return regs->mips64.watch_masks[index] & ~IRW;
-    else
+    if(log)
         log->Printf("Invalid watch register style");
     return 0;
 }
@@ -1361,7 +1361,8 @@ NativeRegisterContextLinux_mips64::NumSu
                 num_valid = regs.mips64.num_valid;
                 return num_valid;
             default:
-                log->Printf("NativeRegisterContextLinux_mips64::%s Error: Unrecognized watch register style", __FUNCTION__);
+                if(log)
+                    log->Printf("NativeRegisterContextLinux_mips64::%s Error: Unrecognized watch register style", __FUNCTION__);
         }
         return 0;
     }
@@ -1392,7 +1393,7 @@ NativeRegisterContextLinux_mips64::DoWri
                                                         const char* reg_name,
                                                         const RegisterValue &value)
 {
-    elf_gregset_t regs;
+    GPR_linux_mips regs;
     Error error = NativeProcessLinux::PtraceWrapper(PTRACE_GETREGS, m_thread.GetID(), NULL, &regs, sizeof regs);
     if (error.Success())
     {




More information about the lldb-commits mailing list