Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 25 Feb 1999 16:04:14 -0500 (EST)
From:      Robert Watson <robert@cyrus.watson.org>
To:        hackers@freebsd.org
Subject:   Signal--how to find address in SIGSEGV?
Message-ID:  <Pine.BSF.3.96.990225160136.4294B-100000@fledge.watson.org>

next in thread | raw e-mail | index | archive | help

I'm playing with a userland library that will provide a simple paging
service to code linked against it.  As such, it catches SIGSEGV and
watches for trap 12 (T_PAGEFLT).  I notice that i386/i386/machdep.c places
the fault address sf.sf_addr; i.e., in the stack frame.  However, the
signal handler prototype:

int
signal_handler(int signal, int code, struct sigcontext *scp)

does not appear to see that as a possible argument.  How can I get access
to the address in question in a C-friendly way?  Also, is there a way to
tell whether or not the address was used in a read or a write (I am
guessing not, other than to mprotect the page as neither, then try
allowing a read, then a write...?)

Thanks,


  Robert N Watson 

robert@fledge.watson.org              http://www.watson.org/~robert/
PGP key fingerprint: 03 01 DD 8E 15 67 48 73  25 6D 10 FC EC 68 C1 1C

Carnegie Mellon University            http://www.cmu.edu/
TIS Labs at Network Associates, Inc.  http://www.tis.com/
SafePort Network Services             http://www.safeport.com/



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.96.990225160136.4294B-100000>