This is an archive of the discontinued LLVM Phabricator instance.

[LLDB][MIPS] Fix TestExpressionInSyscall.py for MIPS
ClosedPublic

Authored by bhushan on Feb 4 2016, 11:32 PM.

Details

Reviewers
clayborg
Summary

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.

Diff Detail

Repository
rL LLVM

Event Timeline

bhushan updated this revision to Diff 46996.Feb 4 2016, 11:32 PM
bhushan retitled this revision from to [LLDB][MIPS] Fix TestExpressionInSyscall.py for MIPS.
bhushan updated this object.
bhushan added a reviewer: clayborg.
bhushan set the repository for this revision to rL LLVM.
clayborg accepted this revision.Feb 5 2016, 9:14 AM
clayborg edited edge metadata.

Sounds reasonable.

This revision is now accepted and ready to land.Feb 5 2016, 9:14 AM