From: Haavard Skinnemoen Date: Tue, 27 Nov 2007 12:02:40 +0000 (+0100) Subject: ptrace: Call arch_ptrace_attach() when request=PTRACE_TRACEME X-Git-Tag: v2.6.25-rc1~1240^2~16 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=6ea6dd93c9454cc9521134f907bc970d09f460e4;p=linux-2.6-omap-h63xx.git ptrace: Call arch_ptrace_attach() when request=PTRACE_TRACEME arch_ptrace_attach() is a hook that allows the architecture to do book-keeping after a ptrace attach. This patch adds a call to this hook when handling a PTRACE_TRACEME request as well. Currently only one architecture, m32r, implements this hook. When called, it initializes a number of debug trap slots in the ptraced task's thread struct, and it looks to me like this is the right thing to do after a PTRACE_TRACEME request as well, not only after PTRACE_ATTACH. Please correct me if I'm wrong. I want to use this hook on AVR32 to turn the debugging hardware on when a process is actually being debugged and keep it off otherwise. To be able to do this, I need to intercept PTRACE_TRACEME and PTRACE_ATTACH, as well as PTRACE_DETACH and thread exit. The latter two can be handled by existing hooks. Signed-off-by: Haavard Skinnemoen --- diff --git a/kernel/ptrace.c b/kernel/ptrace.c index c25db863081..c719bb9d79a 100644 --- a/kernel/ptrace.c +++ b/kernel/ptrace.c @@ -470,6 +470,8 @@ asmlinkage long sys_ptrace(long request, long pid, long addr, long data) lock_kernel(); if (request == PTRACE_TRACEME) { ret = ptrace_traceme(); + if (!ret) + arch_ptrace_attach(current); goto out; }