For GCC, we've got the return address (context->ra in the unwind programs in the original post). The "problem" is that we want to know if that address falls on a signal trampoline frame. If NO, return "end of stack", otherwise unwind the frame.
The KERN_PROC_SIGTRAMP of FreeBSD and DragonFly has in its return structure a pair of addresses representing the starting address and ending address of that process's signal frame, so it's a simple matter of checking if context->fa falls between them. How we did it with libc before is shown in the netbsd-unwind.h link in the original post. This technique looks for __sigtramp_siginfo_2 assembly code but no longer works. I don't know how to do this any other way. GDB doesn't either, it uses the debug information to match the function name __sigtramp_siginfo_2 and I am not even sure that's valid for current NetBSD releases based on what we've learned here. A sysctl that returns an array of address pairs for all signal trampolines in the process is what I'm requesting. If there's another way to determine if an address falls within a signal trampoline, I'd like to see actual code to see if I can adapt it. Of course, the kernel team could just deny the request, but I won't be able to fix the regression caused when the per-signal trampolines were introduced. Thanks, John