]> granicus.if.org Git - strace/commitdiff
Exclude tcp->pfd from non-procfs systems
authorDenys Vlasenko <dvlasenk@redhat.com>
Sat, 20 Aug 2011 11:44:56 +0000 (13:44 +0200)
committerDenys Vlasenko <dvlasenk@redhat.com>
Tue, 23 Aug 2011 10:53:01 +0000 (12:53 +0200)
* defs.h: Make struct tcb::pfd fields conditional on USE_PROCFS.
* strace.c (alloc_tcb): Use tcp->pfd only if USE_PROCFS.
(droptcb): Likewise.

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

diff --git a/defs.h b/defs.h
index 6c7734ed8a37cd0738486106b1ba596ff994ad7d..a06acde6bf4dd0e81f3ecd69a5dc200e2e4d2bbb 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -390,7 +390,7 @@ struct tcb {
        int flags;              /* See below for TCB_ values */
        int pid;                /* Process Id of this entry */
        long scno;              /* System call number */
-       int u_nargs;            /* System call arguments */
+       int u_nargs;            /* System call argument count */
        long u_arg[MAX_ARGS];   /* System call arguments */
 #if defined (LINUX_MIPSN32)
        long long ext_arg[MAX_ARGS];    /* System call arguments */
@@ -409,17 +409,19 @@ struct tcb {
                                /* Support for tracing forked processes */
        long baddr;             /* `Breakpoint' address */
        long inst[2];           /* Instructions on above */
+       int ptrace_errno;
+#ifdef USE_PROCFS
        int pfd;                /* proc file descriptor */
+#endif
 #ifdef SVR4
-#ifdef HAVE_MP_PROCFS
+# ifdef HAVE_MP_PROCFS
        int pfd_stat;
        int pfd_as;
        pstatus_t status;
-#else
+# else
        prstatus_t status;      /* procfs status structure */
+# endif
 #endif
-#endif
-       int ptrace_errno;
 #ifdef FREEBSD
        struct procfs_status status;
        int pfd_reg;
index 127275c0b3a1941bddcb9d3e592be65dff34c237..7e59b083a40c714f7848e7e79a10d00b66a5bc21 100644 (file)
--- a/strace.c
+++ b/strace.c
@@ -1256,7 +1256,9 @@ alloc_tcb(int pid, int command_options_parsed)
                        tcp->pid = pid;
                        tcp->flags = TCB_INUSE | TCB_STARTUP;
                        tcp->outf = outf; /* Initialise to current out file */
+#ifdef USE_PROCFS
                        tcp->pfd = -1;
+#endif
                        nprocs++;
                        if (debug)
                                fprintf(stderr, "new tcb for pid %d, active tcbs:%d\n", tcp->pid, nprocs);
@@ -1613,10 +1615,11 @@ droptcb(struct tcb *tcp)
        if (debug)
                fprintf(stderr, "dropped tcb for pid %d, %d remain\n", tcp->pid, nprocs);
 
+#ifdef USE_PROCFS
        if (tcp->pfd != -1) {
                close(tcp->pfd);
                tcp->pfd = -1;
-#ifdef FREEBSD
+# ifdef FREEBSD
                if (tcp->pfd_reg != -1) {
                        close(tcp->pfd_reg);
                        tcp->pfd_reg = -1;
@@ -1625,12 +1628,11 @@ droptcb(struct tcb *tcp)
                        close(tcp->pfd_status);
                        tcp->pfd_status = -1;
                }
-#endif /* !FREEBSD */
-#ifdef USE_PROCFS
+# endif
                tcp->flags = 0; /* rebuild_pollv needs it */
                rebuild_pollv();
-#endif
        }
+#endif
 
        if (outfname && followfork > 1 && tcp->outf)
                fclose(tcp->outf);