Remove write-only nchildren member from struct tcb

* defs.h: Remove nchildren member from struct tcb.
* process.c (handle_new_child): Remove inc/decrements of tcp->nchildren.
  (internal_fork): Likewise.
* strace.c (startup_attach): Likewise.
  (droptcb): Likewise.
  (alloc_tcb): Remove initialization of tcp->nchildren.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
This commit is contained in:
Denys Vlasenko 2011-06-21 16:06:28 +02:00
parent 8f0f14b6da
commit b56d6d3bfe
3 changed files with 4 additions and 14 deletions

3
defs.h
View File

@ -368,9 +368,8 @@ struct tcb {
struct timeval etime; /* Syscall entry time */
/* Support for tracing forked processes */
struct tcb *parent; /* Parent of this process */
int nchildren; /* # of traced children */
#ifdef LINUX
int nclone_threads; /* # of nchildren with CLONE_THREAD */
int nclone_threads; /* # of children with CLONE_THREAD */
#endif
/* (1st arg of wait4()) */
long baddr; /* `Breakpoint' address */

View File

@ -836,7 +836,6 @@ handle_new_child(struct tcb *tcp, int pid, int bpt)
sizeof tcpchild->inst);
}
tcpchild->parent = tcp;
tcp->nchildren++;
if (tcpchild->flags & TCB_SUSPENDED) {
/* The child was born suspended, due to our having
forced CLONE_PTRACE. */
@ -877,10 +876,8 @@ Process %u resumed (parent %d ready)\n",
new thread, there will never be a
TCB_CLONE_THREAD process that has
children. */
--tcp->nchildren;
tcp = tcp->parent;
tcpchild->parent = tcp;
++tcp->nchildren;
}
if (call_flags & CLONE_THREAD) {
tcpchild->flags |= TCB_CLONE_THREAD;
@ -888,12 +885,10 @@ Process %u resumed (parent %d ready)\n",
}
if ((call_flags & CLONE_PARENT) &&
!(call_flags & CLONE_THREAD)) {
--tcp->nchildren;
tcpchild->parent = NULL;
if (tcp->parent != NULL) {
tcp = tcp->parent;
tcpchild->parent = tcp;
++tcp->nchildren;
}
}
}
@ -1023,7 +1018,6 @@ internal_fork(struct tcb *tcp)
sizeof tcpchild->inst);
}
tcpchild->parent = tcp;
tcp->nchildren++;
if (!qflag)
fprintf(stderr, "Process %d attached\n", pid);
}

View File

@ -514,7 +514,6 @@ startup_attach(void)
else if (tid != tcbtab[tcbi]->pid) {
tcp = alloctcb(tid);
tcp->flags |= TCB_ATTACHED|TCB_CLONE_THREAD|TCB_FOLLOWFORK;
tcbtab[tcbi]->nchildren++;
tcbtab[tcbi]->nclone_threads++;
tcp->parent = tcbtab[tcbi];
}
@ -1284,7 +1283,6 @@ alloc_tcb(int pid, int command_options_parsed)
if ((tcp->flags & TCB_INUSE) == 0) {
tcp->pid = pid;
tcp->parent = NULL;
tcp->nchildren = 0;
#ifdef TCB_CLONE_THREAD
tcp->nclone_threads = 0;
#endif
@ -1662,15 +1660,14 @@ droptcb(struct tcb *tcp)
tcp->pid = 0;
if (tcp->parent != NULL) {
tcp->parent->nchildren--;
#ifdef TCB_CLONE_THREAD
if (tcp->flags & TCB_CLONE_THREAD)
tcp->parent->nclone_threads--;
#endif
#ifdef LINUX
/* Update `tcp->parent->parent->nchildren' and the other fields
like NCLONE_DETACHED, only for zombie group leader that has
already reported and been short-circuited at the top of this
/* Update fields like NCLONE_DETACHED, only
for zombie group leader that has already reported
and been short-circuited at the top of this
function. The same condition as at the top of DETACH. */
if ((tcp->flags & TCB_CLONE_THREAD) &&
tcp->parent->nclone_threads == 0 &&