findSlop: useful function for tracking down excessive slop in gdb
authorsimonmar@microsoft.com <unknown>
Fri, 14 Dec 2007 13:59:09 +0000 (13:59 +0000)
committersimonmar@microsoft.com <unknown>
Fri, 14 Dec 2007 13:59:09 +0000 (13:59 +0000)
rts/sm/Storage.c

index ecd9b54..2305996 100644 (file)
@@ -1118,6 +1118,21 @@ void freeExec (void *addr)
 
 #ifdef DEBUG
 
+// Useful for finding partially full blocks in gdb
+void findSlop(bdescr *bd);
+void findSlop(bdescr *bd)
+{
+    lnat slop;
+
+    for (; bd != NULL; bd = bd->link) {
+        slop = (bd->blocks * BLOCK_SIZE_W) - (bd->free - bd->start);
+        if (slop > (1024/sizeof(W_))) {
+            debugBelch("block at %p (bdescr %p) has %ldKB slop\n",
+                       bd->start, bd, slop / (1024/sizeof(W_)));
+        }
+    }
+}
+
 nat
 countBlocks(bdescr *bd)
 {