On Wed, Oct 01, 2008 at 02:18:55PM +0200, Vladimir Kotal wrote:
> 
> Hi all,
> 
> I am trying to write a D script which would print ustack() for every 
> program in the system receiving SIGSEGV. All the stacks printed in 
> trap()/sigtoproc() context do not have meaningful symbols.
> 
> The following solves the problem to some degree but I'd much rather have 
> a self-contained D script.
> 
> dtrace -w -n 'fbt:genunix:sigtoproc:entry/arg2 == 11/ { 
> self->pid=((proc_t *)arg0)->p_pidp->pid_id; stop(); 
> system("/usr/bin/gcore %d", self->pid); system("/usr/bin/prun %d", 
> self->pid); }'

This is stopping the signal sender, not the signal receiver.

#!/usr/sbin/dtrace -s

#pragma D option destructive
#pragma D option quiet

proc:::signal-send
/args[2] == SIGSEGV/
{
        segv_sent[args[1]->pr_addr] = 1;
}

fbt::issig_forreal:entry
/segv_sent[(uintptr_t)curthread->t_procp]/
{
        segv_sent[(uintptr_t)curthread->t_procp] = 0;
        printf("%6d %s\n", pid, curpsinfo->pr_psargs);
        ustack(20);
        stop();
        system("/usr/bin/prun %d", pid);
}

This should work regardless of the source of the segv.  (the main trick is
calling stop() at the top of issig_forreal();  that will stop the process before
the SEGV is processed, letting dtrace get a stack trace from it.)

Cheers,
- jonathan


> Any ideas (or code) will be appreciated,
> 
> 
> v.
> _______________________________________________
> dtrace-discuss mailing list
> [email protected]
_______________________________________________
dtrace-discuss mailing list
[email protected]

Reply via email to