X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fruntime%2Fx86-64-arch.c;h=2e6ea232ad2216836be3fbcf0a55567ded8cd993;hb=bf40ae88bc289fd765a33861cc4bc0853ed483ba;hp=62333e27ac105060c5a778e6ea855cea1b2c0c40;hpb=e6f4c7523aa628ece995ee01879d3fb90eed6d9f;p=sbcl.git diff --git a/src/runtime/x86-64-arch.c b/src/runtime/x86-64-arch.c index 62333e2..2e6ea23 100644 --- a/src/runtime/x86-64-arch.c +++ b/src/runtime/x86-64-arch.c @@ -44,11 +44,13 @@ unsigned long fast_random_state = 1; void arch_init(void) {} +#ifndef _WIN64 os_vm_address_t arch_get_bad_addr(int sig, siginfo_t *code, os_context_t *context) { return (os_vm_address_t)code->si_addr; } +#endif /* @@ -76,6 +78,8 @@ context_eflags_addr(os_context_t *context) return &context->sc_rflags; #elif defined __NetBSD__ return CONTEXT_ADDR_FROM_STEM(RFLAGS); +#elif defined _WIN64 + return (os_context_register_t*)&context->win32_context->EFlags; #else #error unsupported OS #endif @@ -237,7 +241,7 @@ arch_handle_fun_end_breakpoint(os_context_t *context) { *os_context_pc_addr(context) -= BREAKPOINT_WIDTH; *os_context_pc_addr(context) = - (unsigned long)handle_fun_end_breakpoint(context); + (uword_t)handle_fun_end_breakpoint(context); } void @@ -251,30 +255,37 @@ arch_handle_single_step_trap(os_context_t *context, int trap) void -sigtrap_handler(int signal, siginfo_t *info, os_context_t *context) +restore_breakpoint_from_single_step(os_context_t * context) { - unsigned int trap; - - if (single_stepping) { #ifdef CANNOT_GET_TO_SINGLE_STEP_FLAG - /* Un-install single step helper instructions. */ - *(single_stepping-3) = single_step_save1; - *(single_stepping-2) = single_step_save2; - *(single_stepping-1) = single_step_save3; + /* Un-install single step helper instructions. */ + *(single_stepping-3) = single_step_save1; + *(single_stepping-2) = single_step_save2; + *(single_stepping-1) = single_step_save3; #else - *context_eflags_addr(context) ^= 0x100; + *context_eflags_addr(context) &= ~0x100; #endif - /* Re-install the breakpoint if possible. */ - if (((char *)*os_context_pc_addr(context) > - (char *)single_stepping) && - ((char *)*os_context_pc_addr(context) <= - (char *)single_stepping + BREAKPOINT_WIDTH)) { - fprintf(stderr, "warning: couldn't reinstall breakpoint\n"); - } else { - arch_install_breakpoint(single_stepping); - } + /* Re-install the breakpoint if possible. */ + if (((char *)*os_context_pc_addr(context) > + (char *)single_stepping) && + ((char *)*os_context_pc_addr(context) <= + (char *)single_stepping + BREAKPOINT_WIDTH)) { + fprintf(stderr, "warning: couldn't reinstall breakpoint\n"); + } else { + arch_install_breakpoint(single_stepping); + } + + single_stepping = NULL; + return; +} + +void +sigtrap_handler(int signal, siginfo_t *info, os_context_t *context) +{ + unsigned int trap; - single_stepping = NULL; + if (single_stepping) { + restore_breakpoint_from_single_step(context); return; } @@ -372,12 +383,12 @@ arch_install_interrupt_handlers() * OS I haven't tested on?) and we have to go back to the old CMU * CL way, I hope there will at least be a comment to explain * why.. -- WHN 2001-06-07 */ -#if !defined(LISP_FEATURE_MACH_EXCEPTION_HANDLER) +#if !defined(LISP_FEATURE_MACH_EXCEPTION_HANDLER) && !defined(LISP_FEATURE_WIN32) undoably_install_low_level_interrupt_handler(SIGILL , sigill_handler); undoably_install_low_level_interrupt_handler(SIGTRAP, sigtrap_handler); #endif -#ifdef X86_64_SIGFPE_FIXUP +#if defined(X86_64_SIGFPE_FIXUP) && !defined(LISP_FEATURE_WIN32) undoably_install_low_level_interrupt_handler(SIGFPE, sigfpe_handler); #endif @@ -392,7 +403,7 @@ arch_install_interrupt_handlers() void arch_write_linkage_table_jmp(char * reloc, void * fun) { - unsigned long addr = (unsigned long) fun; + uword_t addr = (uword_t) fun; int i; *reloc++ = 0xFF; /* Opcode for near jump to absolute reg/mem64. */ @@ -414,7 +425,7 @@ arch_write_linkage_table_jmp(char * reloc, void * fun) void arch_write_linkage_table_ref(void * reloc, void * data) { - *(unsigned long *)reloc = (unsigned long)data; + *(uword_t *)reloc = (uword_t)data; } #endif