Update of /cvsroot/sbcl/sbcl/src/runtime
In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv8137/src/runtime
Modified Files:
alpha-arch.c arch.h breakpoint.c breakpoint.h hppa-arch.c
interrupt.c interrupt.h mips-arch.c ppc-arch.c print.c
sparc-arch.c x86-64-arch.c x86-arch.c x86-bsd-os.c
Log Message:
1.0.4.13: refactor trap handling
* All architectures had an essentially identical switch(trap){...}
for different trap codes. Pull this into a single shared
handle_trap function, which dispatches to architecture specific
functions where necessary.
* Remove unnecessary signal and siginfo arguments from breakpoint
handling functions and interrupt_internal_error as a tentative step
towards admitting that POSIX is not the only world out there.
* Clean up some compiler warnings from the runtime, and a missing
anti-copyright header.
* Fix the PPC build... at least on G4 Darwin 10.3: no suseconds_t
here.
Tested on x86, x86-64, and PPC. Sparc, MIPS (and Alpha) testing
needed.
Index: alpha-arch.c
===================================================================
RCS file: /cvsroot/sbcl/sbcl/src/runtime/alpha-arch.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- alpha-arch.c 2 Nov 2006 17:18:37 -0000 1.23
+++ alpha-arch.c 1 Apr 2007 19:36:17 -0000 1.24
@@ -277,6 +277,21 @@
os_flush_icache((os_vm_address_t)next_pc, sizeof(unsigned int));
}
+void
+arch_handle_breakpoint(os_context_t *context)
+{
+ *os_context_pc_addr(context) -=4;
+ handle_breakpoint(context);
+}
+
+void
+arch_handle_fun_end_breakpoint(os_context_t *context)
+{
+ *os_context_pc_addr(context) -=4;
+ *os_context_pc_addr(context) =
+ (int)handle_fun_end_breakpoint(context);
+}
+
static void
sigtrap_handler(int signal, siginfo_t *siginfo, os_context_t *context)
{
@@ -313,38 +328,8 @@
} else
/* a "system service" */
code=*((u32 *)(*os_context_pc_addr(context)));
-
- switch (code) {
- case trap_PendingInterrupt:
- arch_skip_instruction(context);
- interrupt_handle_pending(context);
- break;
-
- case trap_Halt:
- fake_foreign_function_call(context);
- lose("%%primitive halt called; the party is over.\n");
-
- case trap_Error:
- case trap_Cerror:
- interrupt_internal_error(signal, siginfo, context, code==trap_Cerror);
- break;
-
- case trap_Breakpoint: /* call lisp-level handler */
- *os_context_pc_addr(context) -=4;
- handle_breakpoint(signal, siginfo, context);
- break;
-
- case trap_FunEndBreakpoint:
- *os_context_pc_addr(context) -=4;
- *os_context_pc_addr(context) =
- (int)handle_fun_end_breakpoint(signal, siginfo, context);
- break;
-
- default:
- fprintf(stderr, "unidentified breakpoint/trap %d\n",code);
+ if (!maybe_handle_trap(context, code))
interrupt_handle_now(signal, siginfo, context);
- break;
- }
}
unsigned long
Index: arch.h
===================================================================
RCS file: /cvsroot/sbcl/sbcl/src/runtime/arch.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- arch.h 30 Nov 2006 16:20:42 -0000 1.11
+++ arch.h 1 Apr 2007 19:36:17 -0000 1.12
@@ -51,4 +51,13 @@
extern void restore_breakpoint_from_single_step(os_context_t * context);
#endif
+extern void arch_handle_breakpoint(os_context_t* context);
+extern void arch_handle_fun_end_breakpoint(os_context_t *context);
+#ifdef trap_AfterBreakpoint
+extern void arch_handle_after_breakpoint(os_context_t *context);
+#endif
+#ifdef trap_SingleStepAround
+extern void arch_handle_single_step_trap(os_context_t *context, int trap);
+#endif
+
#endif /* __ARCH_H__ */
Index: breakpoint.c
===================================================================
RCS file: /cvsroot/sbcl/sbcl/src/runtime/breakpoint.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- breakpoint.c 19 Sep 2006 21:35:33 -0000 1.26
+++ breakpoint.c 1 Apr 2007 19:36:18 -0000 1.27
@@ -124,7 +124,7 @@
}
}
-void handle_breakpoint(int signal, siginfo_t* info, os_context_t *context)
+void handle_breakpoint(os_context_t *context)
{
lispobj code, context_sap;
@@ -147,8 +147,7 @@
undo_fake_foreign_function_call(context);
}
-void *handle_fun_end_breakpoint(int signal, siginfo_t *info,
- os_context_t *context)
+void *handle_fun_end_breakpoint(os_context_t *context)
{
lispobj code, context_sap, lra;
struct code *codeptr;
Index: breakpoint.h
===================================================================
RCS file: /cvsroot/sbcl/sbcl/src/runtime/breakpoint.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- breakpoint.h 15 Dec 2006 02:57:52 -0000 1.9
+++ breakpoint.h 1 Apr 2007 19:36:18 -0000 1.10
@@ -18,10 +18,8 @@
unsigned int orig_inst);
extern void breakpoint_do_displaced_inst(os_context_t *context,
unsigned int orig_inst);
-extern void handle_breakpoint(int signal, siginfo_t *info,
- os_context_t *context);
-extern void *handle_fun_end_breakpoint(int signal, siginfo_t *info,
- os_context_t *context);
+extern void handle_breakpoint(os_context_t *context);
+extern void *handle_fun_end_breakpoint(os_context_t *context);
extern void handle_single_step_trap (os_context_t *context, int kind,
int register_offset);
Index: hppa-arch.c
===================================================================
RCS file: /cvsroot/sbcl/sbcl/src/runtime/hppa-arch.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- hppa-arch.c 7 Jun 2006 16:25:10 -0000 1.10
+++ hppa-arch.c 1 Apr 2007 19:36:18 -0000 1.11
@@ -181,7 +181,26 @@
}
#endif
-static void sigtrap_handler(int signal, siginfo_t *siginfo, void *void_context)
+void
+arch_handle_breakpoint(os_context_t *context)
+{
+ /*sigsetmask(scp->sc_mask); */
+ handle_breakpoint(context);
+}
+
+void
+arch_handle_fun_end_breakpoint(os_context_t *context)
+{
+ /*sigsetmask(scp->sc_mask); */
+ unsigned long pc;
+ pc = (unsigned long)
+ handle_fun_end_breakpoint(context);
+ *os_context_pc_addr(context) = pc;
+ *os_context_npc_addr(context) = pc + 4;
+}
+
+static void
+sigtrap_handler(int signal, siginfo_t *siginfo, void *void_context)
{
os_context_t *context = arch_os_get_context(&void_context);
unsigned int bad_inst;
@@ -196,49 +215,8 @@
interrupt_handle_now(signal, siginfo, context);
else {
int im5 = bad_inst & 0x1f;
-
- switch (im5) {
- case trap_Halt:
- fake_foreign_function_call(context);
- lose("%%primitive halt called; the party is over.\n");
-
- case trap_PendingInterrupt:
- arch_skip_instruction(context);
- interrupt_handle_pending(context);
- break;
-
- case trap_Error:
- case trap_Cerror:
- interrupt_internal_error(signal, siginfo, context, im5==trap_Cerror);
- break;
-
- case trap_Breakpoint:
- /*sigsetmask(scp->sc_mask); */
- handle_breakpoint(signal, siginfo, context);
- break;
-
- case trap_FunEndBreakpoint:
- /*sigsetmask(scp->sc_mask); */
- {
- unsigned long pc;
- pc = (unsigned long)
- handle_fun_end_breakpoint(signal, siginfo, context);
- *os_context_pc_addr(context) = pc;
- *os_context_npc_addr(context) = pc + 4;
- }
- break;
-
- case trap_SingleStepBreakpoint:
- /* Uh, FIXME */
-#ifdef hpux
- restore_breakpoint(context);
-#endif
- break;
-
- default:
- interrupt_handle_now(signal, siginfo, context);
- break;
- }
+ if (!maybe_handle_trap(context, trap))
+ interrupt_handle_now(signal, sigingo, context);
}
}
Index: interrupt.c
===================================================================
RCS file: /cvsroot/sbcl/sbcl/src/runtime/interrupt.c,v
retrieving revision 1.122
retrieving revision 1.123
diff -u -d -r1.122 -r1.123
--- interrupt.c 26 Mar 2007 10:30:30 -0000 1.122
+++ interrupt.c 1 Apr 2007 19:36:18 -0000 1.123
@@ -67,8 +67,6 @@
#include "genesis/simple-fun.h"
#include "genesis/cons.h"
-
-
static void run_deferred_handler(struct interrupt_data *data, void *v_context);
#ifndef LISP_FEATURE_WIN32
static void store_signal_data_for_later (struct interrupt_data *data,
@@ -368,8 +366,7 @@
/* a handler for the signal caused by execution of a trap opcode
* signalling an internal error */
void
-interrupt_internal_error(int signal, siginfo_t *info, os_context_t *context,
- boolean continuable)
+interrupt_internal_error(os_context_t *context, boolean continuable)
{
lispobj context_sap;
@@ -1432,3 +1429,50 @@
arrange_return_to_lisp_function(context, SymbolFunction(MEMORY_FAULT_ERROR));
}
#endif
+
+/* Common logic far trapping instructions. How we actually handle each
+ * case is highly architecture dependant, but the overall shape is
+ * this. */
+boolean
+maybe_handle_trap(os_context_t *context, int trap)
+{
+ switch(trap) {
+ case trap_PendingInterrupt:
+ FSHOW((stderr, "/<trap pending interrupt>\n"));
+ arch_skip_instruction(context);
+ interrupt_handle_pending(context);
+ break;
+ case trap_Error:
+ case trap_Cerror:
+ FSHOW((stderr, "/<trap error/cerror %d>\n", trap));
+ interrupt_internal_error(context, trap==trap_Cerror);
+ break;
+ case trap_Breakpoint:
+ arch_handle_breakpoint(context);
+ break;
+ case trap_FunEndBreakpoint:
+ arch_handle_fun_end_breakpoint(context);
+ break;
+#ifdef trap_AfterBreakpoint
+ case trap_AfterBreakpoint:
+ arch_handle_after_breakpoint(context);
+ break;
+#endif
+#ifdef trap_SingleStepAround
+ case trap_SingleStepAround:
+ case trap_SingleStepBefore:
+ arch_handle_single_step_trap(context, trap);
+ break;
+#endif
+ case trap_Halt:
+ fake_foreign_function_call(context);
+ lose("%%PRIMITIVE HALT called; the party is over.\n");
+ default:
+ FSHOW((stderr,"/[C--trap default %d %d %x]\n",
+ signal, trap, context));
+ /* Not our trap! */
+ return 0;
+ }
+ return 1;
+}
+
Index: interrupt.h
===================================================================
RCS file: /cvsroot/sbcl/sbcl/src/runtime/interrupt.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- interrupt.h 3 Jun 2006 20:26:53 -0000 1.26
+++ interrupt.h 1 Apr 2007 19:36:18 -0000 1.27
@@ -66,8 +66,7 @@
extern void arrange_return_to_lisp_function(os_context_t *, lispobj);
extern void interrupt_handle_now(int, siginfo_t*, void*);
extern void interrupt_handle_pending(os_context_t*);
-extern void interrupt_internal_error(int, siginfo_t*, os_context_t*,
- boolean continuable);
+extern void interrupt_internal_error(os_context_t*, boolean continuable);
extern boolean handle_guard_page_triggered(os_context_t *,os_vm_address_t);
extern boolean interrupt_maybe_gc(int, siginfo_t*, void*);
extern boolean interrupt_maybe_gc_int(int, siginfo_t *, void *);
@@ -107,4 +106,10 @@
* "cleanly" with union types is in fact a mess. */
#define ARE_SAME_HANDLER(x, y) ((void*)(x) == (void*)(y))
+extern boolean maybe_handle_trap(os_context_t *context, int trap);
+
+#ifndef LISP_FEATURE_WIN32
+extern void lisp_memory_fault_error(os_context_t *context, os_vm_address_t addr);
+#endif
+
#endif
Index: mips-arch.c
===================================================================
RCS file: /cvsroot/sbcl/sbcl/src/runtime/mips-arch.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- mips-arch.c 7 Jun 2006 16:25:10 -0000 1.23
+++ mips-arch.c 1 Apr 2007 19:36:19 -0000 1.24
@@ -363,54 +363,42 @@
displaced_after_inst = arch_install_after_breakpoint(next_pc);
}
+void
+arch_handle_breakpoint(os_context_t *context)
+{
+ handle_breakpoint(context);
+}
+
+void
+arch_handle_fun_end_breakpoint(os_context_t *context)
+{
+ *os_context_pc_addr(context)
+ = (os_context_register_t)(unsigned int)
+ handle_fun_end_breakpoint(context);
+}
+
+void
+arch_handle_after_breakpoint(os_context_t *context)
+{
+ arch_install_breakpoint(skipped_break_addr);
+ arch_remove_breakpoint((unsigned int *)os_context_pc(context),
+ displaced_after_inst);
+ *os_context_sigmask_addr(context) = orig_sigmask;
+}
+
static void
sigtrap_handler(int signal, siginfo_t *info, void *void_context)
{
os_context_t *context = arch_os_get_context(&void_context);
unsigned int code = (os_context_insn(context) >> 6) & 0xfffff;
-
- switch (code) {
- case trap_Halt:
- fake_foreign_function_call(context);
- lose("%%primitive halt called; the party is over.\n");
-
- case trap_PendingInterrupt:
- arch_skip_instruction(context);
- interrupt_handle_pending(context);
- break;
-
- case trap_Error:
- case trap_Cerror:
- interrupt_internal_error(signal, info, context, code == trap_Cerror);
- break;
-
- case trap_Breakpoint:
- handle_breakpoint(signal, info, context);
- break;
-
- case trap_FunEndBreakpoint:
- *os_context_pc_addr(context)
- = (os_context_register_t)(unsigned int)
- handle_fun_end_breakpoint(signal, info, context);
- break;
-
- case trap_AfterBreakpoint:
- arch_install_breakpoint(skipped_break_addr);
- arch_remove_breakpoint((unsigned int *)os_context_pc(context),
- displaced_after_inst);
- *os_context_sigmask_addr(context) = orig_sigmask;
- break;
-
- case 0x10:
+ /* FIXME: WTF is this magic number? Needs to become a #define
+ * and go into maybe_handle_trap. */
+ if (code==0x10) {
arch_clear_pseudo_atomic_interrupted(context);
arch_skip_instruction(context);
interrupt_handle_pending(context);
- return;
-
- default:
- interrupt_handle_now(signal, info, context);
- break;
- }
+ } else if (!maybe_handle_trap(context,code))
+ interrupt_handle_now(signal, info, void_context);
}
#define FIXNUM_VALUE(lispobj) (((int)lispobj) >> N_FIXNUM_TAG_BITS)
Index: ppc-arch.c
===================================================================
RCS file: /cvsroot/sbcl/sbcl/src/runtime/ppc-arch.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- ppc-arch.c 5 Feb 2007 07:23:40 -0000 1.19
+++ ppc-arch.c 1 Apr 2007 19:36:19 -0000 1.20
@@ -1,3 +1,14 @@
+/*
+ * This software is part of the SBCL system. See the README file for
+ * more information.
+ *
+ * This software is derived from the CMU CL system, which was
+ * written at Carnegie Mellon University and released into the
+ * public domain. The software is in the public domain and is
+ * provided with absolutely no warranty. See the COPYING and CREDITS
+ * files for more information.
+ */
+
#include <stdio.h>
#include "sbcl.h"
@@ -9,6 +20,7 @@
#include "signal.h"
#include "interrupt.h"
#include "interr.h"
+#include "breakpoint.h"
#if defined(LISP_FEATURE_GENCGC)
#include "gencgc-alloc-region.h"
@@ -43,7 +55,6 @@
os_vm_address_t
arch_get_bad_addr(int sig, siginfo_t *code, os_context_t *context)
{
- unsigned long pc = (unsigned long)(*os_context_pc_addr(context));
os_vm_address_t addr;
#if defined(LISP_FEATURE_NETBSD)
@@ -207,14 +218,11 @@
{
unsigned int *pc;
unsigned int inst;
- unsigned int or_inst;
unsigned int target, target_ptr, end_addr;
unsigned int opcode;
int size;
- int immed;
boolean were_in_lisp;
char *memory;
- sigset_t block;
target = 0;
size = 0;
@@ -366,6 +374,42 @@
}
#endif
+void
+arch_handle_breakpoint(os_context_t *context)
+{
+ handle_breakpoint(context);
+}
+
+void
+arch_handle_fun_end_breakpoint(os_context_t *context)
+{
+ *os_context_pc_addr(context)
+ =(int)handle_fun_end_breakpoint(context);
+}
+
+/* FIXME: AFTER-BREAKPOINT-TRAP is defined for PPC, but never
+ * emitted as far as I can see. Should it be emitted, do removed
+ * entirely? */
+void
+arch_handle_after_breakpoint(os_context_t *context)
+{
+ *skipped_break_addr = trap_Breakpoint;
+ skipped_break_addr = NULL;
+ *(unsigned int *)*os_context_pc_addr(context)
+ = displaced_after_inst;
+ *os_context_sigmask_addr(context)= orig_sigmask;
+ os_flush_icache((os_vm_address_t) *os_context_pc_addr(context),
+ sizeof(unsigned int));
+}
+
+void
+arch_handle_single_step_trap(os_context_t *context, int trap)
+{
+ unsigned int code = *((u32 *)(*os_context_pc_addr(context)));
+ int register_offset = code >> 5 & 0x1f;
+ handle_single_step_trap(context, trap, register_offset);
+ arch_skip_instruction(context);
+}
static void
sigtrap_handler(int signal, siginfo_t *siginfo, os_context_t *context)
@@ -401,64 +445,16 @@
/* twllei reg_ZERO,N will always trap if reg_ZERO = 0 */
int trap = code & 0x1f;
- switch (trap) {
- case trap_Halt:
- fake_foreign_function_call(context);
- lose("%%primitive halt called; the party is over.\n");
-
- case trap_Error:
- case trap_Cerror:
- interrupt_internal_error(signal, code, context, trap == trap_Cerror);
- break;
-
- case trap_PendingInterrupt:
- /* This is supposed run after WITHOUT-INTERRUPTS if there
- * were pending signals. */
- arch_skip_instruction(context);
- interrupt_handle_pending(context);
- break;
-
- case trap_Breakpoint:
- handle_breakpoint(signal, code, context);
- break;
-
- case trap_FunEndBreakpoint:
- *os_context_pc_addr(context)
- =(int)handle_fun_end_breakpoint(signal, code, context);
- break;
-
- case trap_AfterBreakpoint:
- *skipped_break_addr = trap_Breakpoint;
- skipped_break_addr = NULL;
- *(unsigned int *)*os_context_pc_addr(context)
- = displaced_after_inst;
- *os_context_sigmask_addr(context)= orig_sigmask;
-
- os_flush_icache((os_vm_address_t) *os_context_pc_addr(context),
- sizeof(unsigned int));
- break;
-
- case trap_SingleStepAround:
- case trap_SingleStepBefore:
- {
- int register_offset = code >> 5 & 0x1f;
-
- handle_single_step_trap(context, trap, register_offset);
+ if (!maybe_handle_trap(context,trap))
+ interrupt_handle_now(signal, siginfo, context);
- arch_skip_instruction(context);
- break;
- }
- default:
- interrupt_handle_now(signal, code, context);
- break;
- }
#ifdef LISP_FEATURE_DARWIN
DARWIN_FIX_CONTEXT(context);
#endif
return;
}
if (((code >> 26) == 3) && (((code >> 21) & 31) == 24)) {
- interrupt_internal_error(signal, code, context, 0);
+ interrupt_internal_error(context, 0);
#ifdef LISP_FEATURE_DARWIN
DARWIN_FIX_CONTEXT(context);
#endif
Index: print.c
===================================================================
RCS file: /cvsroot/sbcl/sbcl/src/runtime/print.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- print.c 2 Mar 2007 17:52:55 -0000 1.25
+++ print.c 1 Apr 2007 19:36:19 -0000 1.26
@@ -351,7 +351,12 @@
static void print_unknown(lispobj obj)
{
- printf("unknown object: %p", obj);
+ printf("unknown object: %p", (void *)obj);
+}
+
+static void print_unknown(lispobj obj)
+{
+ printf("unknown object: %p", (void *)obj);
}
static void print_list(lispobj obj)
Index: sparc-arch.c
===================================================================
RCS file: /cvsroot/sbcl/sbcl/src/runtime/sparc-arch.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- sparc-arch.c 29 Dec 2006 00:32:16 -0000 1.19
+++ sparc-arch.c 1 Apr 2007 19:36:19 -0000 1.20
@@ -207,6 +207,30 @@
return result;
}
+void
+arch_handle_breakpoint(os_context_t *context)
+{
+ handle_breakpoint(context);
+}
+
+void
+arch_handle_fun_end_breakpoint(os_context_t *context)
+{
+ *os_context_pc_addr(context) = (int) handle_fun_end_breakpoint(context);
+ *os_context_npc_addr(context) = *os_context_pc_addr(context) + 4;
+}
+
+void
+arch_handle_after_breakpoint(os_context_t *context)
+{
+ *skipped_break_addr = trap_Breakpoint;
+ os_flush_icache(skipped_break_addr, sizeof(unsigned int));
+ skipped_break_addr = NULL;
+ *(unsigned long *) os_context_pc_addr(context) = displaced_after_inst;
+ /* context->sigmask = orig_sigmask; */
+ os_flush_icache((os_vm_address_t) os_context_pc_addr(context), sizeof(unsigned int));
+}
+
static void sigill_handler(int signal, siginfo_t *siginfo, void *void_context)
{
os_context_t *context = arch_os_get_context(&void_context);
@@ -226,44 +250,8 @@
inst = *pc;
trap = inst & 0x3fffff;
-
- switch (trap) {
- case trap_PendingInterrupt:
- arch_skip_instruction(context);
- interrupt_handle_pending(context);
- break;
-
- case trap_Halt:
- fake_foreign_function_call(context);
- lose("%%primitive halt called; the party is over.\n");
-
- case trap_Error:
- case trap_Cerror:
- interrupt_internal_error(signal, siginfo, context, trap == trap_Cerror);
- break;
-
- case trap_Breakpoint:
- handle_breakpoint(signal, siginfo, context);
- break;
-
- case trap_FunEndBreakpoint:
- *os_context_pc_addr(context) = (int) handle_fun_end_breakpoint(signal, siginfo, context);
- *os_context_npc_addr(context) = *os_context_pc_addr(context) + 4;
- break;
-
- case trap_AfterBreakpoint:
- *skipped_break_addr = trap_Breakpoint;
- os_flush_icache(skipped_break_addr, sizeof(unsigned int));
- skipped_break_addr = NULL;
- *(unsigned long *) os_context_pc_addr(context) = displaced_after_inst;
- /* context->sigmask = orig_sigmask; */
- os_flush_icache((os_vm_address_t) os_context_pc_addr(context), sizeof(unsigned int));
- break;
-
- default:
+ if (!maybe_handle_trap(context,trap))
interrupt_handle_now(signal, siginfo, context);
- break;
- }
}
else if ((siginfo->si_code) == ILL_ILLTRP
#ifdef LISP_FEATURE_LINUX
@@ -280,7 +268,7 @@
interrupt_handle_pending(context);
}
else {
- interrupt_internal_error(signal, siginfo, context, 0);
+ interrupt_internal_error(context, 0);
}
}
else {
@@ -333,7 +321,7 @@
if ((op1 & 3) != 0) {
/* The first arg wan't a fixnum. */
- interrupt_internal_error(signal, siginfo, context, 0);
+ interrupt_internal_error(context, 0);
return;
}
@@ -349,7 +337,7 @@
if ((op2 & 3) != 0) {
/* The second arg wan't a fixnum. */
- interrupt_internal_error(signal, siginfo, context, 0);
+ interrupt_internal_error(context, 0);
return;
}
Index: x86-64-arch.c
===================================================================
RCS file: /cvsroot/sbcl/sbcl/src/runtime/x86-64-arch.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- x86-64-arch.c 3 Mar 2007 00:42:03 -0000 1.17
+++ x86-64-arch.c 1 Apr 2007 19:36:19 -0000 1.18
@@ -203,6 +203,30 @@
#endif
}
+void
+arch_handle_breakpoint(os_context_t *context)
+{
+ --*os_context_pc_addr(context);
+ handle_breakpoint(context);
+}
+
+void
+arch_handle_fun_end_breakpoint(os_context_t *context)
+{
+ --*os_context_pc_addr(context);
+ *os_context_pc_addr(context) =
+ (unsigned long)handle_fun_end_breakpoint(context);
+}
+
+void
+arch_handle_single_step_trap(os_context_t *context, int trap)
+{
+ arch_skip_instruction(context);
+ /* On x86-64 the fdefn / function is always in RAX, so we pass
+ * 0 as the register_offset. */
+ handle_single_step_trap(context, trap, 0);
+}
+
void
sigtrap_handler(int signal, siginfo_t *info, void *void_context)
@@ -254,53 +278,9 @@
* number of bytes will follow, the first is the length of the byte
* arguments to follow. */
trap = *(unsigned char *)(*os_context_pc_addr(context));
- switch (trap) {
-
- case trap_PendingInterrupt:
- FSHOW((stderr, "/<trap pending interrupt>\n"));
- arch_skip_instruction(context);
- interrupt_handle_pending(context);
- break;
-
- case trap_Halt:
- /* Note: the old CMU CL code tried to save FPU state
- * here, and restore it after we do our thing, but there
- * seems to be no point in doing that, since we're just
- * going to lose(..) anyway. */
- fake_foreign_function_call(context);
- lose("%%PRIMITIVE HALT called; the party is over.\n");
-
- case trap_Error:
- case trap_Cerror:
- FSHOW((stderr, "<trap error/cerror %d>\n", trap));
- interrupt_internal_error(signal, info, context, trap==trap_Cerror);
- break;
- case trap_Breakpoint:
- --*os_context_pc_addr(context);
- handle_breakpoint(signal, info, context);
- break;
-
- case trap_FunEndBreakpoint:
- --*os_context_pc_addr(context);
- *os_context_pc_addr(context) =
- (unsigned long)handle_fun_end_breakpoint(signal, info, context);
- break;
-
- case trap_SingleStepAround:
- case trap_SingleStepBefore:
- arch_skip_instruction(context);
- /* On x86-64 the fdefn / function is always in RAX, so we pass
- * 0 as the register_offset. */
- handle_single_step_trap(context, trap, 0);
- break;
-
- default:
- FSHOW((stderr,"/[C--trap default %d %d %x]\n",
- signal, code, context));
+ if (!maybe_handle_trap(context, trap))
interrupt_handle_now(signal, info, context);
- break;
- }
}
void
Index: x86-arch.c
===================================================================
RCS file: /cvsroot/sbcl/sbcl/src/runtime/x86-arch.c,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -d -r1.47 -r1.48
--- x86-arch.c 26 Dec 2006 23:10:25 -0000 1.47
+++ x86-arch.c 1 Apr 2007 19:36:19 -0000 1.48
@@ -66,7 +66,7 @@
#elif defined __OpenBSD__
return &context->sc_eflags;
#elif defined LISP_FEATURE_DARWIN
- return &context->uc_mcontext->ss.eflags;
+ return (int *)(&context->uc_mcontext->ss.eflags);
#elif defined __NetBSD__
return &(context->uc_mcontext.__gregs[_REG_EFL]);
#elif defined LISP_FEATURE_WIN32
@@ -233,6 +233,30 @@
}
void
+arch_handle_breakpoint(os_context_t *context)
+{
+ --*os_context_pc_addr(context);
+ handle_breakpoint(context);
+}
+
+void
+arch_handle_fun_end_breakpoint(os_context_t *context)
+{
+ --*os_context_pc_addr(context);
+ *os_context_pc_addr(context) =
+ (int)handle_fun_end_breakpoint(context);
+}
+
+void
+arch_handle_single_step_trap(os_context_t *context, int trap)
+{
+ arch_skip_instruction(context);
+ /* On x86 the fdefn / function is always in EAX, so we pass 0
+ * as the register_offset. */
+ handle_single_step_trap(context, trap, 0);
+}
+
+void
sigtrap_handler(int signal, siginfo_t *info, void *void_context)
{
os_context_t *context = (os_context_t*)void_context;
@@ -278,54 +302,8 @@
* number of bytes will follow, the first is the length of the byte
* arguments to follow. */
trap = *(unsigned char *)(*os_context_pc_addr(context));
- /* FSHOW((stderr, "/<sigtrap trap %d at pc_addr: %p>\n", trap, *os_context_pc_addr(context))); */
- switch (trap) {
-
- case trap_PendingInterrupt:
- FSHOW((stderr, "/<trap pending interrupt>\n"));
- arch_skip_instruction(context);
- interrupt_handle_pending(context);
- break;
-
- case trap_Halt:
- /* Note: the old CMU CL code tried to save FPU state
- * here, and restore it after we do our thing, but there
- * seems to be no point in doing that, since we're just
- * going to lose(..) anyway. */
- fake_foreign_function_call(context);
- lose("%%PRIMITIVE HALT called; the party is over.\n");
-
- case trap_Error:
- case trap_Cerror:
- FSHOW((stderr, "<trap error/cerror %d>\n", trap));
- interrupt_internal_error(signal, info, context, trap==trap_Cerror);
- break;
-
- case trap_Breakpoint:
- --*os_context_pc_addr(context);
- handle_breakpoint(signal, info, context);
- break;
-
- case trap_FunEndBreakpoint:
- --*os_context_pc_addr(context);
- *os_context_pc_addr(context) =
- (int)handle_fun_end_breakpoint(signal, info, context);
- break;
-
- case trap_SingleStepAround:
- case trap_SingleStepBefore:
- arch_skip_instruction(context);
- /* On x86 the fdefn / function is always in EAX, so we pass 0
- * as the register_offset. */
- handle_single_step_trap(context, trap, 0);
- break;
-
- default:
- FSHOW((stderr,"/[C--trap default %d %d %x]\n",
- signal, trap, context));
+ if (!maybe_handle_trap(context, trap))
interrupt_handle_now(signal, info, context);
- break;
- }
}
void
Index: x86-bsd-os.c
===================================================================
RCS file: /cvsroot/sbcl/sbcl/src/runtime/x86-bsd-os.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- x86-bsd-os.c 15 Dec 2006 02:57:53 -0000 1.12
+++ x86-bsd-os.c 1 Apr 2007 19:36:19 -0000 1.13
@@ -36,21 +36,21 @@
{
switch(offset) {
case 0:
- return CONTEXT_ADDR_FROM_STEM(eax);
+ return (int *)CONTEXT_ADDR_FROM_STEM(eax);
case 2:
- return CONTEXT_ADDR_FROM_STEM(ecx);
+ return (int *)CONTEXT_ADDR_FROM_STEM(ecx);
case 4:
- return CONTEXT_ADDR_FROM_STEM(edx);
+ return (int *)CONTEXT_ADDR_FROM_STEM(edx);
case 6:
- return CONTEXT_ADDR_FROM_STEM(ebx);
+ return (int *)CONTEXT_ADDR_FROM_STEM(ebx);
case 8:
- return CONTEXT_ADDR_FROM_STEM(esp);
+ return (int *)CONTEXT_ADDR_FROM_STEM(esp);
case 10:
- return CONTEXT_ADDR_FROM_STEM(ebp);
+ return (int *)CONTEXT_ADDR_FROM_STEM(ebp);
case 12:
- return CONTEXT_ADDR_FROM_STEM(esi);
+ return (int *)CONTEXT_ADDR_FROM_STEM(esi);
case 14:
- return CONTEXT_ADDR_FROM_STEM(edi);
+ return (int *)CONTEXT_ADDR_FROM_STEM(edi);
default:
return 0;
}
@@ -59,7 +59,7 @@
int *
os_context_sp_addr(os_context_t *context)
{
- return CONTEXT_ADDR_FROM_STEM(esp);
+ return (int *)CONTEXT_ADDR_FROM_STEM(esp);
}
#endif /* __FreeBSD__ || __OpenBSD__ */
@@ -109,7 +109,7 @@
#elif defined __NetBSD__
return CONTEXT_ADDR_FROM_STEM(EIP);
#elif defined(LISP_FEATURE_DARWIN) && defined(LISP_FEATURE_X86)
- return CONTEXT_ADDR_FROM_STEM(eip);
+ return (int *)CONTEXT_ADDR_FROM_STEM(eip);
#elif defined LISP_FEATURE_DARWIN
return &context->uc_mcontext->ss.srr0;
#else
|