From: Kenn H. <ke...@us...> - 2003-03-03 00:54:16
|
Update of /cvsroot/linux-vax/kernel-2.5/arch/vax/kernel In directory sc8-pr-cvs1:/tmp/cvs-serv6388/arch/vax/kernel Modified Files: interrupt.c ptrace.c Log Message: Merge Dave's ptrace changes from 2.4. Untested since I don't have a native strace or gdb. Index: interrupt.c =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.5/arch/vax/kernel/interrupt.c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- interrupt.c 16 Feb 2003 23:58:40 -0000 1.11 +++ interrupt.c 3 Mar 2003 00:54:12 -0000 1.12 @@ -47,7 +47,7 @@ An entry in the list is free if the dest_addr field is zero, and is in use if non-zero */ -static struct irqvector irqvectors[NR_IRQVECTORS]; +struct irqvector irqvectors[NR_IRQVECTORS]; /* Default handlers for each SCB vector */ static struct stray_handler stray_handlers[NR_IRQS]; Index: ptrace.c =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.5/arch/vax/kernel/ptrace.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- ptrace.c 31 Jan 2003 08:55:31 -0000 1.8 +++ ptrace.c 3 Mar 2003 00:54:12 -0000 1.9 @@ -20,6 +20,8 @@ #include <linux/user.h> #include <linux/security.h> +#include "interrupt.h" + #if 0 #include <asm/fp.h> #include <asm/mipsregs.h> @@ -29,7 +31,9 @@ #include <asm/system.h> #include <asm/uaccess.h> -#define VAX_MAX_DIST_BETWEEN_PC 20 +#define VAX_MAX_NUM_VALS_TO_CHECK 5 + +extern struct irqvector irqvectors[NR_IRQVECTORS]; /* * search out does damn regs.. that variable length exception info is evil I * tell you evil. @@ -37,28 +41,40 @@ static struct pt_regs *ptrace_find_vax_regs(struct task_struct *child) { struct pt_regs *regs_ptr; - unsigned long *pc1, *pc2; - void *stack_top; + unsigned long *chk_excep_addr; + void *stack_top, *excep_addr; + int num_execp_params; + int i; + + // printk("child sp is %8lX\n", child->thread.pcb.ksp); + stack_top = child->thread_info +1; + stack_top -= 4; /* jump down over PC and PSL which are always there */ + + /* hack attack - apologies to anyone who has just eaten + * this is the worst code I've written since the code this code + * is replacing ... - Dave. + */ + + /* start after the PC/PSL, and look for an exception vector + if we move to malloced vectors this is screwed */ + chk_excep_addr = (unsigned long *)*(unsigned long *)stack_top; + for (i=0; i<VAX_MAX_NUM_VALS_TO_CHECK; i++) + { + excep_addr = ((unsigned long *)stack_top)-i; + chk_excep_addr = (unsigned long *)*(unsigned long *)excep_addr; + if (chk_excep_addr>(unsigned long *)irqvectors && chk_excep_addr<(unsigned long *)(irqvectors+NR_IRQVECTORS)) + break; + } + + if (i==VAX_MAX_NUM_VALS_TO_CHECK) + { + printk("Cannot find exception handler address\n"); + return NULL; + } - stack_top = child->thread_info + THREAD_SIZE; - stack_top -= 4; - - - pc1 = (unsigned long *)stack_top - 2; - pc2 = pc1; - - //printk("pc1 is %8lX at %8lX\n", *pc1, pc1); - /* back step looking for second copy of PC */ - do { - pc2 -= 1; - } while (*pc1!=*pc2 && pc1-pc2<VAX_MAX_DIST_BETWEEN_PC); - - //printk("difference is %d\n", pc1-pc2); - - if (pc1-pc2>=VAX_MAX_DIST_BETWEEN_PC) - return NULL; + num_execp_params = *chk_excep_addr; - regs_ptr = ((void *)pc2) + 8 - sizeof(struct pt_regs); + regs_ptr = excep_addr - 4 - sizeof(struct pt_regs); return regs_ptr; } @@ -117,7 +133,7 @@ retval=0; break; } -// printk("getreg for %d returned %8lX\n", regno>>2, retval); +// printk("getreg for %ld returned %8lX\n", regno>>2, retval); return retval; } |