ptrace: x86: implement user_single_step_siginfo()
Suggested by Roland. Implement user_single_step_siginfo() for x86. Extract this code from send_sigtrap(). Since x86 calls tracehook_report_syscall_exit(step => 0) the new helper is not used yet. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Acked-by: Roland McGrath <roland@redhat.com> Cc: <linux-arch@vger.kernel.org> Cc: Ingo Molnar <mingo@elte.hu> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: "H. Peter Anvin" <hpa@zytor.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
2f0edac555
commit
7f38551fc3
|
@ -292,6 +292,8 @@ extern void user_enable_block_step(struct task_struct *);
|
||||||
#define arch_has_block_step() (boot_cpu_data.x86 >= 6)
|
#define arch_has_block_step() (boot_cpu_data.x86 >= 6)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define ARCH_HAS_USER_SINGLE_STEP_INFO
|
||||||
|
|
||||||
struct user_desc;
|
struct user_desc;
|
||||||
extern int do_get_thread_area(struct task_struct *p, int idx,
|
extern int do_get_thread_area(struct task_struct *p, int idx,
|
||||||
struct user_desc __user *info);
|
struct user_desc __user *info);
|
||||||
|
|
|
@ -1676,21 +1676,33 @@ const struct user_regset_view *task_user_regset_view(struct task_struct *task)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void fill_sigtrap_info(struct task_struct *tsk,
|
||||||
|
struct pt_regs *regs,
|
||||||
|
int error_code, int si_code,
|
||||||
|
struct siginfo *info)
|
||||||
|
{
|
||||||
|
tsk->thread.trap_no = 1;
|
||||||
|
tsk->thread.error_code = error_code;
|
||||||
|
|
||||||
|
memset(info, 0, sizeof(*info));
|
||||||
|
info->si_signo = SIGTRAP;
|
||||||
|
info->si_code = si_code;
|
||||||
|
info->si_addr = user_mode_vm(regs) ? (void __user *)regs->ip : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void user_single_step_siginfo(struct task_struct *tsk,
|
||||||
|
struct pt_regs *regs,
|
||||||
|
struct siginfo *info)
|
||||||
|
{
|
||||||
|
fill_sigtrap_info(tsk, regs, 0, TRAP_BRKPT, info);
|
||||||
|
}
|
||||||
|
|
||||||
void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
|
void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
|
||||||
int error_code, int si_code)
|
int error_code, int si_code)
|
||||||
{
|
{
|
||||||
struct siginfo info;
|
struct siginfo info;
|
||||||
|
|
||||||
tsk->thread.trap_no = 1;
|
fill_sigtrap_info(tsk, regs, error_code, si_code, &info);
|
||||||
tsk->thread.error_code = error_code;
|
|
||||||
|
|
||||||
memset(&info, 0, sizeof(info));
|
|
||||||
info.si_signo = SIGTRAP;
|
|
||||||
info.si_code = si_code;
|
|
||||||
|
|
||||||
/* User-mode ip? */
|
|
||||||
info.si_addr = user_mode_vm(regs) ? (void __user *) regs->ip : NULL;
|
|
||||||
|
|
||||||
/* Send us the fake SIGTRAP */
|
/* Send us the fake SIGTRAP */
|
||||||
force_sig_info(SIGTRAP, &info, tsk);
|
force_sig_info(SIGTRAP, &info, tsk);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue