From 8a22cb4e57315c423197fdd8e33d8acc966ce31d Mon Sep 17 00:00:00 2001 From: davidxu Date: Sun, 5 Oct 2008 02:03:54 +0000 Subject: If the current thread 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. Otherwise, the new thread will receive a (likely unexpected) SIGTRAP when it executes the first instruction after returning to userland. --- sys/amd64/amd64/vm_machdep.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'sys/amd64') diff --git a/sys/amd64/amd64/vm_machdep.c b/sys/amd64/amd64/vm_machdep.c index adddc1c..0cc9b03 100644 --- a/sys/amd64/amd64/vm_machdep.c +++ b/sys/amd64/amd64/vm_machdep.c @@ -280,6 +280,14 @@ cpu_set_upcall(struct thread *td, struct thread *td0) */ bcopy(td0->td_frame, td->td_frame, sizeof(struct trapframe)); + /* If the current thread 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. Otherwise, the new thread will + * receive a (likely unexpected) SIGTRAP when it executes the first + * instruction after returning to userland. + */ + td->td_frame->tf_rflags &= ~PSL_T; + /* * Set registers for trampoline to user mode. Leave space for the * return address on stack. These are the kernel mode register values. -- cgit v1.1