lkml.org 
[lkml]   [2008]   [Sep]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC][PATCH] Demultiplexing SIGTRAP signal

* Srinivasa Ds <srinivasa@in.ibm.com> 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


\
 
 \ /
  Last update: 2008-09-22 12:45    [from the cache]
©2003-2011 Jasper Spaans