From owner-p4-projects@FreeBSD.ORG Sun Jul 30 00:51:11 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 838BA16A4E0; Sun, 30 Jul 2006 00:51:11 +0000 (UTC) X-Original-To: perforce@FreeBSD.org 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 5A68316A4DE for ; Sun, 30 Jul 2006 00:51:11 +0000 (UTC) (envelope-from howardsu@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 17CC943D46 for ; Sun, 30 Jul 2006 00:51:11 +0000 (GMT) (envelope-from howardsu@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k6U0pAZc082087 for ; Sun, 30 Jul 2006 00:51:10 GMT (envelope-from howardsu@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k6U0pAm4082084 for perforce@freebsd.org; Sun, 30 Jul 2006 00:51:10 GMT (envelope-from howardsu@FreeBSD.org) Date: Sun, 30 Jul 2006 00:51:10 GMT Message-Id: <200607300051.k6U0pAm4082084@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to howardsu@FreeBSD.org using -f From: Howard Su To: Perforce Change Reviews Cc: Subject: PERFORCE change 102756 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Jul 2006 00:51:11 -0000 http://perforce.freebsd.org/chv.cgi?CH=102756 Change 102756 by howardsu@su_vm on 2006/07/30 00:50:21 extend the ptrace(2) kernel part. Now the PT_LWPINFO will give more information about why child is stoped. TODO: update man page Affected files ... .. //depot/projects/dtrace/src/sys/kern/kern_exec.c#7 edit .. //depot/projects/dtrace/src/sys/kern/kern_exit.c#6 edit .. //depot/projects/dtrace/src/sys/kern/kern_sig.c#6 edit .. //depot/projects/dtrace/src/sys/kern/sys_process.c#3 edit .. //depot/projects/dtrace/src/sys/sys/proc.h#10 edit .. //depot/projects/dtrace/src/sys/sys/ptrace.h#3 edit Differences ... ==== //depot/projects/dtrace/src/sys/kern/kern_exec.c#7 (text+ko) ==== @@ -667,7 +667,6 @@ */ if (p->p_flag & P_TRACED) { -printf("%s:%s(%d): SIGTRAP to debugger\n",__FUNCTION__,__FILE__,__LINE__); tdsignal(p, td, SIGTRAP, NULL); } ==== //depot/projects/dtrace/src/sys/kern/kern_exit.c#6 (text+ko) ==== @@ -433,7 +433,6 @@ * since their existence means someone is screwing up. */ if (q->p_flag & P_TRACED) { -printf("%s:%s(%d): Kill a traced process\n",__FUNCTION__,__FILE__,__LINE__); q->p_flag &= ~(P_TRACED | P_STOPPED_TRACE); psignal(q, SIGKILL); } @@ -834,7 +833,6 @@ (p->p_suspcount == p->p_numthreads) && (p->p_flag & P_WAITED) == 0 && (p->p_flag & P_TRACED || options & WUNTRACED)) { -printf("%s:%s(%d): \n",__FUNCTION__,__FILE__,__LINE__); mtx_unlock_spin(&sched_lock); p->p_flag |= P_WAITED; sx_xunlock(&proctree_lock); ==== //depot/projects/dtrace/src/sys/kern/kern_sig.c#6 (text+ko) ==== @@ -58,6 +58,7 @@ #include #include #include +#include #include #include #include @@ -2133,7 +2134,6 @@ * either winding down or already on the suspended queue. */ if (p->p_flag & P_TRACED) { -printf("%s:%s(%d): the traced process is already stopped\n",__FUNCTION__,__FILE__,__LINE__); /* * The traced process is already stopped, * so no further action is necessary. @@ -2380,7 +2380,6 @@ WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, &p->p_mtx.mtx_object, "Stopping for traced signal"); -printf("%s:%s(%d): stopping for a traced signal %d\n",__FUNCTION__,__FILE__,__LINE__,sig); mtx_lock_spin(&sched_lock); td->td_flags |= TDF_XSIG; mtx_unlock_spin(&sched_lock); @@ -2412,7 +2411,6 @@ PROC_LOCK(p); if (!(p->p_flag & P_TRACED)) break; -printf("%s:%s(%d): \n",__FUNCTION__,__FILE__,__LINE__); if (td->td_flags & TDF_DBSUSPEND) { if (p->p_flag & P_SINGLE_EXIT) break; @@ -2478,8 +2476,8 @@ /* * If traced, always stop. */ -printf("%s:%s(%d): \n",__FUNCTION__,__FILE__,__LINE__); mtx_unlock(&ps->ps_mtx); + td->td_xsig_why = PL_EVENT_SIGNAL; newsig = ptracestop(td, sig); mtx_lock(&ps->ps_mtx); @@ -2559,7 +2557,6 @@ mtx_unlock(&ps->ps_mtx); WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, &p->p_mtx.mtx_object, "Catching SIGSTOP"); -printf("%s:%s(%d): catching SIGSTOP\n",__FUNCTION__,__FILE__,__LINE__); p->p_flag |= P_STOPPED_SIG; p->p_xstat = sig; mtx_lock_spin(&sched_lock); ==== //depot/projects/dtrace/src/sys/kern/sys_process.c#3 (text+ko) ==== @@ -48,7 +48,7 @@ #include #include - +#include #include #include @@ -939,13 +939,23 @@ } pl = addr; pl->pl_lwpid = td2->td_tid; - if (td2->td_flags & TDF_XSIG) - pl->pl_event = PL_EVENT_SIGNAL; - else - pl->pl_event = 0; + pl->pl_event = td2->td_xsig_why; pl->pl_flags = 0; pl->pl_sigmask = td2->td_sigmask; pl->pl_siglist = td2->td_siglist; + if (data > (int)&((struct ptrace_lwpinfo *)NULL)->pl_sysnum) { + switch(td2->td_xsig_why){ + case PL_EVENT_SYSENTER: + case PL_EVENT_SYSEXIT: + pl->pl_sysnum = td2->td_frame->tf_eax; + break; + case PL_EVENT_SIGNAL: + pl->pl_signal = td2->td_xsig; + break; + } + } + + break; case PT_GETNUMLWPS: ==== //depot/projects/dtrace/src/sys/sys/proc.h#10 (text+ko) ==== @@ -217,6 +217,7 @@ volatile u_int td_generation; /* (k) For detection of preemption */ stack_t td_sigstk; /* (k) Stack ptr and on-stack flag. */ int td_xsig; /* (c) Signal for ptrace */ + int td_xsig_why; /* (c) reason for ptrace signal PL_EVENT_* */ u_long td_profil_addr; /* (k) Temporary addr until AST. */ u_int td_profil_ticks; /* (k) Temporary ticks until AST. */ char td_name[MAXCOMLEN + 1]; /* (*) Thread name. */ ==== //depot/projects/dtrace/src/sys/sys/ptrace.h#3 (text+ko) ==== @@ -91,18 +91,29 @@ int pl_event; /* Event that stopped the LWP. */ #define PL_EVENT_NONE 0 #define PL_EVENT_SIGNAL 1 +#define PL_EVENT_SYSENTER 2 +#define PL_EVENT_SYSEXIT 3 int pl_flags; /* LWP flags. */ #define PL_FLAG_SA 0x01 /* M:N thread */ #define PL_FLAG_BOUND 0x02 /* M:N bound thread */ sigset_t pl_sigmask; /* LWP signal mask */ sigset_t pl_siglist; /* LWP pending signal */ + + union { + int _pl_sysnum; + int _pl_signal; + }pl_data; }; +#define pl_sysnum pl_data._pl_sysnum +#define pl_signal pl_data._pl_signal + #ifdef _KERNEL #define PTRACESTOP_SC(p, td, flag) \ if ((p)->p_flag & P_TRACED && (p)->p_stops & (flag)) { \ PROC_LOCK(p); \ + td->td_xsig_why = (flag==S_PT_SCE)?PL_EVENT_SYSENTER:PL_EVENT_SYSEXIT; \ ptracestop((td), SIGTRAP); \ PROC_UNLOCK(p); \ }