From a2b7a6a58e894c02cff583d2d7d1b971a53d7c2d Mon Sep 17 00:00:00 2001 From: Alastair Bridgewater Date: Mon, 1 Mar 2010 16:32:55 +0000 Subject: [PATCH] 1.0.36.10: UD2-BREAKPOINTS for Win32 * Make UD2-BREAKPOINTS work on Win32. * Add :ud2-breakpoints as a feature affecting fasl format, as it changes the trap code used in compiled code. --- NEWS | 2 +- src/code/early-fasl.lisp | 2 +- src/runtime/win32-os.c | 15 +++++++++++++-- version.lisp-expr | 2 +- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index 741dbcc..4f95560 100644 --- a/NEWS +++ b/NEWS @@ -18,7 +18,7 @@ changes relative to sbcl-1.0.36: WITH-SLOTS usages during compilation. * bug fix: SB-C::CLASS-INFO now prints correctly (lp#514762) * enhancement: Can now build with ud2 instead of int3 as trap instruction on - all x86oid platforms (except win32) with :UD2-BREAKPOINTS target feature. + all x86oid platforms with :UD2-BREAKPOINTS target feature. * bug fix: Breakpoints now work when using ud2 instead of int3 as trap instruction (tested on x86oid linux with ud2-breakpoints). diff --git a/src/code/early-fasl.lisp b/src/code/early-fasl.lisp index 5785573..2249dd1 100644 --- a/src/code/early-fasl.lisp +++ b/src/code/early-fasl.lisp @@ -35,7 +35,7 @@ (macrolet ((define-fasl-format-features () (let (;; master value for *F-P-A-F-F* - (fpaff '(:sb-thread :sb-package-locks :sb-unicode :gencgc))) + (fpaff '(:sb-thread :sb-package-locks :sb-unicode :gencgc :ud2-breakpoints))) `(progn ;; a list of *(SHEBANG-)FEATURES* flags which affect ;; binary compatibility, i.e. which must be the same diff --git a/src/runtime/win32-os.c b/src/runtime/win32-os.c index 32ff6d0..8cdc832 100644 --- a/src/runtime/win32-os.c +++ b/src/runtime/win32-os.c @@ -298,6 +298,17 @@ is_valid_lisp_addr(os_vm_address_t addr) /* A tiny bit of interrupt.c state we want our paws on. */ extern boolean internal_errors_enabled; +#ifdef LISP_FEATURE_UD2_BREAKPOINTS +#define IS_TRAP_EXCEPTION(exception_record, context) \ + (((exception_record)->ExceptionCode == EXCEPTION_ILLEGAL_INSTRUCTION) && \ + (((unsigned short *)((context)->Eip))[0] == 0x0b0f)) +#define TRAP_CODE_WIDTH 2 +#else +#define IS_TRAP_EXCEPTION(exception_record, context) \ + ((exception_record)->ExceptionCode == EXCEPTION_BREAKPOINT) +#define TRAP_CODE_WIDTH 1 +#endif + /* * A good explanation of the exception handling semantics is * http://win32assembly.online.fr/Exceptionhandling.html . @@ -330,7 +341,7 @@ handle_exception(EXCEPTION_RECORD *exception_record, return ExceptionContinueExecution; } - if (exception_record->ExceptionCode == EXCEPTION_BREAKPOINT) { + if (IS_TRAP_EXCEPTION(exception_record, context)) { unsigned char trap; /* This is just for info in case the monitor wants to print an * approximation. */ @@ -338,7 +349,7 @@ handle_exception(EXCEPTION_RECORD *exception_record, (lispobj *)*os_context_sp_addr(context); /* Unlike some other operating systems, Win32 leaves EIP * pointing to the breakpoint instruction. */ - context->Eip++; + context->Eip += TRAP_CODE_WIDTH; /* 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)); diff --git a/version.lisp-expr b/version.lisp-expr index 54ad299..710a0b4 100644 --- a/version.lisp-expr +++ b/version.lisp-expr @@ -17,4 +17,4 @@ ;;; checkins which aren't released. (And occasionally for internal ;;; versions, especially for internal versions off the main CVS ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".) -"1.0.36.9" +"1.0.36.10" -- 1.7.10.4