Date: Fri, 12 May 2006 23:30:14 GMT From: John Birrell <jb@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 97036 for review Message-ID: <200605122330.k4CNUEuM004205@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
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; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200605122330.k4CNUEuM004205>