Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit da654b74 authored by Srinivasa Ds's avatar Srinivasa Ds Committed by Ingo Molnar
Browse files

signals: demultiplexing SIGTRAP signal



Currently a SIGTRAP can denote any one of below reasons.
	- Breakpoint hit
	- H/W debug register hit
	- Single step
	- Signal sent through kill() or rasie()

Architectures like powerpc/parisc provides infrastructure to demultiplex
SIGTRAP signal by passing down the information for receiving SIGTRAP through
si_code of siginfot_t structure. Here is an attempt is generalise this
infrastructure by extending it to x86 and x86_64 archs.

Signed-off-by: default avatarSrinivasa DS <srinivasa@in.ibm.com>
Cc: Roland McGrath <roland@redhat.com>
Cc: akpm@linux-foundation.org
Cc: paulus@samba.org
Cc: linuxppc-dev@ozlabs.org
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 101d5b71
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -113,11 +113,6 @@ typedef struct siginfo {
#undef NSIGSEGV
#define NSIGSEGV	3

/*
 * SIGTRAP si_codes
 */
#define TRAP_BRANCH	(__SI_FAULT|3)	/* process taken branch trap */
#define TRAP_HWBKPT	(__SI_FAULT|4)	/* hardware breakpoint or watchpoint */
#undef NSIGTRAP
#define NSIGTRAP	4

+0 −5
Original line number Diff line number Diff line
@@ -15,11 +15,6 @@

#include <asm-generic/siginfo.h>

/*
 * SIGTRAP si_codes
 */
#define TRAP_BRANCH	(__SI_FAULT|3)	/* process taken branch trap */
#define TRAP_HWBKPT	(__SI_FAULT|4)	/* hardware breakpoint or watchpoint */
#undef NSIGTRAP
#define NSIGTRAP	4

+4 −3
Original line number Diff line number Diff line
@@ -1358,7 +1358,8 @@ const struct user_regset_view *task_user_regset_view(struct task_struct *task)
#endif
}

void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs, int error_code)
void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
					 int error_code, int si_code)
{
	struct siginfo info;

@@ -1367,7 +1368,7 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs, int error_code)

	memset(&info, 0, sizeof(info));
	info.si_signo = SIGTRAP;
	info.si_code = TRAP_BRKPT;
	info.si_code = si_code;

	/* User-mode ip? */
	info.si_addr = user_mode_vm(regs) ? (void __user *) regs->ip : NULL;
@@ -1454,5 +1455,5 @@ asmregparm void syscall_trace_leave(struct pt_regs *regs)
	 */
	if (test_thread_flag(TIF_SINGLESTEP) &&
	    tracehook_consider_fatal_signal(current, SIGTRAP, SIG_DFL))
		send_sigtrap(current, regs, 0);
		send_sigtrap(current, regs, 0, TRAP_BRKPT);
}
+3 −1
Original line number Diff line number Diff line
@@ -891,6 +891,7 @@ void __kprobes do_debug(struct pt_regs *regs, long error_code)
{
	struct task_struct *tsk = current;
	unsigned int condition;
	int si_code;

	trace_hardirqs_fixup();

@@ -935,8 +936,9 @@ void __kprobes do_debug(struct pt_regs *regs, long error_code)
			goto clear_TF_reenable;
	}

	si_code = get_si_code((unsigned long)condition);
	/* Ok, finally something we can handle */
	send_sigtrap(tsk, regs, error_code);
	send_sigtrap(tsk, regs, error_code, si_code);

	/*
	 * Disable additional traps. They'll be re-enabled when
+1 −1
Original line number Diff line number Diff line
@@ -941,7 +941,7 @@ asmlinkage void __kprobes do_debug(struct pt_regs *regs,
	tsk->thread.error_code = error_code;
	info.si_signo = SIGTRAP;
	info.si_errno = 0;
	info.si_code = TRAP_BRKPT;
	info.si_code = get_si_code(condition);
	info.si_addr = user_mode(regs) ? (void __user *)regs->ip : NULL;
	force_sig_info(SIGTRAP, &info, tsk);

Loading