A fix for the clang + eabi + kdb backtrace endless loop

Ian Lepore ian at FreeBSD.org
Sat May 4 15:08:25 UTC 2013


On Fri, 2013-05-03 at 11:51 +0100, Andrew Turner wrote:
> On Wed, 01 May 2013 14:17:32 -0600
> Ian Lepore <ian at FreeBSD.org> wrote:
> 
> > The attached patch fixes the problem where a kdb backtrace loops
> > endlessly on an eabi kernel.  
> > 
> > I'm no expert on this stuff, so while this fixes the problem for me,
> > I'm not sure it's right, especially the STOP_UNWINDING in
> > exception_exit (which handles a test case of breaking into the
> > debugger with the keyboard and typing 'bt').  I'm not going to commit
> > this until it's been reviewed by someone who actually knows what
> > they're doing. :)
> STOP_UNWINDING tells binutils to generate the required unwind op-code
> to tell the kernel's unwinder it needs to stop in this function. There
> is a bug with the unwinder where it should tell the user it is in the
> function, however it doesn't currently.
> 
> See below for more comments.

Thanks for the review and info.  I didn't realize FP was unused in EABI.
I guess keying off it just accidentally worked right in the few cases I
tested.  

I was also a bit worried about the recursion case with using the PC to
see if unwinding seemed to be stuck.  I studied the code some more and
discovered that there's a mask of which registers changed, used for
pretty-printing.  I think that's a safer way to determine whether
unwinding is stuck in a loop -- if no registers changed then nothing was
unwound.

I also restructured things a bit so that the decision to stop unwinding
isn't acted on until after the current frame is printed; that seems to
ensure that the frame for a STOP_UNWINDING function gets printed before
exiting the loop.

So, here's a somewhat more clueful patch; how's this look?

-- Ian

-------------- next part --------------
A non-text attachment was scrubbed...
Name: eabi_unwind_fixes2.diff
Type: text/x-patch
Size: 5197 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-arm/attachments/20130504/f2ceba89/attachment.bin>


More information about the freebsd-arm mailing list