diff --git a/ChangeLog b/ChangeLog index c37cacd7..8a30cd24 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2009-02-10 Denys Vlasenko + + Cleanup after tcb table expansion simplification. + There was code which was trying to continue tracing + even if table expansion fails. Now we treat it as fatal + failure, so this code is removed by this change. + * defs.h: Delete TCB_FOLLOWFORK constant. + * process.c: Delete fork_tcb() and all calls of it. + * strace.c (startup_attach): Remove usage of TCB_FOLLOWFORK. + * syscall.c: Indent preprocessor directives. + 2009-02-09 Denys Vlasenko * defs.h: Correct the comment about TCB_SUSPENDED. diff --git a/defs.h b/defs.h index a51bc874..7b327af6 100644 --- a/defs.h +++ b/defs.h @@ -356,7 +356,6 @@ struct tcb { #define TCB_SUSPENDED 00040 /* Process can not be allowed to resume just now */ #define TCB_BPTSET 00100 /* "Breakpoint" set after fork(2) */ #define TCB_SIGTRAPPED 00200 /* Process wanted to block SIGTRAP */ -#define TCB_FOLLOWFORK 00400 /* Process should have forks followed */ #define TCB_REPRINT 01000 /* We should reprint this syscall on exit */ #ifdef LINUX /* TCB_WAITEXECVE bit means "ignore next SIGTRAP, it's execve exit stop". diff --git a/process.c b/process.c index d61f5485..c1020a93 100644 --- a/process.c +++ b/process.c @@ -484,18 +484,6 @@ 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 @@ -545,7 +533,6 @@ struct tcb *tcp; return 0; if (!followfork) return 0; - fork_tcb(tcp); if (syserror(tcp)) return 0; tcpchild = alloctcb(tcp->u_rval); @@ -882,18 +869,14 @@ internal_clone(struct tcb *tcp) struct tcb *tcpchild; int pid, bpt; + if (!followfork) + return 0; if (entering(tcp)) { - if (!followfork) - return 0; - fork_tcb(tcp); setbpt(tcp); return 0; } else { bpt = tcp->flags & TCB_BPTSET; - if (!(tcp->flags & TCB_FOLLOWFORK)) - return 0; - if (syserror(tcp)) { if (bpt) clearbpt(tcp); @@ -901,7 +884,7 @@ internal_clone(struct tcb *tcp) } pid = tcp->u_rval; - /* Should not happen, but bugs often cause bogus value here */ + /* Should not happen, but bugs often cause bogus value here. */ if (pid <= 1 || (sizeof(pid) != sizeof(tcp->u_rval) && pid != tcp->u_rval) ) { @@ -926,7 +909,6 @@ internal_clone(struct tcb *tcp) else #endif { - fork_tcb(tcp); tcpchild = alloctcb(pid); } @@ -1028,27 +1010,25 @@ struct tcb *tcp; struct tcb *tcpchild; int pid; - int dont_follow = 0; + int follow = 1; #ifdef SYS_vfork if (known_scno(tcp) == SYS_vfork) { /* Attempt to make vfork into fork, which we can follow. */ if (change_syscall(tcp, SYS_fork) < 0) - dont_follow = 1; + follow = 0; } #endif + if (!followfork || !follow) + return 0; + if (entering(tcp)) { - if (!followfork || dont_follow) - return 0; - fork_tcb(tcp); if (setbpt(tcp) < 0) return 0; } else { int bpt = tcp->flags & TCB_BPTSET; - if (!(tcp->flags & TCB_FOLLOWFORK)) - return 0; if (bpt) clearbpt(tcp); @@ -1056,7 +1036,6 @@ struct tcb *tcp; return 0; pid = tcp->u_rval; - fork_tcb(tcp); tcpchild = alloctcb(pid); #ifdef LINUX #ifdef HPPA diff --git a/strace.c b/strace.c index 3b24222c..2f56b879 100644 --- a/strace.c +++ b/strace.c @@ -440,7 +440,7 @@ startup_attach(void) ++nerr; else if (tid != tcbtab[tcbi]->pid) { tcp = alloctcb(tid); - tcp->flags |= TCB_ATTACHED|TCB_CLONE_THREAD|TCB_CLONE_DETACHED|TCB_FOLLOWFORK; + tcp->flags |= TCB_ATTACHED|TCB_CLONE_THREAD|TCB_CLONE_DETACHED; tcbtab[tcbi]->nchildren++; tcbtab[tcbi]->nclone_threads++; tcbtab[tcbi]->nclone_detached++; @@ -2392,12 +2392,12 @@ Process %d attached (waiting for parent)\n", } } - if (cflag) { #ifdef LINUX + if (cflag) { tv_sub(&tcp->dtime, &ru.ru_stime, &tcp->stime); tcp->stime = ru.ru_stime; -#endif } +#endif if (tcp->flags & TCB_SUSPENDED) { /* * Apparently, doing any ptrace() call on a stopped @@ -2533,7 +2533,7 @@ handle_stopped_tcbs(struct tcb *tcp) /* * Interestingly, the process may stop * with STOPSIG equal to some other signal - * than SIGSTOP if we happend to attach + * than SIGSTOP if we happen to attach * just before the process takes a signal. */ if ((tcp->flags & TCB_STARTUP) && WSTOPSIG(status) == SIGSTOP) { diff --git a/syscall.c b/syscall.c index 8ecc8ed5..99b85161 100644 --- a/syscall.c +++ b/syscall.c @@ -38,38 +38,39 @@ #include #include #include +#include #include #include #include #if HAVE_ASM_REG_H -#if defined (SPARC) || defined (SPARC64) +# if defined (SPARC) || defined (SPARC64) # define fpq kernel_fpq # define fq kernel_fq # define fpu kernel_fpu -#endif -#include -#if defined (SPARC) || defined (SPARC64) +# endif +# include +# if defined (SPARC) || defined (SPARC64) # undef fpq # undef fq # undef fpu -#endif +# endif #endif #ifdef HAVE_SYS_REG_H -#include -#ifndef PTRACE_PEEKUSR -# define PTRACE_PEEKUSR PTRACE_PEEKUSER -#endif +# include +# ifndef PTRACE_PEEKUSR +# define PTRACE_PEEKUSR PTRACE_PEEKUSER +# endif #elif defined(HAVE_LINUX_PTRACE_H) -#undef PTRACE_SYSCALL +# undef PTRACE_SYSCALL # ifdef HAVE_STRUCT_IA64_FPREG # define ia64_fpreg XXX_ia64_fpreg # endif # ifdef HAVE_STRUCT_PT_ALL_USER_REGS # define pt_all_user_regs XXX_pt_all_user_regs # endif -#include +# include # undef ia64_fpreg # undef pt_all_user_regs #endif