diff --git a/lisp/breakpoint.c b/lisp/breakpoint.c index 75812cfc08344da61ab22f3e7d6718a7f96485da..48d6ed7bbb277c6c35cf7bfffe9a22dde59be520 100644 --- a/lisp/breakpoint.c +++ b/lisp/breakpoint.c @@ -1,6 +1,6 @@ /* - $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/breakpoint.c,v 1.10 2000/04/12 17:31:19 pw Exp $ + $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/breakpoint.c,v 1.11 2000/09/05 08:51:51 dtc Exp $ This code was written as part of the CMU Common Lisp project at Carnegie Mellon University, and has been placed in the public domain. @@ -34,7 +34,7 @@ static void *compute_pc(lispobj code_obj, int pc_offset) struct code *code; code = (struct code *)PTR(code_obj); - return (void *)((char *)code + HeaderValue(code->header)*sizeof(lispobj) + return (void *)((char *)code + HeaderValue(code->header) * sizeof(lispobj) + pc_offset); } @@ -84,9 +84,10 @@ static lispobj find_code(struct sigcontext *scp) { lispobj codeptr = component_ptr_from_pc(SC_PC(scp)); - if (codeptr==NULL) + if (codeptr == NULL) return NIL; - return (codeptr+type_OtherPointer); + else + return codeptr + type_OtherPointer; } #endif @@ -142,8 +143,11 @@ void handle_breakpoint(int signal, int subcode, struct sigcontext *scp) code = find_code(scp); - /* Don't disallow recursive breakpoint traps. Otherwise, we can't */ - /* use debugger breakpoints anywhere in here. */ + /* + * Don't disallow recursive breakpoint traps. Otherwise, we can't + * use debugger breakpoints anywhere in here. + */ + #if defined POSIX_SIGS sigprocmask(SIG_SETMASK,&scp->sc_mask,NULL); #else @@ -193,10 +197,13 @@ void *handle_function_end_breakpoint(int signal, int subcode, fake_foreign_function_call(scp); code = find_code(scp); - codeptr = (struct code *)PTR(code); + codeptr = (struct code *) PTR(code); + + /* + * Don't disallow recursive breakpoint traps. Otherwise, we can't + * use debugger breakpoints anywhere in here. + */ - /* Don't disallow recursive breakpoint traps. Otherwise, we can't - * use debugger breakpoints anywhere in here. */ #if defined POSIX_SIGS sigprocmask(SIG_SETMASK,&scp->sc_mask,NULL); #else @@ -210,6 +217,6 @@ void *handle_function_end_breakpoint(int signal, int subcode, undo_fake_foreign_function_call(scp); return compute_pc(codeptr->constants[REAL_LRA_SLOT], - fixnum_value(codeptr->constants[REAL_LRA_SLOT+1])); + fixnum_value(codeptr->constants[REAL_LRA_SLOT + 1])); } #endif diff --git a/lisp/gencgc.c b/lisp/gencgc.c index b3bcfec5fcbb18f4c90999e99e469af9a1ffca95..6888f8a1fde410cde0ad0842bf6bcbc8c35efc96 100644 --- a/lisp/gencgc.c +++ b/lisp/gencgc.c @@ -7,7 +7,7 @@ * * Douglas Crosher, 1996, 1997, 1998, 1999. * - * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/gencgc.c,v 1.20 2000/08/27 14:45:41 dtc Exp $ + * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/gencgc.c,v 1.21 2000/09/05 08:51:51 dtc Exp $ * */ @@ -5789,6 +5789,7 @@ static void garbage_collect_generation(int generation, int raise) * Scavenge the Lisp functions of the interrupt handlers, taking * care to avoid SIG_DFL, SIG_IGN. */ + for (i = 0; i < NSIG; i++) { union interrupt_handler handler = interrupt_handlers[i]; if ((handler.c != SIG_IGN) && (handler.c != SIG_DFL)) @@ -5805,6 +5806,7 @@ static void garbage_collect_generation(int generation, int raise) * only be updated with hooks already scavenged so this only needs * doing here. */ + scavenge((lispobj *) &scavenger_hooks, 1); if (SymbolValue(SCAVENGE_READ_ONLY_SPACE) != NIL) { @@ -6237,7 +6239,6 @@ void gc_init(void) current_region_end_addr = boxed_region.end_addr; } - /* * Pickup the dynamic space from after a core load. * diff --git a/lisp/x86-arch.c b/lisp/x86-arch.c index cda357d13867551a782fcac6400c1c1cb94405b3..e19f4fbe0ec8fd9ea91faff37c7d57152aba7314 100644 --- a/lisp/x86-arch.c +++ b/lisp/x86-arch.c @@ -1,6 +1,6 @@ /* x86-arch.c -*- Mode: C; comment-column: 40 -*- * - * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/x86-arch.c,v 1.11 1999/11/11 16:14:16 dtc Exp $ + * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/x86-arch.c,v 1.12 2000/09/05 08:51:52 dtc Exp $ * */ @@ -19,45 +19,47 @@ #include "interr.h" #include "breakpoint.h" -#define DPRINTF(test,e){if(test) fprintf e ;} +#define DPRINTF(test, e) {if(test) fprintf e ;} #define BREAKPOINT_INST 0xcc /* INT3 */ unsigned long fast_random_state = 1; -char * -arch_init(void) +char * arch_init(void) { return "lisp.core"; } -void arch_skip_instruction(context) -struct sigcontext *context; + +/* + * Assuming we get here via an INT3 xxx instruction, the PC now + * points to the interrupt code (lisp value) so we just move past + * it. Skip the code, then if the code if an error-trap or + * Cerror-trap then skip the data bytes that follow. + */ + +void arch_skip_instruction(struct sigcontext *context) { - /* Assuming we get here via an INT3 xxx instruction, the PC now - * points to the interrupt code (lisp value) so we just move past - * it. Skip the code, then if the code if an error-trap or - * Cerror-trap then skip the data bytes that follow. */ int vlen,code; DPRINTF(0,(stderr,"[arch_skip_inst at %x>]\n", context->sc_pc)); /* Get and skip the lisp error code. */ - code = *(char*)context->sc_pc++; + code = *(char*) context->sc_pc++; switch (code) { case trap_Error: case trap_Cerror: /* Lisp error arg vector length */ - vlen = *(char*)context->sc_pc++; + vlen = *(char*) context->sc_pc++; /* Skip lisp error arg data bytes */ while(vlen-- > 0) - (char*)context->sc_pc++; + (char*) context->sc_pc++; break; - case trap_Breakpoint: /* Not tested */ - case trap_FunctionEndBreakpoint: /* not tested */ + case trap_Breakpoint: + case trap_FunctionEndBreakpoint: break; case trap_PendingInterrupt: @@ -66,113 +68,116 @@ struct sigcontext *context; break; default: - fprintf(stderr,"[arch_skip_inst invalid code %d\n]\n",code); + fprintf(stderr, "[arch_skip_inst invalid code %d\n]\n", code); break; } DPRINTF(0,(stderr,"[arch_skip_inst resuming at %x>]\n", context->sc_pc)); } -unsigned char * -arch_internal_error_arguments(struct sigcontext *context) +unsigned char * arch_internal_error_arguments(struct sigcontext *context) { - return (unsigned char *)(context->sc_pc+1); + return (unsigned char *) (context->sc_pc + 1); } -boolean -arch_pseudo_atomic_atomic(struct sigcontext *context) +boolean arch_pseudo_atomic_atomic(struct sigcontext *context) { return SymbolValue(PSEUDO_ATOMIC_ATOMIC); } -void -arch_set_pseudo_atomic_interrupted(struct sigcontext *context) +void arch_set_pseudo_atomic_interrupted(struct sigcontext *context) { SetSymbolValue(PSEUDO_ATOMIC_INTERRUPTED, make_fixnum(1)); } -/* This stuff seems to get called for TRACE and debug activity */ -unsigned long -arch_install_breakpoint(void *pc) + +unsigned long arch_install_breakpoint(void *pc) { unsigned long result = *(unsigned long*)pc; *(char*)pc = BREAKPOINT_INST; /* x86 INT3 */ - *((char*)pc+1) = trap_Breakpoint; /* Lisp trap code */ + *((char*)pc+1) = trap_Breakpoint; /* Lisp trap code */ return result; } -void -arch_remove_breakpoint(void *pc, unsigned long orig_inst) +void arch_remove_breakpoint(void *pc, unsigned long orig_inst) { - *((char *)pc) = orig_inst & 0xff; - *((char *)pc + 1) = (orig_inst & 0xff00) >> 8; + *((char *) pc) = orig_inst & 0xff; + *((char *) pc + 1) = (orig_inst & 0xff00) >> 8; } -#ifdef __linux__ -_syscall1(int,sigreturn,struct sigcontext *,context) -#endif +/* + * When single stepping single_stepping holds the original instruction + * pc location. + */ -/* When single stepping single_stepping holds the original instruction - pc location. */ -unsigned int *single_stepping=NULL; +unsigned int *single_stepping = NULL; #ifndef __linux__ unsigned int single_step_save1; unsigned int single_step_save2; unsigned int single_step_save3; #endif -void -arch_do_displaced_inst(struct sigcontext *context, unsigned long orig_inst) +void arch_do_displaced_inst(struct sigcontext *context, + unsigned long orig_inst) { - unsigned int *pc = (unsigned int*)context->sc_pc; - unsigned int flags = context->sc_efl; + unsigned int *pc = (unsigned int*) context->sc_pc; + + /* + * Put the original instruction back. + */ - /* Put the original instruction back. */ - *((char *)pc) = orig_inst & 0xff; - *((char *)pc + 1) = (orig_inst & 0xff00) >> 8; + *((char *) pc) = orig_inst & 0xff; + *((char *) pc + 1) = (orig_inst & 0xff00) >> 8; #ifdef __linux__ context->eflags |= 0x100; #else - /* Install helper instructions for the single step: - pushf; or [esp],0x100; popf. */ - single_step_save1 = *(pc-3); - single_step_save2 = *(pc-2); - single_step_save3 = *(pc-1); - *(pc-3) = 0x9c909090; - *(pc-2) = 0x00240c81; - *(pc-1) = 0x9d000001; + + /* + * Install helper instructions for the single step: + * pushf; or [esp],0x100; popf. + */ + + single_step_save1 = *(pc - 3); + single_step_save2 = *(pc - 2); + single_step_save3 = *(pc - 1); + *(pc - 3) = 0x9c909090; + *(pc - 2) = 0x00240c81; + *(pc - 1) = 0x9d000001; #endif - single_stepping=(unsigned int*)pc; + single_stepping = (unsigned int*) pc; #ifndef __linux__ - (unsigned int*)context->sc_pc = ((char *)pc-9); + (unsigned int*) context->sc_pc = (char *) pc - 9; #endif } -void -sigtrap_handler(HANDLER_ARGS) +void sigtrap_handler(HANDLER_ARGS) { unsigned int trap; #ifdef __linux__ GET_CONTEXT #endif - /* - fprintf(stderr,"x86sigtrap: %8x %x\n", - context->sc_pc, *(unsigned char *)(context->sc_pc-1)); - fprintf(stderr,"sigtrap(%d %d %x)\n",signal,code,context);*/ - if (single_stepping && (signal==SIGTRAP)) +#if 0 + fprintf(stderr,"x86sigtrap: %8x %x\n", + context->sc_pc, *(unsigned char *)(context->sc_pc-1)); + fprintf(stderr,"sigtrap(%d %d %x)\n",signal,code,context); +#endif + + if (single_stepping && (signal == SIGTRAP)) { - /* fprintf(stderr,"* Single step trap %x\n", single_stepping); */ +#if 0 + fprintf(stderr,"* Single step trap %x\n", single_stepping); +#endif #ifndef __linux__ /* Un-install single step helper instructions. */ @@ -182,24 +187,28 @@ sigtrap_handler(HANDLER_ARGS) #else context->eflags ^= 0x100; #endif - /* Re-install the breakpoint if possible. */ - if ((int)context->sc_pc == (int)single_stepping + 1) - fprintf(stderr,"* Breakpoint not re-install\n"); + + /* + * Re-install the breakpoint if possible. + */ + + if ((int) context->sc_pc == (int) single_stepping + 1) + fprintf(stderr, "* Breakpoint not re-install\n"); else { - char*ptr = (char*)single_stepping; - *((char *)single_stepping) = BREAKPOINT_INST; /* x86 INT3 */ - *((char *)single_stepping+1) = trap_Breakpoint; + char *ptr = (char *) single_stepping; + ptr[0] = BREAKPOINT_INST; /* x86 INT3 */ + ptr[1] = trap_Breakpoint; } - single_stepping=NULL; + single_stepping = NULL; return; } SAVE_CONTEXT(); - /* this is just for info in case monitor wants to print an approx */ - current_control_stack_pointer = (unsigned long*)context->sc_sp; + /* This is just for info in case monitor wants to print an approx */ + current_control_stack_pointer = (unsigned long*) context->sc_sp; #if defined(__linux__) && defined(i386) /* @@ -209,11 +218,15 @@ sigtrap_handler(HANDLER_ARGS) setfpucw(contextstruct.fpstate->cw & ~0xc00); #endif - /* On entry %eip points just after the INT3 byte and aims at the + /* + * On entry %eip points just after the INT3 byte and aims at the * 'kind' value (eg trap_Cerror). For error-trap and Cerror-trap a * number of bytes will follow, the first is the length of the byte - * arguments to follow. */ - trap = *(unsigned char *)(context->sc_pc); + * arguments to follow. + */ + + trap = *(unsigned char *) (context->sc_pc); + switch (trap) { case trap_PendingInterrupt: @@ -240,30 +253,34 @@ sigtrap_handler(HANDLER_ARGS) case trap_Error: case trap_Cerror: - DPRINTF(0,(stderr,"<trap Error %d>\n",code)); + DPRINTF(0, (stderr, "<trap Error %d>\n",code)); #ifdef __linux__ - interrupt_internal_error(signal,contextstruct, code==trap_Cerror); + interrupt_internal_error(signal, contextstruct, code == trap_Cerror); #else - interrupt_internal_error(signal, code, context, code==trap_Cerror); + interrupt_internal_error(signal, code, context, code == trap_Cerror); #endif break; - + case trap_Breakpoint: - /* fprintf(stderr,"*C break\n");*/ - (char*)context->sc_pc -= 1; +#if 0 + fprintf(stderr,"*C break\n"); +#endif + (char*) context->sc_pc -= 1; handle_breakpoint(signal, code, context); - /* fprintf(stderr,"*C break return\n");*/ +#if 0 + fprintf(stderr,"*C break return\n"); +#endif break; case trap_FunctionEndBreakpoint: - (char*)context->sc_pc -= 1; - context->sc_pc = (int)handle_function_end_breakpoint(signal, code, context); + (char*) context->sc_pc -= 1; + context->sc_pc = (int) handle_function_end_breakpoint(signal, code, context); break; default: - DPRINTF(0,(stderr,"[C--trap default %d %d %x]\n",signal,code,context)); + DPRINTF(0,(stderr,"[C--trap default %d %d %x]\n", signal, code,context)); #ifdef __linux__ - interrupt_handle_now(signal,contextstruct); + interrupt_handle_now(signal, contextstruct); #else interrupt_handle_now(signal, code, context); #endif @@ -271,19 +288,18 @@ sigtrap_handler(HANDLER_ARGS) } } -#define FIXNUM_VALUE(lispobj) (((int)lispobj)>>2) +#define FIXNUM_VALUE(lispobj) (((int) lispobj) >> 2) extern void first_handler(); -void -arch_install_interrupt_handlers() + +void arch_install_interrupt_handlers() { - interrupt_install_low_level_handler(SIGILL ,sigtrap_handler); - interrupt_install_low_level_handler(SIGTRAP,sigtrap_handler); + interrupt_install_low_level_handler(SIGILL, sigtrap_handler); + interrupt_install_low_level_handler(SIGTRAP, sigtrap_handler); } -extern lispobj -call_into_lisp(lispobj fun, lispobj *args, int nargs); +extern lispobj call_into_lisp(lispobj fun, lispobj *args, int nargs); /* These next four functions are an interface to the * Lisp call-in facility. Since this is C we can know @@ -296,24 +312,22 @@ call_into_lisp(lispobj fun, lispobj *args, int nargs); * args into a portable vector and let the assembly language * call-in function figure it out. */ -lispobj -funcall0(lispobj function) + +lispobj funcall0(lispobj function) { lispobj *args = NULL; return call_into_lisp(function, args, 0); } -lispobj -funcall1(lispobj function, lispobj arg0) +lispobj funcall1(lispobj function, lispobj arg0) { lispobj args[1]; args[0] = arg0; return call_into_lisp(function, args, 1); } -lispobj -funcall2(lispobj function, lispobj arg0, lispobj arg1) +lispobj funcall2(lispobj function, lispobj arg0, lispobj arg1) { lispobj args[2]; args[0] = arg0; @@ -321,8 +335,7 @@ funcall2(lispobj function, lispobj arg0, lispobj arg1) return call_into_lisp(function, args, 2); } -lispobj -funcall3(lispobj function, lispobj arg0, lispobj arg1, lispobj arg2) +lispobj funcall3(lispobj function, lispobj arg0, lispobj arg1, lispobj arg2) { lispobj args[3]; args[0] = arg0; diff --git a/lisp/x86-assem.S b/lisp/x86-assem.S index 36fef2a17d04a4ee1f8199c68fb2ecef219e0bf1..abc8e03c4975ec559d17b20159b4ac32da54f9f5 100644 --- a/lisp/x86-assem.S +++ b/lisp/x86-assem.S @@ -1,6 +1,6 @@ ### x86-assem.S -*- Mode: Asm; -*- /** - * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/x86-assem.S,v 1.18 2000/05/06 16:55:53 dtc Exp $ + * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/x86-assem.S,v 1.19 2000/09/05 08:51:52 dtc Exp $ * * Authors: Paul F. Werkowski <pw@snoopy.mv.com> * Douglas T. Crosher @@ -50,7 +50,7 @@ * Return values are in eax and maybe edx for quads, or st(0) for * floats. * - * It should work for lisp calls c calls lisp calls c .. + * It should work for lisp calls C calls lisp calls C .. */ .text .align align_16byte,0x90 @@ -122,6 +122,7 @@ Lfp_rtn_value: .size GNAME(call_into_c), . - GNAME(call_into_c) + .text .global GNAME(call_into_lisp) .type GNAME(call_into_lisp),@function @@ -204,15 +205,15 @@ OnLispStack: je Ldone movl 8(%ebx),%esi # arg2 Ldone: - /* registers eax, ecx, edx,edi,esi now live */ + /* Registers eax, ecx, edx,edi,esi now live */ - /* alloc new frame */ + /* Allocate new frame */ mov %esp,%ebx # current sp marks start of new frame push %ebp # fp in save location S0 sub $8,%esp # Ensure 3 slots are allocated, one above. mov %ebx,%ebp # switch to new frame - /* indirect the closure */ + /* Indirect the closure */ call *CLOSURE_FUNCTION_OFFSET(%eax) /* Multi-value return - blow off any extra values */ @@ -222,7 +223,7 @@ Ldone: /* Restore the stack, in case there was a stack change. */ popl %esp # c-sp -/* restore C regs: ebx esi edi */ +/* Restore C regs: ebx esi edi */ popl %edi popl %esi popl %ebx @@ -256,6 +257,7 @@ GNAME(fpu_restore): ret .size GNAME(fpu_restore),.-GNAME(fpu_restore) + /* * The undefined-function trampoline. */