PERFORCE change 56496 for review
David Xu
davidxu at FreeBSD.org
Mon Jul 5 04:47:44 PDT 2004
http://perforce.freebsd.org/chv.cgi?CH=56496
Change 56496 by davidxu at davidxu_alona on 2004/07/05 11:47:36
Allow multiple threads to report debug event at same time,
the last thread will win the race, and others will retry,
debugger has chance to select a thread to be replied.
Affected files ...
.. //depot/projects/davidxu_ksedbg/src/sys/kern/kern_sig.c#5 edit
.. //depot/projects/davidxu_ksedbg/src/sys/sys/proc.h#4 edit
Differences ...
==== //depot/projects/davidxu_ksedbg/src/sys/kern/kern_sig.c#5 (text+ko) ====
@@ -2005,16 +2005,39 @@
{
struct proc *p = td->td_proc;
struct thread *td0;
- int newsig;
PROC_LOCK_ASSERT(p, MA_OWNED);
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK,
&p->p_mtx.mtx_object, "Stopping for traced signal");
- while (P_SHOULDSTOP(p)) {
- if (p->p_flag & P_SINGLE_EXIT)
+ mtx_lock_spin(&sched_lock);
+ td->td_flags |= TDF_XSIG;
+ mtx_unlock_spin(&sched_lock);
+ td->td_xsig = sig;
+ while (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);
+ }
+ /*
+ * Just make wait() to work, the last stopped thread
+ * will win.
+ */
+ p->p_xstat = sig;
+ p->p_xthread = td;
+ p->p_flag |= (P_STOPPED_SIG|P_STOPPED_TRACE);
mtx_lock_spin(&sched_lock);
+ FOREACH_THREAD_IN_PROC(p, td0) {
+ if (TD_IS_SLEEPING(td0) &&
+ (td0->td_flags & TDF_SINTR) &&
+ !TD_IS_SUSPENDED(td0)) {
+ thread_suspend_one(td0);
+ } else if (td != td0) {
+ td0->td_flags |= TDF_ASTPENDING;
+ }
+ }
thread_stopped(p);
thread_suspend_one(td);
PROC_UNLOCK(p);
@@ -2024,33 +2047,7 @@
PICKUP_GIANT();
PROC_LOCK(p);
}
- p->p_xstat = sig;
- p->p_xthread = td;
- p->p_flag |= (P_STOPPED_SIG|P_STOPPED_TRACE);
- mtx_lock_spin(&sched_lock);
- FOREACH_THREAD_IN_PROC(p, td0) {
- if (TD_IS_SLEEPING(td0) &&
- (td0->td_flags & TDF_SINTR) &&
- !TD_IS_SUSPENDED(td0)) {
- thread_suspend_one(td0);
- } else if (td != td0) {
- td0->td_flags |= TDF_ASTPENDING;
- }
- }
- thread_stopped(p);
- thread_suspend_one(td);
- PROC_UNLOCK(p);
- DROP_GIANT();
- mi_switch(SW_INVOL, NULL);
- mtx_unlock_spin(&sched_lock);
- PICKUP_GIANT();
- PROC_LOCK(p);
- newsig = p->p_xstat;
- p->p_xstat = newsig;
- mtx_lock_spin(&sched_lock);
- thread_unsuspend(p);
- mtx_unlock_spin(&sched_lock);
- return (newsig);
+ return (td->td_xsig);
}
/*
==== //depot/projects/davidxu_ksedbg/src/sys/sys/proc.h#4 (text+ko) ====
@@ -303,7 +303,7 @@
volatile u_int td_generation; /* (k) Enable detection of preemption */
stack_t td_sigstk; /* (k) Stack ptr and on-stack flag. */
int td_kflags; /* (c) Flags for KSE threading. */
-
+ int td_xsig; /* (c) Signal for ptrace */
#define td_endzero td_base_pri
/* Copied during fork1() or thread_sched_upcall(). */
@@ -354,6 +354,7 @@
#define TDF_OWEUPC 0x008000 /* Owe thread an addupc() call at next AST. */
#define TDF_NEEDRESCHED 0x010000 /* Thread needs to yield. */
#define TDF_NEEDSIGCHK 0x020000 /* Thread may need signal delivery. */
+#define TDF_XSIG 0x040000 /* Thread is exchanging signal under traced */
#define TDF_UMTXWAKEUP 0x080000 /* Libthr thread must not sleep on a umtx. */
#define TDF_THRWAKEUP 0x100000 /* Libthr thread must not suspend itself. */
More information about the p4-projects
mailing list