1179189Sjb/* 2179189Sjb * CDDL HEADER START 3179189Sjb * 4179189Sjb * The contents of this file are subject to the terms of the 5179189Sjb * Common Development and Distribution License, Version 1.0 only 6179189Sjb * (the "License"). You may not use this file except in compliance 7179189Sjb * with the License. 8179189Sjb * 9179189Sjb * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10179189Sjb * or http://www.opensolaris.org/os/licensing. 11179189Sjb * See the License for the specific language governing permissions 12179189Sjb * and limitations under the License. 13179189Sjb * 14179189Sjb * When distributing Covered Code, include this CDDL HEADER in each 15179189Sjb * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16179189Sjb * If applicable, add the following below this CDDL HEADER, with the 17179189Sjb * fields enclosed by brackets "[]" replaced with your own identifying 18179189Sjb * information: Portions Copyright [yyyy] [name of copyright owner] 19179189Sjb * 20179189Sjb * CDDL HEADER END 21179189Sjb * 22179189Sjb * Portions Copyright 2006 John Birrell jb@freebsd.org 23179189Sjb * 24179189Sjb * $FreeBSD: releng/11.0/cddl/lib/libdtrace/psinfo.d 286420 2015-08-07 19:56:22Z markj $ 25179189Sjb */ 26179189Sjb/* 27179189Sjb * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 28179189Sjb * Use is subject to license terms. 29179189Sjb */ 30179189Sjb 31286420Smarkj#pragma D depends_on module kernel 32286420Smarkj 33179189Sjbtypedef struct psinfo { 34179189Sjb int pr_nlwp; /* number of threads */ 35179189Sjb pid_t pr_pid; /* unique process id */ 36179189Sjb pid_t pr_ppid; /* process id of parent */ 37179189Sjb pid_t pr_pgid; /* pid of process group leader */ 38179189Sjb pid_t pr_sid; /* session id */ 39179189Sjb uid_t pr_uid; /* real user id */ 40179189Sjb uid_t pr_euid; /* effective user id */ 41179189Sjb gid_t pr_gid; /* real group id */ 42179189Sjb gid_t pr_egid; /* effective group id */ 43179189Sjb uintptr_t 44179189Sjb pr_addr; /* address of process */ 45179189Sjb string pr_psargs; /* process arguments */ 46179189Sjb u_int pr_arglen; /* process argument length */ 47239972Srpaulo u_int pr_jailid; /* jail id */ 48179189Sjb} psinfo_t; 49179189Sjb 50179189Sjb#pragma D binding "1.0" translator 51179189Sjbtranslator psinfo_t < struct proc *T > { 52179189Sjb pr_nlwp = T->p_numthreads; 53179189Sjb pr_pid = T->p_pid; 54179189Sjb pr_ppid = (T->p_pptr == 0) ? 0 : T->p_pptr->p_pid; 55179189Sjb pr_pgid = (T->p_leader == 0) ? 0 : T->p_leader->p_pid; 56179189Sjb pr_sid = (T->p_pgrp == 0) ? 0 : ((T->p_pgrp->pg_session == 0) ? 0 : T->p_pgrp->pg_session->s_sid); 57179189Sjb pr_uid = T->p_ucred->cr_ruid; 58179189Sjb pr_euid = T->p_ucred->cr_uid; 59179189Sjb pr_gid = T->p_ucred->cr_rgid; 60179189Sjb pr_egid = T->p_ucred->cr_groups[0]; 61179189Sjb pr_addr = 0; 62256571Smarkj pr_psargs = (T->p_args->ar_args == 0) ? "" : 63256571Smarkj memstr(T->p_args->ar_args, ' ', T->p_args->ar_length); 64179189Sjb pr_arglen = T->p_args->ar_length; 65239972Srpaulo pr_jailid = T->p_ucred->cr_prison->pr_id; 66179189Sjb}; 67179189Sjb 68179189Sjbtypedef struct lwpsinfo { 69179189Sjb id_t pr_lwpid; /* thread ID. */ 70179189Sjb int pr_flag; /* thread flags. */ 71179189Sjb int pr_pri; /* thread priority. */ 72179189Sjb char pr_state; /* numeric lwp state */ 73179189Sjb char pr_sname; /* printable character for pr_state */ 74179189Sjb short pr_syscall; /* system call number (if in syscall) */ 75179189Sjb uintptr_t 76179189Sjb pr_addr; /* internal address of lwp */ 77179189Sjb uintptr_t 78179189Sjb pr_wchan; /* sleep address */ 79179189Sjb} lwpsinfo_t; 80179189Sjb 81179189Sjb#pragma D binding "1.0" translator 82179189Sjbtranslator lwpsinfo_t < struct thread *T > { 83179189Sjb pr_lwpid = T->td_tid; 84179189Sjb pr_pri = T->td_priority; 85179189Sjb pr_flag = T->td_flags; 86179189Sjb pr_state = 0; /* XXX */ 87179189Sjb pr_sname = '?'; /* XXX */ 88179189Sjb pr_syscall = 0; /* XXX */ 89179189Sjb pr_addr = (uintptr_t)T; 90179189Sjb pr_wchan = (uintptr_t)T->td_wchan; 91179189Sjb}; 92179189Sjb 93179189Sjbinline psinfo_t *curpsinfo = xlate <psinfo_t *> (curthread->td_proc); 94179189Sjb#pragma D attributes Stable/Stable/Common curpsinfo 95179189Sjb#pragma D binding "1.0" curpsinfo 96179189Sjb 97179189Sjbinline lwpsinfo_t *curlwpsinfo = xlate <lwpsinfo_t *> (curthread); 98179189Sjb#pragma D attributes Stable/Stable/Common curlwpsinfo 99179189Sjb#pragma D binding "1.0" curlwpsinfo 100179189Sjb 101