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