date and time created 92/08/02 19:56:36 by bostic
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Mon, 3 Aug 1992 10:56:36 +0000 (02:56 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Mon, 3 Aug 1992 10:56:36 +0000 (02:56 -0800)
SCCS-vsn: sys/scripts/bdump 7.1

usr/src/sys/scripts/bdump [new file with mode: 0644]

diff --git a/usr/src/sys/scripts/bdump b/usr/src/sys/scripts/bdump
new file mode 100644 (file)
index 0000000..f50101b
--- /dev/null
@@ -0,0 +1,59 @@
+# Count the number of buffers in the buffer cache for which
+# bp->b_flags & $bufcount_match is non-0.
+#
+#      @(#)bdump       7.1 (Berkeley) %G%
+
+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