summaryrefslogtreecommitdiff
path: root/sys/gdbscripts/bdump
blob: 49d116001c4fef9629f63fdadbdba85e40e1ff6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#	$NetBSD: bdump,v 1.2 1997/02/12 23:35:06 gwr Exp $

# Count the number of buffers in the buffer cache for which
# bp->b_flags & $bufcount_match is non-0.
#
#	@(#)bdump	8.1 (Berkeley) 6/10/93

set $bufcount_match=0x020000
define bufcount

	set $i = 0
	set $num = 0

	while ($i < 512)

		set $bp = bufhash[$i].b_forw
		while ($bp != bufhash[$i].b_back)
			if ($bp->b_flags & $bufcount_match)
				set $num++
			end
			set $bp = $bp->b_forw
		end
		# printf "bucket: %d cumulative %d\n", $i, $num
		set $i++
	end
	printf "Number of buffers with flags & %x in hash table: %d\n", $bufcount_match, $num
end

# Dump the entire buffer cache.

define bufdump

	set $i = 0
	set $num = 0

	while ($i < 512)

		set $bp = bufhash[$i].b_forw
		while ($bp != bufhash[$i].b_back)
			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
			set $num++
			set $bp = $bp->b_forw
		end
		set $i++
	end
	printf "Number of buffers in hash table: %d\n", $num
end

# Dump the buffers in a particular hashbucket.
# usage: dumpbucket bucketnumber
define dumpbucket

	set $num = 0
	set $bp = bufhash[$arg0].b_forw
	while ($bp != bufhash[$arg0].b_back)
		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
		set $num++
		set $bp = $bp->b_forw
	end
	printf "Number of buffers in bucket %d: %d\n", $arg0, $num
end

# Dump the buffers on the empty and age queues

define bdumpnew

	set $i = 0
	set $num = 0

	while ($i < 4)

		printf "Queue %d\n", $i
		set $bp = (struct buf *)bufqueues[$i].qe_next
		while ($bp)
			printf "bp=0x%x flags=0x%x vp=0x%x lbn=%d size=0x%x\n", $bp, $bp->b_flags, $bp->b_vp, $bp->b_lblkno, $bp->b_bufsize
			set $num++
			set $bp = (struct buf *)$bp->b_freelist.qe_next
		end
		set $i++
	end
	printf "Number of buffers in free lists: %d\n", $num
end

define dumpchain

	set $bp = (struct buf *)$arg0
	while ($bp)
		printf "bp=0x%x flags=0x%x bn=0x%x lbn=%d count=%d size=%d\n", $bp, $bp->b_flags, $bp->b_blkno, $bp->b_lblkno, $bp->b_bcount, $bp->b_bufsize
		set $bp = (struct buf *)$bp->b_vnbufs.qe_next
	end
end

define dumpq

	set $num = 0

	printf "Queue %d\n", $arg0
	set $bp = (struct buf *)bufqueues[$arg0].qe_next
	while ($bp)
		printf "bp=0x%x flags=0x%x vp=0x%x lbn=%d size=0x%x\n", $bp, $bp->b_flags, $bp->b_vp, $bp->b_lblkno, $bp->b_bufsize
		set $num++
		set $bp = (struct buf *)$bp->b_freelist.qe_next
	end
	printf "Number of buffers on queue %d: %d\n", $arg0, $num
end