I've been playing around with _Unwind_Backtrace for a C++ project of
mine. Ideally, I would like to call the personality routine from
_Unwind_Backtrace to decode the lsda for me, and I can certainly do it
through the trace function.
The problem that I have, however, is that the unwinding that
_Unwind_Backtrace produces is different from the one
_Unwind_RaiseException produces. More specifically, the contexts
created by _Unwind_Backtrace have the first few register locations
NULLed, so when I run the personality routine in _UA_CLEANUP_PHASE
mode, it tries to dereference those (reg[0] and reg[2] on my
architecture) null pointers and crashes.
What is so fundamentally different about _Unwind_Backtrace and
_Unwind_RaiseException, that _Unwind_RaiseException produces
complete' contexts, while Backtrace does not? Is it because
_Unwind_RaiseException uses __builtin_eh_return and this causes the
compiler to generate the proper information?
How can I trick _Unwind_Backtrace into producing the same contexts
and/or using the personality routine and it behaving just like during
exception handling (minus installing the context at the end, of
course)?