X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Frts%2FPrinter.c;h=e73b3f7574ed785944bc8bb2109d098c43b22eca;hb=1dc12c3c4acba688327fb2429f0a822bd98a5753;hp=d6d106d1c69acf32f3e020b361de3d152ec25ec6;hpb=0d13b281ca8939b0dc281a3442666180c2da3fbd;p=ghc-hetmet.git diff --git a/ghc/rts/Printer.c b/ghc/rts/Printer.c index d6d106d..e73b3f7 100644 --- a/ghc/rts/Printer.c +++ b/ghc/rts/Printer.c @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: Printer.c,v 1.26 2000/04/17 14:31:19 sewardj Exp $ + * $Id: Printer.c,v 1.44 2001/08/09 11:19:16 sewardj Exp $ * * (c) The GHC Team, 1994-2000. * @@ -14,14 +14,18 @@ #include "RtsUtils.h" #include "RtsFlags.h" +#include "MBlock.h" +#include "Storage.h" #include "Bytecodes.h" /* for InstrPtr */ #include "Disassembler.h" #include "Printer.h" +#if defined(GRAN) || defined(PAR) // HWL: explicit fixed header size to make debugging easier int fixed_hs = FIXED_HS, itbl_sz = sizeofW(StgInfoTable), uf_sz=sizeofW(StgUpdateFrame), sf_sz=sizeofW(StgSeqFrame); +#endif /* -------------------------------------------------------------------------- * local function decls @@ -43,24 +47,11 @@ static void printZcoded ( const char *raw ); * Printer * ------------------------------------------------------------------------*/ -#ifdef INTERPRETER -char* lookupHugsItblName ( void* itbl ); -#endif - void printPtr( StgPtr p ) { -#ifdef INTERPRETER - char* str; -#endif const char *raw; if (lookupGHCName( p, &raw )) { printZcoded(raw); -#ifdef INTERPRETER - } else if ((raw = lookupHugsName(p)) != 0) { - fprintf(stderr, "%s", raw); - } else if ((str = lookupHugsItblName(p)) != 0) { - fprintf(stderr, "%p=%s", p, str); -#endif } else { fprintf(stderr, "%p", p); } @@ -78,6 +69,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]); @@ -90,15 +84,16 @@ 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"); -#ifdef INTERPRETER case BCO: - fprintf(stderr,"BCO\n"); - disassemble(stgCast(StgBCO*,obj),"\t"); + disassemble( (StgBCO*)obj ); break; -#endif case AP_UPD: { @@ -107,7 +102,7 @@ void printClosure( StgClosure *obj ) fprintf(stderr,"AP_UPD("); printPtr((StgPtr)ap->fun); for (i = 0; i < ap->n_args; ++i) { fprintf(stderr,", "); - printPtr(ap->payload[i]); + printPtr((P_)ap->payload[i]); } fprintf(stderr,")\n"); break; @@ -126,6 +121,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); @@ -144,32 +145,6 @@ void printClosure( StgClosure *obj ) fprintf(stderr,")\n"); break; - case CAF_UNENTERED: - { - StgCAF* caf = stgCast(StgCAF*,obj); - fprintf(stderr,"CAF_UNENTERED("); - printPtr((StgPtr)caf->body); - fprintf(stderr,", "); - printPtr((StgPtr)caf->value); /* should be null */ - fprintf(stderr,", "); - printPtr((StgPtr)caf->link); - fprintf(stderr,")\n"); - break; - } - - case CAF_ENTERED: - { - StgCAF* caf = stgCast(StgCAF*,obj); - fprintf(stderr,"CAF_ENTERED("); - printPtr((StgPtr)caf->body); - fprintf(stderr,", "); - printPtr((StgPtr)caf->value); - fprintf(stderr,", "); - printPtr((StgPtr)caf->link); - fprintf(stderr,")\n"); - break; - } - case CAF_BLACKHOLE: fprintf(stderr,"CAF_BH("); printPtr((StgPtr)stgCast(StgBlockingQueue*,obj)->blocking_queue); @@ -196,8 +171,7 @@ void printClosure( StgClosure *obj ) case TSO: fprintf(stderr,"TSO("); - fprintf(stderr,"%d (%x)", - stgCast(StgTSO*,obj)->id, stgCast(StgTSO*,obj)); + fprintf(stderr,"%d (%p)",((StgTSO*)obj)->id, (StgTSO*)obj); fprintf(stderr,")\n"); break; @@ -215,6 +189,14 @@ void printClosure( StgClosure *obj ) fprintf(stderr,")\n"); break; +#ifdef DIST + case REMOTE_REF: + fprintf(stderr,"REMOTE_REF("); + printGA((globalAddr *)stgCast(StgFetchMe*,obj)->ga); + fprintf(stderr,")\n"); + break; +#endif + case FETCH_ME_BQ: fprintf(stderr,"FETCH_ME_BQ("); // printGA((globalAddr *)stgCast(StgFetchMe*,obj)->ga); @@ -243,12 +225,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) { @@ -258,6 +244,23 @@ void printClosure( StgClosure *obj ) break; } +#ifdef XMLAMBDA +/* rows are mutarrays in xmlambda, maybe we should make a new type: ROW */ + case MUT_ARR_PTRS_FROZEN: + { + StgWord i; + StgMutArrPtrs* p = stgCast(StgMutArrPtrs*,obj); + + fprintf(stderr,"Row<%i>(",p->ptrs); + for (i = 0; i < p->ptrs; ++i) { + if (i > 0) fprintf(stderr,", "); + printPtr((StgPtr)(p->payload[i])); + } + fprintf(stderr,")\n"); + break; + } +#endif + case FUN: case FUN_1_0: case FUN_0_1: case FUN_1_1: case FUN_0_2: case FUN_2_0: @@ -270,7 +273,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: @@ -286,7 +293,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; } @@ -340,6 +347,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; } } @@ -367,16 +375,21 @@ StgPtr printStackObj( StgPtr sp ) } else { StgClosure* c = (StgClosure*)(*sp); printPtr((StgPtr)*sp); -#ifdef INTERPRETER - if (c == &ret_bco_info) { - fprintf(stderr, "\t\t"); - fprintf(stderr, "ret_bco_info\n" ); + if (c == (StgClosure*)&stg_ctoi_ret_R1p_info) { + fprintf(stderr, "\t\t\tstg_ctoi_ret_R1p_info\n" ); + } else + if (c == (StgClosure*)&stg_ctoi_ret_R1n_info) { + fprintf(stderr, "\t\t\tstg_ctoi_ret_R1n_info\n" ); + } else + if (c == (StgClosure*)&stg_ctoi_ret_F1_info) { + fprintf(stderr, "\t\t\tstg_ctoi_ret_F1_info\n" ); + } else + if (c == (StgClosure*)&stg_ctoi_ret_D1_info) { + fprintf(stderr, "\t\t\tstg_ctoi_ret_D1_info\n" ); + } else + if (c == (StgClosure*)&stg_ctoi_ret_V_info) { + fprintf(stderr, "\t\t\tstg_ctoi_ret_V_info\n" ); } else - if (IS_HUGS_CONSTR_INFO(GET_INFO(c))) { - fprintf(stderr, "\t\t\t"); - fprintf(stderr, "ConstrInfoTable\n" ); - } else -#endif if (get_itbl(c)->type == BCO) { fprintf(stderr, "\t\t\t"); fprintf(stderr, "BCO(...)\n"); @@ -393,7 +406,7 @@ StgPtr printStackObj( StgPtr sp ) void printStackChunk( StgPtr sp, StgPtr spBottom ) { - StgWord32 bitmap; + StgWord bitmap; const StgInfoTable *info; ASSERT(sp <= spBottom); @@ -436,12 +449,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; @@ -456,7 +469,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); } } @@ -542,8 +555,6 @@ static char *closure_type_names[] = { "IND_PERM", /* 31 */ "IND_OLDGEN_PERM", /* 32 */ "IND_STATIC", /* 33 */ - "CAF_UNENTERED", /* 34 */ - "CAF_ENTERED", /* 35 */ "CAF_BLACKHOLE", /* 36 */ "RET_BCO", /* 37 */ "RET_SMALL", /* 38 */ @@ -573,7 +584,8 @@ static char *closure_type_names[] = { "FETCH_ME_BQ", /* 62 */ "RBH", /* 63 */ "EVACUATED", /* 64 */ - "N_CLOSURE_TYPES" /* 65 */ + "REMOTE_REF", /* 65 */ + "N_CLOSURE_TYPES" /* 66 */ }; char * @@ -813,7 +825,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) +#ifdef USING_LIBBFD #include @@ -921,23 +933,45 @@ extern void DEBUG_LoadSymbols( char *name STG_UNUSED ) #include "StoragePriv.h" +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); } }