Re: [RFC][PATCH] Demultiplexing SIGTRAP signal
From: Ingo Molnar
Date: Mon Sep 22 2008 - 06:43:01 EST
* Srinivasa Ds <srinivasa@xxxxxxxxxx> wrote:
> Currently a SIGTRAP signal can denote any one of below reasons.
> - Breakpoint hit
> - H/W debug register hit
> - Single step
> - SIGTRAP 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.
no fundamental objections - assuming existing x86 apps have not grown an
ABI dependency on the existing send_sigtrap() semantics. (Debuggers and
JITs would be a candidate for such dependencies.)
a small implementational detail, this bit:
> @@ -935,8 +936,22 @@ void __kprobes do_debug(struct pt_regs *
> goto clear_TF_reenable;
> }
>
> - /* Ok, finally something we can handle */
> - send_sigtrap(tsk, regs, error_code);
> + tsk->thread.trap_no = 1;
> + tsk->thread.error_code = error_code;
> +
> + memset(&info, 0, sizeof(info));
> + info.si_signo = SIGTRAP;
> + if (condition & DR_STEP)
> + info.si_code = TRAP_TRACE;
> + else if (condition & (DR_TRAP0|DR_TRAP1|DR_TRAP2|DR_TRAP3))
> + info.si_code = TRAP_HWBKPT;
> + else
> + info.si_code = TRAP_BRKPT;
> + /* User-mode ip? */
> + info.si_addr = user_mode_vm(regs) ? (void __user *) regs->ip : NULL;
> +
> + /* Send us the fake SIGTRAP */
> + force_sig_info(SIGTRAP, &info, tsk);
should be pushed into [a sufficiently extended] send_sigtrap() instead.
and this bit:
> - info.si_code = TRAP_BRKPT;
> + if (condition & DR_STEP)
> + info.si_code = TRAP_TRACE;
> + else if (condition & (DR_TRAP0|DR_TRAP1|DR_TRAP2|DR_TRAP3))
> + info.si_code = TRAP_HWBKPT;
> + else
> + info.si_code = TRAP_BRKPT;
should be separated into a helper function as well i guess.
Roland, any objections to the core idea (or to the implementation)?
Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/