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 <[email protected]> --- 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 ------------------------------------------------------------------------------ Beautiful is writing same markup. Internet Explorer 9 supports standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3. Spend less time writing and rewriting code and more time creating great experiences on the web. Be a part of the beta today. http://p.sf.net/sfu/beautyoftheweb _______________________________________________ Strace-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/strace-devel
