X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fruntime%2Fprint.c;h=6f3b5058ef1851295426d119ba02a4fa5212fafd;hb=a157ed0be79751f85b8243c06102eea95af06aa3;hp=451a16d95816d52632e6596666d2394b9eaf3383;hpb=bd455348d39bee562296741689882dcb97c46ba3;p=sbcl.git diff --git a/src/runtime/print.c b/src/runtime/print.c index 451a16d..6f3b505 100644 --- a/src/runtime/print.c +++ b/src/runtime/print.c @@ -49,6 +49,28 @@ 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", @@ -59,6 +81,7 @@ char *lowtag_Names[] = { "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 @@ -172,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; + } } } @@ -214,7 +240,8 @@ 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 = widetag_of(obj); @@ -265,7 +292,9 @@ static void brief_otherimm(lispobj obj) static void print_otherimm(lispobj obj) { - int type, idx; + int type; + + unsigned int idx; type = widetag_of(obj); idx = type >> 2; @@ -312,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) @@ -320,12 +349,19 @@ 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)native_pointer(obj))) { @@ -349,7 +385,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++) { @@ -418,7 +454,7 @@ 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). */ -static char *symbol_slots[] = {"value: ", "unused: ", +static char *symbol_slots[] = {"value: ", "hash: ", "plist: ", "name: ", "package: ", #ifdef LISP_FEATURE_SB_THREAD "tls-index: " , @@ -513,9 +549,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 @@ -670,12 +714,25 @@ 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_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_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]; @@ -688,8 +745,10 @@ static void print_obj(char *prefix, lispobj obj) dont_descend = 1; if (var == NULL && - /* FIXME: What does this "x & y & z & .." expression mean? */ - (obj & FUN_POINTER_LOWTAG & LIST_POINTER_LOWTAG & INSTANCE_POINTER_LOWTAG & OTHER_POINTER_LOWTAG) != 0) + ((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)