]> granicus.if.org Git - strace/commitdiff
Delete fork_tcb()
authorDenys Vlasenko <dvlasenk@redhat.com>
Wed, 22 Jun 2011 10:45:25 +0000 (12:45 +0200)
committerDenys Vlasenko <dvlasenk@redhat.com>
Wed, 22 Jun 2011 10:45:25 +0000 (12:45 +0200)
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>
defs.h
process.c
strace.c

diff --git a/defs.h b/defs.h
index ab24f7cfeb2598763565263b4c0ab0a2e0e1d826..23ed783208f461fe65cbdfba4816dfa857306a9c 100644 (file)
--- a/defs.h
+++ b/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)
 
index 276ce20b85be1f12cd3f40123b283ca6e18c414d..7aa5aa43831d70bf87e4a25fd27bb42a8b31853b 100644 (file)
--- a/process.c
+++ b/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
index 3b393719b49f51b16e306815ccea9c5291f5a81c..84fc1b77bb050d69e94b47d91ce177224ef145a6 100644 (file)
--- a/strace.c
+++ b/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.