1*7c478bd9Sstevel@tonic-gate/* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate/* 23*7c478bd9Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate#pragma ident "%Z%%M% %I% %E% SMI" 28*7c478bd9Sstevel@tonic-gate 29*7c478bd9Sstevel@tonic-gate/* 30*7c478bd9Sstevel@tonic-gate * This file defines the standard set of inlines and translators to be made 31*7c478bd9Sstevel@tonic-gate * available for all D programs to use to examine process model state. 32*7c478bd9Sstevel@tonic-gate */ 33*7c478bd9Sstevel@tonic-gate 34*7c478bd9Sstevel@tonic-gate#pragma D depends_on module procfs 35*7c478bd9Sstevel@tonic-gate 36*7c478bd9Sstevel@tonic-gateinline int errno = curthread->t_lwp ? curthread->t_lwp->lwp_errno : 0; 37*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" errno 38*7c478bd9Sstevel@tonic-gate 39*7c478bd9Sstevel@tonic-gate/* 40*7c478bd9Sstevel@tonic-gate * The following miscellaneous constants are used by the proc(4) translators 41*7c478bd9Sstevel@tonic-gate * defined below. These are assigned the latest values from the system .h's. 42*7c478bd9Sstevel@tonic-gate */ 43*7c478bd9Sstevel@tonic-gateinline char SSLEEP = @SSLEEP@; 44*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" SSLEEP 45*7c478bd9Sstevel@tonic-gateinline char SRUN = @SRUN@; 46*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" SRUN 47*7c478bd9Sstevel@tonic-gateinline char SZOMB = @SZOMB@; 48*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" SZOMB 49*7c478bd9Sstevel@tonic-gateinline char SSTOP = @SSTOP@; 50*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" SSTOP 51*7c478bd9Sstevel@tonic-gateinline char SIDL = @SIDL@; 52*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" SIDL 53*7c478bd9Sstevel@tonic-gateinline char SONPROC = @SONPROC@; 54*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" SONPROC 55*7c478bd9Sstevel@tonic-gate 56*7c478bd9Sstevel@tonic-gateinline int PR_STOPPED = @PR_STOPPED@; 57*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" PR_STOPPED 58*7c478bd9Sstevel@tonic-gateinline int PR_ISTOP = @PR_ISTOP@; 59*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" PR_ISTOP 60*7c478bd9Sstevel@tonic-gateinline int PR_DSTOP = @PR_DSTOP@; 61*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" PR_DSTOP 62*7c478bd9Sstevel@tonic-gateinline int PR_STEP = @PR_STEP@; 63*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" PR_STEP 64*7c478bd9Sstevel@tonic-gateinline int PR_ASLEEP = @PR_ASLEEP@; 65*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" PR_ASLEEP 66*7c478bd9Sstevel@tonic-gateinline int PR_PCINVAL = @PR_PCINVAL@; 67*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" PR_PCINVAL 68*7c478bd9Sstevel@tonic-gateinline int PR_ASLWP = @PR_ASLWP@; 69*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" PR_ASLWP 70*7c478bd9Sstevel@tonic-gateinline int PR_AGENT = @PR_AGENT@; 71*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" PR_AGENT 72*7c478bd9Sstevel@tonic-gateinline int PR_DETACH = @PR_DETACH@; 73*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" PR_DETACH 74*7c478bd9Sstevel@tonic-gateinline int PR_DAEMON = @PR_DAEMON@; 75*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" PR_DAEMON 76*7c478bd9Sstevel@tonic-gateinline int PR_ISSYS = @PR_ISSYS@; 77*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" PR_ISSYS 78*7c478bd9Sstevel@tonic-gateinline int PR_VFORKP = @PR_VFORKP@; 79*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" PR_VFORKP 80*7c478bd9Sstevel@tonic-gateinline int PR_ORPHAN = @PR_ORPHAN@; 81*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" PR_ORPHAN 82*7c478bd9Sstevel@tonic-gateinline int PR_FORK = @PR_FORK@; 83*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" PR_FORK 84*7c478bd9Sstevel@tonic-gateinline int PR_RLC = @PR_RLC@; 85*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" PR_RLC 86*7c478bd9Sstevel@tonic-gateinline int PR_KLC = @PR_KLC@; 87*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" PR_KLC 88*7c478bd9Sstevel@tonic-gateinline int PR_ASYNC = @PR_ASYNC@; 89*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" PR_ASYNC 90*7c478bd9Sstevel@tonic-gateinline int PR_MSACCT = @PR_MSACCT@; 91*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" PR_MSACCT 92*7c478bd9Sstevel@tonic-gateinline int PR_BPTADJ = @PR_BPTADJ@; 93*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" PR_BPTADJ 94*7c478bd9Sstevel@tonic-gateinline int PR_PTRACE = @PR_PTRACE@; 95*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" PR_PTRACE 96*7c478bd9Sstevel@tonic-gateinline int PR_MSFORK = @PR_MSFORK@; 97*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" PR_MSFORK 98*7c478bd9Sstevel@tonic-gateinline int PR_IDLE = @PR_IDLE@; 99*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" PR_IDLE 100*7c478bd9Sstevel@tonic-gate 101*7c478bd9Sstevel@tonic-gateinline char PR_MODEL_ILP32 = @PR_MODEL_ILP32@; 102*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" PR_MODEL_ILP32 103*7c478bd9Sstevel@tonic-gateinline char PR_MODEL_LP64 = @PR_MODEL_LP64@; 104*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" PR_MODEL_LP64 105*7c478bd9Sstevel@tonic-gate 106*7c478bd9Sstevel@tonic-gateinline char SOBJ_NONE = @SOBJ_NONE@; 107*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" SOBJ_NONE 108*7c478bd9Sstevel@tonic-gateinline char SOBJ_MUTEX = @SOBJ_MUTEX@; 109*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" SOBJ_MUTEX 110*7c478bd9Sstevel@tonic-gateinline char SOBJ_RWLOCK = @SOBJ_RWLOCK@; 111*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" SOBJ_RWLOCK 112*7c478bd9Sstevel@tonic-gateinline char SOBJ_CV = @SOBJ_CV@; 113*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" SOBJ_CV 114*7c478bd9Sstevel@tonic-gateinline char SOBJ_SEMA = @SOBJ_SEMA@; 115*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" SOBJ_SEMA 116*7c478bd9Sstevel@tonic-gateinline char SOBJ_USER = @SOBJ_USER@; 117*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" SOBJ_USER 118*7c478bd9Sstevel@tonic-gateinline char SOBJ_USER_PI = @SOBJ_USER_PI@; 119*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" SOBJ_USER_PI 120*7c478bd9Sstevel@tonic-gateinline char SOBJ_SHUTTLE = @SOBJ_SHUTTLE@; 121*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" SOBJ_SHUTTLE 122*7c478bd9Sstevel@tonic-gate 123*7c478bd9Sstevel@tonic-gateinline int SI_USER = @SI_USER@; 124*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" SI_USER 125*7c478bd9Sstevel@tonic-gateinline int SI_LWP = @SI_LWP@; 126*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" SI_LWP 127*7c478bd9Sstevel@tonic-gateinline int SI_QUEUE = @SI_QUEUE@; 128*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" SI_QUEUE 129*7c478bd9Sstevel@tonic-gateinline int SI_TIMER = @SI_TIMER@; 130*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" SI_TIMER 131*7c478bd9Sstevel@tonic-gateinline int SI_ASYNCIO = @SI_ASYNCIO@; 132*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" SI_ASYNCIO 133*7c478bd9Sstevel@tonic-gateinline int SI_MESGQ = @SI_MESGQ@; 134*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" SI_MESGQ 135*7c478bd9Sstevel@tonic-gateinline int SI_RCTL = @SI_RCTL@; 136*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" SI_RCTL 137*7c478bd9Sstevel@tonic-gateinline int ILL_ILLOPC = @ILL_ILLOPC@; 138*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" ILL_ILLOPC 139*7c478bd9Sstevel@tonic-gateinline int ILL_ILLOPN = @ILL_ILLOPN@; 140*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" ILL_ILLOPN 141*7c478bd9Sstevel@tonic-gateinline int ILL_ILLADR = @ILL_ILLADR@; 142*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" ILL_ILLADR 143*7c478bd9Sstevel@tonic-gateinline int ILL_ILLTRP = @ILL_ILLTRP@; 144*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" ILL_ILLTRP 145*7c478bd9Sstevel@tonic-gateinline int ILL_PRVOPC = @ILL_PRVOPC@; 146*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" ILL_PRVOPC 147*7c478bd9Sstevel@tonic-gateinline int ILL_PRVREG = @ILL_PRVREG@; 148*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" ILL_PRVREG 149*7c478bd9Sstevel@tonic-gateinline int ILL_COPROC = @ILL_COPROC@; 150*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" ILL_COPROC 151*7c478bd9Sstevel@tonic-gateinline int ILL_BADSTK = @ILL_BADSTK@; 152*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" ILL_BADSTK 153*7c478bd9Sstevel@tonic-gateinline int FPE_INTDIV = @FPE_INTDIV@; 154*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" FPE_INTDIV 155*7c478bd9Sstevel@tonic-gateinline int FPE_INTOVF = @FPE_INTOVF@; 156*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" FPE_INTOVF 157*7c478bd9Sstevel@tonic-gateinline int FPE_FLTDIV = @FPE_FLTDIV@; 158*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" FPE_FLTDIV 159*7c478bd9Sstevel@tonic-gateinline int FPE_FLTOVF = @FPE_FLTOVF@; 160*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" FPE_FLTOVF 161*7c478bd9Sstevel@tonic-gateinline int FPE_FLTUND = @FPE_FLTUND@; 162*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" FPE_FLTUND 163*7c478bd9Sstevel@tonic-gateinline int FPE_FLTRES = @FPE_FLTRES@; 164*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" FPE_FLTRES 165*7c478bd9Sstevel@tonic-gateinline int FPE_FLTINV = @FPE_FLTINV@; 166*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" FPE_FLTINV 167*7c478bd9Sstevel@tonic-gateinline int FPE_FLTSUB = @FPE_FLTSUB@; 168*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" FPE_FLTSUB 169*7c478bd9Sstevel@tonic-gateinline int SEGV_MAPERR = @SEGV_MAPERR@; 170*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" SEGV_MAPERR 171*7c478bd9Sstevel@tonic-gateinline int SEGV_ACCERR = @SEGV_ACCERR@; 172*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" SEGV_ACCERR 173*7c478bd9Sstevel@tonic-gateinline int BUS_ADRALN = @BUS_ADRALN@; 174*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" BUS_ADRALN 175*7c478bd9Sstevel@tonic-gateinline int BUS_ADRERR = @BUS_ADRERR@; 176*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" BUS_ADRERR 177*7c478bd9Sstevel@tonic-gateinline int BUS_OBJERR = @BUS_OBJERR@; 178*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" BUS_OBJERR 179*7c478bd9Sstevel@tonic-gateinline int TRAP_BRKPT = @TRAP_BRKPT@; 180*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" TRAP_BRKPT 181*7c478bd9Sstevel@tonic-gateinline int TRAP_TRACE = @TRAP_TRACE@; 182*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" TRAP_TRACE 183*7c478bd9Sstevel@tonic-gateinline int CLD_EXITED = @CLD_EXITED@; 184*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" CLD_EXITED 185*7c478bd9Sstevel@tonic-gateinline int CLD_KILLED = @CLD_KILLED@; 186*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" CLD_KILLED 187*7c478bd9Sstevel@tonic-gateinline int CLD_DUMPED = @CLD_DUMPED@; 188*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" CLD_DUMPED 189*7c478bd9Sstevel@tonic-gateinline int CLD_TRAPPED = @CLD_TRAPPED@; 190*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" CLD_TRAPPED 191*7c478bd9Sstevel@tonic-gateinline int CLD_STOPPED = @CLD_STOPPED@; 192*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" CLD_STOPPED 193*7c478bd9Sstevel@tonic-gateinline int CLD_CONTINUED = @CLD_CONTINUED@; 194*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" CLD_CONTINUED 195*7c478bd9Sstevel@tonic-gateinline int POLL_IN = @POLL_IN@; 196*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" POLL_IN 197*7c478bd9Sstevel@tonic-gateinline int POLL_OUT = @POLL_OUT@; 198*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" POLL_OUT 199*7c478bd9Sstevel@tonic-gateinline int POLL_MSG = @POLL_MSG@; 200*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" POLL_MSG 201*7c478bd9Sstevel@tonic-gateinline int POLL_ERR = @POLL_ERR@; 202*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" POLL_ERR 203*7c478bd9Sstevel@tonic-gateinline int POLL_PRI = @POLL_PRI@; 204*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" POLL_PRI 205*7c478bd9Sstevel@tonic-gateinline int POLL_HUP = @POLL_HUP@; 206*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" POLL_HUP 207*7c478bd9Sstevel@tonic-gate 208*7c478bd9Sstevel@tonic-gate/* 209*7c478bd9Sstevel@tonic-gate * Translate from the kernel's proc_t structure to a proc(4) psinfo_t struct. 210*7c478bd9Sstevel@tonic-gate * We do not provide support for pr_size, pr_rssize, pr_pctcpu, and pr_pctmem. 211*7c478bd9Sstevel@tonic-gate * We also do not fill in pr_lwp (the lwpsinfo_t for the representative LWP) 212*7c478bd9Sstevel@tonic-gate * because we do not have the ability to select and stop any representative. 213*7c478bd9Sstevel@tonic-gate * Also, for the moment, pr_wstat, pr_time, and pr_ctime are not supported, 214*7c478bd9Sstevel@tonic-gate * but these could be supported by DTrace in the future using subroutines. 215*7c478bd9Sstevel@tonic-gate * Note that any member added to this translator should also be added to the 216*7c478bd9Sstevel@tonic-gate * kthread_t-to-psinfo_t translator, below. 217*7c478bd9Sstevel@tonic-gate */ 218*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" translator 219*7c478bd9Sstevel@tonic-gatetranslator psinfo_t < proc_t *T > { 220*7c478bd9Sstevel@tonic-gate pr_nlwp = T->p_lwpcnt; 221*7c478bd9Sstevel@tonic-gate pr_pid = T->p_pidp->pid_id; 222*7c478bd9Sstevel@tonic-gate pr_ppid = T->p_ppid; 223*7c478bd9Sstevel@tonic-gate pr_pgid = T->p_pgidp->pid_id; 224*7c478bd9Sstevel@tonic-gate pr_sid = T->p_sessp->s_sidp->pid_id; 225*7c478bd9Sstevel@tonic-gate pr_uid = T->p_cred->cr_ruid; 226*7c478bd9Sstevel@tonic-gate pr_euid = T->p_cred->cr_uid; 227*7c478bd9Sstevel@tonic-gate pr_gid = T->p_cred->cr_rgid; 228*7c478bd9Sstevel@tonic-gate pr_egid = T->p_cred->cr_gid; 229*7c478bd9Sstevel@tonic-gate pr_addr = (uintptr_t)T; 230*7c478bd9Sstevel@tonic-gate 231*7c478bd9Sstevel@tonic-gate pr_ttydev = (T->p_sessp->s_vp == NULL) ? (dev_t)-1 : 232*7c478bd9Sstevel@tonic-gate (T->p_sessp->s_dev == `rwsconsdev) ? `uconsdev : 233*7c478bd9Sstevel@tonic-gate (T->p_sessp->s_dev == `rconsdev) ? `uconsdev : T->p_sessp->s_dev; 234*7c478bd9Sstevel@tonic-gate 235*7c478bd9Sstevel@tonic-gate pr_start = T->p_user.u_start; 236*7c478bd9Sstevel@tonic-gate pr_fname = T->p_user.u_comm; 237*7c478bd9Sstevel@tonic-gate pr_psargs = T->p_user.u_psargs; 238*7c478bd9Sstevel@tonic-gate pr_argc = T->p_user.u_argc; 239*7c478bd9Sstevel@tonic-gate pr_argv = T->p_user.u_argv; 240*7c478bd9Sstevel@tonic-gate pr_envp = T->p_user.u_envp; 241*7c478bd9Sstevel@tonic-gate 242*7c478bd9Sstevel@tonic-gate pr_dmodel = (T->p_model == @DATAMODEL_ILP32@) ? 243*7c478bd9Sstevel@tonic-gate PR_MODEL_ILP32 : PR_MODEL_LP64; 244*7c478bd9Sstevel@tonic-gate 245*7c478bd9Sstevel@tonic-gate pr_taskid = T->p_task->tk_tkid; 246*7c478bd9Sstevel@tonic-gate pr_projid = T->p_task->tk_proj->kpj_id; 247*7c478bd9Sstevel@tonic-gate pr_poolid = T->p_pool->pool_id; 248*7c478bd9Sstevel@tonic-gate pr_zoneid = T->p_zone->zone_id; 249*7c478bd9Sstevel@tonic-gate}; 250*7c478bd9Sstevel@tonic-gate 251*7c478bd9Sstevel@tonic-gate/* 252*7c478bd9Sstevel@tonic-gate * Translate from the kernel's kthread_t structure to a proc(4) psinfo_t 253*7c478bd9Sstevel@tonic-gate * struct. Lacking a facility to define one translator only in terms of 254*7c478bd9Sstevel@tonic-gate * another, we explicitly define each member by using the proc_t-to-psinfo_t 255*7c478bd9Sstevel@tonic-gate * translator, above; any members added to that translator should also be 256*7c478bd9Sstevel@tonic-gate * added here. (The only exception to this is pr_start, which -- due to it 257*7c478bd9Sstevel@tonic-gate * being a structure -- cannot be defined in terms of a translator at all.) 258*7c478bd9Sstevel@tonic-gate */ 259*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" translator 260*7c478bd9Sstevel@tonic-gatetranslator psinfo_t < kthread_t *T > { 261*7c478bd9Sstevel@tonic-gate pr_nlwp = xlate <psinfo_t> (T->t_procp).pr_nlwp; 262*7c478bd9Sstevel@tonic-gate pr_pid = xlate <psinfo_t> (T->t_procp).pr_pid; 263*7c478bd9Sstevel@tonic-gate pr_ppid = xlate <psinfo_t> (T->t_procp).pr_ppid; 264*7c478bd9Sstevel@tonic-gate pr_pgid = xlate <psinfo_t> (T->t_procp).pr_pgid; 265*7c478bd9Sstevel@tonic-gate pr_sid = xlate <psinfo_t> (T->t_procp).pr_sid; 266*7c478bd9Sstevel@tonic-gate pr_uid = xlate <psinfo_t> (T->t_procp).pr_uid; 267*7c478bd9Sstevel@tonic-gate pr_euid = xlate <psinfo_t> (T->t_procp).pr_euid; 268*7c478bd9Sstevel@tonic-gate pr_gid = xlate <psinfo_t> (T->t_procp).pr_gid; 269*7c478bd9Sstevel@tonic-gate pr_egid = xlate <psinfo_t> (T->t_procp).pr_egid; 270*7c478bd9Sstevel@tonic-gate pr_addr = xlate <psinfo_t> (T->t_procp).pr_addr; 271*7c478bd9Sstevel@tonic-gate pr_ttydev = xlate <psinfo_t> (T->t_procp).pr_ttydev; 272*7c478bd9Sstevel@tonic-gate pr_start = (timestruc_t)xlate <psinfo_t> (T->t_procp).pr_start; 273*7c478bd9Sstevel@tonic-gate pr_fname = xlate <psinfo_t> (T->t_procp).pr_fname; 274*7c478bd9Sstevel@tonic-gate pr_psargs = xlate <psinfo_t> (T->t_procp).pr_psargs; 275*7c478bd9Sstevel@tonic-gate pr_argc = xlate <psinfo_t> (T->t_procp).pr_argc; 276*7c478bd9Sstevel@tonic-gate pr_argv = xlate <psinfo_t> (T->t_procp).pr_argv; 277*7c478bd9Sstevel@tonic-gate pr_envp = xlate <psinfo_t> (T->t_procp).pr_envp; 278*7c478bd9Sstevel@tonic-gate pr_dmodel = xlate <psinfo_t> (T->t_procp).pr_dmodel; 279*7c478bd9Sstevel@tonic-gate pr_taskid = xlate <psinfo_t> (T->t_procp).pr_taskid; 280*7c478bd9Sstevel@tonic-gate pr_projid = xlate <psinfo_t> (T->t_procp).pr_projid; 281*7c478bd9Sstevel@tonic-gate pr_poolid = xlate <psinfo_t> (T->t_procp).pr_poolid; 282*7c478bd9Sstevel@tonic-gate pr_zoneid = xlate <psinfo_t> (T->t_procp).pr_zoneid; 283*7c478bd9Sstevel@tonic-gate}; 284*7c478bd9Sstevel@tonic-gate 285*7c478bd9Sstevel@tonic-gate/* 286*7c478bd9Sstevel@tonic-gate * Translate from the kernel's kthread_t structure to a proc(4) lwpsinfo_t. 287*7c478bd9Sstevel@tonic-gate * We do not provide support for pr_nice, pr_oldpri, pr_cpu, or pr_pctcpu. 288*7c478bd9Sstevel@tonic-gate * Also, for the moment, pr_start and pr_time are not supported, but these 289*7c478bd9Sstevel@tonic-gate * could be supported by DTrace in the future using subroutines. 290*7c478bd9Sstevel@tonic-gate */ 291*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" translator 292*7c478bd9Sstevel@tonic-gatetranslator lwpsinfo_t < kthread_t *T > { 293*7c478bd9Sstevel@tonic-gate pr_flag = ((T->t_state == @TS_STOPPED@) ? (PR_STOPPED | 294*7c478bd9Sstevel@tonic-gate ((!(T->t_schedflag & @TS_PSTART@)) ? PR_ISTOP : 0)) : 295*7c478bd9Sstevel@tonic-gate ((T->t_proc_flag & @TP_PRVSTOP@) ? PR_STOPPED | PR_ISTOP : 0)) | 296*7c478bd9Sstevel@tonic-gate ((T == T->t_procp->p_agenttp) ? PR_AGENT : 0) | 297*7c478bd9Sstevel@tonic-gate ((!(T->t_proc_flag & @TP_TWAIT@)) ? PR_DETACH : 0) | 298*7c478bd9Sstevel@tonic-gate ((T->t_proc_flag & @TP_DAEMON@) ? PR_DAEMON : 0) | 299*7c478bd9Sstevel@tonic-gate ((T->t_procp->p_proc_flag & @P_PR_FORK@) ? PR_FORK : 0) | 300*7c478bd9Sstevel@tonic-gate ((T->t_procp->p_proc_flag & @P_PR_RUNLCL@) ? PR_RLC : 0) | 301*7c478bd9Sstevel@tonic-gate ((T->t_procp->p_proc_flag & @P_PR_KILLCL@) ? PR_KLC : 0) | 302*7c478bd9Sstevel@tonic-gate ((T->t_procp->p_proc_flag & @P_PR_ASYNC@) ? PR_ASYNC : 0) | 303*7c478bd9Sstevel@tonic-gate ((T->t_procp->p_proc_flag & @P_PR_BPTADJ@) ? PR_BPTADJ : 0) | 304*7c478bd9Sstevel@tonic-gate ((T->t_procp->p_proc_flag & @P_PR_PTRACE@) ? PR_PTRACE : 0) | 305*7c478bd9Sstevel@tonic-gate ((T->t_procp->p_flag & @SMSACCT@) ? PR_MSACCT : 0) | 306*7c478bd9Sstevel@tonic-gate ((T->t_procp->p_flag & @SMSFORK@) ? PR_MSFORK : 0) | 307*7c478bd9Sstevel@tonic-gate ((T->t_procp->p_flag & @SVFWAIT@) ? PR_VFORKP : 0) | 308*7c478bd9Sstevel@tonic-gate (((T->t_procp->p_flag & @SSYS@) || 309*7c478bd9Sstevel@tonic-gate (T->t_procp->p_as == &`kas)) ? PR_ISSYS : 0) | 310*7c478bd9Sstevel@tonic-gate ((T == T->t_cpu->cpu_idle_thread) ? PR_IDLE : 0); 311*7c478bd9Sstevel@tonic-gate 312*7c478bd9Sstevel@tonic-gate pr_lwpid = T->t_tid; 313*7c478bd9Sstevel@tonic-gate pr_addr = (uintptr_t)T; 314*7c478bd9Sstevel@tonic-gate pr_wchan = (uintptr_t)T->t_lwpchan.lc_wchan; 315*7c478bd9Sstevel@tonic-gate pr_stype = T->t_sobj_ops ? T->t_sobj_ops->sobj_type : 0; 316*7c478bd9Sstevel@tonic-gate 317*7c478bd9Sstevel@tonic-gate pr_state = (T->t_proc_flag & @TP_PRVSTOP@) ? SSTOP : 318*7c478bd9Sstevel@tonic-gate (T->t_state == @TS_SLEEP@) ? SSLEEP : 319*7c478bd9Sstevel@tonic-gate (T->t_state == @TS_RUN@) ? SRUN : 320*7c478bd9Sstevel@tonic-gate (T->t_state == @TS_ONPROC@) ? SONPROC : 321*7c478bd9Sstevel@tonic-gate (T->t_state == @TS_ZOMB@) ? SZOMB : 322*7c478bd9Sstevel@tonic-gate (T->t_state == @TS_STOPPED@) ? SSTOP : 0; 323*7c478bd9Sstevel@tonic-gate 324*7c478bd9Sstevel@tonic-gate pr_sname = (T->t_proc_flag & @TP_PRVSTOP@) ? 'T' : 325*7c478bd9Sstevel@tonic-gate (T->t_state == @TS_SLEEP@) ? 'S' : 326*7c478bd9Sstevel@tonic-gate (T->t_state == @TS_RUN@) ? 'R' : 327*7c478bd9Sstevel@tonic-gate (T->t_state == @TS_ONPROC@) ? 'O' : 328*7c478bd9Sstevel@tonic-gate (T->t_state == @TS_ZOMB@) ? 'Z' : 329*7c478bd9Sstevel@tonic-gate (T->t_state == @TS_STOPPED@) ? 'T' : '?'; 330*7c478bd9Sstevel@tonic-gate 331*7c478bd9Sstevel@tonic-gate pr_syscall = T->t_sysnum; 332*7c478bd9Sstevel@tonic-gate pr_pri = T->t_pri; 333*7c478bd9Sstevel@tonic-gate pr_clname = `sclass[T->t_cid].cl_name; 334*7c478bd9Sstevel@tonic-gate pr_onpro = T->t_cpu->cpu_id; 335*7c478bd9Sstevel@tonic-gate pr_bindpro = T->t_bind_cpu; 336*7c478bd9Sstevel@tonic-gate pr_bindpset = T->t_bind_pset; 337*7c478bd9Sstevel@tonic-gate}; 338*7c478bd9Sstevel@tonic-gate 339*7c478bd9Sstevel@tonic-gateinline psinfo_t *curpsinfo = xlate <psinfo_t *> (curthread->t_procp); 340*7c478bd9Sstevel@tonic-gate#pragma D attributes Stable/Stable/Common curpsinfo 341*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" curpsinfo 342*7c478bd9Sstevel@tonic-gate 343*7c478bd9Sstevel@tonic-gateinline lwpsinfo_t *curlwpsinfo = xlate <lwpsinfo_t *> (curthread); 344*7c478bd9Sstevel@tonic-gate#pragma D attributes Stable/Stable/Common curlwpsinfo 345*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" curlwpsinfo 346*7c478bd9Sstevel@tonic-gate 347*7c478bd9Sstevel@tonic-gateinline string cwd = curthread->t_procp->p_user.u_cdir->v_path == NULL ? 348*7c478bd9Sstevel@tonic-gate "<unknown>" : stringof(curthread->t_procp->p_user.u_cdir->v_path); 349*7c478bd9Sstevel@tonic-gate#pragma D attributes Stable/Stable/Common cwd 350*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" cwd 351*7c478bd9Sstevel@tonic-gate 352*7c478bd9Sstevel@tonic-gateinline string root = curthread->t_procp->p_user.u_rdir == NULL ? "/" : 353*7c478bd9Sstevel@tonic-gate curthread->t_procp->p_user.u_rdir->v_path == NULL ? "<unknown>" : 354*7c478bd9Sstevel@tonic-gate stringof(curthread->t_procp->p_user.u_rdir->v_path); 355*7c478bd9Sstevel@tonic-gate#pragma D attributes Stable/Stable/Common root 356*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" root 357*7c478bd9Sstevel@tonic-gate 358*7c478bd9Sstevel@tonic-gate/* 359*7c478bd9Sstevel@tonic-gate * ppid, uid and gid are used frequently enough to merit their own inlines... 360*7c478bd9Sstevel@tonic-gate */ 361*7c478bd9Sstevel@tonic-gateinline uid_t ppid = curpsinfo->pr_ppid; 362*7c478bd9Sstevel@tonic-gate#pragma D attributes Stable/Stable/Common ppid 363*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" ppid 364*7c478bd9Sstevel@tonic-gate 365*7c478bd9Sstevel@tonic-gateinline uid_t uid = curpsinfo->pr_uid; 366*7c478bd9Sstevel@tonic-gate#pragma D attributes Stable/Stable/Common uid 367*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" uid 368*7c478bd9Sstevel@tonic-gate 369*7c478bd9Sstevel@tonic-gateinline gid_t gid = curpsinfo->pr_gid; 370*7c478bd9Sstevel@tonic-gate#pragma D attributes Stable/Stable/Common gid 371*7c478bd9Sstevel@tonic-gate#pragma D binding "1.0" gid 372