Author: kib
Date: Fri Feb 17 10:27:58 2012
New Revision: 231865
URL: http://svn.freebsd.org/changeset/base/231865

Log:
  MFC r231320:
  Mark the automatically attached child with PL_FLAG_CHILD in struct
  lwpinfo flags, for PT_FOLLOWFORK auto-attachment.

Modified:
  stable/9/sys/kern/kern_fork.c
  stable/9/sys/kern/sys_process.c
  stable/9/sys/sys/proc.h
  stable/9/sys/sys/ptrace.h
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/kern/kern_fork.c
==============================================================================
--- stable/9/sys/kern/kern_fork.c       Fri Feb 17 08:45:08 2012        
(r231864)
+++ stable/9/sys/kern/kern_fork.c       Fri Feb 17 10:27:58 2012        
(r231865)
@@ -1035,7 +1035,9 @@ fork_return(struct thread *td, struct tr
                        p->p_oppid = p->p_pptr->p_pid;
                        proc_reparent(p, dbg);
                        sx_xunlock(&proctree_lock);
+                       td->td_dbgflags |= TDB_CHILD;
                        ptracestop(td, SIGSTOP);
+                       td->td_dbgflags &= ~TDB_CHILD;
                } else {
                        /*
                         * ... otherwise clear the request.

Modified: stable/9/sys/kern/sys_process.c
==============================================================================
--- stable/9/sys/kern/sys_process.c     Fri Feb 17 08:45:08 2012        
(r231864)
+++ stable/9/sys/kern/sys_process.c     Fri Feb 17 10:27:58 2012        
(r231865)
@@ -1145,6 +1145,8 @@ kern_ptrace(struct thread *td, int req, 
                        pl->pl_flags |= PL_FLAG_FORKED;
                        pl->pl_child_pid = td2->td_dbg_forked;
                }
+               if (td2->td_dbgflags & TDB_CHILD)
+                       pl->pl_flags |= PL_FLAG_CHILD;
                pl->pl_sigmask = td2->td_sigmask;
                pl->pl_siglist = td2->td_siglist;
                strcpy(pl->pl_tdname, td2->td_name);

Modified: stable/9/sys/sys/proc.h
==============================================================================
--- stable/9/sys/sys/proc.h     Fri Feb 17 08:45:08 2012        (r231864)
+++ stable/9/sys/sys/proc.h     Fri Feb 17 10:27:58 2012        (r231865)
@@ -383,6 +383,7 @@ do {                                                        
                \
                                      process */
 #define        TDB_STOPATFORK  0x00000080 /* Stop at the return from fork 
(child
                                      only) */
+#define        TDB_CHILD       0x00000100 /* New child indicator for ptrace() 
*/
 
 /*
  * "Private" flags kept in td_pflags:

Modified: stable/9/sys/sys/ptrace.h
==============================================================================
--- stable/9/sys/sys/ptrace.h   Fri Feb 17 08:45:08 2012        (r231864)
+++ stable/9/sys/sys/ptrace.h   Fri Feb 17 10:27:58 2012        (r231865)
@@ -107,6 +107,7 @@ struct ptrace_lwpinfo {
 #define        PL_FLAG_EXEC    0x10    /* exec(2) succeeded */
 #define        PL_FLAG_SI      0x20    /* siginfo is valid */
 #define        PL_FLAG_FORKED  0x40    /* new child */
+#define        PL_FLAG_CHILD   0x80    /* I am from child */
        sigset_t        pl_sigmask;     /* LWP signal mask */
        sigset_t        pl_siglist;     /* LWP pending signal */
        struct __siginfo pl_siginfo;    /* siginfo for signal */
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to