From: Dave A. <ai...@us...> - 2003-02-23 23:54:58
|
Update of /cvsroot/linux-vax/kernel-2.4/arch/vax/kernel In directory sc8-pr-cvs1:/tmp/cvs-serv25982 Modified Files: interrupt.c ptrace.c Log Message: DA: if you thought the old code was bad, wait till you get a load of this, the old ptrace.c worked for a very finite definition of the word worked, it was fine if the program was static and running, however with dynamic libs, it tries to breakpoint before running and our two PCs aren't the same them, and we have issues.. The correct way to do this is to roll the stack back from the current spot, which could be AFAIK any number of levels from where we want to be, which sounds ugly.. so now I look for the exception vector (it has to be in the list..), it works for now... if we do get malloced exception vectors working i would worry if this code is still valid... Index: interrupt.c =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.4/arch/vax/kernel/interrupt.c,v retrieving revision 1.25 retrieving revision 1.26 diff -u -r1.25 -r1.26 --- interrupt.c 12 Feb 2003 02:37:33 -0000 1.25 +++ interrupt.c 23 Feb 2003 23:54:55 -0000 1.26 @@ -44,7 +44,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.4/arch/vax/kernel/ptrace.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- ptrace.c 9 Apr 2002 13:50:55 -0000 1.7 +++ ptrace.c 23 Feb 2003 23:54:55 -0000 1.8 @@ -19,6 +19,8 @@ #include <linux/smp_lock.h> #include <linux/user.h> +#include "interrupt.h" + #if 0 #include <asm/fp.h> #include <asm/mipsregs.h> @@ -28,7 +30,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. @@ -36,28 +40,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 = ((union task_union *)child)+1; - stack_top -= 4; + stack_top -= 4; /* jump down over PC and PSL which are always there */ - - 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); + /* 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; + } - //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; } @@ -116,7 +132,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; } |