Get rid of TCB_ATTACH_DONE
authorDenys Vlasenko <dvlasenk@redhat.com>
Mon, 5 Sep 2011 12:01:33 +0000 (14:01 +0200)
committerDenys Vlasenko <dvlasenk@redhat.com>
Mon, 5 Sep 2011 12:01:33 +0000 (14:01 +0200)
* defs.h: Remove TCB_ATTACH_DONE constant.
* strace.c (startup_attach): Use TCB_STARTUP instead of TCB_ATTACH_DONE
to distinquish attached from not-yet-attached threads.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
defs.h
strace.c

diff --git a/defs.h b/defs.h
index dd8fc648870ba100d32937138a9f1b0eae3db4c8..9c0d340a2674cd115755a88b120c2594330e9af5 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -458,9 +458,6 @@ struct tcb {
  */
 #define TCB_INSYSCALL  00004
 #define TCB_ATTACHED   00010   /* Process is not our own child */
-#ifdef LINUX
-#define TCB_ATTACH_DONE        00020   /* PTRACE_ATTACH was done on this tcb->pid */
-#endif
 #define TCB_BPTSET     00100   /* "Breakpoint" set after fork(2) */
 #define TCB_SIGTRAPPED 00200   /* Process wanted to block SIGTRAP */
 #define TCB_REPRINT    01000   /* We should reprint this syscall on exit */
index e95ff5ce977aa2e68463394bf1c212aa862895cb..c911ae412ed97ff5593a07e08f33233dc0282791 100644 (file)
--- a/strace.c
+++ b/strace.c
@@ -444,13 +444,11 @@ startup_attach(void)
        for (tcbi = 0; tcbi < tcbtabsize; tcbi++) {
                tcp = tcbtab[tcbi];
 
-               if (!(tcp->flags & TCB_INUSE) || !(tcp->flags & TCB_ATTACHED))
-                       continue;
-#ifdef LINUX
-               if (tcp->flags & TCB_ATTACH_DONE)
-                       continue;
-#endif
-               /* Reinitialize the output since it may have changed. */
+               /* Is this a process we should attach to, but not yet attached? */
+               if ((tcp->flags & (TCB_ATTACHED | TCB_STARTUP)) != TCB_ATTACHED)
+                       continue; /* no */
+
+               /* Reinitialize the output since it may have changed */
                tcp->outf = outf;
                newoutf(tcp);
 
@@ -493,7 +491,7 @@ startup_attach(void)
                                        cur_tcp = tcp;
                                        if (tid != tcp->pid)
                                                cur_tcp = alloctcb(tid);
-                                       cur_tcp->flags |= TCB_ATTACHED|TCB_ATTACH_DONE|TCB_STARTUP;
+                                       cur_tcp->flags |= TCB_ATTACHED | TCB_STARTUP;
                                }
                                closedir(dir);
                                if (interactive) {
@@ -548,14 +546,6 @@ startup_attach(void)
        } /* for each tcbtab[] */
 
  ret:
-#ifdef LINUX
-       /* TCB_ATTACH_DONE flag is used only in this function */
-       for (tcbi = 0; tcbi < tcbtabsize; tcbi++) {
-               tcp = tcbtab[tcbi];
-               tcp->flags &= ~TCB_ATTACH_DONE;
-       }
-#endif
-
        if (interactive)
                sigprocmask(SIG_SETMASK, &empty_set, NULL);
 }