mirror of
git://git.code.sf.net/p/sbcl/sbcl
synced 2026-09-10 07:26:40 -04:00
Delete choice of ud2 as tracing breakpoint
The C runtime unconditionally recognizes either int3 or ud2 for internal error traps, or 'into' (Interrupt if Overflow) in 64-bit code. The build-time feature to select a break opcode is relegated to esoteric use by developers, and not intended for users to change. Remove :ud2-breakpoints from features affecting fasl format. Remove still more comments about macOS not working.
This commit is contained in:
parent
806e8b75b6
commit
17b51486f7
|
|
@ -227,11 +227,6 @@
|
|||
;; local storage.
|
||||
; :restore-fs-segment-register-from-tls
|
||||
|
||||
;; On some x86oid operating systems (darwin) SIGTRAP is not reliably
|
||||
;; delivered for the INT3 instruction, so we use the UD2 instruction
|
||||
;; which generates SIGILL instead.
|
||||
; :ud2-breakpoints
|
||||
|
||||
;; Support for detection of unportable code (when applied to the
|
||||
;; COMMON-LISP package, or SBCL-internal pacakges) or bad-neighbourly
|
||||
;; code (when applied to user-level packages), relating to material
|
||||
|
|
|
|||
|
|
@ -42,8 +42,7 @@
|
|||
(defglobal *features-potentially-affecting-fasl-format*
|
||||
(append '(:sb-thread :sb-package-locks :sb-unicode :cheneygc
|
||||
:gencgc :msan :sb-safepoint :sb-safepoint-strictly
|
||||
:sb-dynamic-core)
|
||||
#+(or x86 x86-64) '(:int4-breakpoints :ud2-breakpoints)))
|
||||
:sb-dynamic-core)))
|
||||
|
||||
;;; Return a string representing symbols in *FEATURES-POTENTIALLY-AFFECTING-FASL-FORMAT*
|
||||
;;; which are present in a particular compilation.
|
||||
|
|
|
|||
|
|
@ -35,17 +35,10 @@
|
|||
#include "forwarding-ptr.h"
|
||||
#include "core.h"
|
||||
|
||||
#ifdef LISP_FEATURE_UD2_BREAKPOINTS
|
||||
#define UD2_INST 0x0b0f /* UD2 */
|
||||
#define BREAKPOINT_WIDTH 2
|
||||
#else
|
||||
#ifdef LISP_FEATURE_INT4_BREAKPOINTS
|
||||
# define BREAKPOINT_INST 0xce /* INTO */
|
||||
#else
|
||||
# define BREAKPOINT_INST 0xcc /* INT3 */
|
||||
#endif
|
||||
#define INT3_INST 0xcc
|
||||
#define UD2_INST 0x0b0f
|
||||
#define BREAKPOINT_WIDTH 1
|
||||
#endif
|
||||
|
||||
unsigned int cpuid_fn1_ecx;
|
||||
int avx_supported = 0, avx2_supported = 0;
|
||||
|
||||
|
|
@ -247,16 +240,8 @@ unsigned int
|
|||
arch_install_breakpoint(void *pc)
|
||||
{
|
||||
unsigned int result = *(unsigned int*)pc;
|
||||
|
||||
#ifndef LISP_FEATURE_UD2_BREAKPOINTS
|
||||
*(char*)pc = BREAKPOINT_INST; /* x86 INT3 */
|
||||
*(char*)pc = INT3_INST;
|
||||
*((char*)pc+1) = trap_Breakpoint; /* Lisp trap code */
|
||||
#else
|
||||
*(char*)pc = UD2_INST & 0xff;
|
||||
*((char*)pc+1) = UD2_INST >> 8;
|
||||
*((char*)pc+2) = trap_Breakpoint;
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -265,9 +250,6 @@ arch_remove_breakpoint(void *pc, unsigned int orig_inst)
|
|||
{
|
||||
*((char *)pc) = orig_inst & 0xff;
|
||||
*((char *)pc + 1) = (orig_inst & 0xff00) >> 8;
|
||||
#if BREAKPOINT_WIDTH > 1
|
||||
*((char *)pc + 2) = (orig_inst & 0xff0000) >> 16;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* When single stepping, single_stepping holds the original instruction
|
||||
|
|
@ -402,19 +384,17 @@ void
|
|||
sigill_handler(int __attribute__((unused)) signal,
|
||||
siginfo_t __attribute__((unused)) *siginfo,
|
||||
os_context_t *context) {
|
||||
/* Triggering SIGTRAP using int3 is unreliable on OS X/x86, so
|
||||
* we need to use illegal instructions for traps.
|
||||
*/
|
||||
#if defined(LISP_FEATURE_UD2_BREAKPOINTS) && !defined(LISP_FEATURE_MACH_EXCEPTION_HANDLER)
|
||||
#ifndef LISP_FEATURE_MACH_EXCEPTION_HANDLER
|
||||
if (*((unsigned short *)*os_context_pc_addr(context)) == UD2_INST) {
|
||||
*os_context_pc_addr(context) += 2;
|
||||
return sigtrap_handler(signal, siginfo, context);
|
||||
}
|
||||
#elif defined(LISP_FEATURE_INT4_BREAKPOINTS) && !defined(LISP_FEATURE_MACH_EXCEPTION_HANDLER)
|
||||
if (*((unsigned char *)*os_context_pc_addr(context)) == BREAKPOINT_INST) {
|
||||
*os_context_pc_addr(context) += BREAKPOINT_WIDTH;
|
||||
# ifdef LISP_FEATURE_X86_64 // handle INTO
|
||||
if (*((unsigned char *)*os_context_pc_addr(context)) == 0xCE) {
|
||||
*os_context_pc_addr(context) += 1;
|
||||
return sigtrap_handler(signal, siginfo, context);
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
fake_foreign_function_call(context);
|
||||
|
|
|
|||
|
|
@ -92,21 +92,7 @@
|
|||
#define SIZE(name)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* x86/darwin (as of MacOS X 10.4.5) doesn't reliably fire signal
|
||||
* handlers (SIGTRAP or Mach exception handlers) for 0xCC, wo we have
|
||||
* to use ud2 instead. ud2 is an undefined opcode, #x0b0f, or
|
||||
* 0F 0B in low-endian notation, that causes SIGILL to fire. We check
|
||||
* for this instruction in the SIGILL handler and if we see it, we
|
||||
* advance the EIP by two bytes to skip over ud2 instruction and
|
||||
* call sigtrap_handler. */
|
||||
#if defined(LISP_FEATURE_UD2_BREAKPOINTS)
|
||||
#define TRAP ud2
|
||||
#elif defined(LISP_FEATURE_INT4_BREAKPOINTS)
|
||||
#define TRAP .byte 0xCE /* due to illegality, assembler won't emit "into" */
|
||||
#else
|
||||
#define TRAP int3
|
||||
#endif
|
||||
|
||||
#define THREAD_BASE_REG %r13
|
||||
|
||||
|
|
|
|||
|
|
@ -32,14 +32,9 @@
|
|||
#include "genesis/symbol.h"
|
||||
#include "genesis/vector.h"
|
||||
|
||||
#define BREAKPOINT_INST 0xcc /* INT3 */
|
||||
#define UD2_INST 0x0b0f /* UD2 */
|
||||
|
||||
#ifndef LISP_FEATURE_UD2_BREAKPOINTS
|
||||
#define INT3_INST 0xcc
|
||||
#define UD2_INST 0x0b0f
|
||||
#define BREAKPOINT_WIDTH 1
|
||||
#else
|
||||
#define BREAKPOINT_WIDTH 2
|
||||
#endif
|
||||
|
||||
#ifndef LISP_FEATURE_WIN32
|
||||
os_vm_address_t
|
||||
|
|
@ -161,16 +156,8 @@ unsigned int
|
|||
arch_install_breakpoint(void *pc)
|
||||
{
|
||||
unsigned int result = *(unsigned int*)pc;
|
||||
|
||||
#ifndef LISP_FEATURE_UD2_BREAKPOINTS
|
||||
*(char*)pc = BREAKPOINT_INST; /* x86 INT3 */
|
||||
*(char*)pc = INT3_INST;
|
||||
*((char*)pc+1) = trap_Breakpoint; /* Lisp trap code */
|
||||
#else
|
||||
*(char*)pc = UD2_INST & 0xff;
|
||||
*((char*)pc+1) = UD2_INST >> 8;
|
||||
*((char*)pc+2) = trap_Breakpoint;
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -179,9 +166,6 @@ arch_remove_breakpoint(void *pc, unsigned int orig_inst)
|
|||
{
|
||||
*((char *)pc) = orig_inst & 0xff;
|
||||
*((char *)pc + 1) = (orig_inst & 0xff00) >> 8;
|
||||
#if BREAKPOINT_WIDTH > 1
|
||||
*((char *)pc + 2) = (orig_inst & 0xff0000) >> 16;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* When single stepping, single_stepping holds the original instruction
|
||||
|
|
@ -308,10 +292,7 @@ sigtrap_handler(int signal, siginfo_t *info, os_context_t *context)
|
|||
|
||||
void
|
||||
sigill_handler(int signal, siginfo_t *siginfo, os_context_t *context) {
|
||||
/* Triggering SIGTRAP using int3 is unreliable on OS X/x86, so
|
||||
* we need to use illegal instructions for traps.
|
||||
*/
|
||||
#if defined(LISP_FEATURE_UD2_BREAKPOINTS) && !defined(LISP_FEATURE_MACH_EXCEPTION_HANDLER)
|
||||
#ifndef LISP_FEATURE_MACH_EXCEPTION_HANDLER
|
||||
if (*((unsigned short *)*os_context_pc_addr(context)) == UD2_INST) {
|
||||
*os_context_pc_addr(context) += 2;
|
||||
return sigtrap_handler(signal, siginfo, context);
|
||||
|
|
|
|||
|
|
@ -165,19 +165,7 @@
|
|||
/* the CSP page sits right before the thread */
|
||||
#define THREAD_SAVED_CSP_OFFSET (-N_WORD_BYTES)
|
||||
|
||||
/*
|
||||
* x86/darwin (as of MacOS X 10.4.5) doesn't reliably file signal
|
||||
* handlers (SIGTRAP or Mach exception handlers) for 0xCC, wo we have
|
||||
* to use ud2 instead. ud2 is an undefined opcode, #x0b0f, or
|
||||
* 0F 0B in low-endian notation, that causes SIGILL to fire. We check
|
||||
* for this instruction in the SIGILL handler and if we see it, we
|
||||
* advance the EIP by two bytes to skip over ud2 instruction and
|
||||
* call sigtrap_handler. */
|
||||
#if defined(LISP_FEATURE_UD2_BREAKPOINTS)
|
||||
#define TRAP ud2
|
||||
#else
|
||||
#define TRAP int3
|
||||
#endif
|
||||
|
||||
.text
|
||||
.globl GNAME(all_threads)
|
||||
|
|
|
|||
Loading…
Reference in a new issue