printf("sendsig(%d): sig %d ssp %x usp %x scp %x ft %d\n",
printf("sendsig(%d): sig %d ssp %p usp %p scp %p ft %d\n",
sendsig(catcher, sig, mask, code)	sig_t   catcher;	int     sig, mask;	u_long  code;{	extern short	exframesize[];	extern char	sigcode[], esigcode[];	register struct proc *p = curproc;	register struct sigframe *fp, *kfp;	register struct frame *frame;	register struct sigacts *psp = p->p_sigacts;	register short	ft;	int     oonstack;	frame = (struct frame *) p->p_md.md_regs;	ft = frame->f_format;	oonstack = psp->ps_sigstk.ss_flags & SS_ONSTACK;	/*	 * Allocate and validate space for the signal handler	 * context. Note that if the stack is in P0 space, the	 * call to grow() is a nop, and the useracc() check	 * will fail if the process has not already allocated	 * the space with a `brk'.	 */	if ((psp->ps_flags & SAS_ALTSTACK) && oonstack == 0 &&	    (psp->ps_sigonstack & sigmask(sig))) {		fp = (struct sigframe *) (psp->ps_sigstk.ss_sp +		    psp->ps_sigstk.ss_size - sizeof(struct sigframe));		psp->ps_sigstk.ss_flags |= SS_ONSTACK;	} else		fp = (struct sigframe *) frame->f_regs[SP] - 1;	if ((unsigned) fp <= USRSTACK - ctob(p->p_vmspace->vm_ssize))		(void) grow(p, (unsigned) fp);#ifdef DEBUG	if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid)		printf("sendsig(%d): sig %d ssp %x usp %x scp %x ft %d\n",		    p->p_pid, sig, &oonstack, fp, &fp->sf_sc, ft);#endif	if (useracc((caddr_t) fp, sizeof(struct sigframe), B_WRITE) == 0) {#ifdef DEBUG		if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid)			printf("sendsig(%d): useracc failed on sig %d\n",			    p->p_pid, sig);#endif		/*		 * Process has trashed its stack; give it an illegal		 * instruction to halt it in its tracks.		 */		SIGACTION(p, SIGILL) = SIG_DFL;		sig = sigmask(SIGILL);		p->p_sigignore &= ~sig;		p->p_sigcatch &= ~sig;		p->p_sigmask &= ~sig;		psignal(p, SIGILL);		return;	}	kfp = malloc(sizeof(struct sigframe), M_TEMP, M_WAITOK);	/* Build the argument list for the signal handler. */	kfp->sf_signum = sig;	kfp->sf_code = code;	kfp->sf_scp = &fp->sf_sc;	kfp->sf_handler = catcher;	/*	 * Save necessary hardware state.  Currently this includes:	 *	- general registers	 *	- original exception frame (if not a "normal" frame)	 *	- FP coprocessor state	 */	kfp->sf_state.ss_flags = SS_USERREGS;	bcopy((caddr_t) frame->f_regs,	    (caddr_t) kfp->sf_state.ss_frame.f_regs, sizeof frame->f_regs);	if (ft >= FMT9) {#ifdef DEBUG		if (ft != FMT9 && ft != FMTA && ft != FMTB)			panic("sendsig: bogus frame type");#endif		kfp->sf_state.ss_flags |= SS_RTEFRAME;		kfp->sf_state.ss_frame.f_format = frame->f_format;		kfp->sf_state.ss_frame.f_vector = frame->f_vector;		bcopy((caddr_t) & frame->F_u,		    (caddr_t) & kfp->sf_state.ss_frame.F_u, exframesize[ft]);		/*		 * Leave an indicator that we need to clean up the kernel		 * stack.  We do this by setting the "pad word" above the		 * hardware stack frame to the amount the stack must be		 * adjusted by.		 *		 * N.B. we increment rather than just set f_stackadj in		 * case we are called from syscall when processing a		 * sigreturn.  In that case, f_stackadj may be non-zero.		 */		frame->f_stackadj += exframesize[ft];		frame->f_format = frame->f_vector = 0;#ifdef DEBUG		if (sigdebug & SDB_FOLLOW)			printf("sendsig(%d): copy out %d of frame %d\n",			    p->p_pid, exframesize[ft], ft);#endif	}	if (fputype) {		kfp->sf_state.ss_flags |= SS_FPSTATE;		m68881_save(&kfp->sf_state.ss_fpstate);	}#ifdef DEBUG	if ((sigdebug & SDB_FPSTATE) && *(char *) &kfp->sf_state.ss_fpstate)		printf("sendsig(%d): copy out FP state (%x) to %x\n",		    p->p_pid, *(u_int *) & kfp->sf_state.ss_fpstate,		    &kfp->sf_state.ss_fpstate);#endif	/*	 * Build the signal context to be used by sigreturn.	 */	kfp->sf_sc.sc_onstack = oonstack;	kfp->sf_sc.sc_mask = mask;	kfp->sf_sc.sc_sp = frame->f_regs[SP];	kfp->sf_sc.sc_fp = frame->f_regs[A6];	kfp->sf_sc.sc_ap = (int) &fp->sf_state;	kfp->sf_sc.sc_pc = frame->f_pc;	kfp->sf_sc.sc_ps = frame->f_sr;	(void) copyout((caddr_t) kfp, (caddr_t) fp, sizeof(struct sigframe));	frame->f_regs[SP] = (int) fp;#ifdef DEBUG	if (sigdebug & SDB_FOLLOW)		printf("sendsig(%d): sig %d scp %x fp %x sc_sp %x sc_ap %x\n",		    p->p_pid, sig, kfp->sf_scp, fp,		    kfp->sf_sc.sc_sp, kfp->sf_sc.sc_ap);#endif	/*	 * Signal trampoline code is at base of user stack.	 */	frame->f_pc = (int) (((char *) PS_STRINGS) - (esigcode - sigcode));#ifdef DEBUG	if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid)		printf("sendsig(%d): sig %d returns\n",		    p->p_pid, sig);#endif	free((caddr_t) kfp, M_TEMP);}