]> granicus.if.org Git - strace/commitdiff
strace.c: handle PTRACE_EVENT_EXEC like other events
authorDmitry V. Levin <ldv@altlinux.org>
Fri, 2 Jun 2017 21:49:02 +0000 (21:49 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Fri, 2 Jun 2017 21:49:02 +0000 (21:49 +0000)
There is nothing unusual about PTRACE_EVENT_EXEC that would require
a special treatment.

* strace.c (next_event): Move PTRACE_EVENT_EXEC handling to the main
switch statement.

strace.c

index aa6d5388270a29e9ed34b643188b3a78cdb27f55..6d5c29aac143117e488eb9619b8442f6f479d81e 100644 (file)
--- a/strace.c
+++ b/strace.c
@@ -2311,8 +2311,6 @@ next_event(int *pstatus, siginfo_t *si)
        int pid;
        int wait_errno;
        int status;
-       unsigned int sig;
-       unsigned int event;
        struct tcb *tcp;
        struct rusage ru;
 
@@ -2382,14 +2380,9 @@ next_event(int *pstatus, siginfo_t *si)
 
        clear_regs();
 
-       event = (unsigned int) status >> 16;
-
        /* Set current output file */
        current_tcp = tcp;
 
-       if (event == PTRACE_EVENT_EXEC)
-               return TE_STOP_BEFORE_EXECVE;
-
        if (cflag) {
                tv_sub(&tcp->dtime, &ru.ru_stime, &tcp->stime);
                tcp->stime = ru.ru_stime;
@@ -2411,7 +2404,8 @@ next_event(int *pstatus, siginfo_t *si)
        if (tcp->flags & TCB_STARTUP)
                startup_tcb(tcp);
 
-       sig = WSTOPSIG(status);
+       const unsigned int sig = WSTOPSIG(status);
+       const unsigned int event = (unsigned int) status >> 16;
 
        switch (event) {
        case 0:
@@ -2456,6 +2450,8 @@ next_event(int *pstatus, siginfo_t *si)
                }
                return TE_RESTART;
 #endif
+       case PTRACE_EVENT_EXEC:
+               return TE_STOP_BEFORE_EXECVE;
        case PTRACE_EVENT_EXIT:
                return TE_STOP_BEFORE_EXIT;
        default: