summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorkbyanc <kbyanc@FreeBSD.org>2004-12-08 19:03:55 +0000
committerkbyanc <kbyanc@FreeBSD.org>2004-12-08 19:03:55 +0000
commitf947a8cc1cf9e160deab254a7ff4be233c0f56d3 (patch)
treecc3c26c5ae16a7d5844532ea312c2e51494cdf6c /sys
parentef8150870e5acf935d8d5a80d0e04b08a14c5c14 (diff)
downloadFreeBSD-src-f947a8cc1cf9e160deab254a7ff4be233c0f56d3.zip
FreeBSD-src-f947a8cc1cf9e160deab254a7ff4be233c0f56d3.tar.gz
If the parent process has the trap bit set (i.e. a debugger had single
stepped the process to the system call), we need to clear the trap flag from the new frame unless the debugger had set PF_FORK on the parent. Otherwise, the child will receive a (likely unexpected) SIGTRAP when it executes the first instruction after returning to userland. Reviewed by: bde MFC after: 3 days
Diffstat (limited to 'sys')
-rw-r--r--sys/i386/i386/vm_machdep.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/sys/i386/i386/vm_machdep.c b/sys/i386/i386/vm_machdep.c
index 5ec833f..10e2623 100644
--- a/sys/i386/i386/vm_machdep.c
+++ b/sys/i386/i386/vm_machdep.c
@@ -62,6 +62,7 @@ __FBSDID("$FreeBSD$");
#include <sys/malloc.h>
#include <sys/mbuf.h>
#include <sys/mutex.h>
+#include <sys/pioctl.h>
#include <sys/proc.h>
#include <sys/sf_buf.h>
#include <sys/smp.h>
@@ -195,6 +196,17 @@ cpu_fork(td1, p2, td2, flags)
td2->td_frame->tf_edx = 1;
/*
+ * If the parent process has the trap bit set (i.e. a debugger had
+ * single stepped the process to the system call), we need to clear
+ * the trap flag from the new frame unless the debugger had set PF_FORK
+ * on the parent. Otherwise, the child will receive a (likely
+ * unexpected) SIGTRAP when it executes the first instruction after
+ * returning to userland.
+ */
+ if ((p1->p_pfsflags & PF_FORK) == 0)
+ td2->td_frame->tf_eflags &= ~PSL_T;
+
+ /*
* Set registers for trampoline to user mode. Leave space for the
* return address on stack. These are the kernel mode register values.
*/
OpenPOWER on IntegriCloud