On Tue, Jun 09, 2009 at 02:35:45PM +0800, liqin.chen@xxxxxxxxxxxxx wrote: > +long > +arch_ptrace(struct task_struct *child, long request, long addr, long > data) > +{ > + int ret; > + > + if (request == PTRACE_TRACEME) { > + /* are we already being traced? */ > + if (current->ptrace & PT_PTRACED) > + return -EPERM; > + > + /* set the ptrace bit in the process flags. */ > + current->ptrace |= PT_PTRACED; > + return 0; > + } > + > + ret = -ESRCH; > + if (!child) > + return ret; > + > + ret = -EPERM; > + > + if (request == PTRACE_ATTACH) { > + ret = ptrace_attach(child); > + return ret; > + } > + > + ret = ptrace_check_attach(child, request == PTRACE_KILL); > + if (ret < 0) > + return ret; > + All this stuff has been done by generic ptrace code for a long time and is not needed at all. > + switch (request) { > + case PTRACE_PEEKTEXT: /* read word at location addr. */ > + case PTRACE_PEEKDATA: { > + unsigned long tmp; > + int copied; > + > + copied = access_process_vm(child, addr, &tmp, sizeof(tmp), > 0); > + ret = -EIO; > + if (copied != sizeof(tmp)) > + break; > + > + ret = put_user(tmp, (unsigned long *) data); > + return ret; > + } > + This also has a generic implementation. Please take a look at a modern ptrace implementation like sh, powerpc or x86 to model yours after. -- To unsubscribe from this list: send the line "unsubscribe linux-arch" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html