summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2011-09-27 13:17:02 +0000
committerkib <kib@FreeBSD.org>2011-09-27 13:17:02 +0000
commitf15c4ba986df76cc39987971217719f5ec3b4b06 (patch)
tree711070f981692411dd89024c8710f37e0b59b824 /sys/kern
parentd0ef05f990765cb66af8de8ba973b3faff909d46 (diff)
downloadFreeBSD-src-f15c4ba986df76cc39987971217719f5ec3b4b06.zip
FreeBSD-src-f15c4ba986df76cc39987971217719f5ec3b4b06.tar.gz
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. Found and tested by: Anton Yuzhaninov <citrin citrin ru> Discussed with: jhb MFC after: 2 weeks
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/kern_exec.c10
-rw-r--r--sys/kern/subr_syscall.c10
2 files changed, 9 insertions, 11 deletions
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c
index fe01142..4545848 100644
--- a/sys/kern/kern_exec.c
+++ b/sys/kern/kern_exec.c
@@ -777,16 +777,6 @@ interpret:
KNOTE_LOCKED(&p->p_klist, NOTE_EXEC);
p->p_flag &= ~P_INEXEC;
- /*
- * If tracing the process, trap to the debugger so that
- * breakpoints can be set before the program executes. We
- * have to use tdsignal() to deliver the signal to the current
- * thread since any other threads in this process will exit if
- * execve() succeeds.
- */
- if (p->p_flag & P_TRACED)
- tdsignal(td, SIGTRAP);
-
/* clear "fork but no exec" flag, as we _are_ execing */
p->p_acflag &= ~AFORK;
diff --git a/sys/kern/subr_syscall.c b/sys/kern/subr_syscall.c
index cb0d929..bba4479 100644
--- a/sys/kern/subr_syscall.c
+++ b/sys/kern/subr_syscall.c
@@ -204,9 +204,17 @@ syscallret(struct thread *td, int error, struct syscall_args *sa __unused)
* 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);
}
OpenPOWER on IntegriCloud