17c478bd9Sstevel@tonic-gate/* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 55518d15bSdp * Common Development and Distribution License (the "License"). 65518d15bSdp * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate/* 22*c6402783Sakolb * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate#pragma ident "%Z%%M% %I% %E% SMI" 277c478bd9Sstevel@tonic-gate 287c478bd9Sstevel@tonic-gate/* 297c478bd9Sstevel@tonic-gate * This file defines the standard set of inlines and translators to be made 307c478bd9Sstevel@tonic-gate * available for all D programs to use to examine process model state. 317c478bd9Sstevel@tonic-gate */ 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate#pragma D depends_on module procfs 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate/* 367c478bd9Sstevel@tonic-gate * The following miscellaneous constants are used by the proc(4) translators 377c478bd9Sstevel@tonic-gate * defined below. These are assigned the latest values from the system .h's. 387c478bd9Sstevel@tonic-gate */ 397c478bd9Sstevel@tonic-gateinline char SSLEEP = @SSLEEP@; 407c478bd9Sstevel@tonic-gate#pragma D binding "1.0" SSLEEP 417c478bd9Sstevel@tonic-gateinline char SRUN = @SRUN@; 427c478bd9Sstevel@tonic-gate#pragma D binding "1.0" SRUN 437c478bd9Sstevel@tonic-gateinline char SZOMB = @SZOMB@; 447c478bd9Sstevel@tonic-gate#pragma D binding "1.0" SZOMB 457c478bd9Sstevel@tonic-gateinline char SSTOP = @SSTOP@; 467c478bd9Sstevel@tonic-gate#pragma D binding "1.0" SSTOP 477c478bd9Sstevel@tonic-gateinline char SIDL = @SIDL@; 487c478bd9Sstevel@tonic-gate#pragma D binding "1.0" SIDL 497c478bd9Sstevel@tonic-gateinline char SONPROC = @SONPROC@; 507c478bd9Sstevel@tonic-gate#pragma D binding "1.0" SONPROC 517c478bd9Sstevel@tonic-gate 527c478bd9Sstevel@tonic-gateinline int PR_STOPPED = @PR_STOPPED@; 537c478bd9Sstevel@tonic-gate#pragma D binding "1.0" PR_STOPPED 547c478bd9Sstevel@tonic-gateinline int PR_ISTOP = @PR_ISTOP@; 557c478bd9Sstevel@tonic-gate#pragma D binding "1.0" PR_ISTOP 567c478bd9Sstevel@tonic-gateinline int PR_DSTOP = @PR_DSTOP@; 577c478bd9Sstevel@tonic-gate#pragma D binding "1.0" PR_DSTOP 587c478bd9Sstevel@tonic-gateinline int PR_STEP = @PR_STEP@; 597c478bd9Sstevel@tonic-gate#pragma D binding "1.0" PR_STEP 607c478bd9Sstevel@tonic-gateinline int PR_ASLEEP = @PR_ASLEEP@; 617c478bd9Sstevel@tonic-gate#pragma D binding "1.0" PR_ASLEEP 627c478bd9Sstevel@tonic-gateinline int PR_PCINVAL = @PR_PCINVAL@; 637c478bd9Sstevel@tonic-gate#pragma D binding "1.0" PR_PCINVAL 647c478bd9Sstevel@tonic-gateinline int PR_ASLWP = @PR_ASLWP@; 657c478bd9Sstevel@tonic-gate#pragma D binding "1.0" PR_ASLWP 667c478bd9Sstevel@tonic-gateinline int PR_AGENT = @PR_AGENT@; 677c478bd9Sstevel@tonic-gate#pragma D binding "1.0" PR_AGENT 687c478bd9Sstevel@tonic-gateinline int PR_DETACH = @PR_DETACH@; 697c478bd9Sstevel@tonic-gate#pragma D binding "1.0" PR_DETACH 707c478bd9Sstevel@tonic-gateinline int PR_DAEMON = @PR_DAEMON@; 717c478bd9Sstevel@tonic-gate#pragma D binding "1.0" PR_DAEMON 727c478bd9Sstevel@tonic-gateinline int PR_ISSYS = @PR_ISSYS@; 737c478bd9Sstevel@tonic-gate#pragma D binding "1.0" PR_ISSYS 747c478bd9Sstevel@tonic-gateinline int PR_VFORKP = @PR_VFORKP@; 757c478bd9Sstevel@tonic-gate#pragma D binding "1.0" PR_VFORKP 767c478bd9Sstevel@tonic-gateinline int PR_ORPHAN = @PR_ORPHAN@; 777c478bd9Sstevel@tonic-gate#pragma D binding "1.0" PR_ORPHAN 787c478bd9Sstevel@tonic-gateinline int PR_FORK = @PR_FORK@; 797c478bd9Sstevel@tonic-gate#pragma D binding "1.0" PR_FORK 807c478bd9Sstevel@tonic-gateinline int PR_RLC = @PR_RLC@; 817c478bd9Sstevel@tonic-gate#pragma D binding "1.0" PR_RLC 827c478bd9Sstevel@tonic-gateinline int PR_KLC = @PR_KLC@; 837c478bd9Sstevel@tonic-gate#pragma D binding "1.0" PR_KLC 847c478bd9Sstevel@tonic-gateinline int PR_ASYNC = @PR_ASYNC@; 857c478bd9Sstevel@tonic-gate#pragma D binding "1.0" PR_ASYNC 867c478bd9Sstevel@tonic-gateinline int PR_MSACCT = @PR_MSACCT@; 877c478bd9Sstevel@tonic-gate#pragma D binding "1.0" PR_MSACCT 887c478bd9Sstevel@tonic-gateinline int PR_BPTADJ = @PR_BPTADJ@; 897c478bd9Sstevel@tonic-gate#pragma D binding "1.0" PR_BPTADJ 907c478bd9Sstevel@tonic-gateinline int PR_PTRACE = @PR_PTRACE@; 917c478bd9Sstevel@tonic-gate#pragma D binding "1.0" PR_PTRACE 927c478bd9Sstevel@tonic-gateinline int PR_MSFORK = @PR_MSFORK@; 937c478bd9Sstevel@tonic-gate#pragma D binding "1.0" PR_MSFORK 947c478bd9Sstevel@tonic-gateinline int PR_IDLE = @PR_IDLE@; 957c478bd9Sstevel@tonic-gate#pragma D binding "1.0" PR_IDLE 967c478bd9Sstevel@tonic-gate 977c478bd9Sstevel@tonic-gateinline char PR_MODEL_ILP32 = @PR_MODEL_ILP32@; 987c478bd9Sstevel@tonic-gate#pragma D binding "1.0" PR_MODEL_ILP32 997c478bd9Sstevel@tonic-gateinline char PR_MODEL_LP64 = @PR_MODEL_LP64@; 1007c478bd9Sstevel@tonic-gate#pragma D binding "1.0" PR_MODEL_LP64 1017c478bd9Sstevel@tonic-gate 1027c478bd9Sstevel@tonic-gateinline char SOBJ_NONE = @SOBJ_NONE@; 1037c478bd9Sstevel@tonic-gate#pragma D binding "1.0" SOBJ_NONE 1047c478bd9Sstevel@tonic-gateinline char SOBJ_MUTEX = @SOBJ_MUTEX@; 1057c478bd9Sstevel@tonic-gate#pragma D binding "1.0" SOBJ_MUTEX 1067c478bd9Sstevel@tonic-gateinline char SOBJ_RWLOCK = @SOBJ_RWLOCK@; 1077c478bd9Sstevel@tonic-gate#pragma D binding "1.0" SOBJ_RWLOCK 1087c478bd9Sstevel@tonic-gateinline char SOBJ_CV = @SOBJ_CV@; 1097c478bd9Sstevel@tonic-gate#pragma D binding "1.0" SOBJ_CV 1107c478bd9Sstevel@tonic-gateinline char SOBJ_SEMA = @SOBJ_SEMA@; 1117c478bd9Sstevel@tonic-gate#pragma D binding "1.0" SOBJ_SEMA 1127c478bd9Sstevel@tonic-gateinline char SOBJ_USER = @SOBJ_USER@; 1137c478bd9Sstevel@tonic-gate#pragma D binding "1.0" SOBJ_USER 1147c478bd9Sstevel@tonic-gateinline char SOBJ_USER_PI = @SOBJ_USER_PI@; 1157c478bd9Sstevel@tonic-gate#pragma D binding "1.0" SOBJ_USER_PI 1167c478bd9Sstevel@tonic-gateinline char SOBJ_SHUTTLE = @SOBJ_SHUTTLE@; 1177c478bd9Sstevel@tonic-gate#pragma D binding "1.0" SOBJ_SHUTTLE 1187c478bd9Sstevel@tonic-gate 1197c478bd9Sstevel@tonic-gateinline int SI_USER = @SI_USER@; 1207c478bd9Sstevel@tonic-gate#pragma D binding "1.0" SI_USER 1217c478bd9Sstevel@tonic-gateinline int SI_LWP = @SI_LWP@; 1227c478bd9Sstevel@tonic-gate#pragma D binding "1.0" SI_LWP 1237c478bd9Sstevel@tonic-gateinline int SI_QUEUE = @SI_QUEUE@; 1247c478bd9Sstevel@tonic-gate#pragma D binding "1.0" SI_QUEUE 1257c478bd9Sstevel@tonic-gateinline int SI_TIMER = @SI_TIMER@; 1267c478bd9Sstevel@tonic-gate#pragma D binding "1.0" SI_TIMER 1277c478bd9Sstevel@tonic-gateinline int SI_ASYNCIO = @SI_ASYNCIO@; 1287c478bd9Sstevel@tonic-gate#pragma D binding "1.0" SI_ASYNCIO 1297c478bd9Sstevel@tonic-gateinline int SI_MESGQ = @SI_MESGQ@; 1307c478bd9Sstevel@tonic-gate#pragma D binding "1.0" SI_MESGQ 1317c478bd9Sstevel@tonic-gateinline int SI_RCTL = @SI_RCTL@; 1327c478bd9Sstevel@tonic-gate#pragma D binding "1.0" SI_RCTL 1337c478bd9Sstevel@tonic-gateinline int ILL_ILLOPC = @ILL_ILLOPC@; 1347c478bd9Sstevel@tonic-gate#pragma D binding "1.0" ILL_ILLOPC 1357c478bd9Sstevel@tonic-gateinline int ILL_ILLOPN = @ILL_ILLOPN@; 1367c478bd9Sstevel@tonic-gate#pragma D binding "1.0" ILL_ILLOPN 1377c478bd9Sstevel@tonic-gateinline int ILL_ILLADR = @ILL_ILLADR@; 1387c478bd9Sstevel@tonic-gate#pragma D binding "1.0" ILL_ILLADR 1397c478bd9Sstevel@tonic-gateinline int ILL_ILLTRP = @ILL_ILLTRP@; 1407c478bd9Sstevel@tonic-gate#pragma D binding "1.0" ILL_ILLTRP 1417c478bd9Sstevel@tonic-gateinline int ILL_PRVOPC = @ILL_PRVOPC@; 1427c478bd9Sstevel@tonic-gate#pragma D binding "1.0" ILL_PRVOPC 1437c478bd9Sstevel@tonic-gateinline int ILL_PRVREG = @ILL_PRVREG@; 1447c478bd9Sstevel@tonic-gate#pragma D binding "1.0" ILL_PRVREG 1457c478bd9Sstevel@tonic-gateinline int ILL_COPROC = @ILL_COPROC@; 1467c478bd9Sstevel@tonic-gate#pragma D binding "1.0" ILL_COPROC 1477c478bd9Sstevel@tonic-gateinline int ILL_BADSTK = @ILL_BADSTK@; 1487c478bd9Sstevel@tonic-gate#pragma D binding "1.0" ILL_BADSTK 1497c478bd9Sstevel@tonic-gateinline int FPE_INTDIV = @FPE_INTDIV@; 1507c478bd9Sstevel@tonic-gate#pragma D binding "1.0" FPE_INTDIV 1517c478bd9Sstevel@tonic-gateinline int FPE_INTOVF = @FPE_INTOVF@; 1527c478bd9Sstevel@tonic-gate#pragma D binding "1.0" FPE_INTOVF 1537c478bd9Sstevel@tonic-gateinline int FPE_FLTDIV = @FPE_FLTDIV@; 1547c478bd9Sstevel@tonic-gate#pragma D binding "1.0" FPE_FLTDIV 1557c478bd9Sstevel@tonic-gateinline int FPE_FLTOVF = @FPE_FLTOVF@; 1567c478bd9Sstevel@tonic-gate#pragma D binding "1.0" FPE_FLTOVF 1577c478bd9Sstevel@tonic-gateinline int FPE_FLTUND = @FPE_FLTUND@; 1587c478bd9Sstevel@tonic-gate#pragma D binding "1.0" FPE_FLTUND 1597c478bd9Sstevel@tonic-gateinline int FPE_FLTRES = @FPE_FLTRES@; 1607c478bd9Sstevel@tonic-gate#pragma D binding "1.0" FPE_FLTRES 1617c478bd9Sstevel@tonic-gateinline int FPE_FLTINV = @FPE_FLTINV@; 1627c478bd9Sstevel@tonic-gate#pragma D binding "1.0" FPE_FLTINV 1637c478bd9Sstevel@tonic-gateinline int FPE_FLTSUB = @FPE_FLTSUB@; 1647c478bd9Sstevel@tonic-gate#pragma D binding "1.0" FPE_FLTSUB 1657c478bd9Sstevel@tonic-gateinline int SEGV_MAPERR = @SEGV_MAPERR@; 1667c478bd9Sstevel@tonic-gate#pragma D binding "1.0" SEGV_MAPERR 1677c478bd9Sstevel@tonic-gateinline int SEGV_ACCERR = @SEGV_ACCERR@; 1687c478bd9Sstevel@tonic-gate#pragma D binding "1.0" SEGV_ACCERR 1697c478bd9Sstevel@tonic-gateinline int BUS_ADRALN = @BUS_ADRALN@; 1707c478bd9Sstevel@tonic-gate#pragma D binding "1.0" BUS_ADRALN 1717c478bd9Sstevel@tonic-gateinline int BUS_ADRERR = @BUS_ADRERR@; 1727c478bd9Sstevel@tonic-gate#pragma D binding "1.0" BUS_ADRERR 1737c478bd9Sstevel@tonic-gateinline int BUS_OBJERR = @BUS_OBJERR@; 1747c478bd9Sstevel@tonic-gate#pragma D binding "1.0" BUS_OBJERR 1757c478bd9Sstevel@tonic-gateinline int TRAP_BRKPT = @TRAP_BRKPT@; 1767c478bd9Sstevel@tonic-gate#pragma D binding "1.0" TRAP_BRKPT 1777c478bd9Sstevel@tonic-gateinline int TRAP_TRACE = @TRAP_TRACE@; 1787c478bd9Sstevel@tonic-gate#pragma D binding "1.0" TRAP_TRACE 1797c478bd9Sstevel@tonic-gateinline int CLD_EXITED = @CLD_EXITED@; 1807c478bd9Sstevel@tonic-gate#pragma D binding "1.0" CLD_EXITED 1817c478bd9Sstevel@tonic-gateinline int CLD_KILLED = @CLD_KILLED@; 1827c478bd9Sstevel@tonic-gate#pragma D binding "1.0" CLD_KILLED 1837c478bd9Sstevel@tonic-gateinline int CLD_DUMPED = @CLD_DUMPED@; 1847c478bd9Sstevel@tonic-gate#pragma D binding "1.0" CLD_DUMPED 1857c478bd9Sstevel@tonic-gateinline int CLD_TRAPPED = @CLD_TRAPPED@; 1867c478bd9Sstevel@tonic-gate#pragma D binding "1.0" CLD_TRAPPED 1877c478bd9Sstevel@tonic-gateinline int CLD_STOPPED = @CLD_STOPPED@; 1887c478bd9Sstevel@tonic-gate#pragma D binding "1.0" CLD_STOPPED 1897c478bd9Sstevel@tonic-gateinline int CLD_CONTINUED = @CLD_CONTINUED@; 1907c478bd9Sstevel@tonic-gate#pragma D binding "1.0" CLD_CONTINUED 1917c478bd9Sstevel@tonic-gateinline int POLL_IN = @POLL_IN@; 1927c478bd9Sstevel@tonic-gate#pragma D binding "1.0" POLL_IN 1937c478bd9Sstevel@tonic-gateinline int POLL_OUT = @POLL_OUT@; 1947c478bd9Sstevel@tonic-gate#pragma D binding "1.0" POLL_OUT 1957c478bd9Sstevel@tonic-gateinline int POLL_MSG = @POLL_MSG@; 1967c478bd9Sstevel@tonic-gate#pragma D binding "1.0" POLL_MSG 1977c478bd9Sstevel@tonic-gateinline int POLL_ERR = @POLL_ERR@; 1987c478bd9Sstevel@tonic-gate#pragma D binding "1.0" POLL_ERR 1997c478bd9Sstevel@tonic-gateinline int POLL_PRI = @POLL_PRI@; 2007c478bd9Sstevel@tonic-gate#pragma D binding "1.0" POLL_PRI 2017c478bd9Sstevel@tonic-gateinline int POLL_HUP = @POLL_HUP@; 2027c478bd9Sstevel@tonic-gate#pragma D binding "1.0" POLL_HUP 2037c478bd9Sstevel@tonic-gate 2047c478bd9Sstevel@tonic-gate/* 2057c478bd9Sstevel@tonic-gate * Translate from the kernel's proc_t structure to a proc(4) psinfo_t struct. 2067c478bd9Sstevel@tonic-gate * We do not provide support for pr_size, pr_rssize, pr_pctcpu, and pr_pctmem. 2077c478bd9Sstevel@tonic-gate * We also do not fill in pr_lwp (the lwpsinfo_t for the representative LWP) 2087c478bd9Sstevel@tonic-gate * because we do not have the ability to select and stop any representative. 2097c478bd9Sstevel@tonic-gate * Also, for the moment, pr_wstat, pr_time, and pr_ctime are not supported, 2107c478bd9Sstevel@tonic-gate * but these could be supported by DTrace in the future using subroutines. 2117c478bd9Sstevel@tonic-gate * Note that any member added to this translator should also be added to the 2127c478bd9Sstevel@tonic-gate * kthread_t-to-psinfo_t translator, below. 2137c478bd9Sstevel@tonic-gate */ 2147c478bd9Sstevel@tonic-gate#pragma D binding "1.0" translator 2157c478bd9Sstevel@tonic-gatetranslator psinfo_t < proc_t *T > { 2167c478bd9Sstevel@tonic-gate pr_nlwp = T->p_lwpcnt; 2177c478bd9Sstevel@tonic-gate pr_pid = T->p_pidp->pid_id; 2187c478bd9Sstevel@tonic-gate pr_ppid = T->p_ppid; 2197c478bd9Sstevel@tonic-gate pr_pgid = T->p_pgidp->pid_id; 2207c478bd9Sstevel@tonic-gate pr_sid = T->p_sessp->s_sidp->pid_id; 2217c478bd9Sstevel@tonic-gate pr_uid = T->p_cred->cr_ruid; 2227c478bd9Sstevel@tonic-gate pr_euid = T->p_cred->cr_uid; 2237c478bd9Sstevel@tonic-gate pr_gid = T->p_cred->cr_rgid; 2247c478bd9Sstevel@tonic-gate pr_egid = T->p_cred->cr_gid; 2257c478bd9Sstevel@tonic-gate pr_addr = (uintptr_t)T; 2267c478bd9Sstevel@tonic-gate 2277c478bd9Sstevel@tonic-gate pr_ttydev = (T->p_sessp->s_vp == NULL) ? (dev_t)-1 : 2287c478bd9Sstevel@tonic-gate (T->p_sessp->s_dev == `rwsconsdev) ? `uconsdev : 2297c478bd9Sstevel@tonic-gate (T->p_sessp->s_dev == `rconsdev) ? `uconsdev : T->p_sessp->s_dev; 2307c478bd9Sstevel@tonic-gate 2317c478bd9Sstevel@tonic-gate pr_start = T->p_user.u_start; 2327c478bd9Sstevel@tonic-gate pr_fname = T->p_user.u_comm; 2337c478bd9Sstevel@tonic-gate pr_psargs = T->p_user.u_psargs; 2347c478bd9Sstevel@tonic-gate pr_argc = T->p_user.u_argc; 2357c478bd9Sstevel@tonic-gate pr_argv = T->p_user.u_argv; 2367c478bd9Sstevel@tonic-gate pr_envp = T->p_user.u_envp; 2377c478bd9Sstevel@tonic-gate 2387c478bd9Sstevel@tonic-gate pr_dmodel = (T->p_model == @DATAMODEL_ILP32@) ? 2397c478bd9Sstevel@tonic-gate PR_MODEL_ILP32 : PR_MODEL_LP64; 2407c478bd9Sstevel@tonic-gate 2417c478bd9Sstevel@tonic-gate pr_taskid = T->p_task->tk_tkid; 2427c478bd9Sstevel@tonic-gate pr_projid = T->p_task->tk_proj->kpj_id; 2437c478bd9Sstevel@tonic-gate pr_poolid = T->p_pool->pool_id; 2447c478bd9Sstevel@tonic-gate pr_zoneid = T->p_zone->zone_id; 2457c478bd9Sstevel@tonic-gate}; 2467c478bd9Sstevel@tonic-gate 2477c478bd9Sstevel@tonic-gate/* 2487c478bd9Sstevel@tonic-gate * Translate from the kernel's kthread_t structure to a proc(4) psinfo_t 2497c478bd9Sstevel@tonic-gate * struct. Lacking a facility to define one translator only in terms of 2507c478bd9Sstevel@tonic-gate * another, we explicitly define each member by using the proc_t-to-psinfo_t 2517c478bd9Sstevel@tonic-gate * translator, above; any members added to that translator should also be 2527c478bd9Sstevel@tonic-gate * added here. (The only exception to this is pr_start, which -- due to it 2537c478bd9Sstevel@tonic-gate * being a structure -- cannot be defined in terms of a translator at all.) 2547c478bd9Sstevel@tonic-gate */ 2557c478bd9Sstevel@tonic-gate#pragma D binding "1.0" translator 2567c478bd9Sstevel@tonic-gatetranslator psinfo_t < kthread_t *T > { 2577c478bd9Sstevel@tonic-gate pr_nlwp = xlate <psinfo_t> (T->t_procp).pr_nlwp; 2587c478bd9Sstevel@tonic-gate pr_pid = xlate <psinfo_t> (T->t_procp).pr_pid; 2597c478bd9Sstevel@tonic-gate pr_ppid = xlate <psinfo_t> (T->t_procp).pr_ppid; 2607c478bd9Sstevel@tonic-gate pr_pgid = xlate <psinfo_t> (T->t_procp).pr_pgid; 2617c478bd9Sstevel@tonic-gate pr_sid = xlate <psinfo_t> (T->t_procp).pr_sid; 2627c478bd9Sstevel@tonic-gate pr_uid = xlate <psinfo_t> (T->t_procp).pr_uid; 2637c478bd9Sstevel@tonic-gate pr_euid = xlate <psinfo_t> (T->t_procp).pr_euid; 2647c478bd9Sstevel@tonic-gate pr_gid = xlate <psinfo_t> (T->t_procp).pr_gid; 2657c478bd9Sstevel@tonic-gate pr_egid = xlate <psinfo_t> (T->t_procp).pr_egid; 2667c478bd9Sstevel@tonic-gate pr_addr = xlate <psinfo_t> (T->t_procp).pr_addr; 2677c478bd9Sstevel@tonic-gate pr_ttydev = xlate <psinfo_t> (T->t_procp).pr_ttydev; 2687c478bd9Sstevel@tonic-gate pr_start = (timestruc_t)xlate <psinfo_t> (T->t_procp).pr_start; 2697c478bd9Sstevel@tonic-gate pr_fname = xlate <psinfo_t> (T->t_procp).pr_fname; 2707c478bd9Sstevel@tonic-gate pr_psargs = xlate <psinfo_t> (T->t_procp).pr_psargs; 2717c478bd9Sstevel@tonic-gate pr_argc = xlate <psinfo_t> (T->t_procp).pr_argc; 2727c478bd9Sstevel@tonic-gate pr_argv = xlate <psinfo_t> (T->t_procp).pr_argv; 2737c478bd9Sstevel@tonic-gate pr_envp = xlate <psinfo_t> (T->t_procp).pr_envp; 2747c478bd9Sstevel@tonic-gate pr_dmodel = xlate <psinfo_t> (T->t_procp).pr_dmodel; 2757c478bd9Sstevel@tonic-gate pr_taskid = xlate <psinfo_t> (T->t_procp).pr_taskid; 2767c478bd9Sstevel@tonic-gate pr_projid = xlate <psinfo_t> (T->t_procp).pr_projid; 2777c478bd9Sstevel@tonic-gate pr_poolid = xlate <psinfo_t> (T->t_procp).pr_poolid; 2787c478bd9Sstevel@tonic-gate pr_zoneid = xlate <psinfo_t> (T->t_procp).pr_zoneid; 2797c478bd9Sstevel@tonic-gate}; 2807c478bd9Sstevel@tonic-gate 2817c478bd9Sstevel@tonic-gate/* 2827c478bd9Sstevel@tonic-gate * Translate from the kernel's kthread_t structure to a proc(4) lwpsinfo_t. 2837c478bd9Sstevel@tonic-gate * We do not provide support for pr_nice, pr_oldpri, pr_cpu, or pr_pctcpu. 2847c478bd9Sstevel@tonic-gate * Also, for the moment, pr_start and pr_time are not supported, but these 2857c478bd9Sstevel@tonic-gate * could be supported by DTrace in the future using subroutines. 2867c478bd9Sstevel@tonic-gate */ 2877c478bd9Sstevel@tonic-gate#pragma D binding "1.0" translator 2887c478bd9Sstevel@tonic-gatetranslator lwpsinfo_t < kthread_t *T > { 2897c478bd9Sstevel@tonic-gate pr_flag = ((T->t_state == @TS_STOPPED@) ? (PR_STOPPED | 2907c478bd9Sstevel@tonic-gate ((!(T->t_schedflag & @TS_PSTART@)) ? PR_ISTOP : 0)) : 2917c478bd9Sstevel@tonic-gate ((T->t_proc_flag & @TP_PRVSTOP@) ? PR_STOPPED | PR_ISTOP : 0)) | 2927c478bd9Sstevel@tonic-gate ((T == T->t_procp->p_agenttp) ? PR_AGENT : 0) | 2937c478bd9Sstevel@tonic-gate ((!(T->t_proc_flag & @TP_TWAIT@)) ? PR_DETACH : 0) | 2947c478bd9Sstevel@tonic-gate ((T->t_proc_flag & @TP_DAEMON@) ? PR_DAEMON : 0) | 2957c478bd9Sstevel@tonic-gate ((T->t_procp->p_proc_flag & @P_PR_FORK@) ? PR_FORK : 0) | 2967c478bd9Sstevel@tonic-gate ((T->t_procp->p_proc_flag & @P_PR_RUNLCL@) ? PR_RLC : 0) | 2977c478bd9Sstevel@tonic-gate ((T->t_procp->p_proc_flag & @P_PR_KILLCL@) ? PR_KLC : 0) | 2987c478bd9Sstevel@tonic-gate ((T->t_procp->p_proc_flag & @P_PR_ASYNC@) ? PR_ASYNC : 0) | 2997c478bd9Sstevel@tonic-gate ((T->t_procp->p_proc_flag & @P_PR_BPTADJ@) ? PR_BPTADJ : 0) | 3007c478bd9Sstevel@tonic-gate ((T->t_procp->p_proc_flag & @P_PR_PTRACE@) ? PR_PTRACE : 0) | 3017c478bd9Sstevel@tonic-gate ((T->t_procp->p_flag & @SMSACCT@) ? PR_MSACCT : 0) | 3027c478bd9Sstevel@tonic-gate ((T->t_procp->p_flag & @SMSFORK@) ? PR_MSFORK : 0) | 3037c478bd9Sstevel@tonic-gate ((T->t_procp->p_flag & @SVFWAIT@) ? PR_VFORKP : 0) | 3047c478bd9Sstevel@tonic-gate (((T->t_procp->p_flag & @SSYS@) || 3057c478bd9Sstevel@tonic-gate (T->t_procp->p_as == &`kas)) ? PR_ISSYS : 0) | 3067c478bd9Sstevel@tonic-gate ((T == T->t_cpu->cpu_idle_thread) ? PR_IDLE : 0); 3077c478bd9Sstevel@tonic-gate 3087c478bd9Sstevel@tonic-gate pr_lwpid = T->t_tid; 3097c478bd9Sstevel@tonic-gate pr_addr = (uintptr_t)T; 3107c478bd9Sstevel@tonic-gate pr_wchan = (uintptr_t)T->t_lwpchan.lc_wchan; 3117c478bd9Sstevel@tonic-gate pr_stype = T->t_sobj_ops ? T->t_sobj_ops->sobj_type : 0; 3127c478bd9Sstevel@tonic-gate 3137c478bd9Sstevel@tonic-gate pr_state = (T->t_proc_flag & @TP_PRVSTOP@) ? SSTOP : 3147c478bd9Sstevel@tonic-gate (T->t_state == @TS_SLEEP@) ? SSLEEP : 3157c478bd9Sstevel@tonic-gate (T->t_state == @TS_RUN@) ? SRUN : 3167c478bd9Sstevel@tonic-gate (T->t_state == @TS_ONPROC@) ? SONPROC : 3177c478bd9Sstevel@tonic-gate (T->t_state == @TS_ZOMB@) ? SZOMB : 3187c478bd9Sstevel@tonic-gate (T->t_state == @TS_STOPPED@) ? SSTOP : 0; 3197c478bd9Sstevel@tonic-gate 3207c478bd9Sstevel@tonic-gate pr_sname = (T->t_proc_flag & @TP_PRVSTOP@) ? 'T' : 3217c478bd9Sstevel@tonic-gate (T->t_state == @TS_SLEEP@) ? 'S' : 3227c478bd9Sstevel@tonic-gate (T->t_state == @TS_RUN@) ? 'R' : 3237c478bd9Sstevel@tonic-gate (T->t_state == @TS_ONPROC@) ? 'O' : 3247c478bd9Sstevel@tonic-gate (T->t_state == @TS_ZOMB@) ? 'Z' : 3257c478bd9Sstevel@tonic-gate (T->t_state == @TS_STOPPED@) ? 'T' : '?'; 3267c478bd9Sstevel@tonic-gate 3277c478bd9Sstevel@tonic-gate pr_syscall = T->t_sysnum; 3287c478bd9Sstevel@tonic-gate pr_pri = T->t_pri; 3297c478bd9Sstevel@tonic-gate pr_clname = `sclass[T->t_cid].cl_name; 3307c478bd9Sstevel@tonic-gate pr_onpro = T->t_cpu->cpu_id; 3317c478bd9Sstevel@tonic-gate pr_bindpro = T->t_bind_cpu; 3327c478bd9Sstevel@tonic-gate pr_bindpset = T->t_bind_pset; 333*c6402783Sakolb pr_lgrp = T->t_lpl->lpl_lgrpid; 3347c478bd9Sstevel@tonic-gate}; 3357c478bd9Sstevel@tonic-gate 3367c478bd9Sstevel@tonic-gateinline psinfo_t *curpsinfo = xlate <psinfo_t *> (curthread->t_procp); 3377c478bd9Sstevel@tonic-gate#pragma D attributes Stable/Stable/Common curpsinfo 3387c478bd9Sstevel@tonic-gate#pragma D binding "1.0" curpsinfo 3397c478bd9Sstevel@tonic-gate 3407c478bd9Sstevel@tonic-gateinline lwpsinfo_t *curlwpsinfo = xlate <lwpsinfo_t *> (curthread); 3417c478bd9Sstevel@tonic-gate#pragma D attributes Stable/Stable/Common curlwpsinfo 3427c478bd9Sstevel@tonic-gate#pragma D binding "1.0" curlwpsinfo 3437c478bd9Sstevel@tonic-gate 3447c478bd9Sstevel@tonic-gateinline string cwd = curthread->t_procp->p_user.u_cdir->v_path == NULL ? 3457c478bd9Sstevel@tonic-gate "<unknown>" : stringof(curthread->t_procp->p_user.u_cdir->v_path); 3467c478bd9Sstevel@tonic-gate#pragma D attributes Stable/Stable/Common cwd 3477c478bd9Sstevel@tonic-gate#pragma D binding "1.0" cwd 3487c478bd9Sstevel@tonic-gate 3497c478bd9Sstevel@tonic-gateinline string root = curthread->t_procp->p_user.u_rdir == NULL ? "/" : 3507c478bd9Sstevel@tonic-gate curthread->t_procp->p_user.u_rdir->v_path == NULL ? "<unknown>" : 3517c478bd9Sstevel@tonic-gate stringof(curthread->t_procp->p_user.u_rdir->v_path); 3527c478bd9Sstevel@tonic-gate#pragma D attributes Stable/Stable/Common root 3537c478bd9Sstevel@tonic-gate#pragma D binding "1.0" root 354