1 /* code for low-level debugging/diagnostic output */
4 * This software is part of the SBCL system. See the README file for
7 * This software is derived from the CMU CL system, which was
8 * written at Carnegie Mellon University and released into the
9 * public domain. The software is in the public domain and is
10 * provided with absolutely no warranty. See the COPYING and CREDITS
11 * files for more information.
16 * Some of the code in here is deeply broken, depending on guessing
17 * already out-of-date values instead of getting them from sbcl.h.
26 #include "gc-internal.h"
28 #include "thread.h" /* genesis/primitive-objects.h needs this */
32 /* FSHOW and odxprint provide debugging output for low-level information
33 * (signal handling, exceptions, safepoints) which is hard to debug by
36 * If enabled at all, environment variables control whether calls of the
37 * form odxprint(name, ...) are enabled at run-time, e.g. using
38 * SBCL_DYNDEBUG="fshow fshow_signal safepoints".
40 * In the case of FSHOW and FSHOW_SIGNAL, old-style code from runtime.h
41 * can also be used to enable or disable these more aggressively.
44 struct dyndebug_config dyndebug_config
= {
45 QSHOW
== 2, QSHOW_SIGNALS
== 2
51 #define DYNDEBUG_NFLAGS (sizeof(struct dyndebug_config) / sizeof(int))
52 #define dyndebug_init1(lowercase, uppercase) \
54 int *ptr = &dyndebug_config.dyndebug_##lowercase; \
56 names[n] = #lowercase; \
57 char *val = getenv("SBCL_DYNDEBUG__" uppercase); \
58 *ptr = val && strlen(val); \
62 char *names
[DYNDEBUG_NFLAGS
];
63 int *ptrs
[DYNDEBUG_NFLAGS
];
65 dyndebug_init1(fshow
, "FSHOW");
66 dyndebug_init1(fshow_signal
, "FSHOW_SIGNAL");
67 dyndebug_init1(gencgc_verbose
, "GENCGC_VERBOSE");
68 dyndebug_init1(safepoints
, "SAFEPOINTS");
69 dyndebug_init1(seh
, "SEH");
70 dyndebug_init1(misc
, "MISC");
71 dyndebug_init1(pagefaults
, "PAGEFAULTS");
72 dyndebug_init1(io
, "IO");
73 dyndebug_init1(runtime_link
, "RUNTIME_LINK");
75 int n_output_flags
= n
;
76 dyndebug_init1(backtrace_when_lost
, "BACKTRACE_WHEN_LOST");
77 dyndebug_init1(sleep_when_lost
, "SLEEP_WHEN_LOST");
79 if (n
!= DYNDEBUG_NFLAGS
)
80 fprintf(stderr
, "Bug in dyndebug_init\n");
82 #if defined(LISP_FEATURE_GENCGC)
83 gencgc_verbose
= dyndebug_config
.dyndebug_gencgc_verbose
;
86 char *featurelist
= getenv("SBCL_DYNDEBUG");
89 featurelist
= strdup(featurelist
);
90 char *ptr
= featurelist
;
92 char *token
= strtok(ptr
, " ");
95 if (!strcmp(token
, "all"))
96 for (i
= 0; i
< n_output_flags
; i
++)
99 for (i
= 0; i
< (int)DYNDEBUG_NFLAGS
; i
++)
100 if (!strcmp(token
, names
[i
])) {
104 if (i
== DYNDEBUG_NFLAGS
) {
105 fprintf(stderr
, "No such dyndebug flag: `%s'\n", token
);
113 fprintf(stderr
, "Valid flags are:\n");
114 fprintf(stderr
, " all ;enables all of the following:\n");
116 for (i
= 0; i
< (int)DYNDEBUG_NFLAGS
; i
++) {
117 if (i
== n_output_flags
)
118 fprintf(stderr
, "Additional options:\n");
119 fprintf(stderr
, " %s\n", names
[i
]);
124 #undef dyndebug_init1
125 #undef DYNDEBUG_NFLAGS
128 /* Temporarily, odxprint merely performs the equivalent of a traditional
129 * FSHOW call, i.e. it merely formats to stderr. Ultimately, it should
130 * be restored to its full win32 branch functionality, where output to a
131 * file or to the debugger can be selected at runtime. */
133 void vodxprint_fun(const char *, va_list);
136 odxprint_fun(const char *fmt
, ...)
140 vodxprint_fun(fmt
, args
);
145 vodxprint_fun(const char *fmt
, va_list args
)
147 #ifdef LISP_FEATURE_WIN32
148 DWORD lastError
= GetLastError();
150 int original_errno
= errno
;
157 #ifdef LISP_FEATURE_SB_THREAD
158 struct thread
*arch_os_get_current_thread(void);
159 struct thread
*self
= arch_os_get_current_thread();
160 void *pth
= self
? (void *) self
->os_thread
: 0;
161 snprintf(buf
, sizeof(buf
), "[%p/%p] ", self
, pth
);
165 vsnprintf(buf
+ n
, sizeof(buf
) - n
- 1, fmt
, args
);
166 /* buf is now zero-terminated (even in case of overflow).
167 * Our caller took care of the newline (if any) through `fmt'. */
169 /* A sufficiently POSIXy implementation of stdio will provide
170 * per-FILE locking, as defined in the spec for flockfile. At least
171 * glibc complies with this. Hence we do not need to perform
172 * locking ourselves here. (Should it turn out, of course, that
173 * other libraries opt for speed rather than safety, we need to
174 * revisit this decision.) */
177 #ifdef LISP_FEATURE_WIN32
178 /* stdio's stderr is line-bufferred, i.e. \n ought to flush it.
179 * Unfortunately, MinGW does not behave the way I would expect it
180 * to. Let's be safe: */
186 #ifdef LISP_FEATURE_WIN32
187 SetLastError(lastError
);
189 errno
= original_errno
;
192 /* Translate the rather awkward syntax
193 * FSHOW((stderr, "xyz"))
194 * into the new and cleaner
196 * If we were willing to clean up all existing call sites, we could remove
197 * this wrapper function. (This is a function, because I don't know how to
198 * strip the extra parens in a macro.) */
200 fshow_fun(void __attribute__((__unused__
)) *ignored
,
206 vodxprint_fun(fmt
, args
);
213 #ifdef LISP_FEATURE_GENCGC
214 #include "gencgc-alloc-region.h" /* genesis/thread.h needs this */
216 #if defined(LISP_FEATURE_WIN32)
217 # include "win32-thread-private-events.h" /* genesis/thread.h needs this */
219 #include "genesis/static-symbols.h"
220 #include "genesis/primitive-objects.h"
221 #include "genesis/static-symbols.h"
222 #include "genesis/tagnames.h"
224 static int max_lines
= 20, cur_lines
= 0;
225 static int max_depth
= 5, brief_depth
= 2, cur_depth
= 0;
226 static int max_length
= 5;
227 static boolean dont_descend
= 0, skip_newline
= 0;
228 static int cur_clock
= 0;
230 static void print_obj(char *prefix
, lispobj obj
);
232 #define NEWLINE_OR_RETURN if (continue_p(1)) newline(NULL); else return;
234 static void indent(int in
)
236 static char *spaces
= " ";
239 fputs(spaces
, stdout
);
243 fputs(spaces
+ 64 - in
, stdout
);
246 static boolean
continue_p(boolean newline
)
250 if (cur_depth
>= max_depth
|| dont_descend
)
259 if (cur_lines
>= max_lines
) {
260 printf("More? [y] ");
263 if (fgets(buffer
, sizeof(buffer
), stdin
)) {
264 if (buffer
[0] == 'n' || buffer
[0] == 'N')
269 printf("\nUnable to read response, assuming y.\n");
278 static void newline(char *label
)
282 fputs(label
, stdout
);
284 indent(cur_depth
* 2);
288 static void print_unknown(lispobj obj
)
290 printf("unknown object: %p", (void *)obj
);
293 static void brief_fixnum(lispobj obj
)
295 /* KLUDGE: Rather than update the tables in print_obj(), we
296 declare all fixnum-or-unknown tags to be fixnums and sort it
297 out here with a guard clause. */
298 if (!fixnump(obj
)) return print_unknown(obj
);
300 #ifndef LISP_FEATURE_ALPHA
301 printf("%ld", ((long)obj
)>>N_FIXNUM_TAG_BITS
);
303 printf("%d", ((s32
)obj
)>>N_FIXNUM_TAG_BITS
);
307 static void print_fixnum(lispobj obj
)
309 /* KLUDGE: Rather than update the tables in print_obj(), we
310 declare all fixnum-or-unknown tags to be fixnums and sort it
311 out here with a guard clause. */
312 if (!fixnump(obj
)) return print_unknown(obj
);
314 #ifndef LISP_FEATURE_ALPHA
315 printf(": %ld", ((long)obj
)>>N_FIXNUM_TAG_BITS
);
317 printf(": %d", ((s32
)obj
)>>N_FIXNUM_TAG_BITS
);
321 static void brief_otherimm(lispobj obj
)
326 type
= widetag_of(obj
);
328 case CHARACTER_WIDETAG
:
329 c
= obj
>>8; // no mask. show whatever's there
332 case '\0': charname
= "Nul"; break;
333 case '\n': charname
= "Newline"; break;
334 case '\b': charname
= "Backspace"; break;
335 case '\177': charname
= "Delete"; break;
337 if (c
< 32) printf("^%c", c
+64);
338 else printf(c
< 128 ? "%c" : "U+%X", c
);
341 fputs(charname
, stdout
);
344 case UNBOUND_MARKER_WIDETAG
:
345 printf("<unbound marker>");
349 printf("%s", widetag_names
[type
>> 2]);
354 static void print_otherimm(lispobj obj
)
356 printf(", %s", widetag_names
[widetag_of(obj
) >> 2]);
358 switch (widetag_of(obj
)) {
359 case CHARACTER_WIDETAG
:
365 case UNBOUND_MARKER_WIDETAG
:
369 printf(": data=%"OBJ_FMTX
, (obj
>>8));
374 static void brief_list(lispobj obj
)
383 while (lowtag_of(obj
) == LIST_POINTER_LOWTAG
) {
386 if (++length
>= max_length
) {
391 print_obj("", CONS(obj
)->car
);
392 obj
= CONS(obj
)->cdr
;
405 static void print_list(lispobj obj
)
410 print_obj("car: ", CONS(obj
)->car
);
411 print_obj("cdr: ", CONS(obj
)->cdr
);
415 // takes native pointer as input
416 char * simple_base_stringize(struct vector
* string
)
418 if (widetag_of(string
->header
) == SIMPLE_BASE_STRING_WIDETAG
)
419 return (char*)string
->data
;
420 int length
= string
->length
;
421 char * newstring
= malloc(length
+1);
422 uint32_t * data
= (uint32_t*)string
->data
;
424 for(i
=0;i
<length
;++i
)
425 newstring
[i
] = data
[i
] < 128 ? data
[i
] : '?';
426 newstring
[length
] = 0;
430 static void brief_struct(lispobj obj
)
432 struct instance
*instance
= (struct instance
*)native_pointer(obj
);
433 extern struct vector
* instance_classoid_name(lispobj
*);
434 struct vector
* classoid_name
;
435 classoid_name
= instance_classoid_name((lispobj
*)instance
);
436 if ( classoid_name
) {
437 char * namestring
= simple_base_stringize(classoid_name
);
438 printf("#<ptr to %"OBJ_FMTX
" %s instance>",
439 (uintptr_t)instance_layout((lispobj
*)instance
), namestring
);
440 if ( namestring
!= (char*)classoid_name
->data
)
443 printf("#<ptr to %"OBJ_FMTX
" instance>",
444 (uintptr_t)instance_layout((lispobj
*)instance
));
448 #include "genesis/layout.h"
449 static boolean
tagged_slot_p(struct layout
*layout
, int slot_index
)
451 lispobj bitmap
= layout
->bitmap
;
452 sword_t fixnum
= (sword_t
)bitmap
>> N_FIXNUM_TAG_BITS
; // optimistically
453 return fixnump(bitmap
)
454 ? bitmap
== make_fixnum(-1) ||
455 (slot_index
< N_WORD_BITS
&& ((fixnum
>> slot_index
) & 1) != 0)
456 : positive_bignum_logbitp(slot_index
,
457 (struct bignum
*)native_pointer(bitmap
));
460 static void print_struct(lispobj obj
)
462 struct instance
*instance
= (struct instance
*)native_pointer(obj
);
465 lispobj layout
= instance_layout(native_pointer(obj
));
466 print_obj("type: ", layout
);
467 for (i
=INSTANCE_DATA_START
; i
<instance_length(instance
->header
); i
++) {
468 sprintf(buffer
, "slot %d: ", i
);
469 if (layout
&& tagged_slot_p(LAYOUT(layout
), i
)) {
470 print_obj(buffer
, instance
->slots
[i
]);
473 printf("\n\t %s0x%"OBJ_FMTX
" [raw]", buffer
, instance
->slots
[i
]);
478 void show_lstring(struct vector
* string
, int quotes
, FILE *s
)
481 int i
, len
= fixnum_value(string
->length
);
483 #ifdef SIMPLE_CHARACTER_STRING_WIDETAG
484 if (widetag_of(string
->header
) == SIMPLE_CHARACTER_STRING_WIDETAG
) {
487 putc('u', s
); /* an arbitrary notational convention */
490 if (quotes
) putc('"', s
);
491 for (i
=0 ; i
<len
; i
++) {
492 // hopefully the compiler will optimize out the ucs4_p test
493 // when the runtime is built without Unicode support
496 ch
= i
[(uint32_t*)string
->data
];
498 ch
= i
[(char*)string
->data
];
499 if (ch
>= 32 && ch
< 127) {
500 if (quotes
&& (ch
== '"' || ch
== '\\'))
504 fprintf(s
, ch
> 0xffff ? "\\U%08X" :
505 ch
> 0xff ? "\\u%04X" : "\\x%02X", ch
);
508 if (quotes
) putc('"', s
);
511 static void brief_otherptr(lispobj obj
)
513 extern void safely_show_lstring(struct vector
*, int, FILE*);
514 lispobj
*ptr
, header
;
516 struct symbol
*symbol
;
518 ptr
= native_pointer(obj
);
520 type
= widetag_of(header
);
523 symbol
= (struct symbol
*)ptr
;
524 if (symbol
->package
== NIL
)
526 show_lstring(VECTOR(symbol
->name
), 0, stdout
);
529 case SIMPLE_BASE_STRING_WIDETAG
:
530 #ifdef SIMPLE_CHARACTER_STRING_WIDETAG
531 case SIMPLE_CHARACTER_STRING_WIDETAG
:
533 show_lstring((struct vector
*)ptr
, 1, stdout
);
538 brief_otherimm(header
);
539 if (type
== FDEFN_WIDETAG
) { // Try to print name, if a symbol
540 // FIXME: more address validity checks perhaps?
541 lispobj name
= ((struct fdefn
*)ptr
)->name
;
542 if (lowtag_of(name
) == OTHER_POINTER_LOWTAG
543 && widetag_of(*native_pointer(name
)) == SYMBOL_WIDETAG
) {
545 struct vector
* str
= symbol_name(native_pointer(name
));
546 safely_show_lstring(str
, 0, stdout
);
553 static void print_slots(char **slots
, int count
, lispobj
*ptr
)
555 while (count
-- > 0) {
557 print_obj(*slots
++, *ptr
++);
559 print_obj("???: ", *ptr
++);
564 static lispobj
symbol_function(lispobj
* symbol
)
566 lispobj info
= ((struct symbol
*)symbol
)->info
;
567 if (lowtag_of(info
) == LIST_POINTER_LOWTAG
)
568 info
= CONS(info
)->cdr
;
569 if (lowtag_of(info
) == OTHER_POINTER_LOWTAG
) {
570 struct vector
* v
= VECTOR(info
);
571 int len
= fixnum_value(v
->length
);
573 lispobj elt
= v
->data
[0]; // Just like INFO-VECTOR-FDEFN
574 if (fixnump(elt
) && (fixnum_value(elt
) & 07777) >= 07701) {
575 lispobj fdefn
= v
->data
[len
-1];
576 if (lowtag_of(fdefn
) == OTHER_POINTER_LOWTAG
)
577 return FDEFN(fdefn
)->fun
;
584 static void print_otherptr(lispobj obj
)
586 #ifndef LISP_FEATURE_ALPHA
588 unsigned long header
;
589 unsigned long length
;
595 int count
, type
, index
;
598 ptr
= native_pointer(obj
);
600 printf(" (NULL Pointer)");
605 length
= fixnum_value(*ptr
);
606 count
= HeaderValue(header
);
607 type
= widetag_of(header
);
609 print_obj("header: ", header
);
610 if (!other_immediate_lowtag_p(header
)) {
612 printf("(invalid header object)");
616 if (unprintable_array_types
[type
/8] & (1<<(type
% 8)))
625 #if N_WORD_BITS == 32
630 (unsigned long) *--ptr
, (count
?"_":""));
634 print_slots(ratio_slots
, count
, ptr
);
637 case COMPLEX_WIDETAG
:
638 print_slots(complex_slots
, count
, ptr
);
642 // Only 1 byte of a symbol header conveys its size.
643 // The other bytes may be freely used by the backend.
644 print_slots(symbol_slots
, count
& 0xFF, ptr
);
645 if (symbol_function(ptr
-1) != NIL
)
646 print_obj("fun: ", symbol_function(ptr
-1));
649 #if N_WORD_BITS == 32
650 case SINGLE_FLOAT_WIDETAG
:
652 printf("%g", ((struct single_float
*)native_pointer(obj
))->value
);
655 case DOUBLE_FLOAT_WIDETAG
:
657 printf("%g", ((struct double_float
*)native_pointer(obj
))->value
);
660 #ifdef LONG_FLOAT_WIDETAG
661 case LONG_FLOAT_WIDETAG
:
663 printf("%Lg", ((struct long_float
*)native_pointer(obj
))->value
);
667 #ifdef COMPLEX_SINGLE_FLOAT_WIDETAG
668 case COMPLEX_SINGLE_FLOAT_WIDETAG
:
670 #ifdef LISP_FEATURE_64_BIT
671 printf("%g", ((struct complex_single_float
*)native_pointer(obj
))->data
.data
[0]);
673 printf("%g", ((struct complex_single_float
*)native_pointer(obj
))->real
);
676 #ifdef LISP_FEATURE_64_BIT
677 printf("%g", ((struct complex_single_float
*)native_pointer(obj
))->data
.data
[1]);
679 printf("%g", ((struct complex_single_float
*)native_pointer(obj
))->imag
);
684 #ifdef COMPLEX_DOUBLE_FLOAT_WIDETAG
685 case COMPLEX_DOUBLE_FLOAT_WIDETAG
:
687 printf("%g", ((struct complex_double_float
*)native_pointer(obj
))->real
);
689 printf("%g", ((struct complex_double_float
*)native_pointer(obj
))->imag
);
693 #ifdef COMPLEX_LONG_FLOAT_WIDETAG
694 case COMPLEX_LONG_FLOAT_WIDETAG
:
696 printf("%Lg", ((struct complex_long_float
*)native_pointer(obj
))->real
);
698 printf("%Lg", ((struct complex_long_float
*)native_pointer(obj
))->imag
);
702 case SIMPLE_BASE_STRING_WIDETAG
:
703 #ifdef SIMPLE_CHARACTER_STRING_WIDETAG
704 case SIMPLE_CHARACTER_STRING_WIDETAG
:
707 show_lstring((struct vector
*)native_pointer(obj
), 1, stdout
);
710 case SIMPLE_VECTOR_WIDETAG
:
712 printf("length = %ld", length
);
715 while (length
-- > 0) {
716 sprintf(buffer
, "%d: ", index
++);
717 print_obj(buffer
, *ptr
++);
721 // FIXME: This case looks unreachable. print_struct() does it
722 case INSTANCE_WIDETAG
:
724 count
&= SHORT_HEADER_MAX_WORDS
;
725 printf("length = %ld", (long) count
);
727 while (count
-- > 0) {
728 sprintf(buffer
, "%d: ", index
++);
729 print_obj(buffer
, *ptr
++);
733 case CODE_HEADER_WIDETAG
:
734 count
&= SHORT_HEADER_MAX_WORDS
;
735 // ptr was already bumped up
736 for_each_simple_fun(fun_index
, fun
, (struct code
*)(ptr
-1), 0, {
737 sprintf(buffer
, "f[%d]: ", fun_index
);
738 print_obj(buffer
, make_lispobj(fun
,FUN_POINTER_LOWTAG
));
740 print_slots(code_slots
, count
-1, ptr
);
743 case SIMPLE_FUN_WIDETAG
:
745 make_lispobj(native_pointer((lispobj
)(ptr
-1))
746 -(HeaderValue(header
)&0xFFFF),
747 OTHER_POINTER_LOWTAG
));
748 print_slots(simple_fun_slots
,
749 sizeof simple_fun_slots
/sizeof(char*)-1, ptr
);
752 #ifdef RETURN_PC_WIDETAG
753 case RETURN_PC_WIDETAG
:
754 print_obj("code: ", obj
- (count
* 4));
758 case CLOSURE_WIDETAG
:
759 print_slots(closure_slots
,
760 count
& SHORT_HEADER_MAX_WORDS
, ptr
);
763 case FUNCALLABLE_INSTANCE_WIDETAG
:
764 print_slots(funcallable_instance_slots
,
765 count
& SHORT_HEADER_MAX_WORDS
, ptr
);
768 case VALUE_CELL_WIDETAG
:
769 print_slots(value_cell_slots
, 1, ptr
);
774 #ifndef LISP_FEATURE_ALPHA
775 printf("0x%08lx", (unsigned long) *ptr
);
777 printf("0x%016lx", *(lispobj
*)(ptr
+1));
781 case WEAK_POINTER_WIDETAG
:
782 print_slots(weak_pointer_slots
, 1, ptr
);
785 case CHARACTER_WIDETAG
:
786 case UNBOUND_MARKER_WIDETAG
:
788 printf("pointer to an immediate?");
792 print_slots(fdefn_slots
, 2, ptr
);
793 print_obj("entry: ", fdefn_callee_lispobj((struct fdefn
*)(ptr
-1)));
798 printf("Unknown header object?");
803 static void print_obj(char *prefix
, lispobj obj
)
805 #ifdef LISP_FEATURE_64_BIT
806 static void (*verbose_fns
[])(lispobj obj
)
807 = {print_fixnum
, print_otherimm
, print_fixnum
, print_struct
,
808 print_fixnum
, print_otherimm
, print_fixnum
, print_list
,
809 print_fixnum
, print_otherimm
, print_fixnum
, print_otherptr
,
810 print_fixnum
, print_otherimm
, print_fixnum
, print_otherptr
};
811 static void (*brief_fns
[])(lispobj obj
)
812 = {brief_fixnum
, brief_otherimm
, brief_fixnum
, brief_struct
,
813 brief_fixnum
, brief_otherimm
, brief_fixnum
, brief_list
,
814 brief_fixnum
, brief_otherimm
, brief_fixnum
, brief_otherptr
,
815 brief_fixnum
, brief_otherimm
, brief_fixnum
, brief_otherptr
};
817 static void (*verbose_fns
[])(lispobj obj
)
818 = {print_fixnum
, print_struct
, print_otherimm
, print_list
,
819 print_fixnum
, print_otherptr
, print_otherimm
, print_otherptr
};
820 static void (*brief_fns
[])(lispobj obj
)
821 = {brief_fixnum
, brief_struct
, brief_otherimm
, brief_list
,
822 brief_fixnum
, brief_otherptr
, brief_otherimm
, brief_otherptr
};
824 int type
= lowtag_of(obj
);
825 struct var
*var
= lookup_by_obj(obj
);
827 boolean verbose
= cur_depth
< brief_depth
;
829 if (!continue_p(verbose
))
832 if (var
!= NULL
&& var_clock(var
) == cur_clock
)
835 if (var
== NULL
&& is_lisp_pointer(obj
))
836 var
= define_var(NULL
, obj
, 0);
839 var_setclock(var
, cur_clock
);
841 void (**fns
)(lispobj
) = NULL
;
845 sprintf(buffer
, "$%s=", var_name(var
));
850 printf("%s0x%08lx: ", prefix
, (unsigned long) obj
);
851 if (cur_depth
< brief_depth
) {
852 fputs(lowtag_names
[type
], stdout
);
860 printf("$%s", var_name(var
));
863 printf("$%s=", var_name(var
));
869 else if (is_lisp_pointer(obj
) && !gc_managed_addr_p(obj
))
870 printf("(bad-address)");
884 void print(lispobj obj
)
896 void brief_print(lispobj obj
)
908 // The following accessors, which take a valid native pointer as input
909 // and return a Lisp string, are designed to be foolproof during GC,
910 // hence all the forwarding checks.
912 #include "forwarding-ptr.h"
913 #include "genesis/classoid.h"
914 struct vector
* symbol_name(lispobj
* sym
)
916 if (forwarding_pointer_p(sym
))
917 sym
= native_pointer(forwarding_pointer_value(sym
));
918 if (lowtag_of(((struct symbol
*)sym
)->name
) != OTHER_POINTER_LOWTAG
)
920 lispobj
* name
= native_pointer(((struct symbol
*)sym
)->name
);
921 if (forwarding_pointer_p(name
))
922 name
= native_pointer(forwarding_pointer_value(name
));
923 return (struct vector
*)name
;
925 struct vector
* classoid_name(lispobj
* classoid
)
927 if (forwarding_pointer_p(classoid
))
928 classoid
= native_pointer(forwarding_pointer_value(classoid
));
929 lispobj sym
= ((struct classoid
*)classoid
)->name
;
930 return lowtag_of(sym
) != OTHER_POINTER_LOWTAG
? NULL
931 : symbol_name(native_pointer(sym
));
933 struct vector
* layout_classoid_name(lispobj
* layout
)
935 if (forwarding_pointer_p(layout
))
936 layout
= native_pointer(forwarding_pointer_value(layout
));
937 lispobj classoid
= ((struct layout
*)layout
)->classoid
;
938 return lowtag_of(classoid
) != INSTANCE_POINTER_LOWTAG
? NULL
939 : classoid_name(native_pointer(classoid
));
941 struct vector
* instance_classoid_name(lispobj
* instance
)
943 if (forwarding_pointer_p(instance
))
944 instance
= native_pointer(forwarding_pointer_value(instance
));
945 lispobj layout
= instance_layout(instance
);
946 return lowtag_of(layout
) != INSTANCE_POINTER_LOWTAG
? NULL
947 : layout_classoid_name(native_pointer(layout
));
949 void safely_show_lstring(struct vector
* string
, int quotes
, FILE *s
)
951 extern void show_lstring(struct vector
*, int, FILE*);
952 if (forwarding_pointer_p((lispobj
*)string
))
953 string
= (struct vector
*)forwarding_pointer_value((lispobj
*)string
);
955 #ifdef SIMPLE_CHARACTER_STRING_WIDETAG
956 widetag_of(string
->header
) == SIMPLE_CHARACTER_STRING_WIDETAG
||
958 widetag_of(string
->header
) == SIMPLE_BASE_STRING_WIDETAG
)
959 show_lstring(string
, quotes
, s
);
961 fprintf(s
, "#<[widetag=%02X]>", widetag_of(string
->header
));