This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: _Unwind_Backtrace vs. _Unwind_RaiseException unwinding


Roy Krischer <rkrische@plg.uwaterloo.ca> writes:

> 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)?

In general the personality routine assumes that it is executing in an
exception region.  If you are calling _Unwind_Backtrace, you may well
unwind into code which is not in an exception region.  There is no
particular reason to assume that the personality routine will work in
that case.

It may help to use the -fasynchronous-unwind-tables option.

Also there is a lot of architecture specific in this area, so you need
to tell us your architecture.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]