xref: /original-bsd/sys/scripts/bdump (revision 860e07fc)
1# Count the number of buffers in the buffer cache for which
2# bp->b_flags & $bufcount_match is non-0.
3#
4#	@(#)bdump	7.1 (Berkeley) 08/02/92
5
6set $bufcount_match=0x020000
7define bufcount
8
9	set $i = 0
10	set $num = 0
11
12	while ($i < 512)
13
14		set $bp = bufhash[$i].b_forw
15		while ($bp != bufhash[$i].b_back)
16			if ($bp->b_flags & $bufcount_match)
17				set $num++
18			end
19			set $bp = $bp->b_forw
20		end
21		# printf "bucket: %d cumulative %d\n", $i, $num
22		set $i++
23	end
24	printf "Number of buffers with flags & %x in hash table: %d\n", $bufcount_match, $num
25end
26
27# Dump the entire buffer cache.
28
29define bufdump
30
31	set $i = 0
32	set $num = 0
33
34	while ($i < 512)
35
36		set $bp = bufhash[$i].b_forw
37		while ($bp != bufhash[$i].b_back)
38			printf "bp=0x%x flags=0x%x vp=0x%x lblkno=0x%x blkno=0x%x\n", $bp, $bp->b_flags, $bp->b_vp, $bp->b_lblkno, $bp->b_blkno
39			set $num++
40			set $bp = $bp->b_forw
41		end
42		set $i++
43	end
44	printf "Number of buffers in hash table: %d\n", $num
45end
46
47# Dump the buffers in a particular hashbucket.
48# usage: dumpbucket bucketnumber
49define dumpbucket
50
51	set $num = 0
52	set $bp = bufhash[$arg0].b_forw
53	while ($bp != bufhash[$arg0].b_back)
54		printf "bp=0x%x flags=0x%x vp=0x%x lblkno=0x%x blkno=0x%x\n", $bp, $bp->b_flags, $bp->b_vp, $bp->b_lblkno, $bp->b_blkno
55		set $num++
56		set $bp = $bp->b_forw
57	end
58	printf "Number of buffers in bucket %d: %d\n", $arg0, $num
59end
60