X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fruntime%2Fbacktrace.c;h=f03e84f3bf1e01fc1cabb17178cdec21d6930611;hb=dc71db379ab4162a45c393a2e828f619dae9fa32;hp=dd214e431aa5b0d39f8502ff5ab9bda65e4807c9;hpb=dfa55a883f94470267b626dae77ce7e7dfac3df6;p=sbcl.git diff --git a/src/runtime/backtrace.c b/src/runtime/backtrace.c index dd214e4..f03e84f 100644 --- a/src/runtime/backtrace.c +++ b/src/runtime/backtrace.c @@ -15,20 +15,26 @@ #include #include -#include "runtime.h" #include "sbcl.h" +#include "runtime.h" #include "globals.h" #include "os.h" #include "interrupt.h" #include "lispregs.h" +#ifdef LISP_FEATURE_GENCGC +#include "gencgc-alloc-region.h" +#endif +#include "genesis/static-symbols.h" +#include "genesis/primitive-objects.h" +#include "thread.h" -#ifndef __i386__ +#if !(defined(LISP_FEATURE_X86) || defined(LISP_FEATURE_X86_64)) /* KLUDGE: Sigh ... I know what the call frame looks like and it had * better not change. */ struct call_frame { -#ifndef alpha +#ifndef LISP_FEATURE_ALPHA struct call_frame *old_cont; #else u32 old_cont; @@ -39,13 +45,13 @@ struct call_frame { }; struct call_info { -#ifndef alpha +#ifndef LISP_FEATURE_ALPHA struct call_frame *frame; #else u32 frame; #endif int interrupted; -#ifndef alpha +#ifndef LISP_FEATURE_ALPHA struct code *code; #else u32 code; @@ -64,16 +70,15 @@ code_pointer(lispobj object) lispobj *headerp, header; int type, len; - headerp = (lispobj *) PTR(object); + headerp = (lispobj *) native_pointer(object); header = *headerp; - type = TypeOf(header); + type = widetag_of(header); switch (type) { - case type_CodeHeader: + case CODE_HEADER_WIDETAG: break; - case type_ReturnPcHeader: - case type_FunctionHeader: - case type_ClosureFunctionHeader: + case RETURN_PC_HEADER_WIDETAG: + case SIMPLE_FUN_HEADER_WIDETAG: len = HEADER_LENGTH(header); if (len == 0) headerp = NULL; @@ -90,8 +95,8 @@ code_pointer(lispobj object) static boolean cs_valid_pointer_p(struct call_frame *pointer) { - /* lose("stub: hasn't been updated for X86"); */ - return (((char *) CONTROL_STACK_START <= (char *) pointer) && + struct thread *thread=arch_os_get_current_thread(); + return (((char *) thread->control_stack_start <= (char *) pointer) && ((char *) pointer < (char *) current_control_stack_pointer)); } @@ -113,8 +118,8 @@ call_info_from_context(struct call_info *info, os_context_t *context) unsigned long pc; info->interrupted = 1; - if (LowtagOf(*os_context_register_addr(context, reg_CODE)) - == type_FunctionPointer) { + if (lowtag_of(*os_context_register_addr(context, reg_CODE)) + == FUN_POINTER_LOWTAG) { /* We tried to call a function, but crapped out before $CODE could * be fixed up. Probably an undefined function. */ info->frame = @@ -122,7 +127,7 @@ call_info_from_context(struct call_info *info, os_context_t *context) reg_OCFP)); info->lra = (lispobj)(*os_context_register_addr(context, reg_LRA)); info->code = code_pointer(info->lra); - pc = (unsigned long)PTR(info->lra); + pc = (unsigned long)native_pointer(info->lra); } else { info->frame = @@ -134,7 +139,7 @@ call_info_from_context(struct call_info *info, os_context_t *context) } if (info->code != NULL) info->pc = pc - (unsigned long) info->code - -#ifndef alpha +#ifndef LISP_FEATURE_ALPHA (HEADER_LENGTH(info->code->header) * sizeof(lispobj)); #else (HEADER_LENGTH(((struct code *)info->code)->header) * sizeof(lispobj)); @@ -147,10 +152,11 @@ static int previous_info(struct call_info *info) { struct call_frame *this_frame; + struct thread *thread=arch_os_get_current_thread(); int free; if (!cs_valid_pointer_p(info->frame)) { - printf("Bogus callee value (0x%08x).\n", (unsigned long)info->frame); + printf("Bogus callee value (0x%08lx).\n", (unsigned long)info->frame); return 0; } @@ -164,10 +170,10 @@ previous_info(struct call_info *info) if (info->lra == NIL) { /* We were interrupted. Find the correct signal context. */ - free = SymbolValue(FREE_INTERRUPT_CONTEXT_INDEX)>>2; + free = SymbolValue(FREE_INTERRUPT_CONTEXT_INDEX,thread)>>2; while (free-- > 0) { os_context_t *context = - lisp_interrupt_contexts[free]; + thread->interrupt_contexts[free]; if ((struct call_frame *)(*os_context_register_addr(context, reg_CFP)) == info->frame) { @@ -179,9 +185,9 @@ previous_info(struct call_info *info) else { info->code = code_pointer(info->lra); if (info->code != NULL) - info->pc = (unsigned long)PTR(info->lra) - + info->pc = (unsigned long)native_pointer(info->lra) - (unsigned long)info->code - -#ifndef alpha +#ifndef LISP_FEATURE_ALPHA (HEADER_LENGTH(info->code->header) * sizeof(lispobj)); #else (HEADER_LENGTH(((struct code *)info->code)->header) * sizeof(lispobj)); @@ -201,43 +207,44 @@ backtrace(int nframes) call_info_from_lisp_state(&info); do { - printf("entry_points; #else function = ((struct code *)info.code)->entry_points; #endif while (function != NIL) { - struct function *header; + struct simple_fun *header; lispobj name; - header = (struct function *) PTR(function); + header = (struct simple_fun *) native_pointer(function); name = header->name; - if (LowtagOf(name) == type_OtherPointer) { + if (lowtag_of(name) == OTHER_POINTER_LOWTAG) { lispobj *object; - object = (lispobj *) PTR(name); + object = (lispobj *) native_pointer(name); - if (TypeOf(*object) == type_SymbolHeader) { + if (widetag_of(*object) == SYMBOL_HEADER_WIDETAG) { struct symbol *symbol; symbol = (struct symbol *) object; - object = (lispobj *) PTR(symbol->name); + object = (lispobj *) native_pointer(symbol->name); } - if (TypeOf(*object) == type_SimpleString) { + if (widetag_of(*object) == SIMPLE_BASE_STRING_WIDETAG) { struct vector *string; string = (struct vector *) object; printf("%s, ", (char *) string->data); } else + /* FIXME: broken from (VECTOR NIL) */ printf("(Not simple string??\?), "); } else printf("(Not other pointer??\?), "); @@ -250,7 +257,7 @@ backtrace(int nframes) printf("CODE: ???, "); if (info.lra != NIL) - printf("LRA: 0x%08x, ", (unsigned long)info.lra); + printf("LRA: 0x%08lx, ", (unsigned long)info.lra); else printf(", "); @@ -264,6 +271,8 @@ backtrace(int nframes) #else + + void backtrace(int nframes) {