1fa12c626SMatthew Dillon /* 2fa12c626SMatthew Dillon * VNODEINFO.C 3fa12c626SMatthew Dillon * 4fa12c626SMatthew Dillon * cc -I/usr/src/sys vnodeinfo.c -o /usr/local/bin/vnodeinfo -lkvm 5fa12c626SMatthew Dillon * 6fa12c626SMatthew Dillon * vnodeinfo 7fa12c626SMatthew Dillon * 8fa12c626SMatthew Dillon * Dump the mountlist and related vnodes. 9fa12c626SMatthew Dillon * 105c8e2a54SMatthew Dillon * 115c8e2a54SMatthew Dillon * Copyright (c) 2004 The DragonFly Project. All rights reserved. 125c8e2a54SMatthew Dillon * 135c8e2a54SMatthew Dillon * This code is derived from software contributed to The DragonFly Project 145c8e2a54SMatthew Dillon * by Matthew Dillon <dillon@backplane.com> 155c8e2a54SMatthew Dillon * 165c8e2a54SMatthew Dillon * Redistribution and use in source and binary forms, with or without 175c8e2a54SMatthew Dillon * modification, are permitted provided that the following conditions 185c8e2a54SMatthew Dillon * are met: 195c8e2a54SMatthew Dillon * 205c8e2a54SMatthew Dillon * 1. Redistributions of source code must retain the above copyright 215c8e2a54SMatthew Dillon * notice, this list of conditions and the following disclaimer. 225c8e2a54SMatthew Dillon * 2. Redistributions in binary form must reproduce the above copyright 235c8e2a54SMatthew Dillon * notice, this list of conditions and the following disclaimer in 245c8e2a54SMatthew Dillon * the documentation and/or other materials provided with the 255c8e2a54SMatthew Dillon * distribution. 265c8e2a54SMatthew Dillon * 3. Neither the name of The DragonFly Project nor the names of its 275c8e2a54SMatthew Dillon * contributors may be used to endorse or promote products derived 285c8e2a54SMatthew Dillon * from this software without specific, prior written permission. 295c8e2a54SMatthew Dillon * 305c8e2a54SMatthew Dillon * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 315c8e2a54SMatthew Dillon * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 325c8e2a54SMatthew Dillon * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 335c8e2a54SMatthew Dillon * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 345c8e2a54SMatthew Dillon * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 355c8e2a54SMatthew Dillon * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, 365c8e2a54SMatthew Dillon * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 375c8e2a54SMatthew Dillon * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 385c8e2a54SMatthew Dillon * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 395c8e2a54SMatthew Dillon * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 405c8e2a54SMatthew Dillon * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 415c8e2a54SMatthew Dillon * SUCH DAMAGE. 425c8e2a54SMatthew Dillon * 43d1a5d3fcSMatthew Dillon * $DragonFly: src/test/debug/vnodeinfo.c,v 1.13 2007/05/06 20:45:01 dillon Exp $ 44fa12c626SMatthew Dillon */ 45fa12c626SMatthew Dillon 4678465ba9SMatthew Dillon #define _KERNEL_STRUCTURES 47fa12c626SMatthew Dillon #include <sys/param.h> 48fa12c626SMatthew Dillon #include <sys/user.h> 49fa12c626SMatthew Dillon #include <sys/malloc.h> 50fa12c626SMatthew Dillon #include <sys/signalvar.h> 51bb87550cSMatthew Dillon #include <sys/namecache.h> 52fa12c626SMatthew Dillon #include <sys/mount.h> 53fa12c626SMatthew Dillon #include <sys/vnode.h> 54af456e64SMatthew Dillon #include <sys/buf.h> 55fa12c626SMatthew Dillon 56fa12c626SMatthew Dillon #include <vm/vm.h> 57fa12c626SMatthew Dillon #include <vm/vm_page.h> 58fa12c626SMatthew Dillon #include <vm/vm_kern.h> 5917ba2e5aSMatthew Dillon #include <vm/vm_object.h> 60fa12c626SMatthew Dillon #include <vm/swap_pager.h> 61fa12c626SMatthew Dillon #include <vm/vnode_pager.h> 62fa12c626SMatthew Dillon 633661e25dSMatthew Dillon #include <vfs/ufs/quota.h> 643661e25dSMatthew Dillon #include <vfs/ufs/inode.h> 653661e25dSMatthew Dillon 66fa12c626SMatthew Dillon #include <stdio.h> 67fa12c626SMatthew Dillon #include <stdlib.h> 68fa12c626SMatthew Dillon #include <string.h> 69fa12c626SMatthew Dillon #include <fcntl.h> 70fa12c626SMatthew Dillon #include <kvm.h> 71fa12c626SMatthew Dillon #include <nlist.h> 72fa12c626SMatthew Dillon #include <getopt.h> 73fa12c626SMatthew Dillon 74fa12c626SMatthew Dillon struct nlist Nl[] = { 75fa12c626SMatthew Dillon { "_mountlist" }, 76fa12c626SMatthew Dillon { "_vnode_free_list" }, 77fa12c626SMatthew Dillon { NULL } 78fa12c626SMatthew Dillon }; 79fa12c626SMatthew Dillon 80fa12c626SMatthew Dillon static void kkread(kvm_t *kd, u_long addr, void *buf, size_t nbytes); 81fa12c626SMatthew Dillon static struct mount *dumpmount(kvm_t *kd, struct mount *mp); 82fa12c626SMatthew Dillon static struct vnode *dumpvp(kvm_t *kd, struct vnode *vp, int whichlist); 83af456e64SMatthew Dillon static void dumpbufs(kvm_t *kd, void *bufp, const char *id); 843661e25dSMatthew Dillon static void dumplocks(kvm_t *kd, struct lockf *lockf); 853661e25dSMatthew Dillon static void dumplockinfo(kvm_t *kd, struct lockf_range *item); 8617ba2e5aSMatthew Dillon static int getobjpages(kvm_t *kd, struct vm_object *obj); 87ada41611SMatthew Dillon static int getobjvnpsize(kvm_t *kd, struct vm_object *obj); 88fa12c626SMatthew Dillon 89af456e64SMatthew Dillon int tracebufs = 0; 903661e25dSMatthew Dillon int tracelocks = 0; 91bb87550cSMatthew Dillon int withnames = 0; 92af456e64SMatthew Dillon 93af456e64SMatthew Dillon int 94fa12c626SMatthew Dillon main(int ac, char **av) 95fa12c626SMatthew Dillon { 96fa12c626SMatthew Dillon struct mount *mp; 97fa12c626SMatthew Dillon struct vnode *vp; 98fa12c626SMatthew Dillon kvm_t *kd; 99fa12c626SMatthew Dillon int i; 100fa12c626SMatthew Dillon int ch; 101fa12c626SMatthew Dillon const char *corefile = NULL; 102fa12c626SMatthew Dillon const char *sysfile = NULL; 103fa12c626SMatthew Dillon 1043661e25dSMatthew Dillon while ((ch = getopt(ac, av, "alnbM:N:")) != -1) { 105fa12c626SMatthew Dillon switch(ch) { 106af456e64SMatthew Dillon case 'b': 107af456e64SMatthew Dillon tracebufs = 1; 108af456e64SMatthew Dillon break; 109bb87550cSMatthew Dillon case 'n': 110bb87550cSMatthew Dillon withnames = 1; 111bb87550cSMatthew Dillon break; 1123661e25dSMatthew Dillon case 'l': 1133661e25dSMatthew Dillon tracelocks = 1; 1143661e25dSMatthew Dillon break; 115bb87550cSMatthew Dillon case 'a': 116bb87550cSMatthew Dillon tracebufs = 1; 1173661e25dSMatthew Dillon tracelocks = 1; 118bb87550cSMatthew Dillon withnames = 1; 119bb87550cSMatthew Dillon break; 120fa12c626SMatthew Dillon case 'M': 121fa12c626SMatthew Dillon corefile = optarg; 122fa12c626SMatthew Dillon break; 123fa12c626SMatthew Dillon case 'N': 124fa12c626SMatthew Dillon sysfile = optarg; 125fa12c626SMatthew Dillon break; 126fa12c626SMatthew Dillon default: 127fa12c626SMatthew Dillon fprintf(stderr, "%s [-M core] [-N system]\n", av[0]); 128fa12c626SMatthew Dillon exit(1); 129fa12c626SMatthew Dillon } 130fa12c626SMatthew Dillon } 131fa12c626SMatthew Dillon 132fa12c626SMatthew Dillon if ((kd = kvm_open(sysfile, corefile, NULL, O_RDONLY, "kvm:")) == NULL) { 133fa12c626SMatthew Dillon perror("kvm_open"); 134fa12c626SMatthew Dillon exit(1); 135fa12c626SMatthew Dillon } 136fa12c626SMatthew Dillon if (kvm_nlist(kd, Nl) != 0) { 137fa12c626SMatthew Dillon perror("kvm_nlist"); 138fa12c626SMatthew Dillon exit(1); 139fa12c626SMatthew Dillon } 140fa12c626SMatthew Dillon kkread(kd, Nl[0].n_value, &mp, sizeof(mp)); 141fa12c626SMatthew Dillon while (mp) 142fa12c626SMatthew Dillon mp = dumpmount(kd, mp); 143fa12c626SMatthew Dillon kkread(kd, Nl[1].n_value, &vp, sizeof(vp)); 144fa12c626SMatthew Dillon printf("VNODEFREELIST {\n"); 145fa12c626SMatthew Dillon while (vp) 146fa12c626SMatthew Dillon vp = dumpvp(kd, vp, 0); 147fa12c626SMatthew Dillon printf("}\n"); 148fa12c626SMatthew Dillon return(0); 149fa12c626SMatthew Dillon } 150fa12c626SMatthew Dillon 151fa12c626SMatthew Dillon static struct mount * 152fa12c626SMatthew Dillon dumpmount(kvm_t *kd, struct mount *mp) 153fa12c626SMatthew Dillon { 154fa12c626SMatthew Dillon struct mount mnt; 155fa12c626SMatthew Dillon struct vnode *vp; 156fa12c626SMatthew Dillon 157fa12c626SMatthew Dillon kkread(kd, (u_long)mp, &mnt, sizeof(mnt)); 158fa12c626SMatthew Dillon printf("MOUNTPOINT %s on %s {\n", 159fa12c626SMatthew Dillon mnt.mnt_stat.f_mntfromname, mnt.mnt_stat.f_mntonname); 160fa12c626SMatthew Dillon printf(" lk_flags %08x share %d wait %d excl %d holder = %p\n", 161fa12c626SMatthew Dillon mnt.mnt_lock.lk_flags, mnt.mnt_lock.lk_sharecount, 162fa12c626SMatthew Dillon mnt.mnt_lock.lk_waitcount, mnt.mnt_lock.lk_exclusivecount, 163fa12c626SMatthew Dillon mnt.mnt_lock.lk_lockholder); 164fa12c626SMatthew Dillon printf(" mnt_flag %08x mnt_kern_flag %08x\n", 165fa12c626SMatthew Dillon mnt.mnt_flag, mnt.mnt_kern_flag); 166fa12c626SMatthew Dillon printf(" mnt_nvnodelistsize %d\n", mnt.mnt_nvnodelistsize); 1677bc16b2dSMatthew Dillon printf(" mnt_stat.f_fsid %08x %08x\n", mnt.mnt_stat.f_fsid.val[0], 1687bc16b2dSMatthew Dillon mnt.mnt_stat.f_fsid.val[1]); 169fa12c626SMatthew Dillon vp = mnt.mnt_nvnodelist.tqh_first; 170fa12c626SMatthew Dillon while (vp) 171fa12c626SMatthew Dillon vp = dumpvp(kd, vp, 1); 172fa12c626SMatthew Dillon 173fa12c626SMatthew Dillon printf("}\n"); 174fa12c626SMatthew Dillon 175fa12c626SMatthew Dillon return(mnt.mnt_list.tqe_next); 176fa12c626SMatthew Dillon } 177fa12c626SMatthew Dillon 178fa12c626SMatthew Dillon static const char * 179fa12c626SMatthew Dillon vtype(enum vtype type) 180fa12c626SMatthew Dillon { 181fa12c626SMatthew Dillon static char buf[32]; 182fa12c626SMatthew Dillon 183fa12c626SMatthew Dillon switch(type) { 184fa12c626SMatthew Dillon case VNON: 185fa12c626SMatthew Dillon return("VNON"); 186fa12c626SMatthew Dillon case VREG: 187fa12c626SMatthew Dillon return("VREG"); 188fa12c626SMatthew Dillon case VDIR: 189fa12c626SMatthew Dillon return("VDIR"); 190fa12c626SMatthew Dillon case VBLK: 191fa12c626SMatthew Dillon return("VBLK"); 192fa12c626SMatthew Dillon case VCHR: 193fa12c626SMatthew Dillon return("VCHR"); 194fa12c626SMatthew Dillon case VLNK: 195fa12c626SMatthew Dillon return("VLNK"); 196fa12c626SMatthew Dillon case VSOCK: 197fa12c626SMatthew Dillon return("VSOCK"); 198fa12c626SMatthew Dillon case VFIFO: 199fa12c626SMatthew Dillon return("VFIFO"); 200fa12c626SMatthew Dillon case VBAD: 201fa12c626SMatthew Dillon return("VBAD"); 202fa12c626SMatthew Dillon default: 203fa12c626SMatthew Dillon break; 204fa12c626SMatthew Dillon } 205fa12c626SMatthew Dillon snprintf(buf, sizeof(buf), "%d", (int)type); 206fa12c626SMatthew Dillon return(buf); 207fa12c626SMatthew Dillon } 208fa12c626SMatthew Dillon 209fa12c626SMatthew Dillon static struct vnode * 210fa12c626SMatthew Dillon dumpvp(kvm_t *kd, struct vnode *vp, int whichlist) 211fa12c626SMatthew Dillon { 212fa12c626SMatthew Dillon struct vnode vn; 213fa12c626SMatthew Dillon 214fa12c626SMatthew Dillon kkread(kd, (u_long)vp, &vn, sizeof(vn)); 215fa12c626SMatthew Dillon 216d1a5d3fcSMatthew Dillon printf(" vnode %p usecnt %08x holdcnt %d type=%s flags %08x", 217d1a5d3fcSMatthew Dillon vp, vn.v_sysref.refcnt, vn.v_auxrefs, vtype(vn.v_type), vn.v_flag); 21817ba2e5aSMatthew Dillon 21917ba2e5aSMatthew Dillon if ((vn.v_flag & VOBJBUF) && vn.v_object) { 22017ba2e5aSMatthew Dillon int npages = getobjpages(kd, vn.v_object); 221ada41611SMatthew Dillon int vnpsize = getobjvnpsize(kd, vn.v_object); 222ada41611SMatthew Dillon if (npages || vnpsize) 223ada41611SMatthew Dillon printf(" vmobjpgs=%d vnpsize=%d", npages, vnpsize); 22417ba2e5aSMatthew Dillon } 22517ba2e5aSMatthew Dillon 226fa12c626SMatthew Dillon if (vn.v_flag & VROOT) 22745136f35SMatthew Dillon printf(" VROOT"); 228fa12c626SMatthew Dillon if (vn.v_flag & VTEXT) 22945136f35SMatthew Dillon printf(" VTEXT"); 230fa12c626SMatthew Dillon if (vn.v_flag & VSYSTEM) 23145136f35SMatthew Dillon printf(" VSYSTEM"); 232fa12c626SMatthew Dillon if (vn.v_flag & VISTTY) 23345136f35SMatthew Dillon printf(" VISTTY"); 23445136f35SMatthew Dillon #ifdef VXLOCK 235fa12c626SMatthew Dillon if (vn.v_flag & VXLOCK) 23645136f35SMatthew Dillon printf(" VXLOCK"); 237fa12c626SMatthew Dillon if (vn.v_flag & VXWANT) 23845136f35SMatthew Dillon printf(" VXWANT"); 23945136f35SMatthew Dillon #endif 24045136f35SMatthew Dillon #ifdef VRECLAIMED 24145136f35SMatthew Dillon if (vn.v_flag & VRECLAIMED) 24245136f35SMatthew Dillon printf(" VRECLAIMED"); 24345136f35SMatthew Dillon if (vn.v_flag & VINACTIVE) 24445136f35SMatthew Dillon printf(" VINACTIVE"); 24545136f35SMatthew Dillon #endif 246fa12c626SMatthew Dillon if (vn.v_flag & VOBJBUF) 24745136f35SMatthew Dillon printf(" VOBJBUF"); 248fa12c626SMatthew Dillon if (vn.v_flag & VAGE) 24945136f35SMatthew Dillon printf(" VAGE"); 250fa12c626SMatthew Dillon if (vn.v_flag & VOLOCK) 25145136f35SMatthew Dillon printf(" VOLOCK"); 252fa12c626SMatthew Dillon if (vn.v_flag & VOWANT) 25345136f35SMatthew Dillon printf(" VOWANT"); 25445136f35SMatthew Dillon #ifdef VDOOMED 255fa12c626SMatthew Dillon if (vn.v_flag & VDOOMED) 25645136f35SMatthew Dillon printf(" VDOOMED"); 25745136f35SMatthew Dillon #endif 258fa12c626SMatthew Dillon if (vn.v_flag & VFREE) 25945136f35SMatthew Dillon printf(" VFREE"); 260d1a5d3fcSMatthew Dillon if (vn.v_flag & VCACHED) 261d1a5d3fcSMatthew Dillon printf(" VCACHED"); 26245136f35SMatthew Dillon #ifdef VINFREE 263fa12c626SMatthew Dillon if (vn.v_flag & VINFREE) 26445136f35SMatthew Dillon printf(" VINFREE"); 26545136f35SMatthew Dillon #endif 266fa12c626SMatthew Dillon if (vn.v_flag & VONWORKLST) 26745136f35SMatthew Dillon printf(" VONWORKLST"); 268fa12c626SMatthew Dillon if (vn.v_flag & VMOUNT) 26945136f35SMatthew Dillon printf(" VMOUNT"); 270fa12c626SMatthew Dillon if (vn.v_flag & VOBJDIRTY) 27145136f35SMatthew Dillon printf(" VOBJDIRTY"); 2723661e25dSMatthew Dillon if (vn.v_flag & VMAYHAVELOCKS) 2733661e25dSMatthew Dillon printf(" VMAYHAVELOCKS"); 27417ba2e5aSMatthew Dillon 275fa12c626SMatthew Dillon printf("\n"); 276fa12c626SMatthew Dillon 277fa12c626SMatthew Dillon if (vn.v_lock.lk_sharecount || vn.v_lock.lk_waitcount || 278fa12c626SMatthew Dillon vn.v_lock.lk_exclusivecount || vn.v_lock.lk_lockholder != LK_NOTHREAD) { 279fa12c626SMatthew Dillon printf("\tlk_flags %08x share %d wait %d excl %d holder = %p\n", 280fa12c626SMatthew Dillon vn.v_lock.lk_flags, vn.v_lock.lk_sharecount, 281fa12c626SMatthew Dillon vn.v_lock.lk_waitcount, vn.v_lock.lk_exclusivecount, 282fa12c626SMatthew Dillon vn.v_lock.lk_lockholder); 283fa12c626SMatthew Dillon } 284fa12c626SMatthew Dillon 285bb87550cSMatthew Dillon if (withnames && TAILQ_FIRST(&vn.v_namecache)) { 286bb87550cSMatthew Dillon struct namecache ncp; 287bb87550cSMatthew Dillon int nlen; 288bb87550cSMatthew Dillon char buf[1024]; 289bb87550cSMatthew Dillon 290bb87550cSMatthew Dillon kkread(kd, (u_long)TAILQ_FIRST(&vn.v_namecache), &ncp, sizeof(ncp)); 291bb87550cSMatthew Dillon if ((nlen = ncp.nc_nlen) >= sizeof(buf)) 292bb87550cSMatthew Dillon nlen = sizeof(buf) - 1; 293bb87550cSMatthew Dillon if (nlen < 0) 294bb87550cSMatthew Dillon nlen = 0; 295bb87550cSMatthew Dillon if (nlen) { 296bb87550cSMatthew Dillon kkread(kd, (u_long)ncp.nc_name, buf, nlen); 297bb87550cSMatthew Dillon buf[nlen] = 0; 298bb87550cSMatthew Dillon printf("\tfilename %s\n", buf); 299bb87550cSMatthew Dillon } 300bb87550cSMatthew Dillon } 301bb87550cSMatthew Dillon 302af456e64SMatthew Dillon if (tracebufs) { 303af456e64SMatthew Dillon if (vn.v_rbclean_tree.rbh_root) { 304af456e64SMatthew Dillon printf("\tCLEAN BUFFERS\n"); 305af456e64SMatthew Dillon dumpbufs(kd, vn.v_rbclean_tree.rbh_root, "ROOT"); 306af456e64SMatthew Dillon } 307af456e64SMatthew Dillon if (vn.v_rbdirty_tree.rbh_root) { 308af456e64SMatthew Dillon printf("\tDIRTY BUFFERS\n"); 309af456e64SMatthew Dillon dumpbufs(kd, vn.v_rbdirty_tree.rbh_root, "ROOT"); 310af456e64SMatthew Dillon } 311af456e64SMatthew Dillon } 312af456e64SMatthew Dillon 3133661e25dSMatthew Dillon if (tracelocks) { 3143661e25dSMatthew Dillon if (vn.v_tag == VT_UFS && vn.v_data) { 3153661e25dSMatthew Dillon struct inode *ip = vn.v_data; 3163661e25dSMatthew Dillon struct lockf lockf; 3173661e25dSMatthew Dillon 3183661e25dSMatthew Dillon kkread(kd, (u_long)&ip->i_lockf, &lockf, sizeof(lockf)); 3193661e25dSMatthew Dillon dumplocks(kd, &lockf); 3203661e25dSMatthew Dillon } 3213661e25dSMatthew Dillon } 3223661e25dSMatthew Dillon 3233661e25dSMatthew Dillon 324fa12c626SMatthew Dillon if (whichlist) 325fa12c626SMatthew Dillon return(vn.v_nmntvnodes.tqe_next); 326fa12c626SMatthew Dillon else 327fa12c626SMatthew Dillon return(vn.v_freelist.tqe_next); 328fa12c626SMatthew Dillon } 329fa12c626SMatthew Dillon 330af456e64SMatthew Dillon static void 331af456e64SMatthew Dillon dumpbufs(kvm_t *kd, void *bufp, const char *id) 332af456e64SMatthew Dillon { 333af456e64SMatthew Dillon struct buf buf; 334af456e64SMatthew Dillon 335af456e64SMatthew Dillon kkread(kd, (u_long)bufp, &buf, sizeof(buf)); 336*fa06bda9SMatthew Dillon printf("\t %-8s %p loffset %012llx foffset %08llx", 337af456e64SMatthew Dillon id, bufp, 338e36e284dSMatthew Dillon buf.b_bio1.bio_offset, 339e36e284dSMatthew Dillon buf.b_bio2.bio_offset); 340*fa06bda9SMatthew Dillon printf(" q=%d lck=%d/%d flags=%08x dep=%p", 341*fa06bda9SMatthew Dillon buf.b_qindex, buf.b_lock.lk_sharecount, 342*fa06bda9SMatthew Dillon buf.b_lock.lk_exclusivecount, 343*fa06bda9SMatthew Dillon buf.b_flags, buf.b_dep.lh_first); 344*fa06bda9SMatthew Dillon printf("\n"); 345af456e64SMatthew Dillon 346af456e64SMatthew Dillon if (buf.b_rbnode.rbe_left) 347af456e64SMatthew Dillon dumpbufs(kd, buf.b_rbnode.rbe_left, "LEFT"); 348af456e64SMatthew Dillon if (buf.b_rbnode.rbe_right) 349af456e64SMatthew Dillon dumpbufs(kd, buf.b_rbnode.rbe_right, "RIGHT"); 350af456e64SMatthew Dillon } 351af456e64SMatthew Dillon 3523661e25dSMatthew Dillon static void 3533661e25dSMatthew Dillon dumplocks(kvm_t *kd, struct lockf *lockf) 3543661e25dSMatthew Dillon { 3553661e25dSMatthew Dillon struct lockf_range item; 3563661e25dSMatthew Dillon struct lockf_range *scan; 3573661e25dSMatthew Dillon 3583661e25dSMatthew Dillon if ((scan = TAILQ_FIRST(&lockf->lf_range)) != NULL) { 3593661e25dSMatthew Dillon printf("\tLOCKS\n"); 3603661e25dSMatthew Dillon do { 3613661e25dSMatthew Dillon kkread(kd, (u_long)scan, &item, sizeof(item)); 3623661e25dSMatthew Dillon dumplockinfo(kd, &item); 3633661e25dSMatthew Dillon } while ((scan = TAILQ_NEXT(&item, lf_link)) != NULL); 3643661e25dSMatthew Dillon printf("\n"); 3653661e25dSMatthew Dillon } 3663661e25dSMatthew Dillon if ((scan = TAILQ_FIRST(&lockf->lf_blocked)) != NULL) { 3673661e25dSMatthew Dillon printf("\tBLKED\n"); 3683661e25dSMatthew Dillon do { 3693661e25dSMatthew Dillon kkread(kd, (u_long)scan, &item, sizeof(item)); 3703661e25dSMatthew Dillon dumplockinfo(kd, &item); 3713661e25dSMatthew Dillon } while ((scan = TAILQ_NEXT(&item, lf_link)) != NULL); 3723661e25dSMatthew Dillon printf("\n"); 3733661e25dSMatthew Dillon } 3743661e25dSMatthew Dillon 3753661e25dSMatthew Dillon } 3763661e25dSMatthew Dillon 3773661e25dSMatthew Dillon static void 3783661e25dSMatthew Dillon dumplockinfo(kvm_t *kd, struct lockf_range *item) 3793661e25dSMatthew Dillon { 3803661e25dSMatthew Dillon int ownerpid; 3813661e25dSMatthew Dillon 3823661e25dSMatthew Dillon if (item->lf_owner && (item->lf_flags & F_POSIX)) { 3833661e25dSMatthew Dillon kkread(kd, (u_long)&item->lf_owner->p_pid, 3843661e25dSMatthew Dillon &ownerpid, sizeof(ownerpid)); 3853661e25dSMatthew Dillon } else { 3863661e25dSMatthew Dillon ownerpid = -1; 3873661e25dSMatthew Dillon } 3883661e25dSMatthew Dillon 3893661e25dSMatthew Dillon printf("\t ty=%d flgs=%04x %lld-%lld owner=%d\n", 3903661e25dSMatthew Dillon item->lf_type, item->lf_flags, 3913661e25dSMatthew Dillon item->lf_start, item->lf_end, 3923661e25dSMatthew Dillon ownerpid 3933661e25dSMatthew Dillon ); 3943661e25dSMatthew Dillon } 3953661e25dSMatthew Dillon 39617ba2e5aSMatthew Dillon static 39717ba2e5aSMatthew Dillon int 39817ba2e5aSMatthew Dillon getobjpages(kvm_t *kd, struct vm_object *obj) 39917ba2e5aSMatthew Dillon { 40017ba2e5aSMatthew Dillon struct vm_object vmobj; 40117ba2e5aSMatthew Dillon 40217ba2e5aSMatthew Dillon kkread(kd, (u_long)obj, &vmobj, sizeof(vmobj)); 40317ba2e5aSMatthew Dillon return(vmobj.resident_page_count); 40417ba2e5aSMatthew Dillon } 40517ba2e5aSMatthew Dillon 406ada41611SMatthew Dillon static 407ada41611SMatthew Dillon int 408ada41611SMatthew Dillon getobjvnpsize(kvm_t *kd, struct vm_object *obj) 409ada41611SMatthew Dillon { 410ada41611SMatthew Dillon struct vm_object vmobj; 411ada41611SMatthew Dillon 412ada41611SMatthew Dillon kkread(kd, (u_long)obj, &vmobj, sizeof(vmobj)); 413e36e284dSMatthew Dillon return ((int)vmobj.size); 414ada41611SMatthew Dillon } 415ada41611SMatthew Dillon 41617ba2e5aSMatthew Dillon static void 417fa12c626SMatthew Dillon kkread(kvm_t *kd, u_long addr, void *buf, size_t nbytes) 418fa12c626SMatthew Dillon { 419fa12c626SMatthew Dillon if (kvm_read(kd, addr, buf, nbytes) != nbytes) { 420fa12c626SMatthew Dillon perror("kvm_read"); 421fa12c626SMatthew Dillon exit(1); 422fa12c626SMatthew Dillon } 423fa12c626SMatthew Dillon } 424fa12c626SMatthew Dillon 425