Delete fork_tcb()
Get rid of fork_tcb() function. It used to do what the comment above it says, but now it doesn't do much: it only sets tcp->flags |= TCB_FOLLOWFORK and maybe calls expand_tcbtab(). The second operation is not necessary, since alloc_tcp() will do it itself when needed. This patch deletes fork_tcb(), open-coding tcp->flags |= TCB_FOLLOWFORK where it was formerly called. It also makes nprocs, tcbtabsize and expand_tcbtab() static. (While at it, I nuked redundant extern char **environ declaration: strace.c had *two* of them...) * defs.h: Remove declarations of nprocs, tcbtabsize and expand_tcbtab. * process.c (fork_tcb): Remove this function. (internal_fork): Open-code fork_tcb. (handle_new_child): Likewise. * strace.c: Remove redundant "extern char **environ". Declare nprocs and tcbtabsize static. (expand_tcbtab): Make it static. Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
This commit is contained in:
parent
18da273675
commit
2b60c35b33
2
defs.h
2
defs.h
@ -510,7 +510,6 @@ extern unsigned int ptrace_setoptions;
|
||||
extern int dtime, xflag, qflag;
|
||||
extern cflag_t cflag;
|
||||
extern int acolumn;
|
||||
extern unsigned int nprocs, tcbtabsize;
|
||||
extern int max_strlen;
|
||||
extern struct tcb *tcp_last;
|
||||
|
||||
@ -526,7 +525,6 @@ extern const char *xlookup(const struct xlat *, int);
|
||||
extern struct tcb *alloc_tcb(int, int);
|
||||
extern struct tcb *pid2tcb(int);
|
||||
extern void droptcb(struct tcb *);
|
||||
extern void expand_tcbtab(void);
|
||||
|
||||
#define alloctcb(pid) alloc_tcb((pid), 1)
|
||||
|
||||
|
22
process.c
22
process.c
@ -448,18 +448,6 @@ internal_exit(struct tcb *tcp)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* TCP is creating a child we want to follow.
|
||||
If there will be space in tcbtab for it, set TCB_FOLLOWFORK and return 0.
|
||||
If not, clear TCB_FOLLOWFORK, print an error, and return 1. */
|
||||
static void
|
||||
fork_tcb(struct tcb *tcp)
|
||||
{
|
||||
if (nprocs == tcbtabsize)
|
||||
expand_tcbtab();
|
||||
|
||||
tcp->flags |= TCB_FOLLOWFORK;
|
||||
}
|
||||
|
||||
#ifdef USE_PROCFS
|
||||
|
||||
int
|
||||
@ -507,7 +495,7 @@ internal_fork(struct tcb *tcp)
|
||||
return 0;
|
||||
if (!followfork)
|
||||
return 0;
|
||||
fork_tcb(tcp);
|
||||
tcp->flags |= TCB_FOLLOWFORK;
|
||||
if (syserror(tcp))
|
||||
return 0;
|
||||
tcpchild = alloctcb(tcp->u_rval);
|
||||
@ -808,7 +796,7 @@ handle_new_child(struct tcb *tcp, int pid, int bpt)
|
||||
else
|
||||
#endif /* CLONE_PTRACE */
|
||||
{
|
||||
fork_tcb(tcp);
|
||||
tcp->flags |= TCB_FOLLOWFORK;
|
||||
tcpchild = alloctcb(pid);
|
||||
}
|
||||
|
||||
@ -916,7 +904,7 @@ internal_fork(struct tcb *tcp)
|
||||
if ((sysent[tcp->scno].sys_func == sys_clone) &&
|
||||
(tcp->u_arg[ARG_FLAGS] & CLONE_UNTRACED))
|
||||
return 0;
|
||||
fork_tcb(tcp);
|
||||
tcp->flags |= TCB_FOLLOWFORK;
|
||||
setbpt(tcp);
|
||||
} else {
|
||||
int pid;
|
||||
@ -959,7 +947,7 @@ internal_fork(struct tcb *tcp)
|
||||
if (entering(tcp)) {
|
||||
if (!followfork || dont_follow)
|
||||
return 0;
|
||||
fork_tcb(tcp);
|
||||
tcp->flags |= TCB_FOLLOWFORK;
|
||||
setbpt(tcp);
|
||||
}
|
||||
else {
|
||||
@ -974,7 +962,7 @@ internal_fork(struct tcb *tcp)
|
||||
return 0;
|
||||
|
||||
pid = tcp->u_rval;
|
||||
fork_tcb(tcp);
|
||||
tcp->flags |= TCB_FOLLOWFORK;
|
||||
tcpchild = alloctcb(pid);
|
||||
#ifdef SUNOS4
|
||||
#ifdef oldway
|
||||
|
5
strace.c
5
strace.c
@ -127,9 +127,8 @@ static char *outfname = NULL;
|
||||
FILE *outf;
|
||||
static int curcol;
|
||||
struct tcb **tcbtab;
|
||||
unsigned int nprocs, tcbtabsize;
|
||||
static unsigned int nprocs, tcbtabsize;
|
||||
const char *progname;
|
||||
extern char **environ;
|
||||
|
||||
static int detach(struct tcb *tcp, int sig);
|
||||
static int trace(void);
|
||||
@ -1244,7 +1243,7 @@ main(int argc, char *argv[])
|
||||
exit(exit_code);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
expand_tcbtab(void)
|
||||
{
|
||||
/* Allocate some more TCBs and expand the table.
|
||||
|
Loading…
x
Reference in New Issue
Block a user