1.0.29.44: Complex float improvements
[sbcl.git] / src / runtime / print.c
index 56cdb39..6f3b505 100644 (file)
@@ -1,4 +1,4 @@
-/* code for low-level debugging output */
+/* code for low-level debugging/diagnostic output */
 
 /*
  * This software is part of the SBCL system. See the README file for
 
 /*
  * FIXME:
- *   1. Ordinary users won't get much out of this code, so it shouldn't
- *      be compiled into the ordinary build of the system. Probably it
- *      should be made conditional on the SB-SHOW target feature.
- *   2. Some of the code in here (subtype_Names[] and the various
- *      foo_slots[], at least) is deeply broken, depending on fixed
- *      (and already out-of-date) values in sbcl.h.
+ *   Some of the code in here (the various
+ *   foo_slots[], at least) is deeply broken, depending on guessing
+ *   already out-of-date values instead of getting them from sbcl.h.
  */
 
 #include <stdio.h>
+#include <string.h>
 
+#include "sbcl.h"
 #include "print.h"
 #include "runtime.h"
-#include "sbcl.h"
+
+/* This file can be skipped if we're not supporting LDB. */
+#if defined(LISP_FEATURE_SB_LDB)
+
 #include "monitor.h"
 #include "vars.h"
 #include "os.h"
+#include "gencgc-alloc-region.h" /* genesis/thread.h needs this */
+#include "genesis/static-symbols.h"
+#include "genesis/primitive-objects.h"
+
+#include "genesis/static-symbols.h"
+
+
 
 static int max_lines = 20, cur_lines = 0;
 static int max_depth = 5, brief_depth = 2, cur_depth = 0;
@@ -38,18 +47,41 @@ static int cur_clock = 0;
 
 static void print_obj(char *prefix, lispobj obj);
 
-#define NEWLINE if (continue_p(1)) newline(NULL); else return;
+#define NEWLINE_OR_RETURN if (continue_p(1)) newline(NULL); else return;
 
+/* FIXME: This should be auto-generated by whatever generates
+   constants.h so we don't have to maintain this twice! */
+#ifdef LISP_FEATURE_X86_64
 char *lowtag_Names[] = {
     "even fixnum",
-    "function pointer",
+    "instance pointer",
     "other immediate [0]",
+    "unknown [3]",
+    "unknown [4]",
+    "unknown [5]",
+    "other immediate [1]",
     "list pointer",
     "odd fixnum",
+    "function pointer",
+    "other immediate [2]",
+    "unknown [11]",
+    "unknown [12]",
+    "unknown [13]",
+    "other immediate [3]",
+    "other pointer"
+};
+#else
+char *lowtag_Names[] = {
+    "even fixnum",
     "instance pointer",
+    "other immediate [0]",
+    "list pointer",
+    "odd fixnum",
+    "function pointer",
     "other immediate [1]",
     "other pointer"
 };
