[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Libunwind-devel] unwinding from signal handler (ARM)
From: |
Sven Neumann |
Subject: |
Re: [Libunwind-devel] unwinding from signal handler (ARM) |
Date: |
Fri, 19 Aug 2011 17:09:18 +0200 |
Hi,
On Fri, 2011-08-19 at 16:53 +0200, Ken Werner wrote:
> On 08/19/2011 02:39 PM, Sven Neumann wrote:
> > Hi,
> >
> > we are using libunwind for a while now to obtain backtraces for crash
> > reports. This on an ARM with EABI. Right now we are using a somewhat
> > outdated git snapshot (99e60be), but I'm currently trying to update to
> > 1.0-rc1. I don't have much success though.
> >
> > With 99e60be we had the problem that we could not unwind from a signal
> > handler. But that is exactly what we need to do since we want to get a
> > backtrace from the signal handler that is called when the application
> > crashes (usually signal 11). We found a workaround though, instead of
> > calling unw_getcontext() to get an initial unw_context_t pointer to pass
> > to unw_init_local(), we use the pointer that we got from the signal
> > handler. Here's some pseudo code for this:
> >
> > struct sigaction new_action;
> >
> > new_action.sa_sigaction = logCrash;
> > sigemptyset (&new_action.sa_mask);
> > new_action.sa_flags = SA_SIGINFO;
> >
> > sigaction(SIGSEGV,&new_action, NULL);
> > sigaction(SIGFPE,&new_action, NULL);
> >
> > and in logCrash we do something along the lines of:
> >
> > static void
> > logCrash(int sig, siginfo_t *info, void *ctx)
> > {
> > unw_init_local(&cursor, ctx);
> >
> > do
> > {
> > char name[128];
> > unw_word_t valp;
> > unw_word_t offset;
> > unw_getcontext()
> > if (unw_get_reg(&cursor, UNW_REG_IP,&valp) != 0)
> > break;
> >
> > /* log function name etc. here */
> >
> > ret = unw_step (&cursor);
> > }
> > while (ret> 0);
> > }
> >
> > This worked reasonably well giving us a nice stack trace most of the
> > time.
>
> Hi Sven,
>
> This code is looking strange to me because unw_getcontext() gets called
> in a loop. But we might focus on the new code instead.
Sorry, looks like I pasted that misaligned unw_getcontext() call there
by accident. There's not any call to unw_getcontext() in that code. We
are using the pointer from the signal handler as context.
> > Now I've updated libunwind to 1.0-rc1 and this trick doesn't seem to
> > work any longer. The code appears to crash in libunwind if used as
> > above. I had a look at the ARM implementation and found that there is
> > now code that's supposed to unw_step a signal handler. So I tried
> > without our hack and just use unw_getcontext(). Now it doesn't crash any
> > longer, but it also doesn't unwind over the signal handler. All I get is
> > a stack trace like this:
> >
> > 0x4016cde0 logUnwind() from /usr/lib/libraumfeld-1.0.so.0
> > 0x40205654 ?? from /usr/lib/libunwind.so.7
> >
> > Any ideas what we could do?
>
> Hmm, this is interesting. How does your system look like (which libc,
> kernel version)
Linux 3.0.3, uCLibC 0.9.32.
> and are you stepping over RT or non-RT signal frames?
The signal handler was installed using:
new_action.sa_sigaction = logCrash;
sigemptyset (&new_action.sa_mask);
new_action.sa_flags = SA_SIGINFO;
so as far as I understand it's an RT signal then, right ?
Sven
- [Libunwind-devel] unwinding from signal handler (ARM), Sven Neumann, 2011/08/19
- Re: [Libunwind-devel] unwinding from signal handler (ARM), Sven Neumann, 2011/08/19
- Re: [Libunwind-devel] unwinding from signal handler (ARM), Ken Werner, 2011/08/19
- Re: [Libunwind-devel] unwinding from signal handler (ARM),
Sven Neumann <=
- Re: [Libunwind-devel] unwinding from signal handler (ARM), Ken Werner, 2011/08/19
- Re: [Libunwind-devel] unwinding from signal handler (ARM), Sven Neumann, 2011/08/22
- Re: [Libunwind-devel] unwinding from signal handler (i586), Sven Neumann, 2011/08/22
- Re: [Libunwind-devel] unwinding from signal handler (i586), Lassi Tuura, 2011/08/22
- Re: [Libunwind-devel] unwinding from signal handler (i586), Sven Neumann, 2011/08/22
- Re: [Libunwind-devel] unwinding from signal handler (i586), Arun Sharma, 2011/08/22
- Re: [Libunwind-devel] unwinding from signal handler (i586), Ken Werner, 2011/08/30
- Re: [Libunwind-devel] unwinding from signal handler (ARM), Ken Werner, 2011/08/29
- Re: [Libunwind-devel] unwinding from signal handler (ARM), Ken Werner, 2011/08/29
- Re: [Libunwind-devel] unwinding from signal handler (ARM), Ken Werner, 2011/08/30