Subject: Re: -current kernel broken
To: None <mouse@Collatz.McRCIM.McGill.EDU, port-sparc@NetBSD.ORG>
From: Chris Torek <torek@bsdi.com>
List: port-sparc
Date: 06/19/1996 18:19:11
>But __builtin_return_address _can't_ be implemented in libgcc ...

Actually, it can.  User code can figure out the number of windows
by executing `save's until the cwp field is the same as it was
initially, e.g., in pseudo-code:

	init_cwp = %psr & 31;
	nwindows = 0;
	do {
		save();
		nwindows++;
	} while ((%psr & 31) != init_cwp);
	for (i = 0; i < nwindows; i++)
		restore();

This works because %psr is user-readable.  It is stupid, though,
because it will trap 7 or 8 times instead of once; a `ta 3' is
cheaper.

Note, though, that for the case you disassembled, the trap is
unnecessary, as %i7 is already valid.  One needs to do a flushwin
only to find the caller's caller, etc.

Chris