155817Sbostic# Count the number of buffers in the buffer cache for which 255817Sbostic# bp->b_flags & $bufcount_match is non-0. 355817Sbostic# 4*63238Sbostic# @(#)bdump 8.1 (Berkeley) 06/10/93 555817Sbostic 655817Sbosticset $bufcount_match=0x020000 755817Sbosticdefine bufcount 855817Sbostic 955817Sbostic set $i = 0 1055817Sbostic set $num = 0 1155817Sbostic 1255817Sbostic while ($i < 512) 1355817Sbostic 1455817Sbostic set $bp = bufhash[$i].b_forw 1555817Sbostic while ($bp != bufhash[$i].b_back) 1655817Sbostic if ($bp->b_flags & $bufcount_match) 1755817Sbostic set $num++ 1855817Sbostic end 1955817Sbostic set $bp = $bp->b_forw 2055817Sbostic end 2155817Sbostic # printf "bucket: %d cumulative %d\n", $i, $num 2255817Sbostic set $i++ 2355817Sbostic end 2455817Sbostic printf "Number of buffers with flags & %x in hash table: %d\n", $bufcount_match, $num 2555817Sbosticend 2655817Sbostic 2755817Sbostic# Dump the entire buffer cache. 2855817Sbostic 2955817Sbosticdefine bufdump 3055817Sbostic 3155817Sbostic set $i = 0 3255817Sbostic set $num = 0 3355817Sbostic 3455817Sbostic while ($i < 512) 3555817Sbostic 3655817Sbostic set $bp = bufhash[$i].b_forw 3755817Sbostic while ($bp != bufhash[$i].b_back) 3855817Sbostic 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 3955817Sbostic set $num++ 4055817Sbostic set $bp = $bp->b_forw 4155817Sbostic end 4255817Sbostic set $i++ 4355817Sbostic end 4455817Sbostic printf "Number of buffers in hash table: %d\n", $num 4555817Sbosticend 4655817Sbostic 4755817Sbostic# Dump the buffers in a particular hashbucket. 4855817Sbostic# usage: dumpbucket bucketnumber 4955817Sbosticdefine dumpbucket 5055817Sbostic 5155817Sbostic set $num = 0 5255817Sbostic set $bp = bufhash[$arg0].b_forw 5355817Sbostic while ($bp != bufhash[$arg0].b_back) 5455817Sbostic 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 5555817Sbostic set $num++ 5655817Sbostic set $bp = $bp->b_forw 5755817Sbostic end 5855817Sbostic printf "Number of buffers in bucket %d: %d\n", $arg0, $num 5955817Sbosticend 6057708Sbostic 6157708Sbostic# Dump the buffers on the empty and age queues 6257708Sbostic 6357708Sbosticdefine bdumpnew 6457708Sbostic 6557708Sbostic set $i = 0 6657708Sbostic set $num = 0 6757708Sbostic 6857708Sbostic while ($i < 4) 6957708Sbostic 7057708Sbostic printf "Queue %d\n", $i 7157708Sbostic set $bp = (struct buf *)bufqueues[$i].qe_next 7257708Sbostic while ($bp) 7357708Sbostic 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 7457708Sbostic set $num++ 7557708Sbostic set $bp = (struct buf *)$bp->b_freelist.qe_next 7657708Sbostic end 7757708Sbostic set $i++ 7857708Sbostic end 7957708Sbostic printf "Number of buffers in free lists: %d\n", $num 8057708Sbosticend 8157708Sbostic 8257708Sbosticdefine dumpchain 8357708Sbostic 8457708Sbostic set $bp = (struct buf *)$arg0 8557708Sbostic while ($bp) 8657708Sbostic 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 8757708Sbostic set $bp = (struct buf *)$bp->b_vnbufs.qe_next 8857708Sbostic end 8957708Sbosticend 9057708Sbostic 9157708Sbosticdefine dumpq 9257708Sbostic 9357708Sbostic set $num = 0 9457708Sbostic 9557708Sbostic printf "Queue %d\n", $arg0 9657708Sbostic set $bp = (struct buf *)bufqueues[$arg0].qe_next 9757708Sbostic while ($bp) 9857708Sbostic 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 9957708Sbostic set $num++ 10057708Sbostic set $bp = (struct buf *)$bp->b_freelist.qe_next 10157708Sbostic end 10257708Sbostic printf "Number of buffers on queue %d: %d\n", $arg0, $num 10357708Sbosticend 104