From owner-p4-projects@FreeBSD.ORG Tue Jul 20 05:34:05 2004 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id AAF5C16A4D0; Tue, 20 Jul 2004 05:34:04 +0000 (GMT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6D43C16A4CE for ; Tue, 20 Jul 2004 05:34:04 +0000 (GMT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5066043D5A for ; Tue, 20 Jul 2004 05:34:04 +0000 (GMT) (envelope-from davidxu@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.11/8.12.11) with ESMTP id i6K5Y4WV080591 for ; Tue, 20 Jul 2004 05:34:04 GMT (envelope-from davidxu@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.11/8.12.11/Submit) id i6K5Y4iw080588 for perforce@freebsd.org; Tue, 20 Jul 2004 05:34:04 GMT (envelope-from davidxu@freebsd.org) Date: Tue, 20 Jul 2004 05:34:04 GMT Message-Id: <200407200534.i6K5Y4iw080588@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to davidxu@freebsd.org using -f From: David Xu To: Perforce Change Reviews Subject: PERFORCE change 57760 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Jul 2004 05:34:05 -0000 http://perforce.freebsd.org/chv.cgi?CH=57760 Change 57760 by davidxu@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