[PATCH 3] ptrace: introduce user_single_step_siginfo() helper

2009-11-22 Thread Oleg Nesterov
(already in mm: ptrace-introduce-user_single_step_siginfo-helper.patch)

Suggested by Roland.

Currently there is no way to synthesize a single-stepping trap in the
arch-independent manner. This patch adds the default helper which fills
siginfo_t, arch/ can can override it.

Architetures which implement user_enable_single_step() should add
user_single_step_siginfo() also.

Signed-off-by: Oleg Nesterov o...@redhat.com
Acked-by: Roland McGrath rol...@redhat.com
---

 include/linux/ptrace.h |   12 
 1 file changed, 12 insertions(+)

--- V1/include/linux/ptrace.h~3_DEFAULT_HELPER  2009-11-22 20:09:15.0 
+0100
+++ V1/include/linux/ptrace.h   2009-11-22 20:10:37.0 +0100
@@ -273,6 +273,18 @@ static inline void user_enable_block_ste
 }
 #endif /* arch_has_block_step */
 
+#ifdef ARCH_HAS_USER_SINGLE_STEP_INFO
+extern void user_single_step_siginfo(struct task_struct *tsk,
+   struct pt_regs *regs, siginfo_t *info);
+#else
+static inline void user_single_step_siginfo(struct task_struct *tsk,
+   struct pt_regs *regs, siginfo_t *info)
+{
+   memset(info, 0, sizeof(*info));
+   info-si_signo = SIGTRAP;
+}
+#endif
+
 #ifndef arch_ptrace_stop_needed
 /**
  * arch_ptrace_stop_needed - Decide whether arch_ptrace_stop() should be called



Re: [PATCH 3] ptrace: introduce user_single_step_siginfo() helper

2009-11-22 Thread Srikar Dronamraju
 
 +#ifdef ARCH_HAS_USER_SINGLE_STEP_INFO
 +extern void user_single_step_siginfo(struct task_struct *tsk,
 + struct pt_regs *regs, siginfo_t *info);
 +#else
 +static inline void user_single_step_siginfo(struct task_struct *tsk,
 + struct pt_regs *regs, siginfo_t *info)
 +{
 + memset(info, 0, sizeof(*info));
 + info-si_signo = SIGTRAP;

Is it possible to add si_code and si_addr info 
   info-si_code = TRAP_TRACE;  

   info-si_addr = instruction_pointer(regs);
 +}
 +#endif
 +

Thanks and Regards
-Srikar



Re: [PATCH 3] ptrace: introduce user_single_step_siginfo() helper

2009-11-22 Thread Roland McGrath
 Is it possible to add si_code and si_addr info 
info-si_code = TRAP_TRACE;
   
info-si_addr = instruction_pointer(regs);

This is exactly what arch-specific versions should do here.
The choice of TRAP_TRACE is an arch detail, not a common default.


Thanks,
Roland