]> granicus.if.org Git - strace/commitdiff
get_regs: guard against subsequent invocations
authorDmitry V. Levin <ldv@altlinux.org>
Tue, 11 Apr 2017 04:04:37 +0000 (04:04 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 11 Apr 2017 04:04:37 +0000 (04:04 +0000)
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.

strace.c
syscall.c

index 7214e6efeba28b9def805f7d6c5d879a1fb78fdb..17979538a9f9127ca7b8f1478b58cf715aa77ce1 100644 (file)
--- 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;
 
index f82a0c4a9e149824485f7f30bece9c8bd8a7d802..8cfc3852811bc74ec33bc2caa4c7770438c2de8a 100644 (file)
--- 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,