2 * stuff to handle internal errors
6 * This software is part of the SBCL system. See the README file for
9 * This software is derived from the CMU CL system, which was
10 * written at Carnegie Mellon University and released into the
11 * public domain. The software is in the public domain and is
12 * provided with absolutely no warranty. See the COPYING and CREDITS
13 * files for more information.
29 /* the way that we shut down the system on a fatal error */
32 default_lossage_handler(void)
36 static void (*lossage_handler)(void) = default_lossage_handler;
38 set_lossage_handler(void handler(void))
40 lossage_handler = handler;
47 fprintf(stderr, "fatal error encountered in SBCL runtime system");
49 fprintf(stderr, ":\n");
51 vfprintf(stderr, fmt, ap);
54 fprintf(stderr, "\n");
57 fprintf(stderr, "Argh! lossage_handler() returned, total confusion..\n");
61 /* internal error handler for when the Lisp error system doesn't exist
63 * FIXME: Shouldn't error output go to stderr instead of stdout? (Alas,
64 * this'd require changes in a number of things like brief_print(..),
65 * or I'd have changed it immediately.) */
67 describe_internal_error(os_context_t *context)
69 unsigned char *ptr = arch_internal_error_arguments(context);
70 int len, scoffset, sc, offset, ch;
73 printf("internal error #%d\n", *ptr++);
78 if (scoffset == 253) {
82 else if (scoffset == 254) {
83 scoffset = ptr[0] + ptr[1]*256;
87 else if (scoffset == 255) {
88 scoffset = ptr[0] + (ptr[1]<<8) + (ptr[2]<<16) + (ptr[3]<<24);
93 offset = scoffset >> 5;
95 printf(" SC: %d, Offset: %d", sc, offset);
98 case sc_DescriptorReg:
100 brief_print(*os_context_register_addr(context, offset));
104 ch = *os_context_register_addr(context, offset);
111 case '\n': printf("\t'\\n'\n"); break;
112 case '\b': printf("\t'\\b'\n"); break;
113 case '\t': printf("\t'\\t'\n"); break;
114 case '\r': printf("\t'\\r'\n"); break;
116 if (ch < 32 || ch > 127)
117 printf("\\%03o", ch);
119 printf("\t'%c'\n", ch);
124 #ifdef sc_WordPointerReg
125 case sc_WordPointerReg:
127 printf("\t0x%08x\n", *os_context_register_addr(context, offset));
130 printf("\t%d\n", *os_context_register_addr(context, offset));
133 printf("\t%u\n", *os_context_register_addr(context, offset));
135 #ifdef sc_SingleFloatReg
136 case sc_SingleFloatReg:
137 printf("\t%g\n", *(float *)&context->sc_fpregs[offset]);
140 #ifdef sc_DoubleFloatReg
141 case sc_DoubleFloatReg:
142 printf("\t%g\n", *(double *)&context->sc_fpregs[offset]);
152 /* utility routines used by miscellaneous pieces of code */
154 lispobj debug_print(lispobj string)
156 /* This is a kludge. It's not actually safe - in general - to use
157 %primitive print on the alpha, because it skips half of the
158 number stack setup that should usually be done on a function call,
159 so the called routine (i.e. this one) ends up being able to overwrite
160 local variables in the caller. Rather than fix this everywhere
161 that %primitive print is used (it's only a debugging aid anyway)
162 we just put guarantee our safety by putting an unused buffer on
163 the stack before doing anything else here */
164 char untouched[32]; /* GCC warns about not using this, but that's the point.. */
165 fprintf(stderr, "%s\n",
166 (char *)(((struct vector *)native_pointer(string))->data),untouched);