No empty .Rs/.Re
[netbsd-mini2440.git] / sys / gdbscripts / bdump
blob3639f6da7df70d12f79add65e7e2a10eb057a468
1 #       $NetBSD$
3 # Count the number of buffers in the buffer cache for which
4 # bp->b_flags & $bufcount_match is non-0.
6 #       @(#)bdump       8.1 (Berkeley) 6/10/93
8 set $bufcount_match=0x020000
9 define bufcount
11         set $i = 0
12         set $num = 0
14         while ($i < 512)
16                 set $bp = bufhash[$i].b_forw
17                 while ($bp != bufhash[$i].b_back)
18                         if ($bp->b_flags & $bufcount_match)
19                                 set $num++
20                         end
21                         set $bp = $bp->b_forw
22                 end
23                 # printf "bucket: %d cumulative %d\n", $i, $num
24                 set $i++
25         end
26         printf "Number of buffers with flags & %x in hash table: %d\n", $bufcount_match, $num
27 end
29 # Dump the entire buffer cache.
31 define bufdump
33         set $i = 0
34         set $num = 0
36         while ($i < 512)
38                 set $bp = bufhash[$i].b_forw
39                 while ($bp != bufhash[$i].b_back)
40                         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
41                         set $num++
42                         set $bp = $bp->b_forw
43                 end
44                 set $i++
45         end
46         printf "Number of buffers in hash table: %d\n", $num
47 end
49 # Dump the buffers in a particular hashbucket.
50 # usage: dumpbucket bucketnumber
51 define dumpbucket
53         set $num = 0
54         set $bp = bufhash[$arg0].b_forw
55         while ($bp != bufhash[$arg0].b_back)
56                 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
57                 set $num++
58                 set $bp = $bp->b_forw
59         end
60         printf "Number of buffers in bucket %d: %d\n", $arg0, $num
61 end
63 # Dump the buffers on the empty and age queues
65 define bdumpnew
67         set $i = 0
68         set $num = 0
70         while ($i < 4)
72                 printf "Queue %d\n", $i
73                 set $bp = (struct buf *)bufqueues[$i].qe_next
74                 while ($bp)
75                         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
76                         set $num++
77                         set $bp = (struct buf *)$bp->b_freelist.qe_next
78                 end
79                 set $i++
80         end
81         printf "Number of buffers in free lists: %d\n", $num
82 end
84 define dumpchain
86         set $bp = (struct buf *)$arg0
87         while ($bp)
88                 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
89                 set $bp = (struct buf *)$bp->b_vnbufs.qe_next
90         end
91 end
93 define dumpq
95         set $num = 0
97         printf "Queue %d\n", $arg0
98         set $bp = (struct buf *)bufqueues[$arg0].qe_next
99         while ($bp)
100                 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
101                 set $num++
102                 set $bp = (struct buf *)$bp->b_freelist.qe_next
103         end
104         printf "Number of buffers on queue %d: %d\n", $arg0, $num