Commit f1829925 authored by simonmar's avatar simonmar
Browse files

[project @ 2001-11-28 15:43:23 by simonmar]

Make it work in a DEBUG world again (when DEBUG is on we have ancient
support for doing a heap profile based on info-tables - it is still
there, but I haven't tested it).
parent a4e17de6
/* -----------------------------------------------------------------------------
* $Id: Printer.c,v 1.48 2001/11/20 16:17:23 simonmar Exp $
* $Id: Printer.c,v 1.49 2001/11/28 15:43:23 simonmar Exp $
*
* (c) The GHC Team, 1994-2000.
*
......@@ -41,7 +41,7 @@ static rtsBool lookup_name ( char *name, unsigned *result );
static void enZcode ( char *in, char *out );
#endif
static char unZcode ( char ch );
rtsBool lookupGHCName ( StgPtr addr, const char **result );
const char * lookupGHCName ( void *addr );
static void printZcoded ( const char *raw );
/* --------------------------------------------------------------------------
......@@ -51,7 +51,8 @@ static void printZcoded ( const char *raw );
void printPtr( StgPtr p )
{
const char *raw;
if (lookupGHCName( p, &raw )) {
raw = lookupGHCName(p);
if (raw != NULL) {
printZcoded(raw);
} else {
fprintf(stdout, "%p", p);
......@@ -798,16 +799,15 @@ static void enZcode( char *in, char *out )
}
#endif
rtsBool lookupGHCName( StgPtr addr, const char **result )
const char *lookupGHCName( void *addr )
{
nat i;
for( i = 0; i < table_size && table[i].value != (unsigned) addr; ++i ) {
}
if (i < table_size) {
*result = table[i].name;
return rtsTrue;
return table[i].name;
} else {
return rtsFalse;
return NULL;
}
}
......
/* -----------------------------------------------------------------------------
* $Id: Printer.h,v 1.5 2000/01/14 14:56:40 simonmar Exp $
* $Id: Printer.h,v 1.6 2001/11/28 15:43:23 simonmar Exp $
*
* (c) The GHC Team, 1998-2000
*
......@@ -24,5 +24,5 @@ char * info_type_by_ip ( StgInfoTable *ip );
extern void DEBUG_LoadSymbols( char *name );
extern rtsBool lookupGHCName( StgPtr addr, const char **result );
extern const char *lookupGHCName( void *addr );
#endif
/* -----------------------------------------------------------------------------
* $Id: ProfHeap.c,v 1.29 2001/11/28 15:01:02 simonmar Exp $
* $Id: ProfHeap.c,v 1.30 2001/11/28 15:43:23 simonmar Exp $
*
* (c) The GHC Team, 1998-2000
*
......@@ -28,11 +28,7 @@
#include "RetainerProfile.h"
#include "LdvProfile.h"
#include "Arena.h"
#ifdef DEBUG_HEAP_PROF
#include "Printer.h"
static void fprint_data(FILE *fp);
#endif
/* -----------------------------------------------------------------------------
* era stores the current time period. It is the same as the
......@@ -338,7 +334,9 @@ nextEra( void )
initEra( &censuses[era] );
}
/* -------------------------------------------------------------------------- */
/* -----------------------------------------------------------------------------
* DEBUG heap profiling, by info table
* -------------------------------------------------------------------------- */
#ifdef DEBUG_HEAP_PROF
FILE *hp_file;
......@@ -358,6 +356,9 @@ void endProfiling( void )
}
#endif /* DEBUG_HEAP_PROF */
/* --------------------------------------------------------------------------
* Initialize the heap profilier
* ----------------------------------------------------------------------- */
nat
initHeapProfiling(void)
{
......@@ -536,12 +537,18 @@ str_matches_selector( char* str, char* sel )
if (*sel == '\0') return rtsFalse;
}
}
#endif // PROFILING
// Figure out whether a closure should be counted in this census, by
// testing against all the specified constraints.
/* -----------------------------------------------------------------------------
* Figure out whether a closure should be counted in this census, by
* testing against all the specified constraints.
* -------------------------------------------------------------------------- */
rtsBool
closureSatisfiesConstraints( StgClosure* p )
{
#ifdef DEBUG_HEAP_PROF
return rtsTrue;
#else
rtsBool b;
if (RtsFlags.ProfFlags.modSelector) {
b = str_matches_selector( ((StgClosure *)p)->header.prof.ccs->cc->module,
......@@ -577,8 +584,8 @@ closureSatisfiesConstraints( StgClosure* p )
return rtsFalse;
}
return rtsTrue;
}
#endif /* PROFILING */
}
/* -----------------------------------------------------------------------------
* Aggregate the heap census info for biographical profiling
......@@ -725,10 +732,10 @@ dumpCensus( Census *census )
#ifdef DEBUG_HEAP_PROF
switch (RtsFlags.ProfFlags.doHeapProfile) {
case HEAP_BY_INFOPTR:
fprint_data(hp_file);
fprintf(hp_file, "%s", lookupGHCName(ctr->identity));
break;
case HEAP_BY_CLOSURE_TYPE:
fprint_closure_types(hp_file);
fprintf(hp_file, "%s", (char *)ctr->identity);
break;
}
#endif
......@@ -955,7 +962,9 @@ heapCensus( void )
}
#endif
#ifdef PROFILING
stat_startHeapCensus();
#endif
// traverse the heap, collecting the census info
heapCensusChain( census, small_alloc_list );
......@@ -998,7 +1007,9 @@ heapCensus( void )
// we're into the next time period now
nextEra();
#ifdef PROFILING
stat_endHeapCensus();
#endif
}
#endif /* PROFILING || DEBUG_HEAP_PROF */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment