Subject: finding faulted address
To: None <>
From: Gordon W. Ross <>
List: current-users
Date: 08/22/1995 10:09:20
> From: VaX#n8 <>
> Date: Mon, 21 Aug 1995 23:06:27 -0500 (CDT)

> I'm trying to find the faulted-on address in a SIGBUS handler.
> StunOS passes the address as another parameter to the signal handler,
> but I'm afraid I'm a bit confused as to how to get this from NetBSD.
> I'm looking over the machine/signal.h, but it appears to my untrained eye
> that I'd have to do some decoding of machine instructions (blech) and
> stuff.
> Mainly I'm mprotecting some heap pages and I want to find out which ones
> are being accessed, munprotect them, allow the access, and then later
> mprotect them.

Well, if our signal delivery conformed to POSIX 1003.1b (not yet)
then you would normally find that address as follows:

int segv_catch(signum, si, ctx)
	int signum;
	struct siginfo *si;
	void *ctx;
	void *va;

	va = si->si_value.sival_ptr;
	printf("segv touching address 0x%lx\n", va);

P.S. Typical struct definitions would be: (in sys/signal.h)

union sigval {
	int	sival_int;	/* integer value */
	void	*sival_ptr;	/* pointer value */

struct siginfo {
	int	si_signo;		/* same as handler arg one */
	int 	si_code;		/* like old handler 2nd arg */
	union sigval	si_value;	/* data relevant to the signal */