From: Dmitry V. Levin Date: Tue, 11 Apr 2017 04:04:37 +0000 (+0000) Subject: get_regs: guard against subsequent invocations X-Git-Tag: v4.17~113 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=13ffa2208838348cce3cfe5a3ff99f52b6f6e91e;p=strace get_regs: guard against subsequent invocations At this moment there is only one call to get_regs, but there is going to be more of them, so a guard is needed. This change also adds a clear_regs call before get_regs, which essentially reverts commit v4.9-288-ge9bfff6. * strace.c (trace): Call clear_regs before get_regs. * syscall.c (get_regs): Skip if get_regs_error != -1. --- diff --git a/strace.c b/strace.c index 7214e6ef..17979538 100644 --- a/strace.c +++ b/strace.c @@ -2295,10 +2295,9 @@ trace(void) return true; } + clear_regs(); if (WIFSTOPPED(status)) get_regs(pid); - else - clear_regs(); event = (unsigned int) status >> 16; diff --git a/syscall.c b/syscall.c index f82a0c4a..8cfc3852 100644 --- a/syscall.c +++ b/syscall.c @@ -1156,6 +1156,9 @@ get_regs(pid_t pid) #undef USE_GET_SYSCALL_RESULT_REGS #ifdef ptrace_getregset_or_getregs + if (get_regs_error != -1) + return; + # ifdef HAVE_GETREGS_OLD /* * Try PTRACE_GETREGSET/PTRACE_GETREGS first,