X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Frts%2FPrinter.c;h=e64154d04b61fed5a57db2466443ba513eeabd14;hb=b982291d5ca7b247e15bc11e8719e02615c15c58;hp=c173a9382498e25c92a9d7c8959f94ae415203df;hpb=20fc2f0ced64a12d8e44956931b2ac341ed2186f;p=ghc-hetmet.git diff --git a/ghc/rts/Printer.c b/ghc/rts/Printer.c index c173a93..e64154d 100644 --- a/ghc/rts/Printer.c +++ b/ghc/rts/Printer.c @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: Printer.c,v 1.38 2001/03/22 03:51:10 hwloidl Exp $ + * $Id: Printer.c,v 1.46 2001/08/21 10:12:02 sewardj Exp $ * * (c) The GHC Team, 1994-2000. * @@ -7,6 +7,7 @@ * * ---------------------------------------------------------------------------*/ +#include "PosixSource.h" #include "Rts.h" #include "Printer.h" @@ -69,6 +70,9 @@ static void printStdObject( StgClosure *obj, char* tag ) const StgInfoTable* info = get_itbl(obj); fprintf(stderr,"%s(",tag); printPtr((StgPtr)obj->header.info); +#ifdef PROFILING + fprintf(stderr,", %s", obj->header.prof.ccs->cc->label); +#endif for (i = 0; i < info->layout.payload.ptrs; ++i) { fprintf(stderr,", "); printPtr((StgPtr)obj->payload[i]); @@ -81,13 +85,24 @@ static void printStdObject( StgClosure *obj, char* tag ) void printClosure( StgClosure *obj ) { - switch ( get_itbl(obj)->type ) { + StgInfoTable *info; + + info = get_itbl(obj); + + switch ( info->type ) { case INVALID_OBJECT: barf("Invalid object"); case BCO: disassemble( (StgBCO*)obj ); break; + case MUT_VAR: + { + StgMutVar* mv = (StgMutVar*)obj; + fprintf(stderr,"MUT_VAR(var=%p, link=%p)\n", mv->var, mv->mut_link); + break; + } + case AP_UPD: { StgAP_UPD* ap = stgCast(StgAP_UPD*,obj); @@ -114,6 +129,12 @@ void printClosure( StgClosure *obj ) break; } + case FOREIGN: + fprintf(stderr,"FOREIGN("); + printPtr((StgPtr)( ((StgForeignObj*)obj)->data )); + fprintf(stderr,")\n"); + break; + case IND: fprintf(stderr,"IND("); printPtr((StgPtr)stgCast(StgInd*,obj)->indirectee); @@ -212,12 +233,16 @@ void printClosure( StgClosure *obj ) * tag as well. */ StgWord i, j; - const StgInfoTable* info = get_itbl(obj); - fprintf(stderr,"PACK("); +#ifdef PROFILING + fprintf(stderr,"%s(", info->prof.closure_desc); + fprintf(stderr,"%s", obj->header.prof.ccs->cc->label); +#else + fprintf(stderr,"CONSTR("); printPtr((StgPtr)obj->header.info); fprintf(stderr,"(tag=%d)",info->srt_len); +#endif for (i = 0; i < info->layout.payload.ptrs; ++i) { - fprintf(stderr,", "); + fprintf(stderr,", "); printPtr((StgPtr)obj->payload[i]); } for (j = 0; j < info->layout.payload.nptrs; ++j) { @@ -256,7 +281,11 @@ void printClosure( StgClosure *obj ) case THUNK_1_1: case THUNK_0_2: case THUNK_2_0: case THUNK_STATIC: /* ToDo: will this work for THUNK_STATIC too? */ +#ifdef PROFILING + printStdObject(obj,info->prof.closure_desc); +#else printStdObject(obj,"THUNK"); +#endif break; case THUNK_SELECTOR: @@ -272,7 +301,7 @@ void printClosure( StgClosure *obj ) putchar(arrWordsGetChar(obj,i)); } */ for (i=0; i<((StgArrWords *)obj)->words; i++) - fprintf(stderr, "%d", ((StgArrWords *)obj)->payload[i]); + fprintf(stderr, "%ld", ((StgArrWords *)obj)->payload[i]); fprintf(stderr,"\")\n"); break; } @@ -326,6 +355,7 @@ void printClosure( StgClosure *obj ) //barf("printClosure %d",get_itbl(obj)->type); fprintf(stderr, "*** printClosure: unknown type %d ****\n", get_itbl(obj)->type ); + barf("printClosure %d",get_itbl(obj)->type); return; } } @@ -384,7 +414,7 @@ StgPtr printStackObj( StgPtr sp ) void printStackChunk( StgPtr sp, StgPtr spBottom ) { - StgWord32 bitmap; + StgWord bitmap; const StgInfoTable *info; ASSERT(sp <= spBottom); @@ -427,12 +457,12 @@ void printStackChunk( StgPtr sp, StgPtr spBottom ) sp++; small_bitmap: while (bitmap != 0) { - fprintf(stderr," stk[%d] (%p) = ", spBottom-sp, sp); + fprintf(stderr," stk[%ld] (%p) = ", spBottom-sp, sp); if ((bitmap & 1) == 0) { printPtr((P_)*sp); fprintf(stderr,"\n"); } else { - fprintf(stderr,"Word# %d\n", *sp++); + fprintf(stderr,"Word# %ld\n", *sp++); } sp++; bitmap = bitmap >> 1; @@ -447,7 +477,7 @@ void printStackChunk( StgPtr sp, StgPtr spBottom ) break; } } - fprintf(stderr,"Stack[%d] (%p) = ", spBottom-sp, sp); + fprintf(stderr,"Stack[%ld] (%p) = ", spBottom-sp, sp); sp = printStackObj(sp); } } @@ -803,7 +833,7 @@ static void printZcoded( const char *raw ) /* Causing linking trouble on Win32 plats, so I'm disabling this for now. */ -#if defined(HAVE_BFD_H) && !defined(_WIN32) && !defined(PAR) && !defined(GRAN) +#ifdef USING_LIBBFD #include @@ -911,25 +941,45 @@ extern void DEBUG_LoadSymbols( char *name STG_UNUSED ) #include "StoragePriv.h" -void findPtr(P_ p); /* keep gcc -Wall happy */ +void findPtr(P_ p, int); /* keep gcc -Wall happy */ void -findPtr(P_ p) +findPtr(P_ p, int follow) { nat s, g; - P_ q; + P_ q, r; bdescr *bd; + const int arr_size = 1024; + StgPtr arr[arr_size]; + int i = 0; 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); + for (s = 0; s < generations[g].n_steps; s++) { + if (RtsFlags.GcFlags.generations == 1) { + bd = generations[g].steps[s].to_blocks; + } else { + bd = generations[g].steps[s].blocks; + } + for (; bd; bd = bd->link) { + for (q = bd->start; q < bd->free; q++) { + if (*q == (W_)p) { + if (i < arr_size) { + r = q; + while (!LOOKS_LIKE_GHC_INFO(*r)) { r--; }; + fprintf(stderr, "%p = ", r); + printClosure((StgClosure *)r); + arr[i++] = r; + } else { + return; + } + } + } } - } } - } + } + if (follow && i == 1) { + fprintf(stderr, "-->\n"); + findPtr(arr[0], 1); } }