From: simonmar Date: Wed, 14 Jul 1999 13:44:19 +0000 (+0000) Subject: [project @ 1999-07-14 13:44:19 by simonmar] X-Git-Tag: Approximately_9120_patches~5988 X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=commitdiff_plain;h=0b127ebe6beecf69e0e429b722c645d73d4755df [project @ 1999-07-14 13:44:19 by simonmar] - Add findPtr() - searches through the heap for an occurrence of a given value. Useful when debugging. --- diff --git a/ghc/rts/Printer.c b/ghc/rts/Printer.c index 3fe0313..8be29aa 100644 --- a/ghc/rts/Printer.c +++ b/ghc/rts/Printer.c @@ -1,6 +1,6 @@ /* ----------------------------------------------------------------------------- - * $Id: Printer.c,v 1.14 1999/06/29 13:04:39 panne Exp $ + * $Id: Printer.c,v 1.15 1999/07/14 13:44:19 simonmar Exp $ * * Copyright (c) 1994-1999. * @@ -822,6 +822,28 @@ extern void DEBUG_LoadSymbols( char *name ) #endif /* HAVE_BFD_H */ +#include "StoragePriv.h" + +void +findPtr(P_ p) +{ + nat s, g; + P_ q; + bdescr *bd; + + for (g = 0; g < RtsFlags.GcFlags.generations; g++) { + for (s = 0; s < generations[g].n_steps; s++) { + for (bd = generations[g].steps[s].blocks; bd; bd = bd->link) { + for (q = bd->start; q < bd->free; q++) { + if (*q == (W_)p) { + printf("%p\n", q); + } + } + } + } + } +} + #else /* DEBUG */ void printPtr( StgPtr p ) {