4 * Copyright (c) 2002, 2003 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 #include <sys/cdefs.h>
42 static void dump_vm_anon(kvm_t
*, struct vm_anon
**, int);
43 static char *findname(kvm_t
*, struct kbit
*, struct kbit
*, struct kbit
*,
44 struct kbit
*, struct kbit
*);
45 static int search_cache(kvm_t
*, struct kbit
*, char **, char *, size_t);
47 /* when recursing, output is indented */
48 #define indent(n) ((n) * (recurse > 1 ? recurse - 1 : 0))
49 #define rwx (VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE)
54 process_map(kvm_t
*kd
, struct kinfo_proc2
*proc
,
55 struct kbit
*vmspace
, const char *thing
)
57 struct kbit kbit
, *vm_map
= &kbit
;
61 A(vmspace
) = (u_long
)proc
->p_vmspace
;
62 S(vmspace
) = sizeof(struct vmspace
);
63 thing
= "proc->p_vmspace.vm_map";
64 } else if (S(vmspace
) == (size_t)-1) {
66 /* A(vmspace) set by caller */
67 S(vmspace
) = sizeof(struct vmspace
);
68 /* object identified by caller */
70 heapfound
= 1; /* but really, do kernels have a heap? */
76 S(vm_map
) = sizeof(struct vm_map
);
78 if (S(vmspace
) != 0) {
80 A(vm_map
) = A(vmspace
) + offsetof(struct vmspace
, vm_map
);
81 memcpy(D(vm_map
, vm_map
), &D(vmspace
, vmspace
)->vm_map
,
84 memset(vmspace
, 0, sizeof(*vmspace
));
85 A(vm_map
) = kernel_map_addr
;
89 dump_vm_map(kd
, proc
, vmspace
, vm_map
, thing
);
93 dump_vm_map(kvm_t
*kd
, struct kinfo_proc2
*proc
,
94 struct kbit
*vmspace
, struct kbit
*vm_map
, const char *mname
)
96 struct kbit kbit
[2], *header
, *vm_map_entry
;
97 struct vm_map_entry
*last
, *next
;
101 if (S(vm_map
) == (size_t)-1) {
103 S(vm_map
) = sizeof(struct vm_map
);
108 vm_map_entry
= &kbit
[1];
112 A(header
) = A(vm_map
) + offsetof(struct vm_map
, header
);
113 S(header
) = sizeof(struct vm_map_entry
);
114 memcpy(D(header
, vm_map_entry
), &D(vm_map
, vm_map
)->header
, S(header
));
116 if (S(vmspace
) != 0 && (debug
& PRINT_VMSPACE
)) {
117 printf("proc->p_vmspace %p = {", P(vmspace
));
118 printf(" vm_refcnt = %d,", D(vmspace
, vmspace
)->vm_refcnt
);
119 printf(" vm_shm = %p,\n", D(vmspace
, vmspace
)->vm_shm
);
120 printf(" vm_rssize = %d,", D(vmspace
, vmspace
)->vm_rssize
);
121 printf(" vm_swrss = %d,", D(vmspace
, vmspace
)->vm_swrss
);
122 printf(" vm_tsize = %d,", D(vmspace
, vmspace
)->vm_tsize
);
123 printf(" vm_dsize = %d,\n", D(vmspace
, vmspace
)->vm_dsize
);
124 printf(" vm_ssize = %d,", D(vmspace
, vmspace
)->vm_ssize
);
125 printf(" vm_taddr = %p,", D(vmspace
, vmspace
)->vm_taddr
);
126 printf(" vm_daddr = %p,\n", D(vmspace
, vmspace
)->vm_daddr
);
127 printf(" vm_maxsaddr = %p,",
128 D(vmspace
, vmspace
)->vm_maxsaddr
);
129 printf(" vm_minsaddr = %p }\n",
130 D(vmspace
, vmspace
)->vm_minsaddr
);
133 if (debug
& PRINT_VM_MAP
) {
134 printf("%*s%s %p = {", indent(2), "", mname
, P(vm_map
));
135 printf(" pmap = %p,\n", D(vm_map
, vm_map
)->pmap
);
136 printf("%*s lock = <struct lock>,", indent(2), "");
137 printf(" header = <struct vm_map_entry>,");
138 printf(" nentries = %d,\n", D(vm_map
, vm_map
)->nentries
);
139 printf("%*s size = %#"PRIxVSIZE
",", indent(2), "",
140 D(vm_map
, vm_map
)->size
);
141 printf(" ref_count = %d,", D(vm_map
, vm_map
)->ref_count
);
142 printf("%*s hint = %p,", indent(2), "",
143 D(vm_map
, vm_map
)->hint
);
144 printf("%*s first_free = %p,", indent(2), "",
145 D(vm_map
, vm_map
)->first_free
);
146 printf(" flags = %x <%s%s%s%s%s >,\n", D(vm_map
, vm_map
)->flags
,
147 D(vm_map
, vm_map
)->flags
& VM_MAP_PAGEABLE
? " PAGEABLE" : "",
148 D(vm_map
, vm_map
)->flags
& VM_MAP_INTRSAFE
? " INTRSAFE" : "",
149 D(vm_map
, vm_map
)->flags
& VM_MAP_WIREFUTURE
? " WIREFUTURE" : "",
151 D(vm_map
, vm_map
)->flags
& VM_MAP_DYING
? " DYING" :
154 #ifdef VM_MAP_TOPDOWN
155 D(vm_map
, vm_map
)->flags
& VM_MAP_TOPDOWN
? " TOPDOWN" :
158 printf("%*s timestamp = %u }\n", indent(2), "",
159 D(vm_map
, vm_map
)->timestamp
);
162 const char *name
= mapname(P(vm_map
));
164 printf("%*s%s %p: [0x%#"PRIxVADDR
"->0x%#"PRIxVADDR
"]\n", indent(2), "",
165 recurse
< 2 ? "MAP" : "SUBMAP", P(vm_map
),
166 vm_map_min(D(vm_map
, vm_map
)),
167 vm_map_max(D(vm_map
, vm_map
)));
168 printf("\t%*s#ent=%d, sz=%"PRIxVSIZE
", ref=%d, version=%d, flags=0x%x\n",
169 indent(2), "", D(vm_map
, vm_map
)->nentries
,
170 D(vm_map
, vm_map
)->size
, D(vm_map
, vm_map
)->ref_count
,
171 D(vm_map
, vm_map
)->timestamp
, D(vm_map
, vm_map
)->flags
);
172 printf("\t%*spmap=%p(resident=<unknown>)\n", indent(2), "",
173 D(vm_map
, vm_map
)->pmap
);
174 if (verbose
&& name
!= NULL
)
175 printf("\t%*s([ %s ])\n", indent(2), "", name
);
178 dump_vm_map_entry(kd
, proc
, vmspace
, header
, 1);
181 * we're not recursing into a submap, so print headers
185 #ifdef DISABLED_HEADERS
187 printf("%-*s %-*s rwx RWX CPY NCP I W A\n",
188 (int)sizeof(long) * 2 + 2, "Start",
189 (int)sizeof(long) * 2 + 2, "End");
191 printf("%-*s %-*s rwxp %-*s Dev Inode File\n",
192 (int)sizeof(long) * 2 + 0, "Start",
193 (int)sizeof(long) * 2 + 0, "End",
194 (int)sizeof(long) * 2 + 0, "Offset");
196 printf("%-*s %*s Protection File\n",
197 (int)sizeof(long) * 2 + 0, "Start",
198 (int)sizeof(int) * 2 - 1, "Size ");
201 printf("%-*s %-*s %*s %-*s rwxpc RWX I/W/A Dev %*s"
203 (int)sizeof(long) * 2, "Start",
204 (int)sizeof(long) * 2, "End",
205 (int)sizeof(int) * 2, "Size ",
206 (int)sizeof(long) * 2, "Offset",
207 (int)sizeof(int) * 2, "Inode");
210 /* these are the "sub entries" */
212 next
= D(header
, vm_map_entry
)->next
;
216 while (next
!= 0 && next
!= last
) {
218 A(vm_map_entry
) = addr
;
219 S(vm_map_entry
) = sizeof(struct vm_map_entry
);
220 KDEREF(kd
, vm_map_entry
);
221 next
= D(vm_map_entry
, vm_map_entry
)->next
;
224 end
= D(vm_map_entry
, vm_map_entry
)->start
;
225 else if (verbose
> 1 &&
226 end
!= D(vm_map_entry
, vm_map_entry
)->start
)
227 printf("%*s[%lu pages / %luK]\n", indent(2), "",
228 (D(vm_map_entry
, vm_map_entry
)->start
- end
) /
230 (D(vm_map_entry
, vm_map_entry
)->start
- end
) /
232 total
+= dump_vm_map_entry(kd
, proc
, vmspace
, vm_map_entry
, 0);
234 end
= D(vm_map_entry
, vm_map_entry
)->end
;
238 * we're not recursing into a submap, so print totals
242 printf("%-*s %8luK\n",
243 (int)sizeof(void *) * 2 - 2, " total",
244 (unsigned long)total
);
246 printf("%-*s %9luk\n",
247 (int)sizeof(void *) * 4 - 1, " total",
248 (unsigned long)total
);
253 dump_vm_map_entry(kvm_t
*kd
, struct kinfo_proc2
*proc
, struct kbit
*vmspace
,
254 struct kbit
*vm_map_entry
, int ishead
)
257 struct kbit
*uvm_obj
, *vp
, *vfs
;
258 struct vm_map_entry
*vme
;
264 if (S(vm_map_entry
) == (size_t)-1) {
266 S(vm_map_entry
) = sizeof(struct vm_map_entry
);
267 KDEREF(kd
, vm_map_entry
);
278 vme
= D(vm_map_entry
, vm_map_entry
);
280 if ((ishead
&& (debug
& PRINT_VM_MAP_HEADER
)) ||
281 (!ishead
&& (debug
& PRINT_VM_MAP_ENTRY
))) {
282 printf("%*s%s %p = {", indent(2), "",
283 ishead
? "vm_map.header" : "vm_map_entry",
285 printf(" prev = %p,", vme
->prev
);
286 printf(" next = %p,\n", vme
->next
);
287 printf("%*s start = %#"PRIxVADDR
",", indent(2), "", vme
->start
);
288 printf(" end = %#"PRIxVADDR
",", vme
->end
);
289 printf(" object.uvm_obj/sub_map = %p,\n", vme
->object
.uvm_obj
);
290 printf("%*s offset = %" PRIx64
",", indent(2), "",
292 printf(" etype = %x <%s%s%s%s >,", vme
->etype
,
293 UVM_ET_ISOBJ(vme
) ? " OBJ" : "",
294 UVM_ET_ISSUBMAP(vme
) ? " SUBMAP" : "",
295 UVM_ET_ISCOPYONWRITE(vme
) ? " COW" : "",
296 UVM_ET_ISNEEDSCOPY(vme
) ? " NEEDSCOPY" : "");
297 printf(" protection = %x,\n", vme
->protection
);
298 printf("%*s max_protection = %x,", indent(2), "",
299 vme
->max_protection
);
300 printf(" inheritance = %d,", vme
->inheritance
);
301 printf(" wired_count = %d,\n", vme
->wired_count
);
302 printf("%*s aref = { ar_pageoff = %x, ar_amap = %p },",
303 indent(2), "", vme
->aref
.ar_pageoff
, vme
->aref
.ar_amap
);
304 printf(" advice = %d,\n", vme
->advice
);
305 printf("%*s flags = %x <%s%s%s%s%s > }\n", indent(2), "",
307 vme
->flags
& UVM_MAP_KERNEL
? " KERNEL" : "",
308 vme
->flags
& UVM_MAP_KMAPENT
? " KMAPENT" : "",
309 vme
->flags
& UVM_MAP_FIRST
? " FIRST" : "",
310 vme
->flags
& UVM_MAP_QUANTUM
? " QUANTUM" : "",
311 vme
->flags
& UVM_MAP_NOMERGE
? " NOMERGE" : "");
314 if ((debug
& PRINT_VM_AMAP
) && (vme
->aref
.ar_amap
!= NULL
)) {
315 struct kbit akbit
, *amap
;
318 P(amap
) = vme
->aref
.ar_amap
;
319 S(amap
) = sizeof(struct vm_amap
);
330 if (vme
->object
.uvm_obj
!= NULL
) {
331 P(uvm_obj
) = vme
->object
.uvm_obj
;
332 S(uvm_obj
) = sizeof(struct uvm_object
);
334 if (UVM_ET_ISOBJ(vme
) &&
335 UVM_OBJ_IS_VNODE(D(uvm_obj
, uvm_object
))) {
337 S(vp
) = sizeof(struct vnode
);
344 if (P(vp
) != NULL
&& D(vp
, vnode
)->v_mount
!= NULL
) {
345 P(vfs
) = D(vp
, vnode
)->v_mount
;
346 S(vfs
) = sizeof(struct mount
);
348 D(vp
, vnode
)->v_mount
= D(vfs
, mount
);
352 * dig out the device number and inode number from certain
355 #define V_DATA_IS(vp, type, d, i) do { \
357 P(&data) = D(vp, vnode)->v_data; \
358 S(&data) = sizeof(*D(&data, type)); \
360 dev = D(&data, type)->d; \
361 inode = D(&data, type)->i; \
362 } while (0/*CONSTCOND*/)
368 D(vp
, vnode
)->v_type
== VREG
&&
369 D(vp
, vnode
)->v_data
!= NULL
) {
370 switch (D(vp
, vnode
)->v_tag
) {
374 V_DATA_IS(vp
, inode
, i_dev
, i_number
);
377 V_DATA_IS(vp
, iso_node
, i_dev
, i_number
);
384 name
= findname(kd
, vmspace
, vm_map_entry
, vp
, vfs
, uvm_obj
);
387 printf("%*s0x%#"PRIxVADDR
" 0x%#"PRIxVADDR
" %c%c%c %c%c%c %s %s %d %d %d",
389 vme
->start
, vme
->end
,
390 (vme
->protection
& VM_PROT_READ
) ? 'r' : '-',
391 (vme
->protection
& VM_PROT_WRITE
) ? 'w' : '-',
392 (vme
->protection
& VM_PROT_EXECUTE
) ? 'x' : '-',
393 (vme
->max_protection
& VM_PROT_READ
) ? 'r' : '-',
394 (vme
->max_protection
& VM_PROT_WRITE
) ? 'w' : '-',
395 (vme
->max_protection
& VM_PROT_EXECUTE
) ? 'x' : '-',
396 UVM_ET_ISCOPYONWRITE(vme
) ? "COW" : "NCOW",
397 UVM_ET_ISNEEDSCOPY(vme
) ? "NC" : "NNC",
398 vme
->inheritance
, vme
->wired_count
,
402 printf(" %llu,%llu %llu",
403 (unsigned long long)major(dev
),
404 (unsigned long long)minor(dev
),
405 (unsigned long long)inode
);
413 printf("%*s%0*"PRIxVADDR
"-%0*"PRIxVADDR
" %c%c%c%c %0*" PRIx64
" %02llx:%02llx %llu %s\n",
415 (int)sizeof(void *) * 2, vme
->start
,
416 (int)sizeof(void *) * 2, vme
->end
,
417 (vme
->protection
& VM_PROT_READ
) ? 'r' : '-',
418 (vme
->protection
& VM_PROT_WRITE
) ? 'w' : '-',
419 (vme
->protection
& VM_PROT_EXECUTE
) ? 'x' : '-',
420 UVM_ET_ISCOPYONWRITE(vme
) ? 'p' : 's',
421 (int)sizeof(void *) * 2,
423 (unsigned long long)major(dev
),
424 (unsigned long long)minor(dev
),
425 (unsigned long long)inode
,
426 (name
[0] != ' ') || verbose
? name
: "");
430 printf("%*s - %p: 0x%"PRIxVADDR
"->0x%"PRIxVADDR
": obj=%p/0x%" PRIx64
", amap=%p/%d\n",
432 P(vm_map_entry
), vme
->start
, vme
->end
,
433 vme
->object
.uvm_obj
, vme
->offset
,
434 vme
->aref
.ar_amap
, vme
->aref
.ar_pageoff
);
435 printf("\t%*ssubmap=%c, cow=%c, nc=%c, prot(max)=%d/%d, inh=%d, "
438 UVM_ET_ISSUBMAP(vme
) ? 'T' : 'F',
439 UVM_ET_ISCOPYONWRITE(vme
) ? 'T' : 'F',
440 UVM_ET_ISNEEDSCOPY(vme
) ? 'T' : 'F',
441 vme
->protection
, vme
->max_protection
,
442 vme
->inheritance
, vme
->wired_count
, vme
->advice
);
444 printf("\t%*s", indent(2), "");
446 printf("(dev=%llu,%llu ino=%llu [%s] [%p])\n",
447 (unsigned long long)major(dev
),
448 (unsigned long long)minor(dev
),
449 (unsigned long long)inode
, name
, P(vp
));
450 else if (name
[0] == ' ')
451 printf("(%s)\n", &name
[2]);
453 printf("(%s)\n", name
);
463 if (vme
->protection
& VM_PROT_READ
)
464 strlcat(prot
, "/read", sizeof(prot
));
465 if (vme
->protection
& VM_PROT_WRITE
)
466 strlcat(prot
, "/write", sizeof(prot
));
467 if (vme
->protection
& VM_PROT_EXECUTE
)
468 strlcat(prot
, "/exec", sizeof(prot
));
470 sz
= (size_t)((vme
->end
- vme
->start
) / 1024);
471 printf("%*s%0*lX %6luK %-15s %s\n",
473 (int)sizeof(void *) * 2,
474 (unsigned long)vme
->start
,
481 sz
= (size_t)((vme
->end
- vme
->start
) / 1024);
483 "%*s%0*"PRIxVADDR
"-%0*"PRIxVADDR
" %7luk %0*" PRIx64
" %c%c%c%c%c (%c%c%c) %d/%d/%d %02llu:%02llu %7llu - %s [%p]\n" :
484 "%*s%0*"PRIxVADDR
"-%0*"PRIxVADDR
" %7luk %0*" PRIx64
" %c%c%c%c%c (%c%c%c) %d/%d/%d %02llu:%02llu %7llu - %s\n",
486 (int)sizeof(void *) * 2,
488 (int)sizeof(void *) * 2,
489 vme
->end
- (vme
->start
!= vme
->end
? 1 : 0),
491 (int)sizeof(void *) * 2,
493 (vme
->protection
& VM_PROT_READ
) ? 'r' : '-',
494 (vme
->protection
& VM_PROT_WRITE
) ? 'w' : '-',
495 (vme
->protection
& VM_PROT_EXECUTE
) ? 'x' : '-',
496 UVM_ET_ISCOPYONWRITE(vme
) ? 'p' : 's',
497 UVM_ET_ISNEEDSCOPY(vme
) ? '+' : '-',
498 (vme
->max_protection
& VM_PROT_READ
) ? 'r' : '-',
499 (vme
->max_protection
& VM_PROT_WRITE
) ? 'w' : '-',
500 (vme
->max_protection
& VM_PROT_EXECUTE
) ? 'x' : '-',
504 (unsigned long long)major(dev
),
505 (unsigned long long)minor(dev
),
506 (unsigned long long)inode
,
510 /* no access allowed, don't count space */
511 if ((vme
->protection
& rwx
) == 0)
514 if (recurse
&& UVM_ET_ISSUBMAP(vme
)) {
515 struct kbit mkbit
, *submap
;
519 P(submap
) = vme
->object
.sub_map
;
520 S(submap
) = sizeof(*vme
->object
.sub_map
);
522 dump_vm_map(kd
, proc
, vmspace
, submap
, "submap");
530 dump_amap(kvm_t
*kd
, struct kbit
*amap
)
532 struct vm_anon
**am_anon
;
539 if (S(amap
) == (size_t)-1) {
541 S(amap
) = sizeof(struct vm_amap
);
545 printf("%*s amap %p = { am_ref = %d, "
547 "%*s am_maxslot = %d, am_nslot = %d, am_nused = %d, "
549 "%*s am_bckptr = %p, am_anon = %p, am_ppref = %p }\n",
552 D(amap
, amap
)->am_ref
,
553 D(amap
, amap
)->am_flags
,
555 D(amap
, amap
)->am_maxslot
,
556 D(amap
, amap
)->am_nslot
,
557 D(amap
, amap
)->am_nused
,
558 D(amap
, amap
)->am_slots
,
560 D(amap
, amap
)->am_bckptr
,
561 D(amap
, amap
)->am_anon
,
562 D(amap
, amap
)->am_ppref
);
564 if (!(debug
& DUMP_VM_AMAP_DATA
))
568 * Assume that sizeof(struct vm_anon *) >= sizeof(size_t) and
569 * allocate that amount of space.
571 l
= sizeof(struct vm_anon
*) * D(amap
, amap
)->am_maxslot
;
573 _KDEREF(kd
, (u_long
)D(amap
, amap
)->am_anon
, am_anon
, l
);
575 l
= sizeof(int) * D(amap
, amap
)->am_maxslot
;
576 am_bckptr
= malloc(l
);
577 _KDEREF(kd
, (u_long
)D(amap
, amap
)->am_bckptr
, am_bckptr
, l
);
579 l
= sizeof(int) * D(amap
, amap
)->am_maxslot
;
580 am_slots
= malloc(l
);
581 _KDEREF(kd
, (u_long
)D(amap
, amap
)->am_slots
, am_slots
, l
);
583 if (D(amap
, amap
)->am_ppref
!= NULL
&&
584 D(amap
, amap
)->am_ppref
!= PPREF_NONE
) {
585 l
= sizeof(int) * D(amap
, amap
)->am_maxslot
;
586 am_ppref
= malloc(l
);
587 _KDEREF(kd
, (u_long
)D(amap
, amap
)->am_ppref
, am_ppref
, l
);
592 printf(" page# %9s %8s", "am_bckptr", "am_slots");
594 printf(" %8s ", "am_ppref");
595 printf(" %10s\n", "am_anon");
598 e
= verbose
> 1 ? D(amap
, amap
)->am_maxslot
: D(amap
, amap
)->am_nslot
;
599 for (i
= 0; i
< e
; i
++) {
600 printf(" %4lx", (unsigned long)i
);
602 if (am_anon
[i
] || verbose
> 1)
603 printf(" %8x", am_bckptr
[i
]);
607 if (i
< D(amap
, amap
)->am_nused
|| verbose
> 1)
608 printf(" %8x", am_slots
[i
]);
613 if (l
== 0 || r
|| verbose
> 1)
614 printf(" %8d", am_ppref
[i
]);
619 if (am_ppref
[i
] > 0) {
623 r
= -am_ppref
[i
] - 1;
626 printf(" (%4ld @ %4ld)", (long)l
, (long)r
);
634 dump_vm_anon(kd
, am_anon
, i
);
645 dump_vm_anon(kvm_t
*kd
, struct vm_anon
**alist
, int i
)
648 printf(" %10p", alist
[i
]);
650 if (debug
& PRINT_VM_ANON
) {
651 struct kbit kbit
, *anon
= &kbit
;
653 A(anon
) = (u_long
)alist
[i
];
654 S(anon
) = sizeof(struct vm_anon
);
662 printf(" = { an_ref = %d, an_page = %p, an_swslot = %d }",
663 D(anon
, anon
)->an_ref
, D(anon
, anon
)->an_page
,
664 D(anon
, anon
)->an_swslot
);
671 findname(kvm_t
*kd
, struct kbit
*vmspace
,
672 struct kbit
*vm_map_entry
, struct kbit
*vp
,
673 struct kbit
*vfs
, struct kbit
*uvm_obj
)
675 static char buf
[1024], *name
;
676 struct vm_map_entry
*vme
;
679 vme
= D(vm_map_entry
, vm_map_entry
);
681 if (UVM_ET_ISOBJ(vme
)) {
683 l
= (unsigned)strlen(D(vfs
, mount
)->mnt_stat
.f_mntonname
);
684 switch (search_cache(kd
, vp
, &name
, buf
, sizeof(buf
))) {
685 case 0: /* found something */
689 case 2: /* found nothing */
691 memcpy(name
, " -?- ", (size_t)5);
694 D(vfs
, mount
)->mnt_stat
.f_mntonname
, l
);
696 case 1: /* all is well */
702 D(vfs
, mount
)->mnt_stat
.f_mntonname
, l
);
707 else if (UVM_OBJ_IS_DEVICE(D(uvm_obj
, uvm_object
))) {
711 P(&kdev
) = P(uvm_obj
);
712 S(&kdev
) = sizeof(struct uvm_device
);
714 dev
= D(&kdev
, uvm_device
)->u_device
;
715 name
= devname(dev
, S_IFCHR
);
717 snprintf(buf
, sizeof(buf
), "/dev/%s", name
);
719 snprintf(buf
, sizeof(buf
), " [ device %llu,%llu ]",
720 (unsigned long long)major(dev
),
721 (unsigned long long)minor(dev
));
724 else if (UVM_OBJ_IS_AOBJ(D(uvm_obj
, uvm_object
))) {
725 snprintf(buf
, sizeof(buf
), " [ uvm_aobj ]");
728 else if (UVM_OBJ_IS_UBCPAGER(D(uvm_obj
, uvm_object
))) {
729 snprintf(buf
, sizeof(buf
), " [ ubc_pager ]");
732 else if (UVM_OBJ_IS_VNODE(D(uvm_obj
, uvm_object
))) {
733 snprintf(buf
, sizeof(buf
), " [ ?VNODE? ]");
737 snprintf(buf
, sizeof(buf
), " [ ?? %p ?? ]",
738 D(uvm_obj
, uvm_object
)->pgops
);
743 else if ((char *)D(vmspace
, vmspace
)->vm_maxsaddr
<=
744 (char *)vme
->start
&&
745 ((char *)D(vmspace
, vmspace
)->vm_maxsaddr
+ (size_t)maxssiz
) >=
747 snprintf(buf
, sizeof(buf
), " [ stack ]");
751 else if (!heapfound
&&
752 (vme
->protection
& rwx
) == rwx
&&
753 vme
->start
>= (u_long
)D(vmspace
, vmspace
)->vm_daddr
) {
755 snprintf(buf
, sizeof(buf
), " [ heap ]");
759 else if (UVM_ET_ISSUBMAP(vme
)) {
760 const char *sub
= mapname(vme
->object
.sub_map
);
761 snprintf(buf
, sizeof(buf
), " [ %s ]", sub
? sub
: "(submap)");
766 snprintf(buf
, sizeof(buf
), " [ anon ]");
774 search_cache(kvm_t
*kd
, struct kbit
*vp
, char **name
, char *buf
, size_t blen
)
777 struct cache_entry
*ce
;
780 if (nchashtbl
== NULL
)
784 S(&svp
) = sizeof(struct vnode
);
789 LIST_FOREACH(ce
, &lcache
, ce_next
)
790 if (ce
->ce_vp
== P(&svp
))
792 if (ce
&& ce
->ce_vp
== P(&svp
)) {
796 memcpy(o
, ce
->ce_name
, (unsigned)ce
->ce_nlen
);
797 P(&svp
) = ce
->ce_pvp
;
801 } while (1/*CONSTCOND*/);
809 return (D(&svp
, vnode
)->v_vflag
& VV_ROOT
);