-/* -*- mode: hugs-c; -*- */
+
/* -----------------------------------------------------------------------------
- * $Id: Printer.c,v 1.6 1999/02/05 16:02:46 simonm Exp $
+ * $Id: Printer.c,v 1.18 1999/11/29 18:59:46 sewardj Exp $
*
* Copyright (c) 1994-1999.
*
* ---------------------------------------------------------------------------*/
#include "Rts.h"
+#include "Printer.h"
#ifdef DEBUG
#include "Bytecodes.h" /* for InstrPtr */
#include "Disassembler.h"
-#include "Printer.h"
-
/* --------------------------------------------------------------------------
* local function decls
* ------------------------------------------------------------------------*/
* Printer
* ------------------------------------------------------------------------*/
-extern void printPtr( StgPtr p )
+
+#ifdef INTERPRETER
+extern void* itblNames[];
+extern int nItblNames;
+char* lookupHugsItblName ( void* v )
+{
+ int i;
+ for (i = 0; i < nItblNames; i += 2)
+ if (itblNames[i] == v) return itblNames[i+1];
+ return NULL;
+}
+#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);
fprintf(stderr,")\n");
break;
+ case SE_BLACKHOLE:
+ fprintf(stderr,"SE_BH\n");
+ break;
+
+ case SE_CAF_BLACKHOLE:
+ fprintf(stderr,"SE_CAF_BH\n");
+ break;
+
case BLACKHOLE:
fprintf(stderr,"BH\n");
break;
break;
}
default:
- barf("printClosure %d",get_itbl(obj)->type);
+ //barf("printClosure %d",get_itbl(obj)->type);
+ fprintf(stderr, "*** printClosure: unknown type %d ****\n",
+ get_itbl(obj)->type );
return;
}
}
/*fprintf(stderr,"Stack[%d] = ", &stgStack[STACK_SIZE] - sp); */
if (IS_ARG_TAG(*sp)) {
-
-#ifdef DEBUG_EXTRA
- StackTag tag = (StackTag)*sp;
- switch ( tag ) {
- case ILLEGAL_TAG:
- barf("printStackObj: ILLEGAL_TAG");
- break;
- case REALWORLD_TAG:
- fprintf(stderr,"RealWorld#\n");
- break;
- case INT_TAG:
- fprintf(stderr,"Int# %d\n", *(StgInt*)(sp+1));
- break;
- case INT64_TAG:
- fprintf(stderr,"Int64# %lld\n", *(StgInt64*)(sp+1));
- break;
- case WORD_TAG:
- fprintf(stderr,"Word# %d\n", *(StgWord*)(sp+1));
- break;
- case ADDR_TAG:
- fprintf(stderr,"Addr# "); printPtr(*(StgAddr*)(sp+1)); fprintf(stderr,"\n");
- break;
- case CHAR_TAG:
- fprintf(stderr,"Char# %d\n", *(StgChar*)(sp+1));
- break;
- case FLOAT_TAG:
- fprintf(stderr,"Float# %f\n", PK_FLT(sp+1));
- break;
- case DOUBLE_TAG:
- fprintf(stderr,"Double# %f\n", PK_DBL(sp+1));
- break;
- default:
- barf("printStackObj: unrecognised ARGTAG %d",tag);
+ nat i;
+ StgWord tag = *sp++;
+ fprintf(stderr,"Tagged{");
+ for (i = 0; i < tag; i++) {
+ fprintf(stderr,"0x%x#", (unsigned)(*sp++));
+ if (i < tag-1) fprintf(stderr, ", ");
}
- sp += 1 + ARG_SIZE(tag);
-
-#else /* !DEBUG_EXTRA */
- {
- StgWord tag = *sp++;
- nat i;
- fprintf(stderr,"Tag: %d words\n", tag);
- for (i = 0; i < tag; i++) {
- fprintf(stderr,"Word# %d\n", *sp++);
- }
- }
-#endif
-
+ fprintf(stderr, "}\n");
} else {
+ StgClosure* c = (StgClosure*)(*sp);
printPtr((StgPtr)*sp);
- fprintf(stderr,"\n");
+#ifdef INTERPRETER
+ if (c == &ret_bco_info) {
+ fprintf(stderr, "\t\t");
+ fprintf(stderr, "ret_bco_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");
+ }
+ else {
+ fprintf(stderr, "\t\t\t");
+ printClosure ( (StgClosure*)(*sp));
+ }
sp += 1;
}
return sp;
void printStackChunk( StgPtr sp, StgPtr spBottom )
{
- StgNat32 bitmap;
+ StgWord32 bitmap;
const StgInfoTable *info;
ASSERT(sp <= spBottom);
* Symbol table loading
* ------------------------------------------------------------------------*/
-#ifdef HAVE_BFD_H
+/* Causing linking trouble on Win32 plats, so I'm
+ disabling this for now.
+*/
+#if defined(HAVE_BFD_H) && !defined(_WIN32)
#include <bfd.h>
return rtsFalse;
}
#else
+ (void)flags; /* keep gcc -Wall happy */
if (*name == '\0' ||
(name[0] == 'g' && name[1] == 'c' && name[2] == 'c') ||
(name[0] == 'c' && name[1] == 'c' && name[2] == '.')) {
#endif /* HAVE_BFD_H */
+#include "StoragePriv.h"
+
+void
+findPtr(P_ p)
+{
+ nat s, g;
+ P_ q;
+ bdescr *bd;
+
+ 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);
+ }
+ }
+ }
+ }
+ }
+}
+
+#else /* DEBUG */
+void printPtr( StgPtr p )
+{
+ fprintf(stderr, "ptr 0x%p (enable -DDEBUG for more info) " , p );
+}
+
+void printObj( StgClosure *obj )
+{
+ fprintf(stderr, "obj 0x%p (enable -DDEBUG for more info) " , obj );
+}
#endif /* DEBUG */