PERFORCE change 57626 for review
David Xu
davidxu at FreeBSD.org
Sun Jul 18 06:23:16 PDT 2004
http://perforce.freebsd.org/chv.cgi?CH=57626
Change 57626 by davidxu at davidxu_alona on 2004/07/18 13:22:44
Refine code ptracestop.
Don't schdule upcall in trapsignal if the signal is a debug
signal and we are being debugged, this allows debugger to resume
and single step the thread without going into UTS which maybe be
blocked by schedule lock or other blockable objects.
Affected files ...
.. //depot/projects/davidxu_ksedbg/src/sys/kern/kern_sig.c#12 edit
Differences ...
==== //depot/projects/davidxu_ksedbg/src/sys/kern/kern_sig.c#12 (text+ko) ====
@@ -1484,24 +1484,13 @@
p = td->td_proc;
if (td->td_pflags & TDP_SA) {
- if (td->td_mailbox == NULL)
- thread_user_enter(p, td);
- if ((p->p_flag & P_TRACED) && (sig == SIGTRAP)) {
- mtx_lock_spin(&sched_lock);
- td->td_flags &= ~TDF_CAN_UNBIND;
- mtx_unlock_spin(&sched_lock);
+ /* Don't upcall if it is debug signal */
+ if (!((p->p_flag & P_TRACED) && (sig == SIGTRAP))) {
+ if (td->td_mailbox == NULL)
+ thread_user_enter(p, td);
}
PROC_LOCK(p);
SIGDELSET(td->td_sigmask, sig);
- mtx_lock_spin(&sched_lock);
- /*
- * Force scheduling an upcall, so UTS has chance to
- * process the signal before thread runs again in
- * userland.
- */
- if (td->td_upcall)
- td->td_upcall->ku_flags |= KUF_DOUPCALL;
- mtx_unlock_spin(&sched_lock);
} else {
PROC_LOCK(p);
}
@@ -2016,13 +2005,8 @@
td->td_flags |= TDF_XSIG;
mtx_unlock_spin(&sched_lock);
td->td_xsig = sig;
- while ((p->p_flag & P_TRACED) && (td->td_flags & TDF_XSIG)) {
- if (p->p_flag & P_SINGLE_EXIT) {
- mtx_lock_spin(&sched_lock);
- td->td_flags &= ~TDF_XSIG;
- mtx_unlock_spin(&sched_lock);
- return (sig);
- }
+ while (!(p->p_flag & P_SINGLE_EXIT) && (p->p_flag & P_TRACED)
+ && (td->td_flags & TDF_XSIG)) {
/*
* Just make wait() to work, the last stopped thread
* will win.
@@ -2049,15 +2033,18 @@
mtx_unlock_spin(&sched_lock);
PICKUP_GIANT();
PROC_LOCK(p);
- if (!(p->p_flag & P_TRACED))
+ if ((p->p_flag & P_SINGLE_EXIT) || !(p->p_flag & P_TRACED))
break;
if (td->td_flags & TDF_DBSUSPEND) {
- if (p->p_flag & P_SINGLE_EXIT)
- break;
mtx_lock_spin(&sched_lock);
goto stopme;
}
}
+ if (td->td_flags & TDF_XSIG) {
+ mtx_lock_spin(&sched_lock);
+ td->td_flags &= ~TDF_XSIG;
+ mtx_unlock_spin(&sched_lock);
+ }
return (td->td_xsig);
}
@@ -2111,8 +2098,10 @@
*/
if (SIGISMEMBER(ps->ps_sigignore, sig) && (traced == 0)) {
SIGDELSET(td->td_siglist, sig);
- if (td->td_pflags & TDP_SA)
+ if (td->td_pflags & TDP_SA) {
SIGADDSET(td->td_sigmask, sig);
+ SIG_CANTMASK(td->td_sigmask);
+ }
continue;
}
if (p->p_flag & P_TRACED && (p->p_flag & P_PPWAIT) == 0) {
@@ -2129,8 +2118,10 @@
* otherwise we just look for signals again.
*/
SIGDELSET(td->td_siglist, sig); /* clear old signal */
- if (td->td_pflags & TDP_SA)
+ if (td->td_pflags & TDP_SA) {
SIGADDSET(td->td_sigmask, sig);
+ SIG_CANTMASK(td->td_sigmask);
+ }
if (newsig == 0)
continue;
sig = newsig;
@@ -2281,8 +2272,8 @@
n++;
if ((p->p_flag & P_STOPPED_SIG) && (n == p->p_numthreads)) {
mtx_unlock_spin(&sched_lock);
+ PROC_LOCK(p->p_pptr);
stop(p);
- PROC_LOCK(p->p_pptr);
ps = p->p_pptr->p_sigacts;
mtx_lock(&ps->ps_mtx);
if ((ps->ps_flag & PS_NOCLDSTOP) == 0) {
More information about the p4-projects
mailing list