From owner-freebsd-hackers Thu Feb 25 13: 4:35 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from thithle.watson.org (THITHLE.RES.CMU.EDU [128.2.93.231]) by hub.freebsd.org (Postfix) with ESMTP id 4F95514CD0 for ; Thu, 25 Feb 1999 13:04:32 -0800 (PST) (envelope-from robert@cyrus.watson.org) Received: from fledge.watson.org (robert@fledge.pr.watson.org [192.0.2.3]) by thithle.watson.org (8.8.8/8.8.8) with SMTP id QAA03837 for ; Thu, 25 Feb 1999 16:04:15 -0500 (EST) (envelope-from robert@cyrus.watson.org) Date: Thu, 25 Feb 1999 16:04:14 -0500 (EST) From: Robert Watson X-Sender: robert@fledge.watson.org Reply-To: Robert Watson To: hackers@freebsd.org Subject: Signal--how to find address in SIGSEGV? Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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