[project @ 1999-03-20 17:33:07 by sof]
[ghc-hetmet.git] / ghc / rts / Printer.c
index c314151..7ebf193 100644 (file)
@@ -1,6 +1,6 @@
-/* -*- mode: hugs-c; -*- */
+
 /* -----------------------------------------------------------------------------
- * $Id: Printer.c,v 1.6 1999/02/05 16:02:46 simonm Exp $
+ * $Id: Printer.c,v 1.10 1999/03/15 16:30:29 simonm Exp $
  *
  * Copyright (c) 1994-1999.
  *
@@ -39,14 +39,30 @@ static void    printZcoded   ( const char *raw );
  * Printer
  * ------------------------------------------------------------------------*/
 
+
+#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
+
 extern void printPtr( StgPtr p )
 {
+    char* str;
     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);
@@ -273,7 +289,8 @@ void printClosure( StgClosure *obj )
             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;
     }
 }
@@ -331,8 +348,26 @@ StgPtr printStackObj( StgPtr sp )
 #endif
 
     } 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;
@@ -341,7 +376,7 @@ StgPtr printStackObj( StgPtr sp )
 
 void printStackChunk( StgPtr sp, StgPtr spBottom )
 {
-    StgNat32 bitmap;
+    StgWord32 bitmap;
     const StgInfoTable *info;
 
     ASSERT(sp <= spBottom);