PERFORCE change 57760 for review
David Xu
davidxu at FreeBSD.org
Mon Jul 19 22:34:05 PDT 2004
http://perforce.freebsd.org/chv.cgi?CH=57760
Change 57760 by davidxu at davidxu_celeron on 2004/07/20 05:33:14
Introduce a debug flag TDMF_NOUPCALL, this bit is used to inhibit
kernel from scheduling upcall. When a thread hits a breakpoint or
gets a step trap, we don't unbind the thread, let debug resume only
the thread and single step it to pass breakpoint.
Affected files ...
.. //depot/projects/davidxu_ksedbg/src/sys/kern/kern_kse.c#10 edit
.. //depot/projects/davidxu_ksedbg/src/sys/sys/kse.h#6 edit
Differences ...
==== //depot/projects/davidxu_ksedbg/src/sys/kern/kern_kse.c#10 (text+ko) ====
@@ -150,26 +150,31 @@
error = set_mcontext(td, &tmbx.tm_context.uc_mcontext);
if (!error) {
suword32(&uap->tmbx->tm_lwp, td->td_tid);
- if (uap->flags & KSE_SWITCHIN_SETTMBX) {
- td->td_mailbox = uap->tmbx;
- mtx_lock_spin(&sched_lock);
- td->td_flags |= TDF_CAN_UNBIND;
- mtx_unlock_spin(&sched_lock);
- }
+
if (td->td_proc->p_flag & P_TRACED) {
if (tmbx.tm_dflags & TMDF_SSTEP)
ptrace_single_step(td);
else
ptrace_clear_single_step(td);
- if (tmbx.tm_dflags & TMDF_DONOTRUNUSER) {
+
+ if (tmbx.tm_dflags & TMDF_NOUPCALL) {
+ td->td_mailbox = NULL;
+ goto out;
+ } else if (tmbx.tm_dflags & TMDF_DONOTRUNUSER) {
mtx_lock_spin(&sched_lock);
- /* fuword can block, check again */
- if (td->td_upcall)
- ku->ku_flags |= KUF_DOUPCALL;
+ ku->ku_flags |= KUF_DOUPCALL;
mtx_unlock_spin(&sched_lock);
}
}
+
+ if (uap->flags & KSE_SWITCHIN_SETTMBX) {
+ td->td_mailbox = uap->tmbx;
+ mtx_lock_spin(&sched_lock);
+ td->td_flags |= TDF_CAN_UNBIND;
+ mtx_unlock_spin(&sched_lock);
+ }
}
+out:
return ((error == 0) ? EJUSTRETURN : error);
}
@@ -946,6 +951,7 @@
cpu_set_upcall(td2, td);
/* Let the new thread become owner of the upcall */
ku->ku_owner = td2;
+ ku->ku_mflags = 0;
td2->td_upcall = ku;
td2->td_flags = 0;
td2->td_pflags = TDP_SA|TDP_UPCALLING;
@@ -1079,20 +1085,21 @@
if (flags & TMF_NOUPCALL) {
td->td_mailbox = NULL;
} else {
- td->td_mailbox = tmbx;
- mtx_lock_spin(&sched_lock);
- td->td_flags |= TDF_CAN_UNBIND;
- mtx_unlock_spin(&sched_lock);
if (__predict_false(p->p_flag & P_TRACED)) {
flags = fuword32(&tmbx->tm_dflags);
- if (flags & TMDF_DONOTRUNUSER) {
+ if (flags & TMDF_NOUPCALL) {
+ td->td_mailbox = NULL;
+ return;
+ } else if (flags & TMDF_DONOTRUNUSER) {
mtx_lock_spin(&sched_lock);
- /* fuword can block, check again */
- if (td->td_upcall)
- ku->ku_flags |= KUF_DOUPCALL;
+ ku->ku_flags |= KUF_DOUPCALL;
mtx_unlock_spin(&sched_lock);
}
}
+ td->td_mailbox = tmbx;
+ mtx_lock_spin(&sched_lock);
+ td->td_flags |= TDF_CAN_UNBIND;
+ mtx_unlock_spin(&sched_lock);
}
}
}
==== //depot/projects/davidxu_ksedbg/src/sys/sys/kse.h#6 (text+ko) ====
@@ -102,6 +102,7 @@
/* These flags are kept in tm_dlfags */
#define TMDF_SSTEP 0x01
#define TMDF_DONOTRUNUSER 0x02
+#define TMDF_NOUPCALL 0x04
/* Flags for kse_switchin */
#define KSE_SWITCHIN_SETTMBX 0x01
More information about the p4-projects
mailing list