+#endif
 
 /* FIXME: Yikes! This table implicitly depends on the values in sbcl.h,
  * but doesn't actually depend on them, so if they change, it gets
@@ -63,17 +95,17 @@ char *subtype_Names[] = {
     "ratio",
     "single float",
     "double float",
-#ifdef type_LongFloat
+#ifdef LONG_FLOAT_WIDETAG
     "long float",
 #endif
     "complex",
-#ifdef type_ComplexSingleFloat
+#ifdef COMPLEX_SINGLE_FLOAT_WIDETAG
     "complex single float",
 #endif
-#ifdef type_ComplexDoubleFloat
+#ifdef COMPLEX_DOUBLE_FLOAT_WIDETAG
     "complex double float",
 #endif
-#ifdef type_ComplexLongFloat
+#ifdef COMPLEX_LONG_FLOAT_WIDETAG
     "complex long float",
 #endif
     "simple-array",
@@ -85,30 +117,30 @@ char *subtype_Names[] = {
     "(simple-array (unsigned-byte 8) (*))",
     "(simple-array (unsigned-byte 16) (*))",
     "(simple-array (unsigned-byte 32) (*))",
-#ifdef type_SimpleArraySignedByte8
+#ifdef SIMPLE_ARRAY_SIGNED_BYTE_8_WIDETAG
     "(simple-array (signed-byte 8) (*))",
 #endif
-#ifdef type_SimpleArraySignedByte16
+#ifdef SIMPLE_ARRAY_SIGNED_BYTE_16_WIDETAG
     "(simple-array (signed-byte 16) (*))",
 #endif
-#ifdef type_SimpleArraySignedByte30
+#ifdef SIMPLE_ARRAY_SIGNED_BYTE_30_WIDETAG
     "(simple-array fixnum (*))",
 #endif
-#ifdef type_SimpleArraySignedByte32
+#ifdef SIMPLE_ARRAY_SIGNED_BYTE_32_WIDETAG
     "(simple-array (signed-byte 32) (*))",
 #endif
     "(simple-array single-float (*))",
     "(simple-array double-float (*))",
-#ifdef type_SimpleArrayLongFloat
+#ifdef SIMPLE_ARRAY_LONG_FLOAT_WIDETAG
     "(simple-array long-float (*))",
 #endif
-#ifdef type_SimpleArrayComplexSingleFloat
+#ifdef SIMPLE_ARRAY_COMPLEX_SINGLE_FLOAT_WIDETAG
     "(simple-array (complex single-float) (*))",
 #endif
-#ifdef type_SimpleArrayComplexDoubleFloat
+#ifdef SIMPLE_ARRAY_COMPLEX_DOUBLE_FLOAT_WIDETAG
     "(simple-array (complex double-float) (*))",
 #endif
-#ifdef type_SimpleArrayComplexLongFloat
+#ifdef SIMPLE_ARRAY_COMPLEX_LONG_FLOAT_WIDETAG
     "(simple-array (complex long-float) (*))",
 #endif
     "complex-string",
@@ -163,12 +195,15 @@ static boolean continue_p(boolean newline)
             printf("More? [y] ");
             fflush(stdout);
 
-            fgets(buffer, sizeof(buffer), stdin);
-
-            if (buffer[0] == 'n' || buffer[0] == 'N')
-                throw_to_monitor();
-            else
+            if (fgets(buffer, sizeof(buffer), stdin)) {
+                if (buffer[0] == 'n' || buffer[0] == 'N')
+                    throw_to_monitor();
+                else
+                    cur_lines = 0;
+            } else {
+                printf("\nUnable to read response, assuming y.\n");
                 cur_lines = 0;
+            }
         }
     }
 
@@ -187,7 +222,7 @@ static void newline(char *label)
 
 static void brief_fixnum(lispobj obj)
 {
-#ifndef alpha
+#ifndef LISP_FEATURE_ALPHA
     printf("%ld", ((long)obj)>>2);
 #else
     printf("%d", ((s32)obj)>>2);
@@ -196,7 +231,7 @@ static void brief_fixnum(lispobj obj)
 
 static void print_fixnum(lispobj obj)
 {
-#ifndef alpha
+#ifndef LISP_FEATURE_ALPHA
     printf(": %ld", ((long)obj)>>2);
 #else
     printf(": %d", ((s32)obj)>>2);
@@ -205,12 +240,13 @@ static void print_fixnum(lispobj obj)
 
 static void brief_otherimm(lispobj obj)
 {
-    int type, c, idx;
+    int type, c;
+    unsigned int idx;
     char buffer[10];
 
-    type = TypeOf(obj);
+    type = widetag_of(obj);
     switch (type) {
-        case type_BaseChar:
+        case CHARACTER_WIDETAG:
             c = (obj>>8)&0xff;
             switch (c) {
                 case '\0':
@@ -240,40 +276,42 @@ static void brief_otherimm(lispobj obj)
             }
             break;
 
-        case type_UnboundMarker:
+        case UNBOUND_MARKER_WIDETAG:
             printf("<unbound marker>");
             break;
 
         default:
-           idx = type >> 2;
-           if (idx < (sizeof(subtype_Names) / sizeof(char *)))
-                   printf("%s", subtype_Names[idx]);
-           else
-                   printf("unknown type (0x%0x)", type);
+            idx = type >> 2;
+            if (idx < (sizeof(lowtag_Names) / sizeof(char *)))
+                    printf("%s", lowtag_Names[idx]);
+            else
+                    printf("unknown type (0x%0x)", type);
             break;
     }
 }
 
 static void print_otherimm(lispobj obj)
 {
-    int type, idx;
+    int type;
 
-    type = TypeOf(obj);
+    unsigned int idx;
+
+    type = widetag_of(obj);
     idx = type >> 2;
 
-    if (idx < (sizeof(subtype_Names) / sizeof(char *)))
-           printf(", %s", subtype_Names[idx]);
+    if (idx < (sizeof(lowtag_Names) / sizeof(char *)))
+            printf(", %s", lowtag_Names[idx]);
     else
-           printf(", unknown type (0x%0x)", type);
+            printf(", unknown type (0x%0x)", type);
 
-    switch (TypeOf(obj)) {
-        case type_BaseChar:
+    switch (widetag_of(obj)) {
+        case CHARACTER_WIDETAG:
             printf(": ");
             brief_otherimm(obj);
             break;
 
-        case type_Sap:
-        case type_UnboundMarker:
+        case SAP_WIDETAG:
+        case UNBOUND_MARKER_WIDETAG:
             break;
 
         default:
@@ -287,14 +325,14 @@ static void brief_list(lispobj obj)
     int space = 0;
     int length = 0;
 
-    if (!is_valid_lisp_addr((os_vm_address_t)obj))
-       printf("(invalid Lisp-level address)");
+    if (!is_valid_lisp_addr((os_vm_address_t)native_pointer(obj)))
+        printf("(invalid Lisp-level address)");
     else if (obj == NIL)
         printf("NIL");
     else {
         putchar('(');
-        while (LowtagOf(obj) == type_ListPointer) {
-            struct cons *cons = (struct cons *)PTR(obj);
+        while (lowtag_of(obj) == LIST_POINTER_LOWTAG) {
+            struct cons *cons = (struct cons *)native_pointer(obj);
 
             if (space)
                 putchar(' ');
@@ -303,7 +341,7 @@ static void brief_list(lispobj obj)
                 obj = NIL;
                 break;
             }
-            print_obj(NULL, cons->car);
+            print_obj("", cons->car);
             obj = cons->cdr;
             space = 1;
             if (obj == NIL)
@@ -311,20 +349,27 @@ static void brief_list(lispobj obj)
         }
         if (obj != NIL) {
             printf(" . ");
-            print_obj(NULL, obj);
+            print_obj("", obj);
         }
         putchar(')');
     }
 }
 
+#ifdef LISP_FEATURE_X86_64
+static void print_unknown(lispobj obj)
+{
+  printf("unknown object: %p", (void *)obj);
+}
+#endif
+
 static void print_list(lispobj obj)
 {
-    if (!is_valid_lisp_addr((os_vm_address_t)obj)) {
-       printf("(invalid address)");
+    if (!is_valid_lisp_addr((os_vm_address_t)native_pointer(obj))) {
+        printf("(invalid address)");
     } else if (obj == NIL) {
         printf(" (NIL)");
     } else {
-        struct cons *cons = (struct cons *)PTR(obj);
+        struct cons *cons = (struct cons *)native_pointer(obj);
 
         print_obj("car: ", cons->car);
         print_obj("cdr: ", cons->cdr);
@@ -334,18 +379,18 @@ static void print_list(lispobj obj)
 static void brief_struct(lispobj obj)
 {
     printf("#<ptr to 0x%08lx instance>",
-           (unsigned long) ((struct instance *)PTR(obj))->slots[0]);
+           (unsigned long) ((struct instance *)native_pointer(obj))->slots[0]);
 }
 
 static void print_struct(lispobj obj)
 {
-    struct instance *instance = (struct instance *)PTR(obj);
-    int i;
+    struct instance *instance = (struct instance *)native_pointer(obj);
+    unsigned int i;
     char buffer[16];
-    print_obj("type: ", ((struct instance *)PTR(obj))->slots[0]);
+    print_obj("type: ", ((struct instance *)native_pointer(obj))->slots[0]);
     for (i = 1; i < HeaderValue(instance->header); i++) {
-       sprintf(buffer, "slot %d: ", i);
-       print_obj(buffer, instance->slots[i]);
+        sprintf(buffer, "slot %d: ", i);
+        print_obj(buffer, instance->slots[i]);
     }
 }
 
@@ -357,19 +402,19 @@ static void brief_otherptr(lispobj obj)
     struct vector *vector;
     char *charptr;
 
-    ptr = (lispobj *) PTR(obj);
+    ptr = (lispobj *) native_pointer(obj);
 
     if (!is_valid_lisp_addr((os_vm_address_t)obj)) {
-           printf("(invalid address)");
-           return;
+            printf("(invalid address)");
+            return;
     }
 
     header = *ptr;
-    type = TypeOf(header);
+    type = widetag_of(header);
     switch (type) {
-        case type_SymbolHeader:
+        case SYMBOL_HEADER_WIDETAG:
             symbol = (struct symbol *)ptr;
-            vector = (struct vector *)PTR(symbol->name);
+            vector = (struct vector *)native_pointer(symbol->name);
             for (charptr = (char *)vector->data; *charptr != '\0'; charptr++) {
                 if (*charptr == '"')
                     putchar('\\');
@@ -377,7 +422,7 @@ static void brief_otherptr(lispobj obj)
             }
             break;
 
-        case type_SimpleString:
+        case SIMPLE_BASE_STRING_WIDETAG:
             vector = (struct vector *)ptr;
             putchar('"');
             for (charptr = (char *)vector->data; *charptr != '\0'; charptr++) {
@@ -402,18 +447,24 @@ static void print_slots(char **slots, int count, lispobj *ptr)
             print_obj(*slots++, *ptr++);
         } else {
             print_obj("???: ", *ptr++);
-       }
+        }
     }
 }
 
 /* FIXME: Yikes again! This, like subtype_Names[], needs to depend
- * on the values in sbcl.h. */
-static char *symbol_slots[] = {"value: ", "unused: ",
-    "plist: ", "name: ", "package: ", NULL};
+ * on the values in sbcl.h (or perhaps be generated automatically
+ * by GENESIS as part of sbcl.h). */
+static char *symbol_slots[] = {"value: ", "hash: ",
+    "plist: ", "name: ", "package: ",
+#ifdef LISP_FEATURE_SB_THREAD
+    "tls-index: " ,
+#endif
+    NULL};
 static char *ratio_slots[] = {"numer: ", "denom: ", NULL};
 static char *complex_slots[] = {"real: ", "imag: ", NULL};
 static char *code_slots[] = {"words: ", "entry: ", "debug: ", NULL};
