summaryrefslogtreecommitdiff
path: root/usr/src/uts/intel/ia32/syscall
diff options
context:
space:
mode:
authorksadhukh <none@none>2007-10-11 15:03:05 -0700
committerksadhukh <none@none>2007-10-11 15:03:05 -0700
commit86d5155bbc3a1e403bb819e3532bd882327db151 (patch)
tree7b9fe8c62a973ea0c49d9bbfff6c031e8199aa03 /usr/src/uts/intel/ia32/syscall
parent1d925b368c0579a57acb90e1e8db63c3a5613790 (diff)
downloadillumos-joyent-86d5155bbc3a1e403bb819e3532bd882327db151.tar.gz
6546562 Unexpected SIGTRAP delivered to dbx via /proc (regression due to fix of 6386365?)
Diffstat (limited to 'usr/src/uts/intel/ia32/syscall')
-rw-r--r--usr/src/uts/intel/ia32/syscall/getcontext.c86
1 files changed, 52 insertions, 34 deletions
diff --git a/usr/src/uts/intel/ia32/syscall/getcontext.c b/usr/src/uts/intel/ia32/syscall/getcontext.c
index 889d40871e..35be9fc49c 100644
--- a/usr/src/uts/intel/ia32/syscall/getcontext.c
+++ b/usr/src/uts/intel/ia32/syscall/getcontext.c
@@ -23,7 +23,7 @@
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -89,6 +89,37 @@ savecontext(ucontext_t *ucp, k_sigset_t mask)
}
}
+ /*
+ * If either the trace flag or REQUEST_STEP is set,
+ * arrange for single-stepping and turn off the trace flag.
+ */
+ if ((rp->r_ps & PS_T) || (lwp->lwp_pcb.pcb_flags & REQUEST_STEP)) {
+ /*
+ * Clear PS_T so that saved user context won't have trace
+ * flag set.
+ */
+ rp->r_ps &= ~PS_T;
+
+ if (!(lwp->lwp_pcb.pcb_flags & REQUEST_NOSTEP)) {
+ lwp->lwp_pcb.pcb_flags |= DEBUG_PENDING;
+ /*
+ * trap() always checks DEBUG_PENDING before
+ * checking for any pending signal. This at times
+ * can potentially lead to DEBUG_PENDING not being
+ * honoured. (for eg: the lwp is stopped by
+ * stop_on_fault() called from trap(), after being
+ * awakened it might see a pending signal and call
+ * savecontext(), however on the way back to userland
+ * there is no place it can be detected). Hence in
+ * anticipation of such occassions, set AST flag for
+ * the thread which will make the thread take an
+ * excursion through trap() where it will be handled
+ * appropriately.
+ */
+ aston(curthread);
+ }
+ }
+
getgregs(lwp, ucp->uc_mcontext.gregs);
if (lwp->lwp_pcb.pcb_fpu.fpu_flags & FPU_EN)
getfpregs(lwp, &ucp->uc_mcontext.fpregs);
@@ -96,27 +127,6 @@ savecontext(ucontext_t *ucp, k_sigset_t mask)
ucp->uc_flags &= ~UC_FPU;
sigktou(&mask, &ucp->uc_sigmask);
- /*
- * If the trace flag is set, arrange for single-stepping and
- * turn off the trace flag.
- */
- if (rp->r_ps & PS_T) {
- lwp->lwp_pcb.pcb_flags |= DEBUG_PENDING;
- rp->r_ps &= ~PS_T;
- /*
- * We always check DEBUG_PENDING before checking for any
- * pending signal. This at times can potentially lead to
- * DEBUG_PENDING not being honoured. (for eg: the lwp is
- * stopped by stop_on_fault() called from trap(), after
- * being awakened it might see a pending signal and call
- * savecontext(), however on the way back to userland there
- * is no place it can be detected). Hence in anticipation of
- * such occassion, we set AST flag for the thread which will
- * make the thread take an excursion through trap() where
- * we will handle it appropriately.
- */
- aston(curthread);
- }
}
/*
@@ -277,6 +287,26 @@ savecontext32(ucontext32_t *ucp, k_sigset_t mask)
}
}
+ /*
+ * If either the trace flag or REQUEST_STEP is set, arrange
+ * for single-stepping and turn off the trace flag.
+ */
+ if ((rp->r_ps & PS_T) || (lwp->lwp_pcb.pcb_flags & REQUEST_STEP)) {
+ /*
+ * Clear PS_T so that saved user context won't have trace
+ * flag set.
+ */
+ rp->r_ps &= ~PS_T;
+
+ if (!(lwp->lwp_pcb.pcb_flags & REQUEST_NOSTEP)) {
+ lwp->lwp_pcb.pcb_flags |= DEBUG_PENDING;
+ /*
+ * See comments in savecontext().
+ */
+ aston(curthread);
+ }
+ }
+
getgregs32(lwp, ucp->uc_mcontext.gregs);
if (lwp->lwp_pcb.pcb_fpu.fpu_flags & FPU_EN)
getfpregs32(lwp, &ucp->uc_mcontext.fpregs);
@@ -284,18 +314,6 @@ savecontext32(ucontext32_t *ucp, k_sigset_t mask)
ucp->uc_flags &= ~UC_FPU;
sigktou(&mask, &ucp->uc_sigmask);
- /*
- * If the trace flag is set, arrange for single-stepping and
- * turn off the trace flag.
- */
- if (rp->r_ps & PS_T) {
- lwp->lwp_pcb.pcb_flags |= DEBUG_PENDING;
- rp->r_ps &= ~PS_T;
- /*
- * See comments in savecontext().
- */
- aston(curthread);
- }
}
int