+int searched = 0;
+
+static int
+findPtrBlocks (StgPtr p, bdescr *bd, StgPtr arr[], int arr_size, int i)
+{
+ StgPtr q, r;
+ for (; bd; bd = bd->link) {
+ searched++;
+ for (q = bd->start; q < bd->free; q++) {
+ if (UNTAG_CLOSURE((StgClosure*)*q) == (StgClosure *)p) {
+ if (i < arr_size) {
+ r = q;
+ while (HEAP_ALLOCED((StgPtr)*r) || !LOOKS_LIKE_INFO_PTR(*r) || (P_)*r == NULL) {
+ r--;
+ }
+ debugBelch("%p = ", r);
+ printClosure((StgClosure *)r);
+ arr[i++] = r;
+ } else {
+ return i;
+ }
+ }
+ }
+ }
+ return i;
+}
+