Commit 757c4d2f authored by Jeff Dike's avatar Jeff Dike Committed by Linus Torvalds

[PATCH] UML: 2.6.10 ptrace updates

Add some of the 2.6.10 ptrace updates.
Signed-off-by: default avatarJeff Dike <jdike@addtoit.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 2339405e
...@@ -307,6 +307,25 @@ long sys_ptrace(long request, long pid, long addr, long data) ...@@ -307,6 +307,25 @@ long sys_ptrace(long request, long pid, long addr, long data)
return ret; return ret;
} }
void send_sigtrap(struct task_struct *tsk, union uml_pt_regs *regs,
int error_code)
{
struct siginfo info;
memset(&info, 0, sizeof(info));
info.si_signo = SIGTRAP;
info.si_code = TRAP_BRKPT;
/* User-mode eip? */
info.si_addr = UPT_IS_USER(regs) ? (void __user *) UPT_IP(regs) : NULL;
/* Send us the fakey SIGTRAP */
force_sig_info(SIGTRAP, &info, tsk);
}
/* XXX Check PT_DTRACE vs TIF_SINGLESTEP for singlestepping check and
* PT_PTRACED vs TIF_SYSCALL_TRACE for syscall tracing check
*/
void syscall_trace(union uml_pt_regs *regs, int entryexit) void syscall_trace(union uml_pt_regs *regs, int entryexit)
{ {
int is_singlestep = (current->ptrace & PT_DTRACE) && entryexit; int is_singlestep = (current->ptrace & PT_DTRACE) && entryexit;
...@@ -321,14 +340,19 @@ void syscall_trace(union uml_pt_regs *regs, int entryexit) ...@@ -321,14 +340,19 @@ void syscall_trace(union uml_pt_regs *regs, int entryexit)
audit_syscall_exit(current, regs->eax); audit_syscall_exit(current, regs->eax);
} }
if (!test_thread_flag(TIF_SYSCALL_TRACE) && !is_singlestep) /* Fake a debug trap */
if (is_singlestep)
send_sigtrap(current, regs, 0);
if (!test_thread_flag(TIF_SYSCALL_TRACE))
return; return;
if (!(current->ptrace & PT_PTRACED)) if (!(current->ptrace & PT_PTRACED))
return; return;
/* the 0x80 provides a way for the tracing parent to distinguish /* the 0x80 provides a way for the tracing parent to distinguish
between a syscall stop and SIGTRAP delivery */ between a syscall stop and SIGTRAP delivery */
tracesysgood = (current->ptrace & PT_TRACESYSGOOD) && !is_singlestep; tracesysgood = (current->ptrace & PT_TRACESYSGOOD);
ptrace_notify(SIGTRAP | (tracesysgood ? 0x80 : 0)); ptrace_notify(SIGTRAP | (tracesysgood ? 0x80 : 0));
if (entryexit) /* force do_signal() --> is_syscall() */ if (entryexit) /* force do_signal() --> is_syscall() */
......
...@@ -12,11 +12,13 @@ ...@@ -12,11 +12,13 @@
#define pt_regs pt_regs_subarch #define pt_regs pt_regs_subarch
#define show_regs show_regs_subarch #define show_regs show_regs_subarch
#define send_sigtrap send_sigtrap_subarch
#include "asm/arch/ptrace.h" #include "asm/arch/ptrace.h"
#undef pt_regs #undef pt_regs
#undef show_regs #undef show_regs
#undef send_sigtrap
#undef user_mode #undef user_mode
#undef instruction_pointer #undef instruction_pointer
...@@ -55,6 +57,9 @@ extern int set_fpxregs(unsigned long buf, struct task_struct *tsk); ...@@ -55,6 +57,9 @@ extern int set_fpxregs(unsigned long buf, struct task_struct *tsk);
extern void show_regs(struct pt_regs *regs); extern void show_regs(struct pt_regs *regs);
extern void send_sigtrap(struct task_struct *tsk, union uml_pt_regs *regs,
int error_code);
#endif #endif
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment