158f0484fSRodney W. Grimes /*- 258f0484fSRodney W. Grimes * Copyright (c) 1989, 1992, 1993 358f0484fSRodney W. Grimes * The Regents of the University of California. All rights reserved. 458f0484fSRodney W. Grimes * 558f0484fSRodney W. Grimes * This code is derived from software developed by the Computer Systems 658f0484fSRodney W. Grimes * Engineering group at Lawrence Berkeley Laboratory under DARPA contract 758f0484fSRodney W. Grimes * BG 91-66 and contributed to Berkeley. 858f0484fSRodney W. Grimes * 958f0484fSRodney W. Grimes * Redistribution and use in source and binary forms, with or without 1058f0484fSRodney W. Grimes * modification, are permitted provided that the following conditions 1158f0484fSRodney W. Grimes * are met: 1258f0484fSRodney W. Grimes * 1. Redistributions of source code must retain the above copyright 1358f0484fSRodney W. Grimes * notice, this list of conditions and the following disclaimer. 1458f0484fSRodney W. Grimes * 2. Redistributions in binary form must reproduce the above copyright 1558f0484fSRodney W. Grimes * notice, this list of conditions and the following disclaimer in the 1658f0484fSRodney W. Grimes * documentation and/or other materials provided with the distribution. 1758f0484fSRodney W. Grimes * 4. Neither the name of the University nor the names of its contributors 1858f0484fSRodney W. Grimes * may be used to endorse or promote products derived from this software 1958f0484fSRodney W. Grimes * without specific prior written permission. 2058f0484fSRodney W. Grimes * 2158f0484fSRodney W. Grimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2258f0484fSRodney W. Grimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2358f0484fSRodney W. Grimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2458f0484fSRodney W. Grimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2558f0484fSRodney W. Grimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2658f0484fSRodney W. Grimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2758f0484fSRodney W. Grimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2858f0484fSRodney W. Grimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2958f0484fSRodney W. Grimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3058f0484fSRodney W. Grimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3158f0484fSRodney W. Grimes * SUCH DAMAGE. 3258f0484fSRodney W. Grimes */ 3358f0484fSRodney W. Grimes 34f86e3350SBruce Evans #if 0 3558f0484fSRodney W. Grimes #if defined(LIBC_SCCS) && !defined(lint) 3658f0484fSRodney W. Grimes static char sccsid[] = "@(#)kvm_proc.c 8.3 (Berkeley) 9/23/93"; 3758f0484fSRodney W. Grimes #endif /* LIBC_SCCS and not lint */ 38f86e3350SBruce Evans #endif 39f86e3350SBruce Evans 40f86e3350SBruce Evans #include <sys/cdefs.h> 41f86e3350SBruce Evans __FBSDID("$FreeBSD$"); 4258f0484fSRodney W. Grimes 4358f0484fSRodney W. Grimes /* 4458f0484fSRodney W. Grimes * Proc traversal interface for kvm. ps and w are (probably) the exclusive 4558f0484fSRodney W. Grimes * users of this code, so we've factored it out into a separate module. 4658f0484fSRodney W. Grimes * Thus, we keep this grunge out of the other kvm applications (i.e., 4758f0484fSRodney W. Grimes * most other applications are interested only in open/close/read/nlist). 4858f0484fSRodney W. Grimes */ 4958f0484fSRodney W. Grimes 5058f0484fSRodney W. Grimes #include <sys/param.h> 51b20ea179SAlfred Perlstein #define _WANT_UCRED /* make ucred.h give us 'struct ucred' */ 52aa22cbfeSAlfred Perlstein #include <sys/ucred.h> 53f8197bf0SPawel Jakub Dawidek #include <sys/queue.h> 54f8197bf0SPawel Jakub Dawidek #include <sys/_lock.h> 55f8197bf0SPawel Jakub Dawidek #include <sys/_mutex.h> 56f8197bf0SPawel Jakub Dawidek #include <sys/_task.h> 57413628a7SBjoern A. Zeeb #include <sys/cpuset.h> 5858f0484fSRodney W. Grimes #include <sys/user.h> 5958f0484fSRodney W. Grimes #include <sys/proc.h> 60413628a7SBjoern A. Zeeb #define _WANT_PRISON /* make jail.h give us 'struct prison' */ 61413628a7SBjoern A. Zeeb #include <sys/jail.h> 6258f0484fSRodney W. Grimes #include <sys/exec.h> 6358f0484fSRodney W. Grimes #include <sys/stat.h> 64276de18cSGarance A Drosehn #include <sys/sysent.h> 6558f0484fSRodney W. Grimes #include <sys/ioctl.h> 6658f0484fSRodney W. Grimes #include <sys/tty.h> 67338c7541SDavid Greenman #include <sys/file.h> 682bdd5609SPeter Wemm #include <sys/conf.h> 6951295a4dSJordan K. Hubbard #include <stdio.h> 7051295a4dSJordan K. Hubbard #include <stdlib.h> 7158f0484fSRodney W. Grimes #include <unistd.h> 7258f0484fSRodney W. Grimes #include <nlist.h> 7358f0484fSRodney W. Grimes #include <kvm.h> 7458f0484fSRodney W. Grimes 7558f0484fSRodney W. Grimes #include <sys/sysctl.h> 7658f0484fSRodney W. Grimes 7758f0484fSRodney W. Grimes #include <limits.h> 7877721f53SPeter Wemm #include <memory.h> 7958f0484fSRodney W. Grimes #include <paths.h> 8058f0484fSRodney W. Grimes 8158f0484fSRodney W. Grimes #include "kvm_private.h" 8258f0484fSRodney W. Grimes 8358f0484fSRodney W. Grimes #define KREAD(kd, addr, obj) \ 8458f0484fSRodney W. Grimes (kvm_read(kd, addr, (char *)(obj), sizeof(*obj)) != sizeof(*obj)) 8558f0484fSRodney W. Grimes 8684a0b303SJeff Roberson static int ticks; 8784a0b303SJeff Roberson static int hz; 88de788839SUlrich Spörlein static uint64_t cpu_tick_frequency; 89de788839SUlrich Spörlein 90de788839SUlrich Spörlein /* 91de788839SUlrich Spörlein * From sys/kern/kern_tc.c. Depends on cpu_tick_frequency, which is 92de788839SUlrich Spörlein * read/initialized before this function is ever called. 93de788839SUlrich Spörlein */ 94de788839SUlrich Spörlein static uint64_t 95de788839SUlrich Spörlein cputick2usec(uint64_t tick) 96de788839SUlrich Spörlein { 97de788839SUlrich Spörlein 98de788839SUlrich Spörlein if (cpu_tick_frequency == 0) 99de788839SUlrich Spörlein return (0); 100de788839SUlrich Spörlein if (tick > 18446744073709551) /* floor(2^64 / 1000) */ 101de788839SUlrich Spörlein return (tick / (cpu_tick_frequency / 1000000)); 102de788839SUlrich Spörlein else if (tick > 18446744073709) /* floor(2^64 / 1000000) */ 103de788839SUlrich Spörlein return ((tick * 1000) / (cpu_tick_frequency / 1000)); 104de788839SUlrich Spörlein else 105de788839SUlrich Spörlein return ((tick * 1000000) / cpu_tick_frequency); 106de788839SUlrich Spörlein } 10784a0b303SJeff Roberson 10858f0484fSRodney W. Grimes /* 10958f0484fSRodney W. Grimes * Read proc's from memory file into buffer bp, which has space to hold 11058f0484fSRodney W. Grimes * at most maxcnt procs. 11158f0484fSRodney W. Grimes */ 11258f0484fSRodney W. Grimes static int 113c10970ddSUlrich Spörlein kvm_proclist(kvm_t *kd, int what, int arg, struct proc *p, 114c10970ddSUlrich Spörlein struct kinfo_proc *bp, int maxcnt) 11558f0484fSRodney W. Grimes { 116be04b6d1SDavid E. O'Brien int cnt = 0; 1171f7d2501SKirk McKusick struct kinfo_proc kinfo_proc, *kp; 11858f0484fSRodney W. Grimes struct pgrp pgrp; 11958f0484fSRodney W. Grimes struct session sess; 1202bdd5609SPeter Wemm struct cdev t_cdev; 12158f0484fSRodney W. Grimes struct tty tty; 1221f7d2501SKirk McKusick struct vmspace vmspace; 123840558b9SJohn Baldwin struct sigacts sigacts; 124c10970ddSUlrich Spörlein #if 0 1251f7d2501SKirk McKusick struct pstats pstats; 126c10970ddSUlrich Spörlein #endif 1271f7d2501SKirk McKusick struct ucred ucred; 128f8197bf0SPawel Jakub Dawidek struct prison pr; 12971fad9fdSJulian Elischer struct thread mtd; 13058f0484fSRodney W. Grimes struct proc proc; 131a58930d8STor Egge struct proc pproc; 132276de18cSGarance A Drosehn struct sysentvec sysent; 133276de18cSGarance A Drosehn char svname[KI_EMULNAMELEN]; 13458f0484fSRodney W. Grimes 1351f7d2501SKirk McKusick kp = &kinfo_proc; 1361f7d2501SKirk McKusick kp->ki_structsize = sizeof(kinfo_proc); 1377ab24ea3SJulian Elischer /* 1387ab24ea3SJulian Elischer * Loop on the processes. this is completely broken because we need to be 1397ab24ea3SJulian Elischer * able to loop on the threads and merge the ones that are the same process some how. 1407ab24ea3SJulian Elischer */ 14142680b3aSBen Smithurst for (; cnt < maxcnt && p != NULL; p = LIST_NEXT(&proc, p_list)) { 1426f8c6a69SPeter Wemm memset(kp, 0, sizeof *kp); 14358f0484fSRodney W. Grimes if (KREAD(kd, (u_long)p, &proc)) { 144c10970ddSUlrich Spörlein _kvm_err(kd, kd->program, "can't read proc at %p", p); 14558f0484fSRodney W. Grimes return (-1); 14658f0484fSRodney W. Grimes } 14758551c03SJulian Elischer if (proc.p_state != PRS_ZOMBIE) { 1483daf63fcSJulian Elischer if (KREAD(kd, (u_long)TAILQ_FIRST(&proc.p_threads), 14971fad9fdSJulian Elischer &mtd)) { 15058551c03SJulian Elischer _kvm_err(kd, kd->program, 151c10970ddSUlrich Spörlein "can't read thread at %p", 1523daf63fcSJulian Elischer TAILQ_FIRST(&proc.p_threads)); 1533daf63fcSJulian Elischer return (-1); 1543daf63fcSJulian Elischer } 15558551c03SJulian Elischer } 156b1fc0ec1SRobert Watson if (KREAD(kd, (u_long)proc.p_ucred, &ucred) == 0) { 157b1fc0ec1SRobert Watson kp->ki_ruid = ucred.cr_ruid; 158b1fc0ec1SRobert Watson kp->ki_svuid = ucred.cr_svuid; 159b1fc0ec1SRobert Watson kp->ki_rgid = ucred.cr_rgid; 160b1fc0ec1SRobert Watson kp->ki_svgid = ucred.cr_svgid; 1611b5768beSBrooks Davis kp->ki_cr_flags = ucred.cr_flags; 1621b5768beSBrooks Davis if (ucred.cr_ngroups > KI_NGROUPS) { 1631b5768beSBrooks Davis kp->ki_ngroups = KI_NGROUPS; 1641b5768beSBrooks Davis kp->ki_cr_flags |= KI_CRF_GRP_OVERFLOW; 16568a5cc39SBrooks Davis } else 1661f7d2501SKirk McKusick kp->ki_ngroups = ucred.cr_ngroups; 167d534b0c2SBrooks Davis kvm_read(kd, (u_long)ucred.cr_groups, kp->ki_groups, 1681b5768beSBrooks Davis kp->ki_ngroups * sizeof(gid_t)); 1691f7d2501SKirk McKusick kp->ki_uid = ucred.cr_uid; 170f8197bf0SPawel Jakub Dawidek if (ucred.cr_prison != NULL) { 171f8197bf0SPawel Jakub Dawidek if (KREAD(kd, (u_long)ucred.cr_prison, &pr)) { 172f8197bf0SPawel Jakub Dawidek _kvm_err(kd, kd->program, 173c10970ddSUlrich Spörlein "can't read prison at %p", 174f8197bf0SPawel Jakub Dawidek ucred.cr_prison); 175f8197bf0SPawel Jakub Dawidek return (-1); 176f8197bf0SPawel Jakub Dawidek } 177f8197bf0SPawel Jakub Dawidek kp->ki_jid = pr.pr_id; 178f8197bf0SPawel Jakub Dawidek } 1791f7d2501SKirk McKusick } 18058f0484fSRodney W. Grimes 181694127f8SDaniel Eischen switch(what & ~KERN_PROC_INC_THREAD) { 18258f0484fSRodney W. Grimes 183276de18cSGarance A Drosehn case KERN_PROC_GID: 184276de18cSGarance A Drosehn if (kp->ki_groups[0] != (gid_t)arg) 185276de18cSGarance A Drosehn continue; 186276de18cSGarance A Drosehn break; 187276de18cSGarance A Drosehn 18858f0484fSRodney W. Grimes case KERN_PROC_PID: 18958f0484fSRodney W. Grimes if (proc.p_pid != (pid_t)arg) 19058f0484fSRodney W. Grimes continue; 19158f0484fSRodney W. Grimes break; 19258f0484fSRodney W. Grimes 193276de18cSGarance A Drosehn case KERN_PROC_RGID: 194276de18cSGarance A Drosehn if (kp->ki_rgid != (gid_t)arg) 195276de18cSGarance A Drosehn continue; 196276de18cSGarance A Drosehn break; 197276de18cSGarance A Drosehn 19858f0484fSRodney W. Grimes case KERN_PROC_UID: 1991f7d2501SKirk McKusick if (kp->ki_uid != (uid_t)arg) 20058f0484fSRodney W. Grimes continue; 20158f0484fSRodney W. Grimes break; 20258f0484fSRodney W. Grimes 20358f0484fSRodney W. Grimes case KERN_PROC_RUID: 2041f7d2501SKirk McKusick if (kp->ki_ruid != (uid_t)arg) 20558f0484fSRodney W. Grimes continue; 20658f0484fSRodney W. Grimes break; 20758f0484fSRodney W. Grimes } 20858f0484fSRodney W. Grimes /* 20958f0484fSRodney W. Grimes * We're going to add another proc to the set. If this 21058f0484fSRodney W. Grimes * will overflow the buffer, assume the reason is because 21158f0484fSRodney W. Grimes * nprocs (or the proc list) is corrupt and declare an error. 21258f0484fSRodney W. Grimes */ 21358f0484fSRodney W. Grimes if (cnt >= maxcnt) { 21458f0484fSRodney W. Grimes _kvm_err(kd, kd->program, "nprocs corrupt"); 21558f0484fSRodney W. Grimes return (-1); 21658f0484fSRodney W. Grimes } 21758f0484fSRodney W. Grimes /* 2181f7d2501SKirk McKusick * gather kinfo_proc 21958f0484fSRodney W. Grimes */ 2201f7d2501SKirk McKusick kp->ki_paddr = p; 2217a62aa8aSDavid Schultz kp->ki_addr = 0; /* XXX uarea */ 222b40ce416SJulian Elischer /* kp->ki_kstack = proc.p_thread.td_kstack; XXXKSE */ 2231f7d2501SKirk McKusick kp->ki_args = proc.p_args; 2248b7a975eSJohn Baldwin kp->ki_tracep = proc.p_tracevp; 2251f7d2501SKirk McKusick kp->ki_textvp = proc.p_textvp; 2261f7d2501SKirk McKusick kp->ki_fd = proc.p_fd; 2271f7d2501SKirk McKusick kp->ki_vmspace = proc.p_vmspace; 228840558b9SJohn Baldwin if (proc.p_sigacts != NULL) { 229840558b9SJohn Baldwin if (KREAD(kd, (u_long)proc.p_sigacts, &sigacts)) { 2301f7d2501SKirk McKusick _kvm_err(kd, kd->program, 231c10970ddSUlrich Spörlein "can't read sigacts at %p", proc.p_sigacts); 2321f7d2501SKirk McKusick return (-1); 2331f7d2501SKirk McKusick } 234840558b9SJohn Baldwin kp->ki_sigignore = sigacts.ps_sigignore; 235840558b9SJohn Baldwin kp->ki_sigcatch = sigacts.ps_sigcatch; 2361f7d2501SKirk McKusick } 2378ef6b142SJeff Roberson #if 0 238b61ce5b0SJeff Roberson if ((proc.p_flag & P_INMEM) && proc.p_stats != NULL) { 2391f7d2501SKirk McKusick if (KREAD(kd, (u_long)proc.p_stats, &pstats)) { 2401f7d2501SKirk McKusick _kvm_err(kd, kd->program, 2411f7d2501SKirk McKusick "can't read stats at %x", proc.p_stats); 2421f7d2501SKirk McKusick return (-1); 2431f7d2501SKirk McKusick } 2441f7d2501SKirk McKusick kp->ki_start = pstats.p_start; 24509ff687cSJohn Baldwin 24609ff687cSJohn Baldwin /* 24709ff687cSJohn Baldwin * XXX: The times here are probably zero and need 24809ff687cSJohn Baldwin * to be calculated from the raw data in p_rux and 24909ff687cSJohn Baldwin * p_crux. 25009ff687cSJohn Baldwin */ 2511f7d2501SKirk McKusick kp->ki_rusage = pstats.p_ru; 252276de18cSGarance A Drosehn kp->ki_childstime = pstats.p_cru.ru_stime; 253276de18cSGarance A Drosehn kp->ki_childutime = pstats.p_cru.ru_utime; 254276de18cSGarance A Drosehn /* Some callers want child-times in a single value */ 255276de18cSGarance A Drosehn timeradd(&kp->ki_childstime, &kp->ki_childutime, 256276de18cSGarance A Drosehn &kp->ki_childtime); 2571f7d2501SKirk McKusick } 2588ef6b142SJeff Roberson #endif 259a58930d8STor Egge if (proc.p_oppid) 2601f7d2501SKirk McKusick kp->ki_ppid = proc.p_oppid; 261a58930d8STor Egge else if (proc.p_pptr) { 262a58930d8STor Egge if (KREAD(kd, (u_long)proc.p_pptr, &pproc)) { 2631f7d2501SKirk McKusick _kvm_err(kd, kd->program, 264c10970ddSUlrich Spörlein "can't read pproc at %p", proc.p_pptr); 265a58930d8STor Egge return (-1); 266a58930d8STor Egge } 2671f7d2501SKirk McKusick kp->ki_ppid = pproc.p_pid; 268a58930d8STor Egge } else 2691f7d2501SKirk McKusick kp->ki_ppid = 0; 2706f8c6a69SPeter Wemm if (proc.p_pgrp == NULL) 2716f8c6a69SPeter Wemm goto nopgrp; 2726f8c6a69SPeter Wemm if (KREAD(kd, (u_long)proc.p_pgrp, &pgrp)) { 273c10970ddSUlrich Spörlein _kvm_err(kd, kd->program, "can't read pgrp at %p", 2746f8c6a69SPeter Wemm proc.p_pgrp); 2756f8c6a69SPeter Wemm return (-1); 2766f8c6a69SPeter Wemm } 2771f7d2501SKirk McKusick kp->ki_pgid = pgrp.pg_id; 2781f7d2501SKirk McKusick kp->ki_jobc = pgrp.pg_jobc; 27958f0484fSRodney W. Grimes if (KREAD(kd, (u_long)pgrp.pg_session, &sess)) { 280c10970ddSUlrich Spörlein _kvm_err(kd, kd->program, "can't read session at %p", 28158f0484fSRodney W. Grimes pgrp.pg_session); 28258f0484fSRodney W. Grimes return (-1); 28358f0484fSRodney W. Grimes } 2841f7d2501SKirk McKusick kp->ki_sid = sess.s_sid; 2851f7d2501SKirk McKusick (void)memcpy(kp->ki_login, sess.s_login, 2861f7d2501SKirk McKusick sizeof(kp->ki_login)); 2871f7d2501SKirk McKusick kp->ki_kiflag = sess.s_ttyvp ? KI_CTTY : 0; 2881f7d2501SKirk McKusick if (sess.s_leader == p) 2891f7d2501SKirk McKusick kp->ki_kiflag |= KI_SLEADER; 29058f0484fSRodney W. Grimes if ((proc.p_flag & P_CONTROLT) && sess.s_ttyp != NULL) { 29158f0484fSRodney W. Grimes if (KREAD(kd, (u_long)sess.s_ttyp, &tty)) { 29258f0484fSRodney W. Grimes _kvm_err(kd, kd->program, 293c10970ddSUlrich Spörlein "can't read tty at %p", sess.s_ttyp); 29458f0484fSRodney W. Grimes return (-1); 29558f0484fSRodney W. Grimes } 2962bdd5609SPeter Wemm if (tty.t_dev != NULL) { 2972bdd5609SPeter Wemm if (KREAD(kd, (u_long)tty.t_dev, &t_cdev)) { 2982bdd5609SPeter Wemm _kvm_err(kd, kd->program, 299c10970ddSUlrich Spörlein "can't read cdev at %p", 3002bdd5609SPeter Wemm tty.t_dev); 3012bdd5609SPeter Wemm return (-1); 3022bdd5609SPeter Wemm } 3039c4fb661SPoul-Henning Kamp #if 0 3042bdd5609SPeter Wemm kp->ki_tdev = t_cdev.si_udev; 3059c4fb661SPoul-Henning Kamp #else 3062cfe3fdaSPeter Wemm kp->ki_tdev = NODEV; 3079c4fb661SPoul-Henning Kamp #endif 3082bdd5609SPeter Wemm } 30958f0484fSRodney W. Grimes if (tty.t_pgrp != NULL) { 31058f0484fSRodney W. Grimes if (KREAD(kd, (u_long)tty.t_pgrp, &pgrp)) { 31158f0484fSRodney W. Grimes _kvm_err(kd, kd->program, 312c10970ddSUlrich Spörlein "can't read tpgrp at %p", 31358f0484fSRodney W. Grimes tty.t_pgrp); 31458f0484fSRodney W. Grimes return (-1); 31558f0484fSRodney W. Grimes } 3161f7d2501SKirk McKusick kp->ki_tpgid = pgrp.pg_id; 31758f0484fSRodney W. Grimes } else 3181f7d2501SKirk McKusick kp->ki_tpgid = -1; 3191f7d2501SKirk McKusick if (tty.t_session != NULL) { 3201f7d2501SKirk McKusick if (KREAD(kd, (u_long)tty.t_session, &sess)) { 3211f7d2501SKirk McKusick _kvm_err(kd, kd->program, 322c10970ddSUlrich Spörlein "can't read session at %p", 3231f7d2501SKirk McKusick tty.t_session); 3241f7d2501SKirk McKusick return (-1); 3251f7d2501SKirk McKusick } 3261f7d2501SKirk McKusick kp->ki_tsid = sess.s_sid; 3271f7d2501SKirk McKusick } 3286f8c6a69SPeter Wemm } else { 3296f8c6a69SPeter Wemm nopgrp: 3301f7d2501SKirk McKusick kp->ki_tdev = NODEV; 3316f8c6a69SPeter Wemm } 33271fad9fdSJulian Elischer if ((proc.p_state != PRS_ZOMBIE) && mtd.td_wmesg) 33371fad9fdSJulian Elischer (void)kvm_read(kd, (u_long)mtd.td_wmesg, 3341f7d2501SKirk McKusick kp->ki_wmesg, WMESGLEN); 33558f0484fSRodney W. Grimes 33658f0484fSRodney W. Grimes (void)kvm_read(kd, (u_long)proc.p_vmspace, 3371f7d2501SKirk McKusick (char *)&vmspace, sizeof(vmspace)); 3381f7d2501SKirk McKusick kp->ki_size = vmspace.vm_map.size; 3395f494640SSean Bruno /* 3405f494640SSean Bruno * Approximate the kernel's method of calculating 3415f494640SSean Bruno * this field. 3425f494640SSean Bruno */ 3435f494640SSean Bruno #define pmap_resident_count(pm) ((pm)->pm_stats.resident_count) 3445f494640SSean Bruno kp->ki_rssize = pmap_resident_count(&vmspace.vm_pmap); 3451f7d2501SKirk McKusick kp->ki_swrss = vmspace.vm_swrss; 3461f7d2501SKirk McKusick kp->ki_tsize = vmspace.vm_tsize; 3471f7d2501SKirk McKusick kp->ki_dsize = vmspace.vm_dsize; 3481f7d2501SKirk McKusick kp->ki_ssize = vmspace.vm_ssize; 34958f0484fSRodney W. Grimes 350694127f8SDaniel Eischen switch (what & ~KERN_PROC_INC_THREAD) { 35158f0484fSRodney W. Grimes 35258f0484fSRodney W. Grimes case KERN_PROC_PGRP: 3531f7d2501SKirk McKusick if (kp->ki_pgid != (pid_t)arg) 35458f0484fSRodney W. Grimes continue; 35558f0484fSRodney W. Grimes break; 35658f0484fSRodney W. Grimes 357276de18cSGarance A Drosehn case KERN_PROC_SESSION: 358276de18cSGarance A Drosehn if (kp->ki_sid != (pid_t)arg) 359276de18cSGarance A Drosehn continue; 360276de18cSGarance A Drosehn break; 361276de18cSGarance A Drosehn 36258f0484fSRodney W. Grimes case KERN_PROC_TTY: 36358f0484fSRodney W. Grimes if ((proc.p_flag & P_CONTROLT) == 0 || 3641f7d2501SKirk McKusick kp->ki_tdev != (dev_t)arg) 36558f0484fSRodney W. Grimes continue; 36658f0484fSRodney W. Grimes break; 36758f0484fSRodney W. Grimes } 368b7e7c21aSGarance A Drosehn if (proc.p_comm[0] != 0) 369b7e7c21aSGarance A Drosehn strlcpy(kp->ki_comm, proc.p_comm, MAXCOMLEN); 370276de18cSGarance A Drosehn (void)kvm_read(kd, (u_long)proc.p_sysent, (char *)&sysent, 371276de18cSGarance A Drosehn sizeof(sysent)); 372276de18cSGarance A Drosehn (void)kvm_read(kd, (u_long)sysent.sv_name, (char *)&svname, 373276de18cSGarance A Drosehn sizeof(svname)); 374276de18cSGarance A Drosehn if (svname[0] != 0) 375276de18cSGarance A Drosehn strlcpy(kp->ki_emul, svname, KI_EMULNAMELEN); 376bff4151cSJulian Elischer if ((proc.p_state != PRS_ZOMBIE) && 37771fad9fdSJulian Elischer (mtd.td_blocked != 0)) { 3780d632649SJohn Baldwin kp->ki_kiflag |= KI_LOCKBLOCK; 3790d632649SJohn Baldwin if (mtd.td_lockname) 380bff4151cSJulian Elischer (void)kvm_read(kd, 3810d632649SJohn Baldwin (u_long)mtd.td_lockname, 3820d632649SJohn Baldwin kp->ki_lockname, LOCKNAMELEN); 3830d632649SJohn Baldwin kp->ki_lockname[LOCKNAMELEN] = 0; 3841f7d2501SKirk McKusick } 385de788839SUlrich Spörlein kp->ki_runtime = cputick2usec(proc.p_rux.rux_runtime); 3861f7d2501SKirk McKusick kp->ki_pid = proc.p_pid; 387e8a58a83SJuli Mallett kp->ki_siglist = proc.p_siglist; 38842d3ad71SJeff Roberson SIGSETOR(kp->ki_siglist, mtd.td_siglist); 38931a9779eSJeff Roberson kp->ki_sigmask = mtd.td_sigmask; 3901f7d2501SKirk McKusick kp->ki_xstat = proc.p_xstat; 3911f7d2501SKirk McKusick kp->ki_acflag = proc.p_acflag; 3924f0db5e0SJulian Elischer kp->ki_lock = proc.p_lock; 393bff4151cSJulian Elischer if (proc.p_state != PRS_ZOMBIE) { 39484a0b303SJeff Roberson kp->ki_swtime = (ticks - proc.p_swtick) / hz; 3956143c383SJulian Elischer kp->ki_flag = proc.p_flag; 396b61ce5b0SJeff Roberson kp->ki_sflag = 0; 39730105366SJulian Elischer kp->ki_nice = proc.p_nice; 3981f7d2501SKirk McKusick kp->ki_traceflag = proc.p_traceflag; 3996143c383SJulian Elischer if (proc.p_state == PRS_NORMAL) { 40071fad9fdSJulian Elischer if (TD_ON_RUNQ(&mtd) || 40171fad9fdSJulian Elischer TD_CAN_RUN(&mtd) || 40271fad9fdSJulian Elischer TD_IS_RUNNING(&mtd)) { 403e602ba25SJulian Elischer kp->ki_stat = SRUN; 4044f0db5e0SJulian Elischer } else if (mtd.td_state == 4054f0db5e0SJulian Elischer TDS_INHIBITED) { 40671fad9fdSJulian Elischer if (P_SHOULDSTOP(&proc)) { 407e602ba25SJulian Elischer kp->ki_stat = SSTOP; 4084f0db5e0SJulian Elischer } else if ( 4094f0db5e0SJulian Elischer TD_IS_SLEEPING(&mtd)) { 41071fad9fdSJulian Elischer kp->ki_stat = SSLEEP; 4110d632649SJohn Baldwin } else if (TD_ON_LOCK(&mtd)) { 4120d632649SJohn Baldwin kp->ki_stat = SLOCK; 413e602ba25SJulian Elischer } else { 414e602ba25SJulian Elischer kp->ki_stat = SWAIT; 415e602ba25SJulian Elischer } 41671fad9fdSJulian Elischer } 417e602ba25SJulian Elischer } else { 418e602ba25SJulian Elischer kp->ki_stat = SIDL; 419e602ba25SJulian Elischer } 4204f0db5e0SJulian Elischer /* Stuff from the thread */ 42171fad9fdSJulian Elischer kp->ki_pri.pri_level = mtd.td_priority; 42271fad9fdSJulian Elischer kp->ki_pri.pri_native = mtd.td_base_pri; 42371fad9fdSJulian Elischer kp->ki_lastcpu = mtd.td_lastcpu; 4244f0db5e0SJulian Elischer kp->ki_wchan = mtd.td_wchan; 4257ab24ea3SJulian Elischer if (mtd.td_name[0] != 0) 426925af544SBjoern A. Zeeb strlcpy(kp->ki_tdname, mtd.td_name, MAXCOMLEN); 427a0ddbf49SJulian Elischer kp->ki_oncpu = mtd.td_oncpu; 4287ab24ea3SJulian Elischer if (mtd.td_name[0] != '\0') 429925af544SBjoern A. Zeeb strlcpy(kp->ki_tdname, mtd.td_name, sizeof(kp->ki_tdname)); 430ed062c8dSJulian Elischer kp->ki_pctcpu = 0; 431ed062c8dSJulian Elischer kp->ki_rqindex = 0; 4324f0db5e0SJulian Elischer } else { 4336143c383SJulian Elischer kp->ki_stat = SZOMB; 4346143c383SJulian Elischer } 4351f7d2501SKirk McKusick bcopy(&kinfo_proc, bp, sizeof(kinfo_proc)); 43658f0484fSRodney W. Grimes ++bp; 43758f0484fSRodney W. Grimes ++cnt; 43858f0484fSRodney W. Grimes } 43958f0484fSRodney W. Grimes return (cnt); 44058f0484fSRodney W. Grimes } 44158f0484fSRodney W. Grimes 44258f0484fSRodney W. Grimes /* 44358f0484fSRodney W. Grimes * Build proc info array by reading in proc list from a crash dump. 44458f0484fSRodney W. Grimes * Return number of procs read. maxcnt is the max we will read. 44558f0484fSRodney W. Grimes */ 44658f0484fSRodney W. Grimes static int 447c10970ddSUlrich Spörlein kvm_deadprocs(kvm_t *kd, int what, int arg, u_long a_allproc, 448c10970ddSUlrich Spörlein u_long a_zombproc, int maxcnt) 44958f0484fSRodney W. Grimes { 450be04b6d1SDavid E. O'Brien struct kinfo_proc *bp = kd->procbase; 451be04b6d1SDavid E. O'Brien int acnt, zcnt; 45258f0484fSRodney W. Grimes struct proc *p; 45358f0484fSRodney W. Grimes 45458f0484fSRodney W. Grimes if (KREAD(kd, a_allproc, &p)) { 45558f0484fSRodney W. Grimes _kvm_err(kd, kd->program, "cannot read allproc"); 45658f0484fSRodney W. Grimes return (-1); 45758f0484fSRodney W. Grimes } 45858f0484fSRodney W. Grimes acnt = kvm_proclist(kd, what, arg, p, bp, maxcnt); 45958f0484fSRodney W. Grimes if (acnt < 0) 46058f0484fSRodney W. Grimes return (acnt); 46158f0484fSRodney W. Grimes 46258f0484fSRodney W. Grimes if (KREAD(kd, a_zombproc, &p)) { 46358f0484fSRodney W. Grimes _kvm_err(kd, kd->program, "cannot read zombproc"); 46458f0484fSRodney W. Grimes return (-1); 46558f0484fSRodney W. Grimes } 46658f0484fSRodney W. Grimes zcnt = kvm_proclist(kd, what, arg, p, bp + acnt, maxcnt - acnt); 46758f0484fSRodney W. Grimes if (zcnt < 0) 46858f0484fSRodney W. Grimes zcnt = 0; 46958f0484fSRodney W. Grimes 47058f0484fSRodney W. Grimes return (acnt + zcnt); 47158f0484fSRodney W. Grimes } 47258f0484fSRodney W. Grimes 47358f0484fSRodney W. Grimes struct kinfo_proc * 474c10970ddSUlrich Spörlein kvm_getprocs(kvm_t *kd, int op, int arg, int *cnt) 47558f0484fSRodney W. Grimes { 476c2ac238cSDoug Rabson int mib[4], st, nprocs; 477c2ac238cSDoug Rabson size_t size; 478694127f8SDaniel Eischen int temp_op; 47958f0484fSRodney W. Grimes 48058f0484fSRodney W. Grimes if (kd->procbase != 0) { 48158f0484fSRodney W. Grimes free((void *)kd->procbase); 48258f0484fSRodney W. Grimes /* 48358f0484fSRodney W. Grimes * Clear this pointer in case this call fails. Otherwise, 48458f0484fSRodney W. Grimes * kvm_close() will free it again. 48558f0484fSRodney W. Grimes */ 48658f0484fSRodney W. Grimes kd->procbase = 0; 48758f0484fSRodney W. Grimes } 48858f0484fSRodney W. Grimes if (ISALIVE(kd)) { 48958f0484fSRodney W. Grimes size = 0; 49058f0484fSRodney W. Grimes mib[0] = CTL_KERN; 49158f0484fSRodney W. Grimes mib[1] = KERN_PROC; 49258f0484fSRodney W. Grimes mib[2] = op; 49358f0484fSRodney W. Grimes mib[3] = arg; 494694127f8SDaniel Eischen temp_op = op & ~KERN_PROC_INC_THREAD; 495694127f8SDaniel Eischen st = sysctl(mib, 496694127f8SDaniel Eischen temp_op == KERN_PROC_ALL || temp_op == KERN_PROC_PROC ? 497f2dd06abSTim J. Robbins 3 : 4, NULL, &size, NULL, 0); 49858f0484fSRodney W. Grimes if (st == -1) { 49958f0484fSRodney W. Grimes _kvm_syserr(kd, kd->program, "kvm_getprocs"); 50058f0484fSRodney W. Grimes return (0); 50158f0484fSRodney W. Grimes } 50221687047SDima Dorfman /* 50321687047SDima Dorfman * We can't continue with a size of 0 because we pass 50421687047SDima Dorfman * it to realloc() (via _kvm_realloc()), and passing 0 50521687047SDima Dorfman * to realloc() results in undefined behavior. 50621687047SDima Dorfman */ 50721687047SDima Dorfman if (size == 0) { 50821687047SDima Dorfman /* 50921687047SDima Dorfman * XXX: We should probably return an invalid, 51021687047SDima Dorfman * but non-NULL, pointer here so any client 51121687047SDima Dorfman * program trying to dereference it will 51221687047SDima Dorfman * crash. However, _kvm_freeprocs() calls 51321687047SDima Dorfman * free() on kd->procbase if it isn't NULL, 51421687047SDima Dorfman * and free()'ing a junk pointer isn't good. 51521687047SDima Dorfman * Then again, _kvm_freeprocs() isn't used 51621687047SDima Dorfman * anywhere . . . 51721687047SDima Dorfman */ 51821687047SDima Dorfman kd->procbase = _kvm_malloc(kd, 1); 51921687047SDima Dorfman goto liveout; 52021687047SDima Dorfman } 521b2d3d0f0SDag-Erling Smørgrav do { 522b2d3d0f0SDag-Erling Smørgrav size += size / 10; 523b2d3d0f0SDag-Erling Smørgrav kd->procbase = (struct kinfo_proc *) 524b2d3d0f0SDag-Erling Smørgrav _kvm_realloc(kd, kd->procbase, size); 52558f0484fSRodney W. Grimes if (kd->procbase == 0) 52658f0484fSRodney W. Grimes return (0); 527694127f8SDaniel Eischen st = sysctl(mib, temp_op == KERN_PROC_ALL || 528694127f8SDaniel Eischen temp_op == KERN_PROC_PROC ? 3 : 4, 529b2d3d0f0SDag-Erling Smørgrav kd->procbase, &size, NULL, 0); 530b2d3d0f0SDag-Erling Smørgrav } while (st == -1 && errno == ENOMEM); 53158f0484fSRodney W. Grimes if (st == -1) { 53258f0484fSRodney W. Grimes _kvm_syserr(kd, kd->program, "kvm_getprocs"); 53358f0484fSRodney W. Grimes return (0); 53458f0484fSRodney W. Grimes } 53521687047SDima Dorfman /* 53621687047SDima Dorfman * We have to check the size again because sysctl() 53721687047SDima Dorfman * may "round up" oldlenp if oldp is NULL; hence it 53821687047SDima Dorfman * might've told us that there was data to get when 53921687047SDima Dorfman * there really isn't any. 54021687047SDima Dorfman */ 5410627f53bSDavid Malone if (size > 0 && 5420627f53bSDavid Malone kd->procbase->ki_structsize != sizeof(struct kinfo_proc)) { 54358f0484fSRodney W. Grimes _kvm_err(kd, kd->program, 544c10970ddSUlrich Spörlein "kinfo_proc size mismatch (expected %zu, got %d)", 5451f7d2501SKirk McKusick sizeof(struct kinfo_proc), 5461f7d2501SKirk McKusick kd->procbase->ki_structsize); 54758f0484fSRodney W. Grimes return (0); 54858f0484fSRodney W. Grimes } 54921687047SDima Dorfman liveout: 550d339edcfSDavid Malone nprocs = size == 0 ? 0 : size / kd->procbase->ki_structsize; 55158f0484fSRodney W. Grimes } else { 552de788839SUlrich Spörlein struct nlist nl[7], *p; 55358f0484fSRodney W. Grimes 55458f0484fSRodney W. Grimes nl[0].n_name = "_nprocs"; 55558f0484fSRodney W. Grimes nl[1].n_name = "_allproc"; 55658f0484fSRodney W. Grimes nl[2].n_name = "_zombproc"; 55784a0b303SJeff Roberson nl[3].n_name = "_ticks"; 55884a0b303SJeff Roberson nl[4].n_name = "_hz"; 559de788839SUlrich Spörlein nl[5].n_name = "_cpu_tick_frequency"; 560de788839SUlrich Spörlein nl[6].n_name = 0; 56158f0484fSRodney W. Grimes 56258f0484fSRodney W. Grimes if (kvm_nlist(kd, nl) != 0) { 56358f0484fSRodney W. Grimes for (p = nl; p->n_type != 0; ++p) 56458f0484fSRodney W. Grimes ; 56558f0484fSRodney W. Grimes _kvm_err(kd, kd->program, 56658f0484fSRodney W. Grimes "%s: no such symbol", p->n_name); 56758f0484fSRodney W. Grimes return (0); 56858f0484fSRodney W. Grimes } 56958f0484fSRodney W. Grimes if (KREAD(kd, nl[0].n_value, &nprocs)) { 57058f0484fSRodney W. Grimes _kvm_err(kd, kd->program, "can't read nprocs"); 57158f0484fSRodney W. Grimes return (0); 57258f0484fSRodney W. Grimes } 57384a0b303SJeff Roberson if (KREAD(kd, nl[3].n_value, &ticks)) { 57484a0b303SJeff Roberson _kvm_err(kd, kd->program, "can't read ticks"); 57584a0b303SJeff Roberson return (0); 57684a0b303SJeff Roberson } 57784a0b303SJeff Roberson if (KREAD(kd, nl[4].n_value, &hz)) { 57884a0b303SJeff Roberson _kvm_err(kd, kd->program, "can't read hz"); 57984a0b303SJeff Roberson return (0); 58084a0b303SJeff Roberson } 581de788839SUlrich Spörlein if (KREAD(kd, nl[5].n_value, &cpu_tick_frequency)) { 582de788839SUlrich Spörlein _kvm_err(kd, kd->program, 583de788839SUlrich Spörlein "can't read cpu_tick_frequency"); 584de788839SUlrich Spörlein return (0); 585de788839SUlrich Spörlein } 58658f0484fSRodney W. Grimes size = nprocs * sizeof(struct kinfo_proc); 58758f0484fSRodney W. Grimes kd->procbase = (struct kinfo_proc *)_kvm_malloc(kd, size); 58858f0484fSRodney W. Grimes if (kd->procbase == 0) 58958f0484fSRodney W. Grimes return (0); 59058f0484fSRodney W. Grimes 59158f0484fSRodney W. Grimes nprocs = kvm_deadprocs(kd, op, arg, nl[1].n_value, 59258f0484fSRodney W. Grimes nl[2].n_value, nprocs); 59358f0484fSRodney W. Grimes #ifdef notdef 59458f0484fSRodney W. Grimes size = nprocs * sizeof(struct kinfo_proc); 59558f0484fSRodney W. Grimes (void)realloc(kd->procbase, size); 59658f0484fSRodney W. Grimes #endif 59758f0484fSRodney W. Grimes } 59858f0484fSRodney W. Grimes *cnt = nprocs; 59958f0484fSRodney W. Grimes return (kd->procbase); 60058f0484fSRodney W. Grimes } 60158f0484fSRodney W. Grimes 60258f0484fSRodney W. Grimes void 603c10970ddSUlrich Spörlein _kvm_freeprocs(kvm_t *kd) 60458f0484fSRodney W. Grimes { 60558f0484fSRodney W. Grimes if (kd->procbase) { 60658f0484fSRodney W. Grimes free(kd->procbase); 60758f0484fSRodney W. Grimes kd->procbase = 0; 60858f0484fSRodney W. Grimes } 60958f0484fSRodney W. Grimes } 61058f0484fSRodney W. Grimes 61158f0484fSRodney W. Grimes void * 612c10970ddSUlrich Spörlein _kvm_realloc(kvm_t *kd, void *p, size_t n) 61358f0484fSRodney W. Grimes { 61458f0484fSRodney W. Grimes void *np = (void *)realloc(p, n); 61558f0484fSRodney W. Grimes 616e8420087SWarner Losh if (np == 0) { 617e8420087SWarner Losh free(p); 61858f0484fSRodney W. Grimes _kvm_err(kd, kd->program, "out of memory"); 619e8420087SWarner Losh } 62058f0484fSRodney W. Grimes return (np); 62158f0484fSRodney W. Grimes } 62258f0484fSRodney W. Grimes 62358f0484fSRodney W. Grimes /* 624*ee5169dcSMikolaj Golub * Get the command args or environment. 62558f0484fSRodney W. Grimes */ 62658f0484fSRodney W. Grimes static char ** 627*ee5169dcSMikolaj Golub kvm_argv(kvm_t *kd, const struct kinfo_proc *kp, int env, int nchr) 62858f0484fSRodney W. Grimes { 629b9df5231SPoul-Henning Kamp int oid[4]; 630b7875890SDavid E. O'Brien int i; 631b7875890SDavid E. O'Brien size_t bufsz; 632*ee5169dcSMikolaj Golub static int buflen; 633b9df5231SPoul-Henning Kamp static char *buf, *p; 634b9df5231SPoul-Henning Kamp static char **bufp; 635b9df5231SPoul-Henning Kamp static int argc; 636b9df5231SPoul-Henning Kamp 637c4a7cdb3SPeter Wemm if (!ISALIVE(kd)) { 638c4a7cdb3SPeter Wemm _kvm_err(kd, kd->program, 639c4a7cdb3SPeter Wemm "cannot read user space from dead kernel"); 640c4a7cdb3SPeter Wemm return (0); 641c4a7cdb3SPeter Wemm } 642c4a7cdb3SPeter Wemm 643*ee5169dcSMikolaj Golub if (nchr == 0 || nchr > ARG_MAX) 644*ee5169dcSMikolaj Golub nchr = ARG_MAX; 645*ee5169dcSMikolaj Golub if (buflen == 0) { 646*ee5169dcSMikolaj Golub buf = malloc(nchr); 647*ee5169dcSMikolaj Golub if (buf == NULL) { 648*ee5169dcSMikolaj Golub _kvm_err(kd, kd->program, "cannot allocate memory"); 649*ee5169dcSMikolaj Golub return (0); 650*ee5169dcSMikolaj Golub } 651*ee5169dcSMikolaj Golub buflen = nchr; 652b9df5231SPoul-Henning Kamp argc = 32; 653b9df5231SPoul-Henning Kamp bufp = malloc(sizeof(char *) * argc); 654*ee5169dcSMikolaj Golub } else if (nchr > buflen) { 655*ee5169dcSMikolaj Golub p = realloc(buf, nchr); 656*ee5169dcSMikolaj Golub if (p != NULL) { 657*ee5169dcSMikolaj Golub buf = p; 658*ee5169dcSMikolaj Golub buflen = nchr; 659b9df5231SPoul-Henning Kamp } 660b9df5231SPoul-Henning Kamp } 661b9df5231SPoul-Henning Kamp if (buf != NULL) { 662b9df5231SPoul-Henning Kamp oid[0] = CTL_KERN; 663b9df5231SPoul-Henning Kamp oid[1] = KERN_PROC; 664*ee5169dcSMikolaj Golub oid[2] = env ? KERN_PROC_ENV : KERN_PROC_ARGS; 6651f7d2501SKirk McKusick oid[3] = kp->ki_pid; 666b7875890SDavid E. O'Brien bufsz = buflen; 667b7875890SDavid E. O'Brien i = sysctl(oid, 4, buf, &bufsz, 0, 0); 668b7875890SDavid E. O'Brien if (i == 0 && bufsz > 0) { 669b9df5231SPoul-Henning Kamp i = 0; 670b9df5231SPoul-Henning Kamp p = buf; 671b9df5231SPoul-Henning Kamp do { 672b9df5231SPoul-Henning Kamp bufp[i++] = p; 673b9df5231SPoul-Henning Kamp p += strlen(p) + 1; 674b9df5231SPoul-Henning Kamp if (i >= argc) { 675b9df5231SPoul-Henning Kamp argc += argc; 676b9df5231SPoul-Henning Kamp bufp = realloc(bufp, 677b9df5231SPoul-Henning Kamp sizeof(char *) * argc); 678b9df5231SPoul-Henning Kamp } 679b7875890SDavid E. O'Brien } while (p < buf + bufsz); 680b9df5231SPoul-Henning Kamp bufp[i++] = 0; 681b9df5231SPoul-Henning Kamp return (bufp); 682b9df5231SPoul-Henning Kamp } 683b9df5231SPoul-Henning Kamp } 684b9df5231SPoul-Henning Kamp return (NULL); 685*ee5169dcSMikolaj Golub } 686*ee5169dcSMikolaj Golub 687*ee5169dcSMikolaj Golub char ** 688*ee5169dcSMikolaj Golub kvm_getargv(kvm_t *kd, const struct kinfo_proc *kp, int nchr) 689*ee5169dcSMikolaj Golub { 690*ee5169dcSMikolaj Golub return (kvm_argv(kd, kp, 0, nchr)); 69158f0484fSRodney W. Grimes } 69258f0484fSRodney W. Grimes 69358f0484fSRodney W. Grimes char ** 694c10970ddSUlrich Spörlein kvm_getenvv(kvm_t *kd, const struct kinfo_proc *kp, int nchr) 69558f0484fSRodney W. Grimes { 696*ee5169dcSMikolaj Golub return (kvm_argv(kd, kp, 1, nchr)); 69758f0484fSRodney W. Grimes } 698