[PATCH] Fix strace -p with ARM OABI compat and restart_syscall

Steve Bennett steveb at workware.net.au
Thu Oct 14 04:18:58 UTC 2010


When ARM OABI compat mode is enabled on Linux, a process that has
received a signal and is sitting on a kernel trampoline.
Detect this case so that the process can be traced.

Note: There is probably a much better test for this case.

Signed-off-by: Steve Bennett <steveb at workware.net.au>
---
 syscall.c |   27 +++++++++++++++++++--------
 1 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/syscall.c b/syscall.c
index a742571..a4461fe 100644
--- a/syscall.c
+++ b/syscall.c
@@ -1040,14 +1040,20 @@ get_scno(struct tcb *tcp)
 			/*
 			 * Get the ARM-mode system call number
 			 */
-			errno = 0;
-			scno = ptrace(PTRACE_PEEKTEXT, tcp->pid, (void *)(regs.ARM_pc - 4), NULL);
-			if (errno)
-				return -1;
-
-			if (scno == 0 && (tcp->flags & TCB_WAITEXECVE)) {
-				tcp->flags &= ~TCB_WAITEXECVE;
-				return 0;
+			
+			/* We may be in syscall_restart via a kernel trampoline.
+			 * In this case pc[-4] won't be useful.
+			 * Use a dodgy test for this case.
+			 */
+			if ((regs.ARM_pc & 0xffff0000) == 0xffff0000) {
+				/* restart syscall is 0 */
+				scno = 0x0f900000;
+			}
+			else {
+				errno = 0;
+				scno = ptrace(PTRACE_PEEKTEXT, tcp->pid, (void *)(regs.ARM_pc - 4), NULL);
+				if (errno)
+					return -1;
 			}
 
 			/* Handle the EABI syscall convention.  We do not
@@ -1079,6 +1085,11 @@ get_scno(struct tcb *tcp)
 		} else
 			set_personality(0);
 
+		if (scno == 0 && (tcp->flags & TCB_WAITEXECVE)) {
+			tcp->flags &= ~TCB_WAITEXECVE;
+			return 0;
+		}
+
 		if (tcp->flags & TCB_INSYSCALL) {
 			fprintf(stderr, "pid %d stray syscall entry\n", tcp->pid);
 			tcp->flags &= ~TCB_INSYSCALL;
-- 
1.5.5.3





More information about the Strace-devel mailing list