-static char *fn_slots[] = {"self: ", "next: ", "name: ", "arglist: ", "type: ", NULL};
+static char *fn_slots[] = {
+    "self: ", "next: ", "name: ", "arglist: ", "type: ", NULL};
 static char *closure_slots[] = {"fn: ", NULL};
 static char *funcallable_instance_slots[] = {"fn: ", "lexenv: ", "layout: ", NULL};
 static char *weak_pointer_slots[] = {"value: ", NULL};
@@ -423,9 +474,9 @@ static char *value_cell_slots[] = {"value: ", NULL};
 static void print_otherptr(lispobj obj)
 {
     if (!is_valid_lisp_addr((os_vm_address_t)obj)) {
-       printf("(invalid address)");
+        printf("(invalid address)");
     } else {
-#ifndef alpha
+#ifndef LISP_FEATURE_ALPHA
         lispobj *ptr;
         unsigned long header;
         unsigned long length;
@@ -437,91 +488,104 @@ static void print_otherptr(lispobj obj)
         int count, type, index;
         char *cptr, buffer[16];
 
-       ptr = (lispobj*) PTR(obj);
-       if (ptr == NULL) {
-               printf(" (NULL Pointer)");
-               return;
-       }
+        ptr = (lispobj*) native_pointer(obj);
+        if (ptr == NULL) {
+                printf(" (NULL Pointer)");
+                return;
+        }
 
-       header = *ptr++;
-       length = (*ptr) >> 2;
-       count = header>>8;
-       type = TypeOf(header);
+        header = *ptr++;
+        length = (*ptr) >> 2;
+        count = header>>8;
+        type = widetag_of(header);
 
         print_obj("header: ", header);
-        if (LowtagOf(header) != type_OtherImmediate0 && LowtagOf(header) != type_OtherImmediate1) {
-            NEWLINE;
+        if (lowtag_of(header) != OTHER_IMMEDIATE_0_LOWTAG &&
+            lowtag_of(header) != OTHER_IMMEDIATE_1_LOWTAG) {
+            NEWLINE_OR_RETURN;
             printf("(invalid header object)");
             return;
         }
 
         switch (type) {
-            case type_Bignum:
+            case BIGNUM_WIDETAG:
                 ptr += count;
-                NEWLINE;
+                NEWLINE_OR_RETURN;
                 printf("0x");
                 while (count-- > 0)
                     printf("%08lx", (unsigned long) *--ptr);
                 break;
 
-            case type_Ratio:
+            case RATIO_WIDETAG:
                 print_slots(ratio_slots, count, ptr);
                 break;
 
-            case type_Complex:
+            case COMPLEX_WIDETAG:
                 print_slots(complex_slots, count, ptr);
                 break;
 
-            case type_SymbolHeader:
+            case SYMBOL_HEADER_WIDETAG:
                 print_slots(symbol_slots, count, ptr);
                 break;
 
-            case type_SingleFloat:
-                NEWLINE;
-                printf("%g", ((struct single_float *)PTR(obj))->value);
+#if N_WORD_BITS == 32
+            case SINGLE_FLOAT_WIDETAG:
+                NEWLINE_OR_RETURN;
+                printf("%g", ((struct single_float *)native_pointer(obj))->value);
                 break;
-
-            case type_DoubleFloat:
-                NEWLINE;
-                printf("%g", ((struct double_float *)PTR(obj))->value);
+#endif
+            case DOUBLE_FLOAT_WIDETAG:
+                NEWLINE_OR_RETURN;
+                printf("%g", ((struct double_float *)native_pointer(obj))->value);
                 break;
 
-#ifdef type_LongFloat
-            case type_LongFloat:
-                NEWLINE;
-                printf("%Lg", ((struct long_float *)PTR(obj))->value);
+#ifdef LONG_FLOAT_WIDETAG
+            case LONG_FLOAT_WIDETAG:
+                NEWLINE_OR_RETURN;
+                printf("%Lg", ((struct long_float *)native_pointer(obj))->value);
                 break;
 #endif
 
-#ifdef type_ComplexSingleFloat
-            case type_ComplexSingleFloat:
-                NEWLINE;
-                printf("%g", ((struct complex_single_float *)PTR(obj))->real);
-                NEWLINE;
-                printf("%g", ((struct complex_single_float *)PTR(obj))->imag);
+#ifdef COMPLEX_SINGLE_FLOAT_WIDETAG
+            case COMPLEX_SINGLE_FLOAT_WIDETAG:
+                NEWLINE_OR_RETURN;
+#ifdef LISP_FEATURE_X86_64
+                printf("%g", ((struct complex_single_float *)native_pointer(obj))->data.data[0]);
+#else
+                printf("%g", ((struct complex_single_float *)native_pointer(obj))->real);
+#endif
+                NEWLINE_OR_RETURN;
+#ifdef LISP_FEATURE_X86_64
+                printf("%g", ((struct complex_single_float *)native_pointer(obj))->data.data[1]);
+#else
+                printf("%g", ((struct complex_single_float *)native_pointer(obj))->imag);
+#endif
                 break;
 #endif
 
-#ifdef type_ComplexDoubleFloat
-            case type_ComplexDoubleFloat:
-                NEWLINE;
-                printf("%g", ((struct complex_double_float *)PTR(obj))->real);
-                NEWLINE;
-                printf("%g", ((struct complex_double_float *)PTR(obj))->imag);
+#ifdef COMPLEX_DOUBLE_FLOAT_WIDETAG
+            case COMPLEX_DOUBLE_FLOAT_WIDETAG:
+                NEWLINE_OR_RETURN;
+                printf("%g", ((struct complex_double_float *)native_pointer(obj))->real);
+                NEWLINE_OR_RETURN;
+                printf("%g", ((struct complex_double_float *)native_pointer(obj))->imag);
                 break;
 #endif
 
-#ifdef type_ComplexLongFloat
-            case type_ComplexLongFloat:
-                NEWLINE;
-                printf("%Lg", ((struct complex_long_float *)PTR(obj))->real);
-                NEWLINE;
-                printf("%Lg", ((struct complex_long_float *)PTR(obj))->imag);
+#ifdef COMPLEX_LONG_FLOAT_WIDETAG
+            case COMPLEX_LONG_FLOAT_WIDETAG:
+                NEWLINE_OR_RETURN;
+                printf("%Lg", ((struct complex_long_float *)native_pointer(obj))->real);
+                NEWLINE_OR_RETURN;
+                printf("%Lg", ((struct complex_long_float *)native_pointer(obj))->imag);
                 break;
 #endif
 
-            case type_SimpleString:
-                NEWLINE;
+            case SIMPLE_BASE_STRING_WIDETAG:
+#ifdef SIMPLE_CHARACTER_STRING_WIDETAG
+        case SIMPLE_CHARACTER_STRING_WIDETAG: /* FIXME */
+#endif
+                NEWLINE_OR_RETURN;
                 cptr = (char *)(ptr+1);
                 putchar('"');
                 while (length-- > 0)
@@ -529,9 +593,8 @@ static void print_otherptr(lispobj obj)
                 putchar('"');
                 break;
 
-            case type_SimpleVector:
-            case type_InstanceHeader:
-                NEWLINE;
+            case SIMPLE_VECTOR_WIDETAG:
+                NEWLINE_OR_RETURN;
                 printf("length = %ld", length);
                 ptr++;
                 index = 0;
@@ -541,95 +604,108 @@ static void print_otherptr(lispobj obj)
                 }
                 break;
 
-            case type_SimpleArray:
-            case type_SimpleBitVector:
-            case type_SimpleArrayUnsignedByte2:
-            case type_SimpleArrayUnsignedByte4:
-            case type_SimpleArrayUnsignedByte8:
-            case type_SimpleArrayUnsignedByte16:
-            case type_SimpleArrayUnsignedByte32:
-#ifdef type_SimpleArraySignedByte8
-           case type_SimpleArraySignedByte8:
+            case INSTANCE_HEADER_WIDETAG:
+                NEWLINE_OR_RETURN;
+                printf("length = %ld", (long) count);
+                index = 0;
+                while (count-- > 0) {
+                    sprintf(buffer, "%d: ", index++);
+                    print_obj(buffer, *ptr++);
+                }
+                break;
+
+            case SIMPLE_ARRAY_WIDETAG:
+            case SIMPLE_BIT_VECTOR_WIDETAG:
+            case SIMPLE_ARRAY_UNSIGNED_BYTE_2_WIDETAG:
+            case SIMPLE_ARRAY_UNSIGNED_BYTE_4_WIDETAG:
+            case SIMPLE_ARRAY_UNSIGNED_BYTE_8_WIDETAG:
+            case SIMPLE_ARRAY_UNSIGNED_BYTE_16_WIDETAG:
+            case SIMPLE_ARRAY_UNSIGNED_BYTE_32_WIDETAG:
+#ifdef SIMPLE_ARRAY_SIGNED_BYTE_8_WIDETAG
+            case SIMPLE_ARRAY_SIGNED_BYTE_8_WIDETAG:
+#endif
+#ifdef SIMPLE_ARRAY_SIGNED_BYTE_16_WIDETAG
+            case SIMPLE_ARRAY_SIGNED_BYTE_16_WIDETAG:
 #endif
-#ifdef type_SimpleArraySignedByte16
-           case type_SimpleArraySignedByte16:
+#ifdef SIMPLE_ARRAY_SIGNED_BYTE_30_WIDETAG
+            case SIMPLE_ARRAY_SIGNED_BYTE_30_WIDETAG:
 #endif
-#ifdef type_SimpleArraySignedByte30
-           case type_SimpleArraySignedByte30:
+#ifdef SIMPLE_ARRAY_SIGNED_BYTE_32_WIDETAG
+            case SIMPLE_ARRAY_SIGNED_BYTE_32_WIDETAG:
 #endif
-#ifdef type_SimpleArraySignedByte32
-           case type_SimpleArraySignedByte32:
+            case SIMPLE_ARRAY_SINGLE_FLOAT_WIDETAG:
+            case SIMPLE_ARRAY_DOUBLE_FLOAT_WIDETAG:
+#ifdef SIMPLE_ARRAY_LONG_FLOAT_WIDETAG
+            case SIMPLE_ARRAY_LONG_FLOAT_WIDETAG:
 #endif
-            case type_SimpleArraySingleFloat:
-            case type_SimpleArrayDoubleFloat:
-#ifdef type_SimpleArrayLongFloat
-            case type_SimpleArrayLongFloat:
+#ifdef SIMPLE_ARRAY_COMPLEX_SINGLE_FLOAT_WIDETAG
+            case SIMPLE_ARRAY_COMPLEX_SINGLE_FLOAT_WIDETAG:
 #endif
-#ifdef type_SimpleArrayComplexSingleFloat
-           case type_SimpleArrayComplexSingleFloat:
+#ifdef SIMPLE_ARRAY_COMPLEX_DOUBLE_FLOAT_WIDETAG
+            case SIMPLE_ARRAY_COMPLEX_DOUBLE_FLOAT_WIDETAG:
 #endif
-#ifdef type_SimpleArrayComplexDoubleFloat
-           case type_SimpleArrayComplexDoubleFloat:
+#ifdef SIMPLE_ARRAY_COMPLEX_LONG_FLOAT_WIDETAG
+            case SIMPLE_ARRAY_COMPLEX_LONG_FLOAT_WIDETAG:
 #endif
-#ifdef type_SimpleArrayComplexLongFloat
-           case type_SimpleArrayComplexLongFloat:
+            case COMPLEX_BASE_STRING_WIDETAG:
+#ifdef COMPLEX_CHARACTER_STRING_WIDETAG
+        case COMPLEX_CHARACTER_STRING_WIDETAG:
 #endif
-            case type_ComplexString:
-            case type_ComplexBitVector:
-            case type_ComplexVector:
-            case type_ComplexArray:
+            case COMPLEX_VECTOR_NIL_WIDETAG:
+            case COMPLEX_BIT_VECTOR_WIDETAG:
+            case COMPLEX_VECTOR_WIDETAG:
+            case COMPLEX_ARRAY_WIDETAG:
                 break;
 
-            case type_CodeHeader:
+            case CODE_HEADER_WIDETAG:
                 print_slots(code_slots, count-1, ptr);
                 break;
 
-            case type_FunctionHeader:
-            case type_ClosureFunctionHeader:
+            case SIMPLE_FUN_HEADER_WIDETAG:
                 print_slots(fn_slots, 5, ptr);
                 break;
 
-            case type_ReturnPcHeader:
+            case RETURN_PC_HEADER_WIDETAG:
                 print_obj("code: ", obj - (count * 4));
                 break;
 
-            case type_ClosureHeader:
+            case CLOSURE_HEADER_WIDETAG:
                 print_slots(closure_slots, count, ptr);
                 break;
 
-            case type_FuncallableInstanceHeader:
+            case FUNCALLABLE_INSTANCE_HEADER_WIDETAG:
                 print_slots(funcallable_instance_slots, count, ptr);
                 break;
 
-            case type_ValueCellHeader:
-               print_slots(value_cell_slots, 1, ptr);
+            case VALUE_CELL_HEADER_WIDETAG:
+                print_slots(value_cell_slots, 1, ptr);
                 break;
 
-            case type_Sap:
-                NEWLINE;
-#ifndef alpha
+            case SAP_WIDETAG:
+                NEWLINE_OR_RETURN;
+#ifndef LISP_FEATURE_ALPHA
                 printf("0x%08lx", (unsigned long) *ptr);
 #else
                 printf("0x%016lx", *(lispobj*)(ptr+1));
 #endif
                 break;
 
-            case type_WeakPointer:
-               print_slots(weak_pointer_slots, 1, ptr);
+            case WEAK_POINTER_WIDETAG:
+                print_slots(weak_pointer_slots, 1, ptr);
                 break;
 
-            case type_BaseChar:
-            case type_UnboundMarker:
-                NEWLINE;
+            case CHARACTER_WIDETAG:
+            case UNBOUND_MARKER_WIDETAG:
+                NEWLINE_OR_RETURN;
                 printf("pointer to an immediate?");
                 break;
 
-           case type_Fdefn:
-               print_slots(fdefn_slots, count, ptr);
-               break;
-               
+            case FDEFN_WIDETAG:
+                print_slots(fdefn_slots, count, ptr);
+                break;
+
             default:
-                NEWLINE;
+                NEWLINE_OR_RETURN;
                 printf("Unknown header object?");
                 break;
         }
@@ -638,25 +714,41 @@ static void print_otherptr(lispobj obj)
 
 static void print_obj(char *prefix, lispobj obj)
 {
+#ifdef LISP_FEATURE_X86_64
     static void (*verbose_fns[])(lispobj obj)
-       = {print_fixnum, print_otherptr, print_otherimm, print_list,
-          print_fixnum, print_struct, print_otherimm, print_otherptr};
+        = {print_fixnum, print_struct, print_otherimm, print_unknown,
+           print_unknown, print_unknown, print_otherimm, print_list,
+           print_fixnum, print_otherptr, print_otherimm, print_unknown,
+           print_unknown, print_unknown, print_otherimm, print_otherptr};
     static void (*brief_fns[])(lispobj obj)
-       = {brief_fixnum, brief_otherptr, brief_otherimm, brief_list,
-          brief_fixnum, brief_struct, brief_otherimm, brief_otherptr};
-    int type = LowtagOf(obj);
+        = {brief_fixnum, brief_struct, brief_otherimm, print_unknown,
+           print_unknown,  print_unknown, brief_otherimm, brief_list,
+           brief_fixnum, brief_otherptr, brief_otherimm, print_unknown,
+           print_unknown,  print_unknown,brief_otherimm, brief_otherptr};
+#else
+    static void (*verbose_fns[])(lispobj obj)
+        = {print_fixnum, print_struct, print_otherimm, print_list,
+           print_fixnum, print_otherptr, print_otherimm, print_otherptr};
+    static void (*brief_fns[])(lispobj obj)
+        = {brief_fixnum, brief_struct, brief_otherimm, brief_list,
+           brief_fixnum, brief_otherptr, brief_otherimm, brief_otherptr};
+#endif
+    int type = lowtag_of(obj);
     struct var *var = lookup_by_obj(obj);
     char buffer[256];
     boolean verbose = cur_depth < brief_depth;
 
-
     if (!continue_p(verbose))
         return;
 
     if (var != NULL && var_clock(var) == cur_clock)
         dont_descend = 1;
 
-    if (var == NULL && (obj & type_FunctionPointer & type_ListPointer & type_InstancePointer & type_OtherPointer) != 0)
+    if (var == NULL &&
+        ((obj & LOWTAG_MASK) == FUN_POINTER_LOWTAG ||
+         (obj & LOWTAG_MASK) == LIST_POINTER_LOWTAG ||
+         (obj & LOWTAG_MASK) == INSTANCE_POINTER_LOWTAG ||
+         (obj & LOWTAG_MASK) == OTHER_POINTER_LOWTAG))
         var = define_var(NULL, obj, 0);
 
     if (var != NULL)
@@ -720,3 +812,13 @@ void brief_print(lispobj obj)
     print_obj("", obj);
     putchar('\n');
 }
+
+#else
+
+void
+brief_print(lispobj obj)
+{
+    printf("lispobj 0x%lx\n", (unsigned long)obj);
+}
+
+#endif /* defined(LISP_FEATURE_SB_LDB) */