kvm_proc.c (172265) | kvm_proc.c (173004) |
---|---|
1/*- 2 * Copyright (c) 1989, 1992, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software developed by the Computer Systems 6 * Engineering group at Lawrence Berkeley Laboratory under DARPA contract 7 * BG 91-66 and contributed to Berkeley. 8 * --- 24 unchanged lines hidden (view full) --- 33 34#if 0 35#if defined(LIBC_SCCS) && !defined(lint) 36static char sccsid[] = "@(#)kvm_proc.c 8.3 (Berkeley) 9/23/93"; 37#endif /* LIBC_SCCS and not lint */ 38#endif 39 40#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1989, 1992, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software developed by the Computer Systems 6 * Engineering group at Lawrence Berkeley Laboratory under DARPA contract 7 * BG 91-66 and contributed to Berkeley. 8 * --- 24 unchanged lines hidden (view full) --- 33 34#if 0 35#if defined(LIBC_SCCS) && !defined(lint) 36static char sccsid[] = "@(#)kvm_proc.c 8.3 (Berkeley) 9/23/93"; 37#endif /* LIBC_SCCS and not lint */ 38#endif 39 40#include <sys/cdefs.h> |
41__FBSDID("$FreeBSD: head/lib/libkvm/kvm_proc.c 172265 2007-09-21 04:11:34Z jeff $"); | 41__FBSDID("$FreeBSD: head/lib/libkvm/kvm_proc.c 173004 2007-10-26 08:00:41Z julian $"); |
42 43/* 44 * Proc traversal interface for kvm. ps and w are (probably) the exclusive 45 * users of this code, so we've factored it out into a separate module. 46 * Thus, we keep this grunge out of the other kvm applications (i.e., 47 * most other applications are interested only in open/close/read/nlist). 48 */ 49 --- 65 unchanged lines hidden (view full) --- 115 struct proc proc; 116 struct proc pproc; 117 struct timeval tv; 118 struct sysentvec sysent; 119 char svname[KI_EMULNAMELEN]; 120 121 kp = &kinfo_proc; 122 kp->ki_structsize = sizeof(kinfo_proc); | 42 43/* 44 * Proc traversal interface for kvm. ps and w are (probably) the exclusive 45 * users of this code, so we've factored it out into a separate module. 46 * Thus, we keep this grunge out of the other kvm applications (i.e., 47 * most other applications are interested only in open/close/read/nlist). 48 */ 49 --- 65 unchanged lines hidden (view full) --- 115 struct proc proc; 116 struct proc pproc; 117 struct timeval tv; 118 struct sysentvec sysent; 119 char svname[KI_EMULNAMELEN]; 120 121 kp = &kinfo_proc; 122 kp->ki_structsize = sizeof(kinfo_proc); |
123 /* 124 * Loop on the processes. this is completely broken because we need to be 125 * able to loop on the threads and merge the ones that are the same process some how. 126 */ |
|
123 for (; cnt < maxcnt && p != NULL; p = LIST_NEXT(&proc, p_list)) { 124 memset(kp, 0, sizeof *kp); 125 if (KREAD(kd, (u_long)p, &proc)) { 126 _kvm_err(kd, kd->program, "can't read proc at %x", p); 127 return (-1); 128 } 129 if (proc.p_state != PRS_ZOMBIE) { 130 if (KREAD(kd, (u_long)TAILQ_FIRST(&proc.p_threads), --- 266 unchanged lines hidden (view full) --- 397 } else { 398 kp->ki_stat = SIDL; 399 } 400 /* Stuff from the thread */ 401 kp->ki_pri.pri_level = mtd.td_priority; 402 kp->ki_pri.pri_native = mtd.td_base_pri; 403 kp->ki_lastcpu = mtd.td_lastcpu; 404 kp->ki_wchan = mtd.td_wchan; | 127 for (; cnt < maxcnt && p != NULL; p = LIST_NEXT(&proc, p_list)) { 128 memset(kp, 0, sizeof *kp); 129 if (KREAD(kd, (u_long)p, &proc)) { 130 _kvm_err(kd, kd->program, "can't read proc at %x", p); 131 return (-1); 132 } 133 if (proc.p_state != PRS_ZOMBIE) { 134 if (KREAD(kd, (u_long)TAILQ_FIRST(&proc.p_threads), --- 266 unchanged lines hidden (view full) --- 401 } else { 402 kp->ki_stat = SIDL; 403 } 404 /* Stuff from the thread */ 405 kp->ki_pri.pri_level = mtd.td_priority; 406 kp->ki_pri.pri_native = mtd.td_base_pri; 407 kp->ki_lastcpu = mtd.td_lastcpu; 408 kp->ki_wchan = mtd.td_wchan; |
409 if (mtd.td_name[0] != 0) 410 strlcpy(kp->ki_ocomm, mtd.td_name, MAXOCOMLEN); |
|
405 kp->ki_oncpu = mtd.td_oncpu; | 411 kp->ki_oncpu = mtd.td_oncpu; |
406 | 412 if (mtd.td_name[0] != '\0') 413 strlcpy(kp->ki_ocomm, mtd.td_name, sizeof(kp->ki_ocomm)); |
407 if (!(proc.p_flag & P_SA)) { 408 kp->ki_pctcpu = 0; 409 kp->ki_rqindex = 0; 410 } else { 411 kp->ki_tdflags = -1; 412 /* All the rest are 0 for now */ 413 } 414 } else { --- 595 unchanged lines hidden --- | 414 if (!(proc.p_flag & P_SA)) { 415 kp->ki_pctcpu = 0; 416 kp->ki_rqindex = 0; 417 } else { 418 kp->ki_tdflags = -1; 419 /* All the rest are 0 for now */ 420 } 421 } else { --- 595 unchanged lines hidden --- |