xref: /netbsd-src/sys/gdbscripts/vchain (revision e89934bbf778a6d6d6894877c4da59d0c7835b0f)
1#	$NetBSD: vchain,v 1.8 2016/12/14 15:48:55 hannken Exp $
2
3#	@(#)vchain	8.1 (Berkeley) 6/10/93
4#
5
6define vchain
7	set $num = 0
8
9	set $vp=(struct vnode *)$arg0
10	set $vi=(struct vnode_impl *)$arg0
11	while ($vp)
12		printf "vp: 0x%lx lrulist_next: 0x%lx usecount: %d flags: i:0x%x v:0x%x u:0x%x\n",\
13		       $vp, $vi->vi_lrulist.tqe_next, $vp->v_uobj.uo_refs, \
14		       $vp->v_iflag, $vp->v_vflag, $vp->v_uflag
15		set $num++
16		set $vp = $vp->v_mntvnodes.tqe_next
17	end
18	printf "Number of vnodes: %d\n", $num
19end
20
21document vchain
22Given a vnode, follow its mount pointers
23end
24
25define vprint
26	set $vp=(struct vnode *)$arg0
27	set $ip=(struct inode *)$vp->v_data
28end
29
30define mp_vchain
31	set $mp = (struct mount *)$arg0
32	vchain $mp->mnt_vnodelist.tqh_first
33end
34document mp_vchain
35print the vnode chain for a given mount point
36end
37
38define vall
39	set $mp=mountlist.tqh_first
40	while ($mp)
41		printf "\tmount point at 0x%x\n", $mp
42		mp_vchain $mp
43		set $mp=$mp->mnt_list.tqe_next
44
45		# "break"
46		if ((const void *)$mp == (const void *)&mountlist)
47			set $mp = 0
48		end
49	end
50end
51document vall
52print vnode chains for all mount points
53end
54
55define mountdump
56	set $mp=mountlist.tqh_first
57	while ($mp)
58		printf "%s on %s type %s, (mp 0x%x, privdata 0x%x)\n", \
59		    $mp->mnt_stat->f_mntfromname, $mp->mnt_stat->f_mntonname, \
60		    $mp->mnt_op->vfs_name, $mp, $mp->mnt_data
61		set $mp=$mp->mnt_list.tqe_next
62		if ((const void *)$mp == (const void *)&mountlist)
63			set $mp = 0
64		end
65	end
66end
67