From: Jeffrey Hsu <hsu@soda.berkeley.edu>

The following patch adds the addr argument to signal handlers.

The kernel with the patch is no more and no less in compliance or in
violation of POSIX and ANSI C than the kernel before the patch.

The added functionality this addr argument provides is quite useful.  It
enables an entire class of algorithms which use mprotect to trace memory
references.  Beside garbage collectors, I have heard of this technique being
applied to debuggers and profilers.  The only benchmarking I've performed is
using akcl to compile maxima:  without the kernel patch, it takes 7 hours to
compile maxima, while with stratified garbage collection, it only takes 50
minutes.

Basically, I can't think of a reason not to add the addr argument and there
is a compelling need for it.

If you find the patch acceptable, please let me know so I can send my
FreeBSD akcl config files to wfs for inclusion in the core akcl release.
The old 386BSD config files there won't work on either NetBSD or FreeBSD.
This commit is contained in:
Andrew Moore 1993-12-03 05:10:08 +00:00
parent 16111ced9f
commit 05e634ef64
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=827
9 changed files with 26 additions and 9 deletions

View File

@ -35,7 +35,7 @@
* SUCH DAMAGE.
*
* from: @(#)machdep.c 7.4 (Berkeley) 6/3/91
* $Id: machdep.c,v 1.18 1993/11/17 23:24:56 wollman Exp $
* $Id: machdep.c,v 1.19 1993/11/25 01:30:55 wollman Exp $
*/
#include "npx.h"
@ -460,6 +460,7 @@ sendsig(catcher, sig, mask, code)
fp->sf_signum = sig;
fp->sf_code = code;
fp->sf_scp = &fp->sf_sc;
fp->sf_addr = (char *) regs[tERR];
fp->sf_handler = catcher;
/* save scratch registers */

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)trap.c 7.4 (Berkeley) 5/13/91
* $Id: trap.c,v 1.8 1993/11/25 01:31:01 wollman Exp $
* $Id: trap.c,v 1.9 1993/11/28 09:28:54 davidg Exp $
*/
/*
@ -370,6 +370,9 @@ if(curpcb == 0 || curproc == 0) goto we_re_toast;
goto we_re_toast;
}
i = (rv == KERN_PROTECTION_FAILURE) ? SIGBUS : SIGSEGV;
ucode = type &~ T_USER;
frame.tf_err = eva;
/* kludge to pass faulting virtual address to sendsig */
break;
}

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)frame.h 5.2 (Berkeley) 1/18/91
* $Id: frame.h,v 1.3 1993/11/07 17:42:56 wollman Exp $
* $Id: frame.h,v 1.4 1993/11/17 23:25:03 wollman Exp $
*/
#ifndef _MACHINE_FRAME_H_
@ -105,6 +105,7 @@ struct sigframe {
int sf_signum;
int sf_code;
struct sigcontext *sf_scp;
char *sf_addr;
sig_t sf_handler;
int sf_eax;
int sf_edx;

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)reg.h 5.5 (Berkeley) 1/18/91
* $Id: reg.h,v 1.3 1993/11/07 17:43:07 wollman Exp $
* $Id: reg.h,v 1.4 1993/11/16 09:54:57 davidg Exp $
*/
#ifndef _MACHINE_REG_H_
@ -60,6 +60,8 @@
#define tECX (8)
#define tEAX (9)
#define tERR (11)
#define tEIP (12)
#define tCS (13)
#define tEFLAGS (14)

View File

@ -35,7 +35,7 @@
* SUCH DAMAGE.
*
* from: @(#)machdep.c 7.4 (Berkeley) 6/3/91
* $Id: machdep.c,v 1.18 1993/11/17 23:24:56 wollman Exp $
* $Id: machdep.c,v 1.19 1993/11/25 01:30:55 wollman Exp $
*/
#include "npx.h"
@ -460,6 +460,7 @@ sendsig(catcher, sig, mask, code)
fp->sf_signum = sig;
fp->sf_code = code;
fp->sf_scp = &fp->sf_sc;
fp->sf_addr = (char *) regs[tERR];
fp->sf_handler = catcher;
/* save scratch registers */

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)trap.c 7.4 (Berkeley) 5/13/91
* $Id: trap.c,v 1.8 1993/11/25 01:31:01 wollman Exp $
* $Id: trap.c,v 1.9 1993/11/28 09:28:54 davidg Exp $
*/
/*
@ -370,6 +370,9 @@ if(curpcb == 0 || curproc == 0) goto we_re_toast;
goto we_re_toast;
}
i = (rv == KERN_PROTECTION_FAILURE) ? SIGBUS : SIGSEGV;
ucode = type &~ T_USER;
frame.tf_err = eva;
/* kludge to pass faulting virtual address to sendsig */
break;
}

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)frame.h 5.2 (Berkeley) 1/18/91
* $Id: frame.h,v 1.3 1993/11/07 17:42:56 wollman Exp $
* $Id: frame.h,v 1.4 1993/11/17 23:25:03 wollman Exp $
*/
#ifndef _MACHINE_FRAME_H_
@ -105,6 +105,7 @@ struct sigframe {
int sf_signum;
int sf_code;
struct sigcontext *sf_scp;
char *sf_addr;
sig_t sf_handler;
int sf_eax;
int sf_edx;

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)reg.h 5.5 (Berkeley) 1/18/91
* $Id: reg.h,v 1.3 1993/11/07 17:43:07 wollman Exp $
* $Id: reg.h,v 1.4 1993/11/16 09:54:57 davidg Exp $
*/
#ifndef _MACHINE_REG_H_
@ -60,6 +60,8 @@
#define tECX (8)
#define tEAX (9)
#define tERR (11)
#define tEIP (12)
#define tCS (13)
#define tEFLAGS (14)

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)trap.c 7.4 (Berkeley) 5/13/91
* $Id: trap.c,v 1.8 1993/11/25 01:31:01 wollman Exp $
* $Id: trap.c,v 1.9 1993/11/28 09:28:54 davidg Exp $
*/
/*
@ -370,6 +370,9 @@ if(curpcb == 0 || curproc == 0) goto we_re_toast;
goto we_re_toast;
}
i = (rv == KERN_PROTECTION_FAILURE) ? SIGBUS : SIGSEGV;
ucode = type &~ T_USER;
frame.tf_err = eva;
/* kludge to pass faulting virtual address to sendsig */
break;
}