From owner-p4-projects@FreeBSD.ORG Fri May 12 23:30:22 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 D859E16A715; Fri, 12 May 2006 23:30:17 +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 94D2E16A63F for ; Fri, 12 May 2006 23:30:15 +0000 (UTC) (envelope-from jb@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id A1E0643D46 for ; Fri, 12 May 2006 23:30:14 +0000 (GMT) (envelope-from jb@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 k4CNUEbs004208 for ; Fri, 12 May 2006 23:30:14 GMT (envelope-from jb@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k4CNUEuM004205 for perforce@freebsd.org; Fri, 12 May 2006 23:30:14 GMT (envelope-from jb@freebsd.org) Date: Fri, 12 May 2006 23:30:14 GMT Message-Id: <200605122330.k4CNUEuM004205@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jb@freebsd.org using -f From: John Birrell To: Perforce Change Reviews Cc: Subject: PERFORCE change 97036 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: Fri, 12 May 2006 23:30:26 -0000 http://perforce.freebsd.org/chv.cgi?CH=97036 Change 97036 by jb@jb_freebsd2 on 2006/05/12 23:29:15 Port the code for some of the special types now that I can see the tests accessing these. This includes 'execname', 'pid', 'tid' which are pretty fundamental to the operation of DTrace. There are still things here that are Solaris-specific, so they remain commented out. These pieces of code aren't being processed because the tests tend to access Solaris-specific structures which fail to resolve in dtrace(1), so the probes never get created and consequently they commented out bits of code don't get accessed. Affected files ... .. //depot/projects/dtrace/src/sys/cddl/dev/dtrace/dtrace_dif.c#6 edit Differences ... ==== //depot/projects/dtrace/src/sys/cddl/dev/dtrace/dtrace_dif.c#6 (text+ko) ==== @@ -51,7 +51,7 @@ return (mstate->dtms_arg[ndx]); case DIF_VAR_UREGS: { -printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); +printf("%s:%s(%d): DIF_VAR_UREGS\n",__FUNCTION__,__FILE__,__LINE__); #ifdef DOODAD klwp_t *lwp; @@ -122,7 +122,7 @@ return (mstate->dtms_stackdepth); case DIF_VAR_USTACKDEPTH: -printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); +printf("%s:%s(%d): DIF_VAR_USTACKDEPTH\n",__FUNCTION__,__FILE__,__LINE__); #ifdef DOODAD if (!dtrace_priv_proc(state)) return (0); @@ -223,6 +223,7 @@ mstate->dtms_probe->dtpr_name); case DIF_VAR_PID: +#if defined(sun) if (!dtrace_priv_proc(state)) return (0); @@ -231,11 +232,8 @@ * always due to a high-level interrupt. (And we're assuming * that there is only a single high level interrupt.) */ -printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); -#ifdef DOODAD if (DTRACE_ANCHORED(mstate->dtms_probe) && CPU_ON_INTR(CPU)) return (pid0.pid_id); -#endif /* * It is always safe to dereference one's own t_procp pointer: @@ -245,16 +243,13 @@ * threads and processes don't clean up their own state -- * they leave that task to whomever reaps them.) */ -printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); -#ifdef DOODAD return ((uint64_t)curthread->t_procp->p_pidp->pid_id); #else -return 0; + return ((uint64_t)curproc->p_pid); #endif case DIF_VAR_TID: -printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); -#ifdef DOODAD +#if defined(sun) /* * See comment in DIF_VAR_PID. */ @@ -263,12 +258,11 @@ return ((uint64_t)curthread->t_tid); #else -return 0; + return ((uint64_t)curthread->td_tid); #endif case DIF_VAR_EXECNAME: -printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); -#ifdef DOODAD +#if defined(sun) if (!dtrace_priv_proc(state)) return (0); @@ -287,12 +281,11 @@ return ((uint64_t)(uintptr_t) curthread->t_procp->p_user.u_comm); #else -return 0; + return ((uint64_t)(uintptr_t) curproc->p_comm); #endif case DIF_VAR_ZONENAME: -printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); -#ifdef DOODAD +#if defined(sun) if (!dtrace_priv_proc(state)) return (0); @@ -311,7 +304,7 @@ return ((uint64_t)(uintptr_t) curthread->t_procp->p_zone->zone_name); #else -return 0; + return 0; #endif default: @@ -353,7 +346,7 @@ break; case DIF_SUBR_MUTEX_OWNED: -printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); +printf("%s:%s(%d): DIF_SUBR_MUTEX_OWNED\n",__FUNCTION__,__FILE__,__LINE__); #ifdef DOODAD m.mx = dtrace_load64(tupregs[0].dttk_value); if (MUTEX_TYPE_ADAPTIVE(&m.mi)) @@ -364,7 +357,7 @@ break; case DIF_SUBR_MUTEX_OWNER: -printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); +printf("%s:%s(%d): DIF_SUBR_MUTEX_OWNER\n",__FUNCTION__,__FILE__,__LINE__); #ifdef DOODAD m.mx = dtrace_load64(tupregs[0].dttk_value); if (MUTEX_TYPE_ADAPTIVE(&m.mi) && @@ -376,7 +369,7 @@ break; case DIF_SUBR_MUTEX_TYPE_ADAPTIVE: -printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); +printf("%s:%s(%d): DIF_SUBR_MUTEX_TYPE_ADAPTIVE\n",__FUNCTION__,__FILE__,__LINE__); #ifdef DOODAD m.mx = dtrace_load64(tupregs[0].dttk_value); regs[rd] = MUTEX_TYPE_ADAPTIVE(&m.mi); @@ -384,7 +377,7 @@ break; case DIF_SUBR_MUTEX_TYPE_SPIN: -printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); +printf("%s:%s(%d): DIF_SUBR_MUTEX_TYPE_SPIN\n",__FUNCTION__,__FILE__,__LINE__); #ifdef DOODAD m.mx = dtrace_load64(tupregs[0].dttk_value); regs[rd] = MUTEX_TYPE_SPIN(&m.mi); @@ -392,7 +385,7 @@ break; case DIF_SUBR_RW_READ_HELD: { -printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); +printf("%s:%s(%d): DIF_SUBR_RW_READ_HELD\n",__FUNCTION__,__FILE__,__LINE__); #ifdef DOODAD uintptr_t tmp; @@ -403,7 +396,7 @@ } case DIF_SUBR_RW_WRITE_HELD: -printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); +printf("%s:%s(%d): DIF_SUBR_RW_WRITE_HELD\n",__FUNCTION__,__FILE__,__LINE__); #ifdef DOODAD r.rw = dtrace_loadptr(tupregs[0].dttk_value); regs[rd] = _RW_WRITE_HELD(&r.ri); @@ -411,7 +404,7 @@ break; case DIF_SUBR_RW_ISWRITER: -printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); +printf("%s:%s(%d): DIF_SUBR_RW_ISWRITER\n",__FUNCTION__,__FILE__,__LINE__); #ifdef DOODAD r.rw = dtrace_loadptr(tupregs[0].dttk_value); regs[rd] = _RW_ISWRITER(&r.ri); @@ -519,7 +512,7 @@ case DIF_SUBR_MSGSIZE: case DIF_SUBR_MSGDSIZE: { -printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); +printf("%s:%s(%d): DIF_SUBR_MSGSIZE or DIF_SUBR_MSGDSIZE\n",__FUNCTION__,__FILE__,__LINE__); #ifdef DOODAD uintptr_t baddr = tupregs[0].dttk_value, daddr; uintptr_t wptr, rptr; @@ -572,25 +565,31 @@ } case DIF_SUBR_PROGENYOF: { -printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); -#ifdef DOODAD pid_t pid = tupregs[0].dttk_value; proc_t *p; int rval = 0; DTRACE_CPUFLAG_SET(CPU_DTRACE_NOFAULT); +#if defined(sun) for (p = curthread->t_procp; p != NULL; p = p->p_parent) { if (p->p_pidp->pid_id == pid) { rval = 1; break; } } +#else + for (p = curproc; p != NULL; p = p->p_pptr) { + if (p->p_pid == pid) { + rval = 1; + break; + } + } +#endif DTRACE_CPUFLAG_CLEAR(CPU_DTRACE_NOFAULT); regs[rd] = rval; -#endif break; } @@ -665,8 +664,6 @@ case DIF_SUBR_STRSTR: case DIF_SUBR_INDEX: case DIF_SUBR_RINDEX: { -printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); -#ifdef DOODAD /* * We're going to iterate over the string looking for the * specified string. We will iterate until we have reached @@ -800,29 +797,27 @@ } } -#endif break; } case DIF_SUBR_STRTOK: { -printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); -#ifdef DOODAD uintptr_t addr = tupregs[0].dttk_value; uintptr_t tokaddr = tupregs[1].dttk_value; uint64_t size = state->dts_options[DTRACEOPT_STRSIZE]; uintptr_t limit, toklimit = tokaddr + size; - uint8_t c, tokmap[32]; /* 256 / 8 */ + uint8_t c = 0; + uint8_t tokmap[32]; /* 256 / 8 */ char *dest = (char *)mstate->dtms_scratch_ptr; int i; if (mstate->dtms_scratch_ptr + size > mstate->dtms_scratch_base + mstate->dtms_scratch_size) { DTRACE_CPUFLAG_SET(CPU_DTRACE_NOSCRATCH); - regs[rd] = NULL; + regs[rd] = 0; break; } - if (addr == NULL) { + if (addr == 0) { /* * If the address specified is NULL, we use our saved * strtok pointer from the mstate. Note that this @@ -868,8 +863,8 @@ * We return NULL in this case, and we set the saved * address to NULL as well. */ - regs[rd] = NULL; - mstate->dtms_strtok = NULL; + regs[rd] = 0; + mstate->dtms_strtok = 0; break; } @@ -892,13 +887,10 @@ regs[rd] = (uintptr_t)dest; mstate->dtms_scratch_ptr += size; mstate->dtms_strtok = addr; -#endif break; } case DIF_SUBR_SUBSTR: { -printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); -#ifdef DOODAD uintptr_t s = tupregs[0].dttk_value; uint64_t size = state->dts_options[DTRACEOPT_STRSIZE]; char *d = (char *)mstate->dtms_scratch_ptr; @@ -913,7 +905,7 @@ if (mstate->dtms_scratch_ptr + size > mstate->dtms_scratch_base + mstate->dtms_scratch_size) { DTRACE_CPUFLAG_SET(CPU_DTRACE_NOSCRATCH); - regs[rd] = NULL; + regs[rd] = 0; break; } @@ -941,12 +933,11 @@ mstate->dtms_scratch_ptr += size; regs[rd] = (uintptr_t)d; -#endif break; } case DIF_SUBR_GETMAJOR: -printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); +printf("%s:%s(%d): DIF_SUBR_GETMAJOR\n",__FUNCTION__,__FILE__,__LINE__); #ifdef DOODAD #ifdef _LP64 regs[rd] = (tupregs[0].dttk_value >> NBITSMINOR64) & MAXMAJ64; @@ -957,7 +948,7 @@ break; case DIF_SUBR_GETMINOR: -printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); +printf("%s:%s(%d): DIF_SUBR_GETMINOR\n",__FUNCTION__,__FILE__,__LINE__); #ifdef DOODAD #ifdef _LP64 regs[rd] = tupregs[0].dttk_value & MAXMIN64; @@ -968,7 +959,7 @@ break; case DIF_SUBR_DDI_PATHNAME: { -printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); +printf("%s:%s(%d): DIF_SUBR_DDI_PATHNAME\n",__FUNCTION__,__FILE__,__LINE__); #ifdef DOODAD /* * This one is a galactic mess. We are going to roughly @@ -1200,8 +1191,6 @@ } case DIF_SUBR_LLTOSTR: { -printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); -#ifdef DOODAD int64_t i = (int64_t)tupregs[0].dttk_value; int64_t val = i < 0 ? i * -1 : i; uint64_t size = 22; /* enough room for 2^64 in decimal */ @@ -1210,7 +1199,7 @@ if (mstate->dtms_scratch_ptr + size > mstate->dtms_scratch_base + mstate->dtms_scratch_size) { DTRACE_CPUFLAG_SET(CPU_DTRACE_NOSCRATCH); - regs[rd] = NULL; + regs[rd] = 0; break; } @@ -1225,14 +1214,11 @@ regs[rd] = (uintptr_t)end + 1; mstate->dtms_scratch_ptr += size; -#endif break; } case DIF_SUBR_DIRNAME: case DIF_SUBR_BASENAME: { -printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); -#ifdef DOODAD char *dest = (char *)mstate->dtms_scratch_ptr; uint64_t size = state->dts_options[DTRACEOPT_STRSIZE]; uintptr_t src = tupregs[0].dttk_value; @@ -1243,7 +1229,7 @@ if (mstate->dtms_scratch_ptr + size > mstate->dtms_scratch_base + mstate->dtms_scratch_size) { DTRACE_CPUFLAG_SET(CPU_DTRACE_NOSCRATCH); - regs[rd] = NULL; + regs[rd] = 0; break; } @@ -1355,7 +1341,6 @@ dest[j] = '\0'; regs[rd] = (uintptr_t)dest; mstate->dtms_scratch_ptr += size; -#endif break; }