2 #include <sys/sysctl.h>
4 #include <libprocstat.h>
5 # ifndef KVME_TYPE_MGTDEVICE
6 # define KVME_TYPE_MGTDEVICE 8
9 procstat_vm(struct procstat
*procstat
, struct kinfo_proc
*kipp
)
11 struct kinfo_vmentry
*freep
, *kve
;
18 ptrwidth
= 2*sizeof(void *) + 2;
20 fprintf(stderr
, "%*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(stderr
, "%#*jx ", ptrwidth
, (uintmax_t)kve
->kve_start
);
34 fprintf(stderr
, "%#*jx ", ptrwidth
, (uintmax_t)kve
->kve_end
);
35 fprintf(stderr
, "%s", kve
->kve_protection
& KVME_PROT_READ
? "r" : "-");
36 fprintf(stderr
, "%s", kve
->kve_protection
& KVME_PROT_WRITE
? "w" : "-");
37 fprintf(stderr
, "%s ", kve
->kve_protection
& KVME_PROT_EXEC
? "x" : "-");
38 fprintf(stderr
, "%4d ", kve
->kve_resident
);
39 fprintf(stderr
, "%4d ", kve
->kve_private_resident
);
40 fprintf(stderr
, "%3d ", kve
->kve_ref_count
);
41 fprintf(stderr
, "%3d ", kve
->kve_shadow_count
);
42 fprintf(stderr
, "%-1s", kve
->kve_flags
& KVME_FLAG_COW
? "C" : "-");
43 fprintf(stderr
, "%-1s", kve
->kve_flags
& KVME_FLAG_NEEDS_COPY
? "N" :
45 fprintf(stderr
, "%-1s", kve
->kve_flags
& KVME_FLAG_SUPER
? "S" : "-");
46 fprintf(stderr
, "%-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(stderr
, "%-2s ", str
);
82 fprintf(stderr
, "%-s\n", kve
->kve_path
);