X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fruntime%2Fprint.c;h=a7a578c2a95e5a6f631b6f61dd23b3081be48dc5;hb=f2db6743b1fadeea9e72cb583d857851c87efcd4;hp=f448e519811f595c9bbaa58f06a98ba3f5af77fe;hpb=be66f39b89fd11c0abea5697a6e666447df988a8;p=sbcl.git diff --git a/src/runtime/print.c b/src/runtime/print.c index f448e51..a7a578c 100644 --- a/src/runtime/print.c +++ b/src/runtime/print.c @@ -34,10 +34,8 @@ #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" - - +#include "genesis/tagnames.h" static int max_lines = 20, cur_lines = 0; static int max_depth = 5, brief_depth = 2, cur_depth = 0; @@ -49,123 +47,6 @@ static void print_obj(char *prefix, lispobj obj); #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", - "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 - * all broken. We should either get rid of it or - * rewrite the code so that it's cleanly initialized by gc_init_tables[] - * in a way which varies correctly with the values in sbcl.h. */ -char *subtype_Names[] = { - "unused 0", - "unused 1", - "bignum", - "ratio", - "single float", - "double float", -#ifdef LONG_FLOAT_WIDETAG - "long float", -#endif - "complex", -#ifdef COMPLEX_SINGLE_FLOAT_WIDETAG - "complex single float", -#endif -#ifdef COMPLEX_DOUBLE_FLOAT_WIDETAG - "complex double float", -#endif -#ifdef COMPLEX_LONG_FLOAT_WIDETAG - "complex long float", -#endif - "simple-array", - "simple-string", - "simple-bit-vector", - "simple-vector", - "(simple-array (unsigned-byte 2) (*))", - "(simple-array (unsigned-byte 4) (*))", - "(simple-array (unsigned-byte 8) (*))", - "(simple-array (unsigned-byte 16) (*))", - "(simple-array (unsigned-byte 32) (*))", -#ifdef SIMPLE_ARRAY_SIGNED_BYTE_8_WIDETAG - "(simple-array (signed-byte 8) (*))", -#endif -#ifdef SIMPLE_ARRAY_SIGNED_BYTE_16_WIDETAG - "(simple-array (signed-byte 16) (*))", -#endif -#ifdef SIMPLE_ARRAY_SIGNED_BYTE_30_WIDETAG - "(simple-array fixnum (*))", -#endif -#ifdef SIMPLE_ARRAY_SIGNED_BYTE_32_WIDETAG - "(simple-array (signed-byte 32) (*))", -#endif - "(simple-array single-float (*))", - "(simple-array double-float (*))", -#ifdef SIMPLE_ARRAY_LONG_FLOAT_WIDETAG - "(simple-array long-float (*))", -#endif -#ifdef SIMPLE_ARRAY_COMPLEX_SINGLE_FLOAT_WIDETAG - "(simple-array (complex single-float) (*))", -#endif -#ifdef SIMPLE_ARRAY_COMPLEX_DOUBLE_FLOAT_WIDETAG - "(simple-array (complex double-float) (*))", -#endif -#ifdef SIMPLE_ARRAY_COMPLEX_LONG_FLOAT_WIDETAG - "(simple-array (complex long-float) (*))", -#endif - "complex-string", - "complex-bit-vector", - "(array * (*))", - "array", - "code header", - "function header", - "closure header", - "funcallable-instance header", - "unused function header 1", - "unused function header 2", - "unused function header 3", - "closure function header", - "return PC header", - "value cell header", - "symbol header", - "character", - "SAP", - "unbound marker", - "weak pointer", - "instance header", - "fdefn" -}; - static void indent(int in) { static char *spaces = " "; @@ -195,12 +76,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; + } } } @@ -237,7 +121,7 @@ static void print_fixnum(lispobj obj) static void brief_otherimm(lispobj obj) { - int type, c, idx; + int type, c; char buffer[10]; type = widetag_of(obj); @@ -277,26 +161,14 @@ static void brief_otherimm(lispobj obj) break; default: - idx = type >> 2; - if (idx < (sizeof(lowtag_Names) / sizeof(char *))) - printf("%s", lowtag_Names[idx]); - else - printf("unknown type (0x%0x)", type); + printf("%s", widetag_names[type >> 2]); break; } } static void print_otherimm(lispobj obj) { - int type, idx; - - type = widetag_of(obj); - idx = type >> 2; - - if (idx < (sizeof(lowtag_Names) / sizeof(char *))) - printf(", %s", lowtag_Names[idx]); - else - printf(", unknown type (0x%0x)", type); + printf(", %s", widetag_names[widetag_of(obj) >> 2]); switch (widetag_of(obj)) { case CHARACTER_WIDETAG: @@ -379,7 +251,7 @@ static void brief_struct(lispobj obj) static void print_struct(lispobj obj) { struct instance *instance = (struct instance *)native_pointer(obj); - int i; + unsigned int i; char buffer[16]; print_obj("type: ", ((struct instance *)native_pointer(obj))->slots[0]); for (i = 1; i < HeaderValue(instance->header); i++) { @@ -445,9 +317,9 @@ static void print_slots(char **slots, int count, lispobj *ptr) } } -/* FIXME: Yikes again! This, like subtype_Names[], needs to depend - * on the values in sbcl.h (or perhaps be generated automatically - * by GENESIS as part of sbcl.h). */ +/* FIXME: Yikes! This needs to depend 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 @@ -489,13 +361,12 @@ static void print_otherptr(lispobj obj) } header = *ptr++; - length = (*ptr) >> 2; - count = header>>8; + length = fixnum_value(*ptr); + count = HeaderValue(header); type = widetag_of(header); print_obj("header: ", header); - if (lowtag_of(header) != OTHER_IMMEDIATE_0_LOWTAG && - lowtag_of(header) != OTHER_IMMEDIATE_1_LOWTAG) { + if (!other_immediate_lowtag_p(header)) { NEWLINE_OR_RETURN; printf("(invalid header object)"); return; @@ -543,9 +414,17 @@ static void print_otherptr(lispobj obj) #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 @@ -604,9 +483,24 @@ static void print_otherptr(lispobj obj) case SIMPLE_BIT_VECTOR_WIDETAG: case SIMPLE_ARRAY_UNSIGNED_BYTE_2_WIDETAG: case SIMPLE_ARRAY_UNSIGNED_BYTE_4_WIDETAG: + case SIMPLE_ARRAY_UNSIGNED_BYTE_7_WIDETAG: case SIMPLE_ARRAY_UNSIGNED_BYTE_8_WIDETAG: + case SIMPLE_ARRAY_UNSIGNED_BYTE_15_WIDETAG: case SIMPLE_ARRAY_UNSIGNED_BYTE_16_WIDETAG: +#ifdef SIMPLE_ARRAY_UNSIGNED_BYTE_29_WIDETAG + case SIMPLE_ARRAY_UNSIGNED_BYTE_29_WIDETAG: +#endif + case SIMPLE_ARRAY_UNSIGNED_BYTE_31_WIDETAG: case SIMPLE_ARRAY_UNSIGNED_BYTE_32_WIDETAG: +#ifdef SIMPLE_ARRAY_UNSIGNED_BYTE_60_WIDETAG + case SIMPLE_ARRAY_UNSIGNED_BYTE_60_WIDETAG: +#endif +#ifdef SIMPLE_ARRAY_UNSIGNED_BYTE_63_WIDETAG + case SIMPLE_ARRAY_UNSIGNED_BYTE_63_WIDETAG: +#endif +#ifdef SIMPLE_ARRAY_UNSIGNED_BYTE_64_WIDETAG + case SIMPLE_ARRAY_UNSIGNED_BYTE_64_WIDETAG: +#endif #ifdef SIMPLE_ARRAY_SIGNED_BYTE_8_WIDETAG case SIMPLE_ARRAY_SIGNED_BYTE_8_WIDETAG: #endif @@ -619,6 +513,12 @@ static void print_otherptr(lispobj obj) #ifdef SIMPLE_ARRAY_SIGNED_BYTE_32_WIDETAG case SIMPLE_ARRAY_SIGNED_BYTE_32_WIDETAG: #endif +#ifdef SIMPLE_ARRAY_SIGNED_BYTE_61_WIDETAG + case SIMPLE_ARRAY_SIGNED_BYTE_61_WIDETAG: +#endif +#ifdef SIMPLE_ARRAY_SIGNED_BYTE_64_WIDETAG + case SIMPLE_ARRAY_SIGNED_BYTE_64_WIDETAG: +#endif case SIMPLE_ARRAY_SINGLE_FLOAT_WIDETAG: case SIMPLE_ARRAY_DOUBLE_FLOAT_WIDETAG: #ifdef SIMPLE_ARRAY_LONG_FLOAT_WIDETAG @@ -750,7 +650,7 @@ static void print_obj(char *prefix, lispobj obj) newline(NULL); printf("%s0x%08lx: ", prefix, (unsigned long) obj); if (cur_depth < brief_depth) { - fputs(lowtag_Names[type], stdout); + fputs(lowtag_names[type], stdout); (*verbose_fns[type])(obj); } else