diff options
author | Denys Vlasenko <dvlasenk@redhat.com> | 2011-06-23 21:46:37 +0200 |
---|---|---|
committer | Denys Vlasenko <dvlasenk@redhat.com> | 2011-06-23 21:46:37 +0200 |
commit | 65d7c4d66c209dce592a5a2ec0d1f83eef6b2f28 (patch) | |
tree | 30b0af1daebe99f9982ca41647bc336887bad337 /process.c | |
parent | 1c706b38097183a17d35dc05aade7f8d439d104d (diff) | |
download | strace-65d7c4d66c209dce592a5a2ec0d1f83eef6b2f28.tar.gz strace-65d7c4d66c209dce592a5a2ec0d1f83eef6b2f28.tar.bz2 strace-65d7c4d66c209dce592a5a2ec0d1f83eef6b2f28.tar.xz |
Remove TCB_FOLLOWFORK
TCB_FOLLOWFORK flag seems to be unnecessary, because we either follow
all [v]forks/clones or don't follow any, therefore global variable
followfork is an already existing indicator of what we want to do.
This patch drops all setting/clearing of TCB_FOLLOWFORK bit,
and replaces checks for this bit by checks of followfork value.
In internal_fork, check is moved to in front of if(), since
the check is needed on both "entering" and "exiting" branch.
* defs.h: Remove TCB_FOLLOWFORK define.
* process.c (internal_fork): Do not set/clear TCB_FOLLOWFORK,
test followfork instead of tcp->flags & TCB_FOLLOWFORK.
(handle_new_child): Likewise.
* strace.c (startup_attach): Likewise.
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Diffstat (limited to 'process.c')
-rw-r--r-- | process.c | 22 |
1 files changed, 8 insertions, 14 deletions
@@ -495,7 +495,6 @@ internal_fork(struct tcb *tcp) return 0; if (!followfork) return 0; - tcp->flags |= TCB_FOLLOWFORK; if (syserror(tcp)) return 0; tcpchild = alloctcb(tcp->u_rval); @@ -796,7 +795,6 @@ handle_new_child(struct tcb *tcp, int pid, int bpt) else #endif /* CLONE_PTRACE */ { - tcp->flags |= TCB_FOLLOWFORK; tcpchild = alloctcb(pid); } @@ -891,10 +889,10 @@ internal_fork(struct tcb *tcp) == (PTRACE_O_TRACECLONE | PTRACE_O_TRACEFORK | PTRACE_O_TRACEVFORK)) return 0; + if (!followfork) + return 0; + if (entering(tcp)) { - tcp->flags &= ~TCB_FOLLOWFORK; - if (!followfork) - return 0; /* * In occasion of using PTRACE_O_TRACECLONE, we won't see the * new child if clone is called with flag CLONE_UNTRACED, so @@ -903,15 +901,11 @@ internal_fork(struct tcb *tcp) if ((sysent[tcp->scno].sys_func == sys_clone) && (tcp->u_arg[ARG_FLAGS] & CLONE_UNTRACED)) return 0; - tcp->flags |= TCB_FOLLOWFORK; setbpt(tcp); } else { int pid; int bpt; - if (!(tcp->flags & TCB_FOLLOWFORK)) - return 0; - bpt = tcp->flags & TCB_BPTSET; if (syserror(tcp)) { @@ -943,17 +937,18 @@ internal_fork(struct tcb *tcp) dont_follow = 1; } #endif + + if (!followfork) + return 0; + if (entering(tcp)) { - if (!followfork || dont_follow) + if (dont_follow) return 0; - tcp->flags |= TCB_FOLLOWFORK; setbpt(tcp); } else { int bpt = tcp->flags & TCB_BPTSET; - if (!(tcp->flags & TCB_FOLLOWFORK)) - return 0; if (bpt) clearbpt(tcp); @@ -961,7 +956,6 @@ internal_fork(struct tcb *tcp) return 0; pid = tcp->u_rval; - tcp->flags |= TCB_FOLLOWFORK; tcpchild = alloctcb(pid); #ifdef SUNOS4 #ifdef oldway |