X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fruntime%2Fwin32-os.c;h=b0e9b6faa6741c4bdb1f8a52b188eee7a428cafd;hb=8a632c14b592472873cfb214239c9387bc1a1ced;hp=00e0276ce9ed13b471649680cd3cbb408821207e;hpb=afe9091b25da5799f7bfd71c5497cbbd71045012;p=sbcl.git diff --git a/src/runtime/win32-os.c b/src/runtime/win32-os.c index 00e0276..b0e9b6f 100644 --- a/src/runtime/win32-os.c +++ b/src/runtime/win32-os.c @@ -43,6 +43,7 @@ #include "runtime.h" #include "alloc.h" #include "genesis/primitive-objects.h" +#include "dynbind.h" #include #include @@ -50,16 +51,6 @@ #include #include -/* KLUDGE: Avoid double definition of boolean by rpcndr.h included via - * shlobj.h. - * - * FIXME: We should probably arrange to use the rpcndr.h boolean on Windows, - * or get rid of our own boolean type. - */ -#define boolean rpcndr_boolean -#include -#undef boolean - #include #include @@ -304,10 +295,6 @@ is_valid_lisp_addr(os_vm_address_t addr) return 0; } -/* - * any OS-dependent special low-level handling for signals - */ - /* A tiny bit of interrupt.c state we want our paws on. */ extern boolean internal_errors_enabled; @@ -320,8 +307,18 @@ EXCEPTION_DISPOSITION handle_exception(EXCEPTION_RECORD *exception_record, struct lisp_exception_frame *exception_frame, CONTEXT *context, - void *dc) /* FIXME: What's dc again? */ + void *dispatcher_context) { + if (exception_record->ExceptionFlags & (EH_UNWINDING | EH_EXIT_UNWIND)) { + /* If we're being unwound, be graceful about it. */ + + /* Undo any dynamic bindings. */ + unbind_to_here(exception_frame->bindstack_pointer, + arch_os_get_current_thread()); + + return ExceptionContinueSearch; + } + /* For EXCEPTION_ACCESS_VIOLATION only. */ void *fault_address = (void *)exception_record->ExceptionInformation[1]; @@ -334,18 +331,20 @@ handle_exception(EXCEPTION_RECORD *exception_record, } if (exception_record->ExceptionCode == EXCEPTION_BREAKPOINT) { - /* Pick off sigtrap case first. */ - - extern void sigtrap_handler(int signal, siginfo_t *info, void *context); - /* - * Unlike some other operating systems, Win32 leaves EIP - * pointing to the breakpoint instruction. - */ + unsigned char trap; + /* This is just for info in case the monitor wants to print an + * approximation. */ + current_control_stack_pointer = + (lispobj *)*os_context_sp_addr(context); + /* Unlike some other operating systems, Win32 leaves EIP + * pointing to the breakpoint instruction. */ context->Eip++; - - sigtrap_handler(0, NULL, context); - - return ExceptionContinueExecution; + /* Now EIP points just after the INT3 byte and aims at the + * 'kind' value (eg trap_Cerror). */ + trap = *(unsigned char *)(*os_context_pc_addr(context)); + handle_trap(context, trap); + /* Done, we're good to go! */ + return ExceptionContinueExecution; } else if (exception_record->ExceptionCode == EXCEPTION_ACCESS_VIOLATION && (is_valid_lisp_addr(fault_address) || @@ -397,8 +396,8 @@ handle_exception(EXCEPTION_RECORD *exception_record, */ if (internal_errors_enabled) { - lispobj context_sap; - lispobj exception_record_sap; + lispobj context_sap; + lispobj exception_record_sap; /* We're making the somewhat arbitrary decision that having * internal errors enabled means that lisp has sufficient @@ -406,24 +405,24 @@ handle_exception(EXCEPTION_RECORD *exception_record, * aren't supposed to happen during cold init or reinit * anyway. */ - fake_foreign_function_call(context); + fake_foreign_function_call(context); - /* Allocate the SAP objects while the "interrupts" are still - * disabled. */ - context_sap = alloc_sap(context); - exception_record_sap = alloc_sap(exception_record); + /* Allocate the SAP objects while the "interrupts" are still + * disabled. */ + context_sap = alloc_sap(context); + exception_record_sap = alloc_sap(exception_record); - /* The exception system doesn't automatically clear pending - * exceptions, so we lose as soon as we execute any FP - * instruction unless we do this first. */ - _clearfp(); + /* The exception system doesn't automatically clear pending + * exceptions, so we lose as soon as we execute any FP + * instruction unless we do this first. */ + _clearfp(); - /* Call into lisp to handle things. */ - funcall2(SymbolFunction(HANDLE_WIN32_EXCEPTION), context_sap, - exception_record_sap); + /* Call into lisp to handle things. */ + funcall2(StaticSymbolFunction(HANDLE_WIN32_EXCEPTION), context_sap, + exception_record_sap); - /* If Lisp doesn't nlx, we need to put things back. */ - undo_fake_foreign_function_call(context); + /* If Lisp doesn't nlx, we need to put things back. */ + undo_fake_foreign_function_call(context); /* FIXME: HANDLE-WIN32-EXCEPTION should be allowed to decline */ return ExceptionContinueExecution; @@ -446,7 +445,7 @@ handle_exception(EXCEPTION_RECORD *exception_record, fflush(stderr); fake_foreign_function_call(context); - lose("fake_foreign_function_call fell through"); + lose("Exception too early in cold init, cannot continue."); /* FIXME: WTF? How are we supposed to end up here? */ return ExceptionContinueSearch;