This is an archive of the discontinued LLVM Phabricator instance.

[libcxxabi] Make _Unwind_Backtrace() work on ARM.
ClosedPublic

Authored by danalbert on Aug 28 2014, 4:08 PM.

Details

Summary

Since the personality functions do the actual unwinding on ARM, and will
also stop unwinding when they encounter a handler, we invoke
_Unwind_VRS_Interpret() directly form _Unwind_Backtrace().

To simplify, the logic for decoding an EHT is moved out of
unwindOneFrame() and into its own function, decode_eht_entry(). Unlike
unwindOneFrame(), which could only handle ARM's compact personality
function entries (section 6.3) decode_eht_entry() can handle the generic
entries (section 6.2).

Diff Detail

Repository
rL LLVM

Event Timeline

danalbert updated this revision to Diff 13062.Aug 28 2014, 4:08 PM
danalbert retitled this revision from to [libcxxabi] Make _Unwind_Backtrace() work on ARM..
danalbert updated this object.
danalbert edited the test plan for this revision. (Show Details)
danalbert added a reviewer: jroelofs.
danalbert added a subscriber: Unknown Object (MLST).
jroelofs added inline comments.Aug 28 2014, 4:48 PM
include/unwind.h
210 ↗(On Diff #13062)

This is an implementation detail, and doesn't belong in the public interface. Can this go in a header in src/Unwind?

src/Unwind/Unwind-EHABI.cpp
171 ↗(On Diff #13062)

The assert should stay.

241 ↗(On Diff #13062)

const_cast is icky. can we make this return const uint32_t*?

src/Unwind/UnwindLevel1-gcc-ext.c
145 ↗(On Diff #13062)

This needs to go before the callback is called, otherwise the first callback would have the context corresponding to the _Unwind_Backtrace function itself. The best place is probably right under the if (unw_step(...)) { block.

danalbert updated this revision to Diff 13064.Aug 28 2014, 5:09 PM

Add test and fix ordering of unwinding in _Unwind_Backtrace() (was
unwinding after calling callback, causing _Unwind_Backtrace() to be
included in backtrace).

danalbert updated this revision to Diff 13066.Aug 28 2014, 5:46 PM
  • Address review comments.
danalbert updated this object.Aug 28 2014, 5:47 PM
danalbert edited the test plan for this revision. (Show Details)
jroelofs edited edge metadata.Aug 28 2014, 5:54 PM

with the assert added back, LGTM.

I'll think about how to make the asserts tighter, and we can come back & fix up the test case if there ends up being a better way to do that.

src/Unwind/Unwind-EHABI.cpp
174 ↗(On Diff #13064)

assert((*unwindingData & 0xf0000000) == 0x80000000 && "Must be a compact entry");

jroelofs accepted this revision.Aug 28 2014, 5:57 PM
jroelofs edited edge metadata.

just saw you posted a new revision... this one LGTM too.

This revision is now accepted and ready to land.Aug 28 2014, 5:57 PM
piman added a subscriber: piman.Aug 28 2014, 6:48 PM
piman added inline comments.
src/Unwind/Unwind-EHABI.cpp
223 ↗(On Diff #13066)

Mmh, this makes assumptions about the personality routine doesn't it?
The generic model is supposed to be compatible with a variety of languages and I'm not sure we can assume the generic data is the same as what the C++ personality routine expects, can we?

jroelofs added inline comments.Aug 29 2014, 6:18 AM
src/Unwind/Unwind-EHABI.cpp
223 ↗(On Diff #13066)

In the generic model, the unwind opcodes come first, and then the LSDA comes after... this looks correct to me.

danalbert closed this revision.Aug 29 2014, 8:35 AM
danalbert updated this revision to Diff 13093.

Closed by commit rL216730 (authored by @danalbert).