On Thu, Feb 4, 2016 at 11:32 PM Bhushan Attarde via lldb-commits < lldb-commits@lists.llvm.org> wrote:
> bhushan created this revision. > bhushan added a reviewer: clayborg. > bhushan added subscribers: lldb-commits, nitesh.jain, mohit.bhakkad, > sagar, jaydeep. > bhushan set the repository for this revision to rL LLVM. > > This test (TestExpressionInSyscall.py) checks if we are able to evaluate > expressions when the inferior is blocked in a syscall. > > As a part of expression evaluation LLDB checks for memory allocation on > target (by executing mmap). > So we setup call to mmap by setting argument registers and PC. > Now the process is stopped in the syscall and when it continue to allocate > memory, the system call is restarted. > > In MIPS, to restart a syscall, kernel decreases the PC by 4 so the > resulting PC now points to mmap-4 > and also register R7 that provides 'flags' argument to mmap gets clobbered > to 0 and hence mmap fails. > > A fix to this issue is to postpone the syscall restart until the > expression is evaluated. > In MIPS, register R0 controls syscall restart. This patch writes 0 into > register R0 when preparing call to mmap. > This setting avoids a syscall restart and prevents automatic decrement of > the PC so that expression can be evaluated correctly. > > Once the expression completes the registers are restored and program > resumes the interrupted syscall when the continue command is issued. > > This fixes TestExpressionInSyscall.py and solves bug 23659 for MIPS. > > Repository: > rL LLVM > > http://reviews.llvm.org/D16916 > > Files: > source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp > source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp > > Index: source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp > =================================================================== > --- source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp > +++ source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp > @@ -207,6 +207,17 @@ > const RegisterInfo *sp_reg_info = reg_ctx->GetRegisterInfo > (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); > const RegisterInfo *ra_reg_info = reg_ctx->GetRegisterInfo > (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_RA); > const RegisterInfo *r25_info = reg_ctx->GetRegisterInfoByName("r25", > 0); > + const RegisterInfo *r0_info = reg_ctx->GetRegisterInfoByName("zero", > 0); > + > + if (log) > + log->Printf("Writing R0: 0x%" PRIx64, (uint64_t)0); > Your indentation is wrong here. Please use clang-format on this patch. > + > + /* Write r0 with 0, in case we are stopped in syscall, > + * such setting prevents automatic decrement of the PC. > + * This clears the bug 23659 for MIPS. > + */ > + if (!reg_ctx->WriteRegisterFromUnsigned (r0_info, (uint64_t)0)) > + return false; > > if (log) > log->Printf("Writing SP: 0x%" PRIx64, (uint64_t)sp); > Index: source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp > =================================================================== > --- source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp > +++ source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp > @@ -242,6 +242,17 @@ > const RegisterInfo *sp_reg_info = reg_ctx->GetRegisterInfo > (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); > const RegisterInfo *ra_reg_info = reg_ctx->GetRegisterInfo > (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_RA); > const RegisterInfo *r25_info = reg_ctx->GetRegisterInfoByName("r25", > 0); > + const RegisterInfo *r0_info = reg_ctx->GetRegisterInfoByName("zero", > 0); > + > + if (log) > + log->Printf("Writing R0: 0x%" PRIx64, (uint64_t)0); > Also wrong here. > + > + /* Write r0 with 0, in case we are stopped in syscall, > + * such setting prevents automatic decrement of the PC. > + * This clears the bug 23659 for MIPS. > + */ > + if (!reg_ctx->WriteRegisterFromUnsigned (r0_info, (uint64_t)0)) > + return false; > > if (log) > log->Printf("Writing SP: 0x%" PRIx64, (uint64_t)sp); > > > _______________________________________________ > lldb-commits mailing list > lldb-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits >
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits