Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 11 Oct 2011 13:54:20 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r226256 - stable/8/sys/kern
Message-ID:  <201110111354.p9BDsKAP018108@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Tue Oct 11 13:54:20 2011
New Revision: 226256
URL: http://svn.freebsd.org/changeset/base/226256

Log:
  MFC r225791:
  Do not deliver SIGTRAP on exec as the normal signal, use ptracestop() on
  syscall exit path. Otherwise, if SIGTRAP is ignored, that tdsendsignal()
  do not want to deliver the signal, and debugger never get a notification
  of exec.

Modified:
  stable/8/sys/kern/kern_exec.c
  stable/8/sys/kern/subr_syscall.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)

Modified: stable/8/sys/kern/kern_exec.c
==============================================================================
--- stable/8/sys/kern/kern_exec.c	Tue Oct 11 13:45:04 2011	(r226255)
+++ stable/8/sys/kern/kern_exec.c	Tue Oct 11 13:54:20 2011	(r226256)
@@ -743,17 +743,6 @@ interpret:
 	KNOTE_LOCKED(&p->p_klist, NOTE_EXEC);
 	p->p_flag &= ~P_INEXEC;
 
-	/*
-	 * If tracing the process, trap to debugger so breakpoints
-	 * can be set before the program executes.
-	 * Use tdsignal to deliver signal to current thread, use
-	 * psignal may cause the signal to be delivered to wrong thread
-	 * because that thread will exit, remember we are going to enter
-	 * single thread mode.
-	 */
-	if (p->p_flag & P_TRACED)
-		tdsignal(p, td, SIGTRAP, NULL);
-
 	/* clear "fork but no exec" flag, as we _are_ execing */
 	p->p_acflag &= ~AFORK;
 

Modified: stable/8/sys/kern/subr_syscall.c
==============================================================================
--- stable/8/sys/kern/subr_syscall.c	Tue Oct 11 13:45:04 2011	(r226255)
+++ stable/8/sys/kern/subr_syscall.c	Tue Oct 11 13:54:20 2011	(r226256)
@@ -186,9 +186,17 @@ syscallret(struct thread *td, int error,
 	 * is not the case, this code will need to be revisited.
 	 */
 	STOPEVENT(p, S_SCX, sa->code);
-	PTRACESTOP_SC(p, td, S_PT_SCX);
 	if (traced || (td->td_dbgflags & (TDB_EXEC | TDB_FORK)) != 0) {
 		PROC_LOCK(p);
+		/*
+		 * If tracing the execed process, trap to the debugger
+		 * so that breakpoints can be set before the program
+		 * executes.  If debugger requested tracing of syscall
+		 * returns, do it now too.
+		 */
+		if (traced && ((td->td_dbgflags & TDB_EXEC) != 0 ||
+		    (p->p_stops & S_PT_SCX) != 0))
+			ptracestop(td, SIGTRAP);
 		td->td_dbgflags &= ~(TDB_SCX | TDB_EXEC | TDB_FORK);
 		PROC_UNLOCK(p);
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201110111354.p9BDsKAP018108>