diff -rNU3 smalltalk-2.1-orig/config/fault.m4 smalltalk-2.1/config/fault.m4 --- smalltalk-2.1-orig/config/fault.m4 Mon Mar 31 09:02:27 2003 +++ smalltalk-2.1/config/fault.m4 Mon Mar 31 09:43:22 2003 @@ -17,6 +17,7 @@ AC_TRY_RUN([ #include #include +#include $4 #include #include @@ -46,7 +47,7 @@ void *fault_address = (void *) ($6); handler_called++; if (fault_address != (void*)(page + 0x678)) - exit (1); + exit (3); if (mprotect ((void *) page, 0x10000, PROT_READ | PROT_WRITE) < 0) exit (2); } diff -rNU3 smalltalk-2.1-orig/config/sigaltstack.m4 smalltalk-2.1/config/sigaltstack.m4 --- smalltalk-2.1-orig/config/sigaltstack.m4 Mon Mar 31 09:02:27 2003 +++ smalltalk-2.1/config/sigaltstack.m4 Mon Mar 31 10:08:26 2003 @@ -1,5 +1,5 @@ -# sigaltstack.m4 serial 1 (libsigsegv-2.0) -dnl Copyright (C) 2002 Bruno Haible +# sigaltstack.m4 serial 2 (libsigsegv-2.0) +dnl Copyright (C) 2002, 2003 Bruno Haible dnl This file is free software, distributed under the terms of the GNU dnl General Public License. As a special exception to the GNU General dnl Public License, this file may be distributed as part of a program @@ -11,12 +11,19 @@ AC_REQUIRE([AC_PROG_CC]) AC_REQUIRE([AC_CANONICAL_HOST]) + AC_CHECK_TYPE(stack_t, , + [AC_DEFINE(stack_t, struct sigaltstack, + [Define to struct sigaltstack if that's the type of the argument to sigaltstack])], + [#include + #include ]) + AC_CHECK_FUNCS(sigaltstack) AC_CACHE_CHECK([for working sigaltstack], sv_cv_sigaltstack, [ if test "$ac_cv_func_sigaltstack" = yes; then AC_TRY_RUN([ #include #include +#include #if HAVE_SETRLIMIT # include # include diff -rNU3 smalltalk-2.1-orig/lib-src/strsignal.c smalltalk-2.1/lib-src/strsignal.c --- smalltalk-2.1-orig/lib-src/strsignal.c Mon Mar 31 09:02:27 2003 +++ smalltalk-2.1/lib-src/strsignal.c Mon Mar 31 13:33:59 2003 @@ -558,7 +558,7 @@ void psignal (signo, message) unsigned signo; - char *message; + const char *message; { if (signal_names == NULL) { diff -rNU3 smalltalk-2.1-orig/libgst/byte.h smalltalk-2.1/libgst/byte.h --- smalltalk-2.1-orig/libgst/byte.h Mon Mar 31 09:02:27 2003 +++ smalltalk-2.1/libgst/byte.h Mon Mar 31 13:40:51 2003 @@ -163,7 +163,7 @@ _gst_cur_bytecodes->stack_depth -= (n)) /* Subtract N from the current stack depth. */ -#define GET_STACK_DEPTH(n) \ +#define GET_STACK_DEPTH() \ (_gst_cur_bytecodes->max_stack_depth) /* Allocate a new array of bytecodes. */ diff -rNU3 smalltalk-2.1-orig/libgst/comp.c smalltalk-2.1/libgst/comp.c --- smalltalk-2.1-orig/libgst/comp.c Mon Mar 31 09:02:27 2003 +++ smalltalk-2.1/libgst/comp.c Mon Mar 31 13:43:11 2003 @@ -38,15 +38,15 @@ #include #include /* for printf */ -#ifdef HAVE_SYS_RESOURCE_H -# include -#endif - #if defined(HAVE_SYS_TIME_H) || defined(TIME_WITH_SYS_TIME) # include #endif #if !defined(HAVE_SYS_TIME_H) || defined(TIME_WITH_SYS_TIME) # include +#endif + +#ifdef HAVE_SYS_RESOURCE_H +# include #endif #if STDC_HEADERS diff -rNU3 smalltalk-2.1-orig/sigsegv/config.h.in smalltalk-2.1/sigsegv/config.h.in --- smalltalk-2.1-orig/sigsegv/config.h.in Mon Mar 31 09:02:27 2003 +++ smalltalk-2.1/sigsegv/config.h.in Mon Mar 31 13:50:18 2003 @@ -93,3 +93,7 @@ /* Version number of package */ #undef VERSION + +/* Define to struct sigaltstack if that's the type of the argument to + sigaltstack */ +#undef stack_t diff -rNU3 smalltalk-2.1-orig/sigsegv/configure.in smalltalk-2.1/sigsegv/configure.in --- smalltalk-2.1-orig/sigsegv/configure.in Mon Mar 31 09:02:27 2003 +++ smalltalk-2.1/sigsegv/configure.in Mon Mar 31 13:49:37 2003 @@ -70,7 +70,7 @@ dnl List of signals that are sent when an invalid virtual memory address dnl is accessed, or when the stack overflows. case "$host_os" in - sunos4* | freebsd* | hpux*) + sunos4* | freebsd* | hpux* | darwin*) CFG_SIGNALS=signals-segv-bus.h ;; *) CFG_SIGNALS=signals-segv.h ;; @@ -297,6 +297,13 @@ esac FAULT_CONTEXT='struct vregs' ;; + darwin*) + case "$host_cpu" in + powerpc) CFG_FAULT=fault-darwin-powerpc.h ;; + i386) CFG_FAULT=fault-darwin-i386.h ;; + esac + FAULT_CONTEXT='void' + ;; esac fi AC_MSG_CHECKING([for the fault handler specifics]) @@ -428,6 +435,7 @@ CFG_STACKVMA=stackvma-procfs.c else case "$host_os" in + darwin*) CFG_STACKVMA=stackvma-mach.c ;; linux*) CFG_STACKVMA=stackvma-linux.c ;; freebsd*) CFG_STACKVMA=stackvma-freebsd.c ;; beos*) CFG_STACKVMA=stackvma-beos.c ;; @@ -483,6 +491,9 @@ [*-*-freebsd*], [], [stack_t ss; +#ifndef SS_ONSTACK +#define SS_ONSTACK SA_ONSTACK +#endif if (sigaltstack (NULL, &ss) >= 0) { ss.ss_flags &= ~SS_ONSTACK; diff -rNU3 smalltalk-2.1-orig/sigsegv/src/fault-darwin-i386.h smalltalk-2.1/sigsegv/src/fault-darwin-i386.h --- smalltalk-2.1-orig/sigsegv/src/fault-darwin-i386.h Thu Jan 1 01:00:00 1970 +++ smalltalk-2.1/sigsegv/src/fault-darwin-i386.h Mon Mar 31 11:39:03 2003 @@ -0,0 +1,22 @@ +/* Fault handler information. Darwin PPC version. + Copyright (C) 2003 Paolo Bonzini + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#define SIGSEGV_FAULT_HANDLER_ARGLIST int sig, int code, struct sigcontext *scp +#define SIGSEGV_FAULT_STACKPOINTER (scp->sc_esp) +#define SIGSEGV_FAULT_CONTEXT (NULL) + +#define SS_DISABLE SA_DISABLE diff -rNU3 smalltalk-2.1-orig/sigsegv/src/fault-darwin-powerpc.h smalltalk-2.1/sigsegv/src/fault-darwin-powerpc.h --- smalltalk-2.1-orig/sigsegv/src/fault-darwin-powerpc.h Thu Jan 1 01:00:00 1970 +++ smalltalk-2.1/sigsegv/src/fault-darwin-powerpc.h Mon Mar 31 11:37:57 2003 @@ -0,0 +1,23 @@ +/* Fault handler information. Darwin PPC version. + Copyright (C) 2003 Paolo Bonzini + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#define SIGSEGV_FAULT_HANDLER_ARGLIST int sig, int code, struct sigcontext *scp +#define SIGSEGV_FAULT_STACKPOINTER (scp->sc_regs ? ((unsigned *)scp->sc_regs)[3] : scp->sc_sp) + +#define SIGSEGV_FAULT_CONTEXT (NULL) + +#define SS_DISABLE SA_DISABLE diff -rNU3 smalltalk-2.1-orig/sigsegv/src/leave-setcontext.c smalltalk-2.1/sigsegv/src/leave-setcontext.c --- smalltalk-2.1-orig/sigsegv/src/leave-setcontext.c Mon Mar 31 09:02:27 2003 +++ smalltalk-2.1/sigsegv/src/leave-setcontext.c Mon Mar 31 09:44:10 2003 @@ -18,6 +18,7 @@ #include "config.h" #include +#include #include void diff -rNU3 smalltalk-2.1-orig/sigsegv/src/leave-sigaltstack.c smalltalk-2.1/sigsegv/src/leave-sigaltstack.c --- smalltalk-2.1-orig/sigsegv/src/leave-sigaltstack.c Mon Mar 31 09:02:27 2003 +++ smalltalk-2.1/sigsegv/src/leave-sigaltstack.c Mon Mar 31 13:48:40 2003 @@ -19,6 +19,11 @@ #include #include +#include + +#ifndef SS_ONSTACK +#define SS_ONSTACK SA_ONSTACK /* needed for Darwin */ +#endif void sigsegv_reset_onstack_flag (void) diff -rNU3 smalltalk-2.1-orig/sigsegv/src/stackvma-mach.c smalltalk-2.1/sigsegv/src/stackvma-mach.c --- smalltalk-2.1-orig/sigsegv/src/stackvma-mach.c Thu Jan 1 01:00:00 1970 +++ smalltalk-2.1/sigsegv/src/stackvma-mach.c Mon Mar 31 13:51:45 2003 @@ -0,0 +1,114 @@ +/* Determine the virtual memory area of a given address. Mach version. + Copyright (C) 2003 Paolo Bonzini + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "config.h" +#include "stackvma.h" +#include + +#ifdef HAVE_UNISTD_H +#include +#endif +#include +#include +#include +#ifndef NeXT +#include +#endif + +int +sigsegv_get_vma (unsigned long req_address, struct vma_struct *vma) +{ + unsigned long prev_address = 0, prev_size = 0; + unsigned long join_address = 0, join_size = 0; + int more = 1; + vm_address_t address; + vm_size_t size; + mach_port_t object_name; +#ifdef VM_REGION_BASIC_INFO + task_t task = mach_task_self(); + struct vm_region_basic_info info; + mach_msg_type_number_t info_count = VM_REGION_BASIC_INFO_COUNT; +#else + task_t task = task_self(); + vm_prot_t protection, max_protection; + vm_inherit_t inheritance; + boolean_t shared; + vm_offset_t offset; +#endif + + for (address = VM_MIN_ADDRESS; more; address += size) + { +#ifdef VM_REGION_BASIC_INFO + more = vm_region(task, &address, &size, VM_REGION_BASIC_INFO, + (vm_region_info_t)&info, &info_count, &object_name) == KERN_SUCCESS; +#else + more = vm_region(task, &address, &size, &protection, &max_protection, + &inheritance, &shared, &object_name, &offset) == KERN_SUCCESS; +#endif + if (!more) + { + address = join_address + join_size; + size = 0; + } + + if ((unsigned long) address == join_address + join_size) + join_size += size; + else + { + prev_address = join_address; + prev_size = join_size; + join_address = (unsigned long) address; + join_size = size; + } + +#ifdef VM_REGION_BASIC_INFO + if (object_name != MACH_PORT_NULL) + mach_port_deallocate(mach_task_self(), object_name); + info_count = VM_REGION_BASIC_INFO_COUNT; +#endif + +#if STACK_DIRECTION < 0 + if (join_address < req_address && join_address + join_size > req_address) + { + vma->start = join_address; + vma->end = join_address + join_size; + vma->prev_end = prev_address; + return 0; + } +#else + if (prev_address < req_address && prev_address + prev_size > req_address) + { + vma->start = prev_address; + vma->end = prev_address + prev_size; + vma->next_start = join_address; + return 0; + } +#endif + } + +#if STACK_DIRECTION > 0 + if (join_address < req_address && join_address + size > req_address) + { + vma->start = prev_address; + vma->end = prev_address + prev_size; + vma->next_start = ~0; + return 0; + } +#endif + + return -1; +} diff -rNU3 smalltalk-2.1-orig/sigsegv/tests/sigsegv1.c smalltalk-2.1/sigsegv/tests/sigsegv1.c --- smalltalk-2.1-orig/sigsegv/tests/sigsegv1.c Mon Mar 31 09:02:27 2003 +++ smalltalk-2.1/sigsegv/tests/sigsegv1.c Mon Mar 31 10:49:37 2003 @@ -30,8 +30,9 @@ int handler (void *fault_address, int serious) { + printf ("called\n"); handler_called++; - if (fault_address != (void *)(page + 0x678)) + if (fault_address != (void *)(page + 0x678) || handler_called > 100) abort (); if (mprotect ((void *) page, 0x4000, PROT_READ_WRITE) == 0) return 1; diff -rNU3 smalltalk-2.1-orig/sigsegv/tests/sigsegv2.c smalltalk-2.1/sigsegv/tests/sigsegv2.c --- smalltalk-2.1-orig/sigsegv/tests/sigsegv2.c Mon Mar 31 09:02:27 2003 +++ smalltalk-2.1/sigsegv/tests/sigsegv2.c Mon Mar 31 10:50:25 2003 @@ -26,12 +26,15 @@ static sigsegv_dispatcher dispatcher; static unsigned int logcount = 0; -static unsigned long logdata[3]; +static unsigned long logdata[20]; static int area_handler (void *fault_address, void *user_arg) { unsigned long area = *(unsigned long *)user_arg; + if (logcount > 10) + abort (); + logdata[logcount++] = area; if (!((unsigned long)fault_address >= area && (unsigned long)fault_address - area < 0x4000))