Re: [PATCHSET ptrace] ptrace: implement PTRACE_SEIZE/INTERRUPT and group stop notification, take#4

From: Pedro Alves
Date: Thu Jun 16 2011 - 05:56:26 EST


Hi Tejun,

On Thursday 16 June 2011 09:38:28, Tejun Heo wrote:
> On Fri, Jun 03, 2011 at 11:25:15AM +0100, Pedro Alves wrote:
> > It'd be _very_ useful for x86 (and others) to have
> > something like TRAP_BRKPT for int3. Both for ptracers
> > and in-process self debuggers.
> >
> > I'd be super happy to be told we have that already
> > in recent kernels and I missed it. :-)
>
> Unfortunately, AFAICS, x86 doesn't have it nor is there a generic
> mechanism, but this should be solvable without disrupting existing
> users.

Hmm, looks like there was an earlier attempt:

<http://lkml.indiana.edu/hypermail/linux/kernel/0809.2/1898.html>

Reading that thread, there were some minor revisions, but I didn't
see any objection. It seems that patch made it 2.6.28 (the only
sources I have handy), as I see get_si_code calls in arch/x86/kernel/traps.c,
and arch/x86/include/asm/traps.h.

But, I'm running 2.6.38, x86-64, and

#include <stdio.h>
#include <string.h>
#include <signal.h>

static void
handler (int sig, siginfo_t *info, void *context)
{
printf ("si_code = %x\n", info->si_code);
}

int
main (void)
{
struct sigaction action;

memset (&action, 0, sizeof (action));
action.sa_sigaction = handler;
action.sa_flags |= SA_SIGINFO;
sigaction (SIGTRAP, &action, NULL);

asm volatile ("int3");

return 0;
}

still prints:

$ ./trap
si_code = 80

Hmm... I don't have any other kernel version sources or
git checkout handy at the moment to check the history
behind this.

--
Pedro Alves
--
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/