/* -----------------------------------------------------------------------------
- * $Id: ProfHeap.c,v 1.44 2003/03/18 14:36:56 simonmar Exp $
+ * $Id: ProfHeap.c,v 1.50 2003/11/12 17:49:08 sof Exp $
*
* (c) The GHC Team, 1998-2003
*
struct _counter *next;
} counter;
-static inline void
+STATIC_INLINE void
initLDVCtr( counter *ctr )
{
ctr->c.ldv.prim = 0;
* 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) {
* 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
/* --------------------------------------------------------------------------
* Initialize censuses[era];
* ----------------------------------------------------------------------- */
-static inline void
+STATIC_INLINE void
initEra(Census *census)
{
census->hash = allocHashTable();
#ifdef DEBUG_HEAP_PROF
FILE *hp_file;
+static char *hp_filename;
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();
}
initEra( &censuses[era] );
- fprintf(hp_file, "JOB \"%s", prog_argv[0]);
+ /* initProfilingLogFile(); */
+ fprintf(hp_file, "JOB \"%s", prog_name);
#ifdef PROFILING
{
fprintf(hp_file, "END_SAMPLE 0.00\n");
#ifdef DEBUG_HEAP_PROF
- DEBUG_LoadSymbols(prog_argv[0]);
+ DEBUG_LoadSymbols(prog_name);
#endif
#ifdef PROFILING
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);
case FUN:
case THUNK:
case IND_PERM:
+ case IND_OLDGEN:
case IND_OLDGEN_PERM:
case CAF_BLACKHOLE:
case SE_CAF_BLACKHOLE:
break;
case BCO:
+ prim = rtsTrue;
+ size = bco_sizeW((StgBCO *)p);
+ break;
+
case MVAR:
case WEAK:
case FOREIGN: