1 /* $NetBSD: psinfo.d,v 1.6 2018/05/28 21:05:09 chs Exp $ */ 2 3 /* 4 * CDDL HEADER START 5 * 6 * The contents of this file are subject to the terms of the 7 * Common Development and Distribution License, Version 1.0 only 8 * (the "License"). You may not use this file except in compliance 9 * with the License. 10 * 11 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 12 * or http://www.opensolaris.org/os/licensing. 13 * See the License for the specific language governing permissions 14 * and limitations under the License. 15 * 16 * When distributing Covered Code, include this CDDL HEADER in each 17 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 18 * If applicable, add the following below this CDDL HEADER, with the 19 * fields enclosed by brackets "[]" replaced with your own identifying 20 * information: Portions Copyright [yyyy] [name of copyright owner] 21 * 22 * CDDL HEADER END 23 * 24 * Portions Copyright 2006 John Birrell jb@freebsd.org 25 * 26 * $FreeBSD: head/cddl/lib/libdtrace/psinfo.d 304825 2016-08-25 23:24:57Z gnn $ 27 */ 28 /* 29 * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 30 * Use is subject to license terms. 31 */ 32 33 typedef struct psinfo { 34 int pr_nlwp; /* number of threads */ 35 pid_t pr_pid; /* unique process id */ 36 pid_t pr_ppid; /* process id of parent */ 37 pid_t pr_pgid; /* pid of process group leader */ 38 pid_t pr_sid; /* session id */ 39 uid_t pr_uid; /* real user id */ 40 uid_t pr_euid; /* effective user id */ 41 gid_t pr_gid; /* real group id */ 42 gid_t pr_egid; /* effective group id */ 43 uintptr_t 44 pr_addr; /* address of process */ 45 string pr_psargs; /* process arguments */ 46 u_int pr_arglen; /* process argument length */ 47 } psinfo_t; 48 49 #pragma D binding "1.0" translator 50 translator psinfo_t < struct proc *T > { 51 pr_nlwp = T->p_nlwps; 52 pr_pid = T->p_pid; 53 pr_ppid = (T->p_pptr == 0) ? 0 : T->p_pptr->p_pid; 54 pr_pgid = (T->p_pgrp->pg_session->s_leader == 0) ? 0 : T->p_pgrp->pg_session->s_leader->p_pid; 55 pr_sid = (T->p_pgrp == 0) ? 0 : ((T->p_pgrp->pg_session == 0) ? 0 : T->p_pgrp->pg_session->s_sid); 56 pr_uid = T->p_cred->cr_uid; 57 pr_euid = T->p_cred->cr_euid; 58 pr_gid = T->p_cred->cr_gid; 59 pr_egid = T->p_cred->cr_egid; 60 pr_addr = 0; 61 pr_psargs = stringof(T->p_comm); 62 pr_arglen = strlen(T->p_comm); 63 }; 64 65 typedef struct lwpsinfo { 66 id_t pr_lwpid; /* thread ID. */ 67 int pr_flag; /* thread flags. */ 68 int pr_pri; /* thread priority. */ 69 char pr_state; /* numeric lwp state */ 70 char pr_sname; /* printable character for pr_state */ 71 short pr_syscall; /* system call number (if in syscall) */ 72 uintptr_t 73 pr_addr; /* internal address of lwp */ 74 uintptr_t 75 pr_wchan; /* sleep address */ 76 } lwpsinfo_t; 77 78 #pragma D binding "1.0" translator 79 translator lwpsinfo_t < struct lwp *T > { 80 pr_lwpid = T->l_lid; 81 pr_pri = T->l_priority; 82 pr_flag = T->l_flag; 83 pr_state = T->l_stat; 84 pr_sname = '?'; /* XXX */ 85 pr_syscall = 0; /* XXX */ 86 pr_addr = (uintptr_t)T; 87 pr_wchan = (uintptr_t)T->l_wchan; 88 }; 89 90 inline psinfo_t *curpsinfo = xlate <psinfo_t *> (curthread->l_proc); 91 #pragma D attributes Stable/Stable/Common curpsinfo 92 #pragma D binding "1.0" curpsinfo 93 94 inline lwpsinfo_t *curlwpsinfo = xlate <lwpsinfo_t *> (curthread); 95 #pragma D attributes Stable/Stable/Common curlwpsinfo 96 #pragma D binding "1.0" curlwpsinfo 97