X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Frts%2FProfHeap.c;h=837591bf46e6a28b5dfb6de9389befd6dee31346;hb=272a418428beede04a9c4ae027474878c59d6ca1;hp=e0979a4eed9d2fe5c1518974aa9bedb1dd55d304;hpb=32f4da4f221388d4b429d865ee7916bfb7450de3;p=ghc-hetmet.git diff --git a/ghc/rts/ProfHeap.c b/ghc/rts/ProfHeap.c index e0979a4..837591b 100644 --- a/ghc/rts/ProfHeap.c +++ b/ghc/rts/ProfHeap.c @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: ProfHeap.c,v 1.46 2003/05/16 14:16:53 simonmar Exp $ + * $Id: ProfHeap.c,v 1.50 2003/11/12 17:49:08 sof Exp $ * * (c) The GHC Team, 1998-2003 * @@ -72,7 +72,7 @@ typedef struct _counter { struct _counter *next; } counter; -static inline void +STATIC_INLINE void initLDVCtr( counter *ctr ) { ctr->c.ldv.prim = 0; @@ -177,7 +177,7 @@ static char *type_names[] = { * the band to which this closure's heap space is attributed in the * heap profile. * ------------------------------------------------------------------------- */ -static inline void * +STATIC_INLINE void * closureIdentity( StgClosure *p ) { switch (RtsFlags.ProfFlags.doHeapProfile) { @@ -215,14 +215,14 @@ closureIdentity( StgClosure *p ) * Profiling type predicates * ----------------------------------------------------------------------- */ #ifdef PROFILING -static inline rtsBool +STATIC_INLINE rtsBool doingLDVProfiling( void ) { return (RtsFlags.ProfFlags.doHeapProfile == HEAP_BY_LDV || RtsFlags.ProfFlags.bioSelector != NULL); } -static inline rtsBool +STATIC_INLINE rtsBool doingRetainerProfiling( void ) { return (RtsFlags.ProfFlags.doHeapProfile == HEAP_BY_RETAINER @@ -304,7 +304,7 @@ LDV_recordDead( StgClosure *c, nat size ) /* -------------------------------------------------------------------------- * Initialize censuses[era]; * ----------------------------------------------------------------------- */ -static inline void +STATIC_INLINE void initEra(Census *census) { census->hash = allocHashTable(); @@ -351,6 +351,7 @@ nextEra( void ) #ifdef DEBUG_HEAP_PROF FILE *hp_file; +static char *hp_filename; void initProfiling1( void ) { @@ -358,6 +359,20 @@ void initProfiling1( void ) void initProfiling2( void ) { + if (RtsFlags.ProfFlags.doHeapProfile) { + /* Initialise the log file name */ + hp_filename = stgMallocBytes(strlen(prog_name) + 6, "hpFileName"); + sprintf(hp_filename, "%s.hp", prog_name); + + /* open the log file */ + if ((hp_file = fopen(hp_filename, "w")) == NULL) { + fprintf(stderr, "Can't open profiling report file %s\n", + hp_filename); + RtsFlags.ProfFlags.doHeapProfile = 0; + return; + } + } + initHeapProfiling(); } @@ -407,7 +422,8 @@ initHeapProfiling(void) initEra( &censuses[era] ); - fprintf(hp_file, "JOB \"%s", prog_argv[0]); + /* initProfilingLogFile(); */ + fprintf(hp_file, "JOB \"%s", prog_name); #ifdef PROFILING { @@ -432,7 +448,7 @@ initHeapProfiling(void) fprintf(hp_file, "END_SAMPLE 0.00\n"); #ifdef DEBUG_HEAP_PROF - DEBUG_LoadSymbols(prog_argv[0]); + DEBUG_LoadSymbols(prog_name); #endif #ifdef PROFILING @@ -825,6 +841,15 @@ heapCensusChain( Census *census, bdescr *bd ) rtsBool prim; for (; bd != NULL; bd = bd->link) { + + // HACK: ignore pinned blocks, because they contain gaps. + // It's not clear exactly what we'd like to do here, since we + // can't tell which objects in the block are actually alive. + // Perhaps the whole block should be counted as SYSTEM memory. + if (bd->flags & BF_PINNED) { + continue; + } + p = bd->start; while (p < bd->free) { info = get_itbl((StgClosure *)p);