summaryrefslogtreecommitdiff
path: root/strace.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2013-02-05 16:36:13 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2013-02-05 16:36:13 +0100
commitce7d953ebecc10f71e191b6d18cfeb2399429d5f (patch)
tree3d3a9a4989bf5ecb0dfe95ba54013ac6b3c4af6f /strace.c
parentbeae4c7182d8204a0d9fa9db2295c42744f7f377 (diff)
downloadstrace-ce7d953ebecc10f71e191b6d18cfeb2399429d5f.tar.gz
strace-ce7d953ebecc10f71e191b6d18cfeb2399429d5f.tar.bz2
strace-ce7d953ebecc10f71e191b6d18cfeb2399429d5f.tar.xz
Optimize out PTRACE_PEEKUSER with -i
strace -i was fetching PC with a separate PEEKUSER despite having GETREGS data: ptrace(PTRACE_GETREGS, 22331, 0, 0x8087f00) = 0 ptrace(PTRACE_PEEKUSER, 22331, 4*EIP, [0x80dd7b7]) = 0 write(3, "[080dd7b7] ioctl(0, SNDCTL_TMR_T"..., 82) = 82 ptrace(PTRACE_SYSCALL, 22331, 0, SIG_0) = 0 Now it does this: ptrace(PTRACE_GETREGS, 22549, 0, 0x8087ea0) = 0 write(3, "[080dd7b7] ioctl(0, SNDCTL_TMR_T"..., 82) = 82 ptrace(PTRACE_SYSCALL, 22549, 0, SIG_0) = 0 Analogous improvement in sys_sigreturn() is also implemented. * defs.h: Declare extern struct pt_regs regs for SPARC[64] and ARM. Declare clear_regs(), get_regs() and get_regs_error flag variable. * strace.c (trace): Call get_regs(pid) as soon as we know the tcb and that it is stopped. * syscall.c (get_regs): New function. Used to fetch registers early, just after tracee has stopped. (printcall): Move it here from util.c. Use global regs.REG data, if available on the arch, instead of re-fetching it. (get_scno): Use global regs.REG data. (get_syscall_result): Likewise. * signal.c (sys_sigreturn): Likewise. * util.c (printcall): Moved to syscall.c. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'strace.c')
-rw-r--r--strace.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/strace.c b/strace.c
index 1331e38..3df3fbb 100644
--- a/strace.c
+++ b/strace.c
@@ -1933,6 +1933,10 @@ trace(void)
}
}
+ clear_regs();
+ if (WIFSTOPPED(status))
+ get_regs(pid);
+
/* Under Linux, execve changes pid to thread leader's pid,
* and we see this changed pid on EVENT_EXEC and later,
* execve sysexit. Leader "disappears" without exit