4#include <libprocstat.h>
5# ifndef KVME_TYPE_MGTDEVICE
6# define KVME_TYPE_MGTDEVICE 8
9procstat_vm(
struct procstat *procstat,
struct kinfo_proc *kipp,
FILE *errout)
11 struct kinfo_vmentry *freep, *kve;
18 ptrwidth = 2*
sizeof(
void *) + 2;
20 fprintf(errout,
"%*s %*s %3s %4s %4s %3s %3s %4s %-2s %-s\n",
21 ptrwidth,
"START", ptrwidth,
"END",
"PRT",
"RES",
22 "P""RES",
"REF",
"SHD",
"FL",
"TP",
"PATH");
24#ifdef HAVE_PROCSTAT_GETVMMAP
25 freep = procstat_getvmmap(procstat, kipp, &cnt);
27 freep = kinfo_getvmmap(kipp->ki_pid, &cnt);
31 for (i = 0; i < cnt; i++) {
33 fprintf(errout,
"%#*jx ", ptrwidth, (uintmax_t)kve->kve_start);
34 fprintf(errout,
"%#*jx ", ptrwidth, (uintmax_t)kve->kve_end);
35 fprintf(errout,
"%s", kve->kve_protection & KVME_PROT_READ ?
"r" :
"-");
36 fprintf(errout,
"%s", kve->kve_protection & KVME_PROT_WRITE ?
"w" :
"-");
37 fprintf(errout,
"%s ", kve->kve_protection & KVME_PROT_EXEC ?
"x" :
"-");
38 fprintf(errout,
"%4d ", kve->kve_resident);
39 fprintf(errout,
"%4d ", kve->kve_private_resident);
40 fprintf(errout,
"%3d ", kve->kve_ref_count);
41 fprintf(errout,
"%3d ", kve->kve_shadow_count);
42 fprintf(errout,
"%-1s", kve->kve_flags & KVME_FLAG_COW ?
"C" :
"-");
43 fprintf(errout,
"%-1s", kve->kve_flags & KVME_FLAG_NEEDS_COPY ?
"N" :
45 fprintf(errout,
"%-1s", kve->kve_flags & KVME_FLAG_SUPER ?
"S" :
"-");
46 fprintf(errout,
"%-1s ", kve->kve_flags & KVME_FLAG_GROWS_UP ?
"U" :
47 kve->kve_flags & KVME_FLAG_GROWS_DOWN ?
"D" :
"-");
48 switch (kve->kve_type) {
52 case KVME_TYPE_DEFAULT:
61 case KVME_TYPE_DEVICE:
73 case KVME_TYPE_MGTDEVICE:
76 case KVME_TYPE_UNKNOWN:
81 fprintf(errout,
"%-2s ", str);
82 fprintf(errout,
"%-s\n", kve->kve_path);