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.
28 #include "genesis/static-symbols.h"
29 #include "genesis/vector.h"
31 /* the way that we shut down the system on a fatal error */
34 default_lossage_handler(void)
38 static void (*lossage_handler)(void) = default_lossage_handler;
40 set_lossage_handler(void handler(void))
42 lossage_handler = handler;
49 fprintf(stderr, "fatal error encountered in SBCL pid %d",getpid());
51 fprintf(stderr, ":\n");
53 vfprintf(stderr, fmt, ap);
56 fprintf(stderr, "\n");
59 fprintf(stderr, "Argh! lossage_handler() returned, total confusion..\n");
63 /* internal error handler for when the Lisp error system doesn't exist
65 * FIXME: Shouldn't error output go to stderr instead of stdout? (Alas,
66 * this'd require changes in a number of things like brief_print(..),
67 * or I'd have changed it immediately.) */
69 describe_internal_error(os_context_t *context)
71 unsigned char *ptr = arch_internal_error_arguments(context);
72 int len, scoffset, sc, offset, ch;
75 printf("internal error #%d\n", *ptr++);
80 if (scoffset == 253) {
84 else if (scoffset == 254) {
85 scoffset = ptr[0] + ptr[1]*256;
89 else if (scoffset == 255) {
90 scoffset = ptr[0] + (ptr[1]<<8) + (ptr[2]<<16) + (ptr[3]<<24);
95 offset = scoffset >> 5;
97 printf(" SC: %d, Offset: %d", sc, offset);
100 case sc_DescriptorReg:
102 brief_print(*os_context_register_addr(context, offset));
106 ch = *os_context_register_addr(context, offset);
113 case '\n': printf("\t'\\n'\n"); break;
114 case '\b': printf("\t'\\b'\n"); break;
115 case '\t': printf("\t'\\t'\n"); break;
116 case '\r': printf("\t'\\r'\n"); break;
118 if (ch < 32 || ch > 127)
119 printf("\\%03o", ch);
121 printf("\t'%c'\n", ch);
126 #ifdef sc_WordPointerReg
127 case sc_WordPointerReg:
129 printf("\t0x%08x\n", *os_context_register_addr(context, offset));
132 printf("\t%d\n", *os_context_register_addr(context, offset));
135 printf("\t%u\n", *os_context_register_addr(context, offset));
137 #ifdef sc_SingleFloatReg
138 case sc_SingleFloatReg:
139 printf("\t%g\n", *(float *)&context->sc_fpregs[offset]);
142 #ifdef sc_DoubleFloatReg
143 case sc_DoubleFloatReg:
144 printf("\t%g\n", *(double *)&context->sc_fpregs[offset]);
154 /* utility routines used by miscellaneous pieces of code */
156 lispobj debug_print(lispobj string)
158 /* This is a kludge. It's not actually safe - in general - to use
159 %primitive print on the alpha, because it skips half of the
160 number stack setup that should usually be done on a function call,
161 so the called routine (i.e. this one) ends up being able to overwrite
162 local variables in the caller. Rather than fix this everywhere
163 that %primitive print is used (it's only a debugging aid anyway)
164 we just put guarantee our safety by putting an unused buffer on
165 the stack before doing anything else here */
166 char untouched[32]; /* GCC warns about not using this, but that's the point.. */
167 fprintf(stderr, "%s\n",
168 (char *)(((struct vector *)native_pointer(string))->data),untouched);