diff --git a/code/foreign.lisp b/code/foreign.lisp index 5d54b9441d0592dd9b3901fe7acfcbc8c950fd87..b7ede3f52672c6996afe6d7e4da33f24d254fe5b 100644 --- a/code/foreign.lisp +++ b/code/foreign.lisp @@ -5,7 +5,7 @@ ;;; Carnegie Mellon University, and has been placed in the public domain. ;;; (ext:file-comment - "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/foreign.lisp,v 1.48 2004/06/13 09:55:20 emarsden Exp $") + "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/foreign.lisp,v 1.49 2004/07/07 15:03:11 rtoy Exp $") ;;; ;;; ********************************************************************** ;;; @@ -705,11 +705,11 @@ environment passed to Lisp." *dso-linker* (list* #+(or solaris linux FreeBSD4) "-G" - #+(or OpenBSD irix) "-shared" + #+(or OpenBSD NetBSD irix) "-shared" "-o" output-file ;; Cause all specified libs to be loaded in full - #+(or OpenBSD linux FreeBSD4) "--whole-archive" + #+(or OpenBSD linux FreeBSD4 NetBSD) "--whole-archive" #+solaris "-z" #+solaris "allextract" (append (mapcar #'(lambda (name) @@ -725,7 +725,7 @@ environment passed to Lisp." files)) ;; Return to default ld behaviour for libs (list - #+(or OpenBSD linux FreeBSD4) + #+(or OpenBSD linux FreeBSD4 NetBSD) "--no-whole-archive" #+solaris "-z" #+solaris "defaultextract") libraries)) diff --git a/code/unix.lisp b/code/unix.lisp index aafc79cf58de826b1f7aa2df5cb91d43a765c143..02782811718da6bb97bbe634eccf02d83c9ce283 100644 --- a/code/unix.lisp +++ b/code/unix.lisp @@ -5,7 +5,7 @@ ;;; Carnegie Mellon University, and has been placed in the public domain. ;;; (ext:file-comment - "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/unix.lisp,v 1.92 2004/03/24 13:26:19 emarsden Exp $") + "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/unix.lisp,v 1.93 2004/07/07 15:03:11 rtoy Exp $") ;;; ;;; ********************************************************************** ;;; @@ -928,6 +928,21 @@ (pw-expire int) ; account expiration (pw-fields int))) ; internal +#+netbsd +(def-alien-type nil + (struct passwd + (pw-name (* char)) ; user's login name + (pw-passwd (* char)) ; no longer used + (pw-uid uid-t) ; user id + (pw-gid gid-t) ; group id + (pw-change int) ; password change time + (pw-class (* char)) ; user access class + (pw-gecos (* char)) ; typically user's full name + (pw-dir (* char)) ; user's home directory + (pw-shell (* char)) ; user's login shell + (pw-expire int))) ; account expiration + + ;; see <grp.h> (def-alien-type nil (struct group @@ -987,7 +1002,7 @@ (defconstant map_anonymous #+solaris #x100 ; Solaris #+linux 32 ; Linux - #+freebsd #x1000) + #+bsd #x1000) (defconstant ms_async 1) (defconstant ms_sync 4) @@ -2856,7 +2871,7 @@ :dir (string (cast (slot result 'pw-dir) c-call:c-string)) :shell (string (cast (slot result 'pw-shell) c-call:c-string))))))) -#+FreeBSD +#+(or FreeBSD NetBSD) (defun unix-getpwnam (login) "Return a USER-INFO structure for the user identified by LOGIN, or NIL if not found." (declare (type simple-string login)) @@ -2907,7 +2922,7 @@ :dir (string (cast (slot result 'pw-dir) c-call:c-string)) :shell (string (cast (slot result 'pw-shell) c-call:c-string))))))) -#+FreeBSD +#+(or FreeBSD NetBSD) (defun unix-getpwuid (uid) "Return a USER-INFO structure for the user identified by UID, or NIL if not found." (declare (type unix-uid uid)) @@ -2956,7 +2971,7 @@ :until (zerop (sap-int (alien-sap member))) :collect (string (cast member c-call:c-string)))))))) -#+FreeBSD +#+(or FreeBSD NetBSD) (defun unix-getgrnam (name) "Return a GROUP-INFO structure for the group identified by NAME, or NIL if not found." (declare (type simple-string name)) @@ -3006,7 +3021,7 @@ :until (zerop (sap-int (alien-sap member))) :collect (string (cast member c-call:c-string)))))))) -#+FreeBSD +#+(or FreeBSD NetBSD) (defun unix-getgrgid (gid) "Return a GROUP-INFO structure for the group identified by GID, or NIL if not found." (declare (type unix-gid gid)) diff --git a/code/x86-vm.lisp b/code/x86-vm.lisp index 4ef5a575ea24c53de2e3cfd911e76f75e194a520..dfe8213f7cf914a09518c8c7b4d4a3ced44a4006 100644 --- a/code/x86-vm.lisp +++ b/code/x86-vm.lisp @@ -7,7 +7,7 @@ ;;; Scott Fahlman or slisp-group@cs.cmu.edu. ;;; (ext:file-comment - "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/x86-vm.lisp,v 1.21 2002/08/27 22:18:25 moore Exp $") + "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/x86-vm.lisp,v 1.22 2004/07/07 15:03:11 rtoy Exp $") ;;; ;;; ********************************************************************** ;;; @@ -103,7 +103,7 @@ (sc-sp unsigned-int) (sc-ss unsigned-int))) -;;; OpenBSD/NetBSD also have sigcontext structs that look more like Linux. +;;; OpenBSD also have sigcontext structs that look more like Linux. #+openbsd (def-alien-type sigcontext (struct nil @@ -129,7 +129,9 @@ (sc-err unsigned-int) )) -#+netbsd +;; NetBSD + +#+netbsd1.6 (def-alien-type sigcontext (struct nil (sc-gs unsigned-int) @@ -157,6 +159,46 @@ (sc-mask (array unsigned-int 4)) )) +#+netbsd +(def-alien-type sigaltstack + (struct nil + (ss-sp unsigned-int) + (ss-size unsigned-int) + (ss-flags unsigned-int))) + +#+netbsd +(def-alien-type mcontext + (struct nil + (mc-gs unsigned-long) + (mc-fs unsigned-long) + (mc-es unsigned-long) + (mc-ds unsigned-long) + (mc-edi unsigned-long) + (mc-esi unsigned-long) + (mc-ebp unsigned-long) + (mc-esp unsigned-long) + (mc-ebx unsigned-long) + (mc-edx unsigned-long) + (mc-ecx unsigned-long) + (mc-eax unsigned-long) + (mc-trapno unsigned-long) + (mc-err unsigned-long) + (mc-eip unsigned-long) + (mc-cs unsigned-long) + (mc-efl unsigned-long) + (mc-uesp unsigned-long) + (mc-ss unsigned-long))) + +#+netbsd +(def-alien-type ucontext + (struct nil + (uc-flags unsigned-long) + (uc-link unsigned-long) + (uc-sigmask (array unsigned-long 4)) + (uc-stack sigaltstack) + (uc-mcontext mcontext))) + + ;; For Linux... #+linux (def-alien-type sigcontext @@ -328,6 +370,7 @@ ;;; Given the sigcontext, extract the internal error arguments from the ;;; instruction stream. ;;; +#-netbsd (defun internal-error-arguments (scp) (declare (type (alien (* sigcontext)) scp)) (with-alien ((scp (* sigcontext) scp)) @@ -351,22 +394,54 @@ (sc-offsets (c::read-var-integer vector index))) (values error-number (sc-offsets)))))))) +#+netbsd +(defun internal-error-arguments (ucp) + (declare (type (alien (* ucontext)) ucp)) + (%primitive print "internal-error-arguments") + (with-alien ((mcp (* mcontext) (slot ucp 'uc-mcontext))) + (let ((pc (int-sap (slot mcp 'mc-eip)))) + (declare (type system-area-pointer pc)) + ;; using INT3 the pc is .. INT3 <here> code length bytes... + (let* ((length (sap-ref-8 pc 1)) + (vector (make-array length :element-type '(unsigned-byte 8)))) + (declare (type (unsigned-byte 8) length) + (type (simple-array (unsigned-byte 8) (*)) vector)) + (copy-from-system-area pc (* vm:byte-bits 2) + vector (* vm:word-bits + vm:vector-data-offset) + (* length vm:byte-bits)) + (let* ((index 0) + (error-number (c::read-var-integer vector index))) + (collect ((sc-offsets)) + (loop + (when (>= index length) + (return)) + (sc-offsets (c::read-var-integer vector index))) + (values error-number (sc-offsets)))))))) ;;;; Sigcontext access functions. ;;; SIGCONTEXT-PROGRAM-COUNTER -- Interface. ;;; +#-netbsd (defun sigcontext-program-counter (scp) (declare (type (alien (* sigcontext)) scp)) (with-alien ((scp (* sigcontext) scp)) (int-sap (slot scp 'sc-pc)))) +#+netbsd +(defun sigcontext-program-counter (ucp) + (declare (type (alien (* ucontext)) ucp)) + (with-alien ((mcp (* mcontext) (slot ucp 'uc-mcontext))) + (int-sap (slot mcp 'sc-eip)))) + ;;; SIGCONTEXT-REGISTER -- Interface. ;;; ;;; An escape register saves the value of a register for a frame that someone ;;; interrupts. ;;; +#-netbsd (defun sigcontext-register (scp index) (declare (type (alien (* sigcontext)) scp)) (with-alien ((scp (* sigcontext) scp)) @@ -380,7 +455,7 @@ (#.esi-offset (slot scp 'sc-esi)) (#.edi-offset (slot scp 'sc-edi))))) - +#-netbsd (defun %set-sigcontext-register (scp index new) (declare (type (alien (* sigcontext)) scp)) (with-alien ((scp (* sigcontext) scp)) @@ -395,6 +470,35 @@ (#.edi-offset (setf (slot scp 'sc-edi) new)))) new) +#+netbsd +(defun sigcontext-register (ucp index) + (declare (type (alien (* ucontext)) ucp)) + (with-alien ((mcp (* mcontext) (slot ucp 'uc-mcontext))) + (case index ; ugly -- I know. + (#.eax-offset (slot mcp 'mc-eax)) + (#.ecx-offset (slot mcp 'mc-ecx)) + (#.edx-offset (slot mcp 'mc-edx)) + (#.ebx-offset (slot mcp 'mc-ebx)) + (#.esp-offset (slot mcp 'mc-esp)) + (#.ebp-offset (slot mcp 'mc-ebp)) + (#.esi-offset (slot mcp 'mc-esi)) + (#.edi-offset (slot mcp 'mc-edi))))) + +#+netbsd +(defun %set-sigcontext-register (ucp index new) + (declare (type (alien (* ucontext)) ucp)) + (with-alien ((mcp (* mcontext) (slot ucp 'uc-mcontext))) + (case index + (#.eax-offset (setf (slot mcp 'mc-eax) new)) + (#.ecx-offset (setf (slot mcp 'mc-ecx) new)) + (#.edx-offset (setf (slot mcp 'mc-edx) new)) + (#.ebx-offset (setf (slot mcp 'mc-ebx) new)) + (#.esp-offset (setf (slot mcp 'mc-esp) new)) + (#.ebp-offset (setf (slot mcp 'mc-ebp) new)) + (#.esi-offset (setf (slot mcp 'mc-esi) new)) + (#.edi-offset (setf (slot mcp 'mc-edi) new)))) + new) + (defsetf sigcontext-register %set-sigcontext-register) @@ -446,13 +550,19 @@ ;;; same format as returned by FLOATING-POINT-MODES. ;;; -#+BSD +#+(or freebsd openbsd) (defun sigcontext-floating-point-modes (scp) (declare (type (alien (* sigcontext)) scp) (ignore scp)) ;; This is broken until some future release of FreeBSD/OpenBSD!!! (floating-point-modes)) +#+netbsd +(defun sigcontext-floating-point-modes (ucp) + (declare (type (alien (* ucontext)) ucp) + (ignore ucp)) + (floating-point-modes)) + #+linux (defun sigcontext-floating-point-modes (scp) (declare (type (alien (* sigcontext)) scp)) diff --git a/compiler/x86/parms.lisp b/compiler/x86/parms.lisp index 6ecd0256e80c6b71ce9eb4b854446d0d13cd89d6..336bf4c44614f37fd80e5da6c948b8be4d0788a3 100644 --- a/compiler/x86/parms.lisp +++ b/compiler/x86/parms.lisp @@ -7,7 +7,7 @@ ;;; Scott Fahlman or slisp-group@cs.cmu.edu. ;;; (ext:file-comment - "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/x86/parms.lisp,v 1.27 2004/01/16 03:08:59 toy Exp $") + "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/x86/parms.lisp,v 1.28 2004/07/07 15:03:11 rtoy Exp $") ;;; ;;; ********************************************************************** ;;; @@ -185,7 +185,8 @@ #-FreeBSD #x28000000) (defconstant target-dynamic-space-start #+linux #x58000000 - #-linux #x48000000) + #+(or FreeBSD OpenBSD) #x48000000 + #+NetBSD #x48800000) (defconstant target-foreign-linkage-space-start #+linux #xBE000000 #-linux #xB0000000) diff --git a/lisp/Config.NetBSD_gencgc b/lisp/Config.NetBSD_gencgc index f6bf462ec36cb3f9c666abd2580046765694f46b..5d1e8a42662c3532f1df1d69a0495f71378f4c1b 100644 --- a/lisp/Config.NetBSD_gencgc +++ b/lisp/Config.NetBSD_gencgc @@ -1,19 +1,47 @@ PATH1 = ../../src/lisp PATH2 = ../../p86/lisp +ARCH = $(shell uname -m) vpath %.h $(PATH2):$(PATH1) vpath %.c $(PATH2):$(PATH1) vpath %.S $(PATH2):$(PATH1) CPPFLAGS = -I. -I$(PATH2) -I$(PATH1) -I- -I/usr/X11R6/include -CC = gcc +CC = gcc -pipe LD = ld CPP = cpp -CFLAGS = -Wstrict-prototypes -Wall -O2 -g -DGENCGC -Di386 -ASFLAGS = -g -DGENCGC -Di386 +CFLAGS = -Wstrict-prototypes -Wall -O2 -g +ASFLAGS = -g -x assembler-with-cpp NM = nm -gp UNDEFSYMPATTERN = -Xlinker -u -Xlinker & -ASSEM_SRC = x86-assem.S -ARCH_SRC = x86-arch.c -OS_SRC = NetBSD-os.c os-common.c undefineds.c -OS_LINK_FLAGS = -static + +ifeq ($(ARCH), i386) + ASSEM_SRC = x86-assem.S + ARCH_SRC = x86-arch.c + ASFLAGS += -Di386 -DGENCGC -DLINKAGE_TABLE + CFLAGS += -Di386 -DGENCGC -DLINKAGE_TABLE + GC_SRC = gencgc.c +endif + +ifeq ($(ARCH), sparc64) + ASSEM_SRC = sparc-assem.S + ARCH_SRC = sparc-arch.c + ASFLAGS += -Dsparc64 -DLINKAGE_TABLE + CFLAGS += -Dsparc64 -DLINKAGE_TABLE +endif + +ifeq ($(ARCH), sparc) + ASSEM_SRC = sparc-assem.S + ARCH_SRC = sparc-arch.c + ASFLAGS += -Dsparc + CFLAGS += -Dsparc +endif + +ifeq ($(ARCH), powerpc) + ASSEM_SRC = ppc-assem.S + ARCH_SRC = ppc-arch.c + ASFLAGS += -Dppc + CFLAGS += -Dppc +endif + +OS_SRC = NetBSD-os.c os-common.c elf.c +OS_LINK_FLAGS = -dynamic -export-dynamic OS_LIBS = -GC_SRC = gencgc.c diff --git a/lisp/NetBSD-os.c b/lisp/NetBSD-os.c index 57722a6b23d5104e2a6b3f814d6b2befecc0551a..30026e1a3c757c40f490ba264108cc6396e57bd9 100644 --- a/lisp/NetBSD-os.c +++ b/lisp/NetBSD-os.c @@ -15,7 +15,7 @@ * Frobbed for OpenBSD by Pierre R. Mai, 2001. * Frobbed for NetBSD by Pierre R. Mai, 2002. * - * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/NetBSD-os.c,v 1.1 2002/01/28 20:19:39 pmai Exp $ + * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/NetBSD-os.c,v 1.2 2004/07/07 15:03:11 rtoy Exp $ * */ @@ -36,6 +36,7 @@ #include <signal.h> /* #include <sys/sysinfo.h> */ #include <sys/proc.h> +#include <dlfcn.h> #include "validate.h" size_t os_vm_page_size; @@ -51,8 +52,22 @@ void os_init(void) os_vm_page_size = OS_VM_DEFAULT_PAGESIZE; } -int sc_reg(struct sigcontext *c, int offset) +int sc_reg(os_context_t *c, int offset) { +#ifdef i386 +#if USE_SA_SIGINFO + switch(offset) + { + case 0: return c->uc_mcontext.__gregs[_REG_EAX]; + case 2: return c->uc_mcontext.__gregs[_REG_ECX]; + case 4: return c->uc_mcontext.__gregs[_REG_EDX]; + case 6: return c->uc_mcontext.__gregs[_REG_EBX]; + case 8: return c->uc_mcontext.__gregs[_REG_ESP]; + case 10: return c->uc_mcontext.__gregs[_REG_EBP]; + case 12: return c->uc_mcontext.__gregs[_REG_ESI]; + case 14: return c->uc_mcontext.__gregs[_REG_EDI]; + } +#else switch(offset) { case 0: return c->sc_eax; @@ -64,6 +79,8 @@ int sc_reg(struct sigcontext *c, int offset) case 12: return c->sc_esi; case 14: return c->sc_edi; } +#endif +#endif return 0; } @@ -94,7 +111,7 @@ os_vm_address_t os_validate(os_vm_address_t addr, os_vm_size_t len) else flags |= MAP_VARIABLE; - DPRINTF(0, (stderr, "os_validate %x %d =>", addr, len)); + DPRINTF(0, (stderr, "os_validate %p %d =>", addr, len)); if (addr) { @@ -120,7 +137,7 @@ os_vm_address_t os_validate(os_vm_address_t addr, os_vm_size_t len) return NULL; } - DPRINTF(0, (stderr, " %x", resaddr)); + DPRINTF(0, (stderr, " %p", resaddr)); curaddr+=curlen; len-=curlen; @@ -138,7 +155,7 @@ os_vm_address_t os_validate(os_vm_address_t addr, os_vm_size_t len) return NULL; } - DPRINTF(0, (stderr, " %x\n", addr)); + DPRINTF(0, (stderr, " %p\n", addr)); } return addr; @@ -146,7 +163,7 @@ os_vm_address_t os_validate(os_vm_address_t addr, os_vm_size_t len) void os_invalidate(os_vm_address_t addr, os_vm_size_t len) { - DPRINTF(0, (stderr, "os_invalidate %x %d\n", addr, len)); + DPRINTF(0, (stderr, "os_invalidate %p %d\n", addr, len)); if (munmap(addr, len) == -1) perror("munmap"); @@ -189,14 +206,15 @@ static boolean in_range_p(os_vm_address_t a, lispobj sbeg, size_t slen) boolean valid_addr(os_vm_address_t addr) { - int ret; os_vm_address_t newaddr; newaddr = os_trunc_to_page(addr); if ( in_range_p(addr, READ_ONLY_SPACE_START, READ_ONLY_SPACE_SIZE) || in_range_p(addr, STATIC_SPACE_START , STATIC_SPACE_SIZE ) || in_range_p(addr, DYNAMIC_0_SPACE_START, dynamic_space_size ) +#ifndef GENCGC || in_range_p(addr, DYNAMIC_1_SPACE_START, dynamic_space_size ) +#endif || in_range_p(addr, CONTROL_STACK_START , CONTROL_STACK_SIZE ) || in_range_p(addr, BINDING_STACK_START , BINDING_STACK_SIZE )) return TRUE; @@ -206,16 +224,30 @@ boolean valid_addr(os_vm_address_t addr) static void sigsegv_handler(HANDLER_ARGS) { +#if defined GENCGC + caddr_t fault_addr = code ? code->si_addr : 0; + int page_index = find_page_index((void*)fault_addr); - /* - * Since NetBSD on x86 currently provides no way to get the faulting - * memory address (i.e. the contents of the CR2 register), the page - * protection mechanism of the generational GC currently can't be - * used (see gengc.c), hence we don't neet to do anything here. - * - * See OpenBSD-os.c for details of what should be here, once NetBSD - * provides siginfo_t. - */ +#if SIGSEGV_VERBOSE + fprintf(stderr,"Signal %d, fault_addr=%p, page_index=%d:\n", + signal, fault_addr, page_index); +#endif + + /* Check if the fault is within the dynamic space. */ + if (page_index != -1) { + /* Un-protect the page */ + + /* The page should have been marked write protected */ + if (!PAGE_WRITE_PROTECTED(page_index)) + fprintf(stderr, "*** Sigsegv in page not marked as write protected\n"); + + os_protect(page_address(page_index), 4096, OS_VM_PROT_ALL); + page_table[page_index].flags &= ~PAGE_WRITE_PROTECTED_MASK; + page_table[page_index].flags |= PAGE_WRITE_PROTECT_CLEARED_MASK; + + return; + } +#endif SAVE_CONTEXT(); @@ -236,3 +268,26 @@ void os_install_interrupt_handlers(void) interrupt_install_low_level_handler(SIGSEGV, sigsegv_handler); interrupt_install_low_level_handler(SIGBUS, sigbus_handler); } + +void * +os_dlsym (const char *sym_name, lispobj lib_list) +{ + if (lib_list != NIL) + { + lispobj lib_list_head; + + for (lib_list_head = lib_list; + lib_list_head != NIL; + lib_list_head = CONS (lib_list_head)->cdr) + { + struct cons *lib_cons = CONS (CONS (lib_list_head)->car); + struct sap *dlhandle = (struct sap *) PTR (lib_cons->car); + void *sym_addr = dlsym ((void *) dlhandle->pointer, sym_name); + + if (sym_addr) + return sym_addr; + } + } + + return dlsym (RTLD_DEFAULT, sym_name); +} diff --git a/lisp/NetBSD-os.h b/lisp/NetBSD-os.h index 5bc341bb4e2462420272568271e799b948896927..9a8a0a2466785b6181c9a116f6244d5b1fcaeb67 100644 --- a/lisp/NetBSD-os.h +++ b/lisp/NetBSD-os.h @@ -1,6 +1,6 @@ /* - $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/NetBSD-os.h,v 1.1 2002/01/28 20:17:11 pmai Exp $ + $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/NetBSD-os.h,v 1.2 2004/07/07 15:03:11 rtoy 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. @@ -10,6 +10,7 @@ #include <sys/types.h> #include <sys/mman.h> #include <sys/signal.h> +#include <ucontext.h> #define MAP_ANONYMOUS MAP_ANON #define MAP_VARIABLE 0 @@ -26,12 +27,10 @@ typedef int os_vm_prot_t; #define OS_VM_DEFAULT_PAGESIZE 4096 #define POSIX_SIGS -/* NetBSD 1.5.2 doesn't have this yet */ -#define USE_SA_SIGINFO 0 +#define HANDLER_ARGS int signal, siginfo_t *code, ucontext_t *context +#define CODE(code) ((code) ? code->si_code : 0) +#define os_context_t ucontext_t -#ifndef sa_sigaction -#define sa_sigaction sa_handler -#endif +int sc_reg(ucontext_t *,int); -#define uc_sigmask sc_mask -int sc_reg(struct sigcontext*,int); +#define PROTECTION_VIOLATION_SIGNAL SIGSEGV diff --git a/lisp/arch.h b/lisp/arch.h index 8874192c6586b7d039a86f42765121af3c4b33cc..9e94adee12818b5d27812cc09827949867476e84 100644 --- a/lisp/arch.h +++ b/lisp/arch.h @@ -1,6 +1,6 @@ /* - $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/arch.h,v 1.6 2002/08/27 22:18:31 moore Exp $ + $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/arch.h,v 1.7 2004/07/07 15:03:11 rtoy 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. @@ -14,15 +14,15 @@ #include "signal.h" extern char *arch_init(void); -extern void arch_skip_instruction(struct sigcontext *scp); -extern boolean arch_pseudo_atomic_atomic(struct sigcontext *scp); -extern void arch_set_pseudo_atomic_interrupted(struct sigcontext *scp); +extern void arch_skip_instruction(os_context_t *scp); +extern boolean arch_pseudo_atomic_atomic(os_context_t *scp); +extern void arch_set_pseudo_atomic_interrupted(os_context_t *scp); extern os_vm_address_t arch_get_bad_addr(HANDLER_ARGS); -extern unsigned char *arch_internal_error_arguments(struct sigcontext *scp); +extern unsigned char *arch_internal_error_arguments(os_context_t *scp); extern unsigned long arch_install_breakpoint(void *pc); extern void arch_remove_breakpoint(void *pc, unsigned long orig_inst); extern void arch_install_interrupt_handlers(void); -extern void arch_do_displaced_inst(struct sigcontext *scp, +extern void arch_do_displaced_inst(os_context_t *scp, unsigned long orig_inst); extern lispobj funcall0(lispobj function); extern lispobj funcall1(lispobj function, lispobj arg0); diff --git a/lisp/breakpoint.c b/lisp/breakpoint.c index 49c5eb101e1ec384e122c188f29f136bfdc47015..72303a9dcbfab55c88a446e58127aec69d95173a 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.12 2000/10/27 19:25:54 dtc Exp $ + $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/breakpoint.c,v 1.13 2004/07/07 15:03:11 rtoy 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. @@ -52,7 +52,7 @@ void breakpoint_remove(lispobj code_obj, int pc_offset, arch_remove_breakpoint(compute_pc(code_obj, pc_offset), orig_inst); } -void breakpoint_do_displaced_inst(struct sigcontext *scp, +void breakpoint_do_displaced_inst(os_context_t *scp, unsigned long orig_inst) { #if !defined(hpux) && !defined(irix) && !defined(i386) @@ -83,7 +83,7 @@ static lispobj find_code(struct sigcontext *scp) #endif #ifdef i386 -static lispobj find_code(struct sigcontext *scp) +static lispobj find_code(os_context_t *scp) { lispobj *codeptr = component_ptr_from_pc(SC_PC(scp)); @@ -94,7 +94,7 @@ static lispobj find_code(struct sigcontext *scp) } #endif -static int compute_offset(struct sigcontext *scp, lispobj code) +static int compute_offset(os_context_t *scp, lispobj code) { if (code == NIL) return 0; @@ -122,7 +122,7 @@ static int compute_offset(struct sigcontext *scp, lispobj code) } #ifndef i386 -void handle_breakpoint(int signal, int subcode, struct sigcontext *scp) +void handle_breakpoint(int signal, int subcode, os_context_t *scp) { lispobj code; @@ -138,7 +138,7 @@ void handle_breakpoint(int signal, int subcode, struct sigcontext *scp) undo_fake_foreign_function_call(scp); } #else -void handle_breakpoint(int signal, int subcode, struct sigcontext *scp) +void handle_breakpoint(int signal, int subcode, os_context_t *scp) { lispobj code, scp_sap=alloc_sap(scp); @@ -152,7 +152,7 @@ void handle_breakpoint(int signal, int subcode, struct sigcontext *scp) */ #if defined POSIX_SIGS - sigprocmask(SIG_SETMASK,&scp->sc_mask,NULL); + sigprocmask(SIG_SETMASK,&scp->uc_sigmask,NULL); #else sigsetmask(scp->sc_mask); #endif @@ -167,7 +167,7 @@ void handle_breakpoint(int signal, int subcode, struct sigcontext *scp) #ifndef i386 void *handle_function_end_breakpoint(int signal, int subcode, - struct sigcontext *scp) + os_context_t *scp) { lispobj code, lra; struct code *codeptr; @@ -192,7 +192,7 @@ void *handle_function_end_breakpoint(int signal, int subcode, } #else void *handle_function_end_breakpoint(int signal, int subcode, - struct sigcontext *scp) + os_context_t *scp) { lispobj code, scp_sap=alloc_sap(scp); struct code *codeptr; @@ -208,7 +208,7 @@ void *handle_function_end_breakpoint(int signal, int subcode, */ #if defined POSIX_SIGS - sigprocmask(SIG_SETMASK,&scp->sc_mask,NULL); + sigprocmask(SIG_SETMASK,&scp->uc_sigmask,NULL); #else sigsetmask(scp->sc_mask); #endif diff --git a/lisp/breakpoint.h b/lisp/breakpoint.h index 8f45fe841811b8538162617113904ab43c349b4d..7e8bade393ec271dc140dc96f40d8b2f10f2fb76 100644 --- a/lisp/breakpoint.h +++ b/lisp/breakpoint.h @@ -1,5 +1,5 @@ /* - * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/breakpoint.h,v 1.1 1992/07/28 20:14:15 wlott Exp $ + * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/breakpoint.h,v 1.2 2004/07/07 15:03:11 rtoy Exp $ */ #ifndef _BREAKPOINT_H_ @@ -8,10 +8,10 @@ extern unsigned long breakpoint_install(lispobj code_obj, int pc_offset); extern void breakpoint_remove(lispobj code_obj, int pc_offset, unsigned long orig_inst); -extern void breakpoint_do_displaced_inst(struct sigcontext *scp, +extern void breakpoint_do_displaced_inst(os_context_t *scp, unsigned long orig_inst); -extern void handle_breakpoint(int signal, int subcode, struct sigcontext *scp); +extern void handle_breakpoint(int signal, int subcode, os_context_t *scp); extern void *handle_function_end_breakpoint(int signal, int subcode, - struct sigcontext *scp); + os_context_t *scp); #endif diff --git a/lisp/elf.c b/lisp/elf.c index e2fac62eb86a64fcf8ca1543a2a5d33ab2f6d4c2..4bc2d749e7d9f585ecb9aac9fda4d3799c8fedf2 100644 --- a/lisp/elf.c +++ b/lisp/elf.c @@ -25,7 +25,7 @@ static char elf_magic_string[] = {ELFMAG0, ELFMAG1, ELFMAG2, ELFMAG3}; /* Note: FreeBSD has nice macros that let you use Elf_Ehdr etc. declarations; unfortunately Linux doesn't have this so you have to do Elf32_Ehdr etc. Bad for moving to 64 bits.... */ -#if defined(__linux__) || defined(sparc) +#if defined(__linux__) || defined(sparc) || defined(__NetBSD__) typedef Elf32_Ehdr Elf_Ehdr; typedef Elf32_Shdr Elf_Shdr; #endif diff --git a/lisp/gencgc.c b/lisp/gencgc.c index 8b0f5d457cac41b267750522cce9661d11a34449..eea9a82312e54675043a00b7d289eb290941071a 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.55 2004/05/19 22:20:49 cwang Exp $ + * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/gencgc.c,v 1.56 2004/07/07 15:03:11 rtoy Exp $ * */ @@ -202,14 +202,7 @@ unsigned counters_verbose = 0; * To enable the use of page protection to help avoid the scavenging * of pages that don't have pointers to younger generations. */ -#ifdef __NetBSD__ - -/* NetBSD on x86 has no way to retrieve the faulting address in the - * SIGSEGV handler, so for the moment we can't use page protection. */ -boolean enable_page_protection = FALSE; -#else /* Netbsd */ boolean enable_page_protection = TRUE; -#endif /* Netbsd */ /* * Hunt for pointers to old-space, when GCing generations >= verify_gen. diff --git a/lisp/interrupt.c b/lisp/interrupt.c index f14f71a3f2966d3ec9ec569f3a0f18388263c985..b6c4fccfe610ddaff799bcd117be0fe6c62d225c 100644 --- a/lisp/interrupt.c +++ b/lisp/interrupt.c @@ -1,4 +1,4 @@ -/* $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/interrupt.c,v 1.37 2004/06/18 22:08:12 cwang Exp $ */ +/* $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/interrupt.c,v 1.38 2004/07/07 15:03:12 rtoy Exp $ */ /* Interrupt handing magic. */ @@ -24,14 +24,14 @@ boolean internal_errors_enabled = 0; -struct sigcontext *lisp_interrupt_contexts[MAX_INTERRUPTS]; +os_context_t *lisp_interrupt_contexts[MAX_INTERRUPTS]; union interrupt_handler interrupt_handlers[NSIG]; void (*interrupt_low_level_handlers[NSIG]) (HANDLER_ARGS) = {0}; static int pending_signal = 0; -#if defined(SOLARIS) || defined(__OpenBSD__) +#if defined(SOLARIS) || defined(__OpenBSD__) || defined(__NetBSD__) static siginfo_t *pending_code; #define PASSCODE(code) ((code)) #define DEREFCODE(code) ((code)) @@ -54,7 +54,7 @@ static boolean maybe_gc_pending = FALSE; \****************************************************************/ void -build_fake_control_stack_frame(struct sigcontext *context) +build_fake_control_stack_frame(os_context_t *context) { #if !(defined(i386) || defined(__x86_64)) lispobj oldcont; @@ -97,7 +97,7 @@ build_fake_control_stack_frame(struct sigcontext *context) } void -fake_foreign_function_call(struct sigcontext *context) +fake_foreign_function_call(os_context_t *context) { int context_index; #if !defined(i386) && !defined(__x86_64) @@ -141,7 +141,7 @@ fake_foreign_function_call(struct sigcontext *context) } void -undo_fake_foreign_function_call(struct sigcontext *context) +undo_fake_foreign_function_call(os_context_t *context) { /* Block all blockable signals */ #ifdef POSIX_SIGS @@ -207,7 +207,7 @@ interrupt_internal_error(HANDLER_ARGS, boolean continuable) } void -interrupt_handle_pending(struct sigcontext *context) +interrupt_handle_pending(os_context_t *context) { boolean were_in_lisp = !foreign_function_call_active; @@ -240,7 +240,7 @@ interrupt_handle_pending(struct sigcontext *context) if (pending_signal) { int signal; -#if defined(SOLARIS) || defined(__OpenBSD__) +#if defined(SOLARIS) || defined(__OpenBSD__) || defined(__NetBSD__) siginfo_t *code; #else int code; @@ -655,12 +655,18 @@ unsigned long install_handler(int signal, #endif void -interrupt_handle_space_overflow(lispobj error, struct sigcontext *context) +interrupt_handle_space_overflow(lispobj error, os_context_t *context) { #ifdef i386 /* ECX is the argument count. */ - context->sc_eip = (int) ((struct function *) PTR (error))->code; +#if USE_SA_SIGINFO + context->uc_mcontext.__gregs[_REG_EIP] == + (int) ((struct function *) PTR (error))->code; + context->uc_mcontext.__gregs[_REG_ECX] == 0; +#else + SC_PC(context) = (int) ((struct function *) PTR (error))->code; context->sc_ecx = 0; +#endif #else #ifdef __x86_64 /* RCX is the argument count. */ diff --git a/lisp/interrupt.h b/lisp/interrupt.h index e0d54d5ccc11512fe6ebd9f7ebf9151951116086..cad270b2b88221be8144cb1d5b97edd99404392d 100644 --- a/lisp/interrupt.h +++ b/lisp/interrupt.h @@ -1,4 +1,4 @@ -/* $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/interrupt.h,v 1.6 1997/11/25 15:27:32 dtc Exp $ */ +/* $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/interrupt.h,v 1.7 2004/07/07 15:03:12 rtoy Exp $ */ #if !defined(_INCLUDE_INTERRUPT_H_) #define _INCLUDE_INTERRUPT_H_ @@ -7,7 +7,7 @@ #define MAX_INTERRUPTS (4096) -extern struct sigcontext *lisp_interrupt_contexts[MAX_INTERRUPTS]; +extern os_context_t *lisp_interrupt_contexts[MAX_INTERRUPTS]; union interrupt_handler { lispobj lisp; @@ -15,10 +15,10 @@ union interrupt_handler { }; extern void interrupt_init(void); -extern void fake_foreign_function_call(struct sigcontext *context); -extern void undo_fake_foreign_function_call(struct sigcontext *context); +extern void fake_foreign_function_call(os_context_t *context); +extern void undo_fake_foreign_function_call(os_context_t *context); extern void interrupt_handle_now(HANDLER_ARGS); -extern void interrupt_handle_pending(struct sigcontext *scp); +extern void interrupt_handle_pending(os_context_t *scp); extern void interrupt_internal_error(HANDLER_ARGS, boolean continuable); extern boolean interrupt_maybe_gc(HANDLER_ARGS); extern void interrupt_install_low_level_handler diff --git a/lisp/lisp.c b/lisp/lisp.c index 17e8fbbea28ce5b01c9d6bd4ebc0ea0ab71e6e00..1b405070b1c97115768c76845324614ac61752c9 100644 --- a/lisp/lisp.c +++ b/lisp/lisp.c @@ -1,7 +1,7 @@ /* * main() entry point for a stand alone lisp image. * - * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/lisp.c,v 1.40 2004/05/20 00:32:25 cwang Exp $ + * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/lisp.c,v 1.41 2004/07/07 15:03:12 rtoy Exp $ * */ @@ -464,8 +464,10 @@ int main(int argc, char *argv[], char *envp[]) default_core = "lisp.core"; os_init(); +#if defined(__FreeBSD__) || defined(__linux__) if (builtin_image_flag != 0) map_core_sections(argv[0]); +#endif validate(); gc_init(); diff --git a/lisp/monitor.c b/lisp/monitor.c index 21e5f2d287a5bb2c9a07b1957b37ee7a0a3d4391..a79ef195480bf5a357e4837fa283692071da96b5 100644 --- a/lisp/monitor.c +++ b/lisp/monitor.c @@ -1,4 +1,4 @@ -/* $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/monitor.c,v 1.14 2004/05/19 23:26:15 cwang Exp $ */ +/* $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/monitor.c,v 1.15 2004/07/07 15:03:12 rtoy Exp $ */ #include <stdio.h> #include <sys/types.h> @@ -333,7 +333,7 @@ static void purify_cmd(char **ptr) purify(NIL, NIL); } -static void print_context(struct sigcontext *context) +static void print_context(os_context_t *context) { int i; diff --git a/lisp/os-common.c b/lisp/os-common.c index f15d83fb0b33118ace56c9d5dc4b7bd37bd83367..35f267caa339d8364cee4015db10d71a1f6e7a7c 100644 --- a/lisp/os-common.c +++ b/lisp/os-common.c @@ -1,6 +1,6 @@ /* - $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/os-common.c,v 1.13 2004/05/19 23:32:05 cwang Exp $ + $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/os-common.c,v 1.14 2004/07/07 15:03:12 rtoy 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. @@ -50,7 +50,7 @@ os_vm_size_t length; addr=os_validate(block_start,block_size); if(addr==NULL || addr!=block_start) - fprintf(stderr,"os_zero: block moved, 0x%08x ==> 0x%08x!\n",block_start,addr); + fprintf(stderr,"os_zero: block moved, 0x%08p ==> 0x%08p!\n",block_start,addr); } } @@ -395,7 +395,7 @@ os_guard_control_stack (int zone, int guard) non-zero if FAULT_ADDR is in a guard zone. */ int -os_control_stack_overflow (void *fault_addr, struct sigcontext *context) +os_control_stack_overflow (void *fault_addr, os_context_t *context) { enum stack_zone_t zone; @@ -430,8 +430,12 @@ os_control_stack_overflow (void *fault_addr, struct sigcontext *context) #ifdef i386 /* ECX is the argument count. */ - context->sc_eip = (int) ((struct function *) PTR (error))->code; + SC_PC(context) = (int) ((struct function *) PTR (error))->code; +#if USE_SA_SIGINFO + context->uc_mcontext.__gregs[_REG_ECX] == 0; +#else context->sc_ecx = 0; +#endif #else #ifdef __x86_64 /* RCX is the argument count. */ diff --git a/lisp/os.h b/lisp/os.h index b0091152e2c162cdea91a90c65a7e1f0fbd8bec1..3cc935733f19566d0d6a42d3d3edc780dfbbae21 100644 --- a/lisp/os.h +++ b/lisp/os.h @@ -1,5 +1,5 @@ /* - * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/os.h,v 1.12 2003/05/29 22:03:01 toy Exp $ + * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/os.h,v 1.13 2004/07/07 15:03:12 rtoy Exp $ * * Common interface for os-dependent functions. * @@ -47,8 +47,11 @@ #endif #endif +#ifndef os_context_t +#define os_context_t struct sigcontext +#endif #ifndef HANDLER_ARGS -#define HANDLER_ARGS int signal, int code, struct sigcontext *context +#define HANDLER_ARGS int signal, int code, os_context_t *context #endif #ifndef CODE #define CODE(code) code @@ -108,6 +111,6 @@ extern void *os_dlsym (const char *sym_name, lispobj lib_list); enum stack_zone_t {BOTH_ZONES, YELLOW_ZONE, RED_ZONE}; extern int os_stack_grows_down (void); extern void os_guard_control_stack (int zone, int guard); -extern int os_control_stack_overflow (void *, struct sigcontext *); +extern int os_control_stack_overflow (void *, os_context_t *); #endif diff --git a/lisp/undefineds.h b/lisp/undefineds.h index 0f714fa81a352ea8bc5e69da2d28e04eb824d457..63c5a63f1eaf8ac0b23da50ca02501aad091efd6 100644 --- a/lisp/undefineds.h +++ b/lisp/undefineds.h @@ -1,5 +1,5 @@ /* Routines that must be linked into the core for lisp to work. */ -/* $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/undefineds.h,v 1.32 2003/03/03 18:40:58 pmai Exp $ */ +/* $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/undefineds.h,v 1.33 2004/07/07 15:03:12 rtoy Exp $ */ /* Pick up all the syscalls. */ F(accept) @@ -80,6 +80,7 @@ F(mkdir) F(mknod) F(mmap) F(mount) +F(msync) F(munmap) F(open) F(pipe) @@ -126,6 +127,8 @@ F(setreuid) F(setrlimit) F(setsockopt) F(settimeofday) +F(setgid) +F(setuid) F(shutdown) #ifndef SVR4 F(sigblock) diff --git a/lisp/x86-arch.c b/lisp/x86-arch.c index 31f2d0c3342e07ff92e425ae5cd7effdf0109198..4ca8991d2f8960178980417dc109995006135523 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.21 2004/05/18 21:45:30 cwang Exp $ + * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/x86-arch.c,v 1.22 2004/07/07 15:03:12 rtoy Exp $ * */ @@ -39,23 +39,23 @@ char * arch_init(void) * Cerror-trap then skip the data bytes that follow. */ -void arch_skip_instruction(struct sigcontext *context) +void arch_skip_instruction(os_context_t *context) { int vlen,code; - DPRINTF(0,(stderr,"[arch_skip_inst at %x>]\n", context->sc_pc)); + DPRINTF(0,(stderr,"[arch_skip_inst at %x>]\n", SC_PC(context))); /* Get and skip the lisp error code. */ - code = *(char*) context->sc_pc++; + code = *(char*) SC_PC(context)++; switch (code) { case trap_Error: case trap_Cerror: /* Lisp error arg vector length */ - vlen = *(char*) context->sc_pc++; + vlen = *(char*) SC_PC(context)++; /* Skip lisp error arg data bytes */ while(vlen-- > 0) - ((char*) context->sc_pc)++; + ((char*) SC_PC(context))++; break; case trap_Breakpoint: @@ -72,20 +72,20 @@ void arch_skip_instruction(struct sigcontext *context) break; } - DPRINTF(0,(stderr,"[arch_skip_inst resuming at %x>]\n", context->sc_pc)); + DPRINTF(0,(stderr,"[arch_skip_inst resuming at %x>]\n", SC_PC(context))); } -unsigned char * arch_internal_error_arguments(struct sigcontext *context) +unsigned char * arch_internal_error_arguments(os_context_t *context) { - return (unsigned char *) (context->sc_pc + 1); + return (unsigned char *) (SC_PC(context) + 1); } -boolean arch_pseudo_atomic_atomic(struct sigcontext *context) +boolean arch_pseudo_atomic_atomic(os_context_t *context) { return SymbolValue(PSEUDO_ATOMIC_ATOMIC); } -void arch_set_pseudo_atomic_interrupted(struct sigcontext *context) +void arch_set_pseudo_atomic_interrupted(os_context_t *context) { SetSymbolValue(PSEUDO_ATOMIC_INTERRUPTED, make_fixnum(1)); } @@ -122,10 +122,10 @@ unsigned int single_step_save2; unsigned int single_step_save3; #endif -void arch_do_displaced_inst(struct sigcontext *context, +void arch_do_displaced_inst(os_context_t *context, unsigned long orig_inst) { - unsigned int *pc = (unsigned int*) context->sc_pc; + unsigned int *pc = (unsigned int*) SC_PC(context); /* * Put the original instruction back. @@ -154,7 +154,7 @@ void arch_do_displaced_inst(struct sigcontext *context, single_stepping = (unsigned int*) pc; #ifndef __linux__ - (unsigned int*) context->sc_pc = (char *) pc - 9; + (unsigned int*) SC_PC(context) = (char *) pc - 9; #endif } @@ -169,7 +169,7 @@ void sigtrap_handler(HANDLER_ARGS) #if 0 fprintf(stderr,"x86sigtrap: %8x %x\n", - context->sc_pc, *(unsigned char *)(context->sc_pc-1)); + SC_PC(context), *(unsigned char *)(SC_PC(context)-1)); fprintf(stderr,"sigtrap(%d %d %x)\n",signal,code,context); #endif @@ -191,8 +191,7 @@ void sigtrap_handler(HANDLER_ARGS) /* * Re-install the breakpoint if possible. */ - - if ((int) context->sc_pc == (int) single_stepping + 1) + if ((int) SC_PC(context) == (int) single_stepping + 1) fprintf(stderr, "* Breakpoint not re-install\n"); else { @@ -208,7 +207,7 @@ void sigtrap_handler(HANDLER_ARGS) SAVE_CONTEXT(); /* This is just for info in case monitor wants to print an approx */ - current_control_stack_pointer = (unsigned long*) context->sc_sp; + current_control_stack_pointer = (unsigned long*) SC_SP(context); #if defined(__linux__) && defined(i386) /* @@ -226,7 +225,7 @@ void sigtrap_handler(HANDLER_ARGS) * arguments to follow. */ - trap = *(unsigned char *) (context->sc_pc); + trap = *(unsigned char *) SC_PC(context); switch (trap) { @@ -266,7 +265,8 @@ void sigtrap_handler(HANDLER_ARGS) #if 0 fprintf(stderr,"*C break\n"); #endif - (char*) context->sc_pc -= 1; + (char*) SC_PC(context) -= 1; + handle_breakpoint(signal, code, context); #if 0 fprintf(stderr,"*C break return\n"); @@ -274,8 +274,8 @@ void sigtrap_handler(HANDLER_ARGS) break; case trap_FunctionEndBreakpoint: - (char*) context->sc_pc -= 1; - context->sc_pc = (int) handle_function_end_breakpoint(signal, code, context); + (char*) SC_PC(context) -= 1; + SC_PC(context) = (int) handle_function_end_breakpoint(signal, code, context); break; #ifdef trap_DynamicSpaceOverflowWarning @@ -291,7 +291,7 @@ void sigtrap_handler(HANDLER_ARGS) break; #endif default: - DPRINTF(0,(stderr,"[C--trap default %d %d %x]\n", signal, code,context)); + DPRINTF(0,(stderr,"[C--trap default %d %d %p]\n", signal, code,context)); #ifdef __linux__ interrupt_handle_now(signal, contextstruct); #else diff --git a/lisp/x86-lispregs.h b/lisp/x86-lispregs.h index ef6180b54164cbaa7e6cf72d5f465885b4945ab1..9c2e74811b7d720e64bbbd6dd9d5a5a2bec8103a 100644 --- a/lisp/x86-lispregs.h +++ b/lisp/x86-lispregs.h @@ -1,5 +1,5 @@ /* x86-lispregs.h -*- Mode: C; -*- - * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/x86-lispregs.h,v 1.2 1998/05/01 01:21:41 dtc Exp $ + * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/x86-lispregs.h,v 1.3 2004/07/07 15:03:12 rtoy Exp $ */ /* These register names and offsets correspond to definitions @@ -41,5 +41,12 @@ */ #define SC_REG(sc, n) sc_reg(sc,n) + +#ifdef __NetBSD__ +#define SC_PC(uc) ((uc)->uc_mcontext.__gregs[_REG_EIP]) +#define SC_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_ESP]) +#else #define SC_PC(sc) ((sc)->sc_pc) +#define SC_SP(sc) ((sc)->sc_esp) +#endif diff --git a/lisp/x86-validate.h b/lisp/x86-validate.h index ddae9a759d9f0f68e63858e8efcb80a5c4e1a78e..a128f20331d2b037a61f312753ac84dd437e6528 100644 --- a/lisp/x86-validate.h +++ b/lisp/x86-validate.h @@ -3,7 +3,7 @@ * This code was written as part of the CMU Common Lisp project at * Carnegie Mellon University, and has been placed in the public domain. * - * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/x86-validate.h,v 1.19 2004/01/16 03:32:21 toy Exp $ + * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/x86-validate.h,v 1.20 2004/07/07 15:03:12 rtoy Exp $ * */ @@ -80,18 +80,21 @@ #endif /* __FreeBSD__ */ -#if defined(__OpenBSD__) || defined(__NetBSD__) +#ifdef __OpenBSD__ #define READ_ONLY_SPACE_START (0x10000000) #define READ_ONLY_SPACE_SIZE (0x0ffff000) /* 256MB - 1 page */ #define STATIC_SPACE_START (0x28000000) #define STATIC_SPACE_SIZE (0x0ffff000) /* 256MB - 1 page */ -#define BINDING_STACK_START (0x20000000) +#define BINDING_STACK_START (0x38000000) #define BINDING_STACK_SIZE (0x07fff000) /* 128MB - 1 page */ -#define CONTROL_STACK_START (0x38000000) -#define CONTROL_STACK_SIZE (0x07fff000) /* 128MB - 1 page */ +#define CONTROL_STACK_START (0x40000000) +#define CONTROL_STACK_SIZE (0x07fd8000) /* 128MB - SIGSTKSZ */ + +#define SIGNAL_STACK_START (0x47fd8000) +#define SIGNAL_STACK_SIZE SIGSTKSZ #define DYNAMIC_0_SPACE_START (0x48000000) #ifdef GENCGC @@ -102,6 +105,34 @@ #define DEFAULT_DYNAMIC_SPACE_SIZE (0x20000000) /* 512MB */ #endif +#ifdef __NetBSD__ +#define READ_ONLY_SPACE_START (0x10000000) +#define READ_ONLY_SPACE_SIZE (0x0ffff000) /* 256MB - 1 page */ + +#define STATIC_SPACE_START (0x28000000) +#define STATIC_SPACE_SIZE (0x0ffff000) /* 256MB - 1 page */ + +#define BINDING_STACK_START (0x38000000) +#define BINDING_STACK_SIZE (0x07fff000) /* 128MB - 1 page */ + +#define CONTROL_STACK_START (0x40000000) +#define CONTROL_STACK_SIZE (0x07fd8000) /* 128MB - SIGSTKSZ */ + +#define SIGNAL_STACK_START (0x47fd8000) +#define SIGNAL_STACK_SIZE SIGSTKSZ + +#define DYNAMIC_0_SPACE_START (0x48800000) +#ifdef GENCGC +#define DYNAMIC_SPACE_SIZE (0x67800000) /* 1.625GB */ +#else +#define DYNAMIC_SPACE_SIZE (0x04000000) /* 64MB */ +#endif +#define DEFAULT_DYNAMIC_SPACE_SIZE (0x20000000) /* 512MB */ +#ifdef LINKAGE_TABLE +#define FOREIGN_LINKAGE_SPACE_START (0xb0000000) +#define FOREIGN_LINKAGE_SPACE_SIZE (0x100000) /* 1MB */ +#endif +#endif #ifdef __linux__ #define READ_ONLY_SPACE_START (SpaceStart_TargetReadOnly)