From: Dave A. <ai...@us...> - 2001-11-08 22:17:21
|
Update of /cvsroot/linux-vax/kernel-2.4/arch/vax/kernel In directory usw-pr-cvs1:/tmp/cvs-serv8907 Modified Files: ptrace.c Log Message: DA: ptrace getreg/putreg should be more functional if not correct Index: ptrace.c =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.4/arch/vax/kernel/ptrace.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ptrace.c 2001/11/04 21:58:32 1.2 +++ ptrace.c 2001/11/08 22:17:16 1.3 @@ -31,16 +31,21 @@ static int putreg(struct task_struct *child, unsigned long regno, unsigned long value) { - printk("putreg called with regno %d\n", regno); + unsigned long retval = ~0UL; + void *stack_top; + struct pt_regs *regs_ptr; + + stack_top = ((union task_union *)child)+1; + stack_top -= 4; + + regs_ptr = stack_top - 16 - sizeof(struct pt_regs); + + printk("putreg called with regno %d\n", regno>>2); switch(regno >> 2) { - case 0 ... 13: - *(unsigned long *)((&child->thread.pcb)+4+(regno>>2))=value; - break; - case PT_SP: - child->thread.pcb.usp=value; - break; - case PT_PC: - child->thread.pcb.pc=value; + case 0 ... 16: + // retval = *(((unsigned long *)regs_ptr) + (regno>>2)); + *(((unsigned long *)regs_ptr) + (regno>>2)) = value; + // *(unsigned long *)((&child->thread.pcb)+4+(regno>>2))=value; break; default: printk("putreg for %d failed\n", regno); @@ -55,27 +60,23 @@ unsigned long regno) { unsigned long retval = ~0UL; + void *stack_top; + struct pt_regs *regs_ptr; + + stack_top = ((union task_union *)child)+1; + stack_top -= 4; - /* this code takes the register from the PCB for the process. PC is reg 15 but 14'th after R0 in - the pcb so it is special cased. have to add some stack pointers at some stage */ + /* get the registers from where we shoved them on the stack at the last + exception for this process.. not sure if this is always correct but + will do for now - 4 longwords back from end of stack is end of regs */ + + regs_ptr = stack_top - 16 - sizeof(struct pt_regs); + + switch(regno >> 2) { - case 0 ... 13: - retval = (unsigned long)*(unsigned long *)((&child->thread.pcb)+4+(regno>>2)); - break; - case PT_SP: - retval = child->thread.pcb.usp; - break; - case PT_PC: - { - int i; - struct pt_regs regs; - - // hex_dump((void *)(child->thread.pcb.ksp-0x80), 256); - // printk("ksp:%8lX ap:%8lX fp:%8lX\n", child->thread.pcb.ksp, child->thread.pcb.ap, child->thread.pcb.ksp+0x64); - /* FIXME: explain 0x64 == 100 = 25 * 4 pc is stored 25 longs into stack.... */ - retval = (unsigned long)*(unsigned long *)(child->thread.pcb.ksp + 0x64); + case 0 ... 16: + retval = *(((unsigned long *)regs_ptr) + (regno>>2)); break; - } default: printk("getreg for %d failed\n", regno); retval=0; |