This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Merging calls to `abort'
On Tue, 2005-03-15 at 09:59, Clifford Wolf wrote:
> Hi,
>
> On Sun, Mar 13, 2005 at 03:01:00PM +0200, Kai Henningsen wrote:
> > Most of the rest of the error handling in this project is concerned with
> > the absence of the feature I loved in the IBM PL/I compilers under the
> > name "SNAP;" - putting out a stack backtrace (the usual idiom for abort()
> > was "SNAP; STOP;" IIRC). Now *that* would be a useful feature to have.
>
> It is there: __builtin_return_address(n)
>
> I have a small example of how to use that on my homepage:
>
> http://www.clifford.at/cfun/elfstuff/backtrace.c
>
> This example is using the ELF dladdr() function - so it can only resolve
> symbols in a .so file - not in the main program. (I think it works if the
> main program is compiled with -rdynamic - but I didn't check that).
>
> I hope that helps.
I doubt it will, because most platforms don't support
__builtin_return_address(n) for any value of n other than 0.
On modern machines it's generally impossible to unwind the stack frame
without comprehensive unwind tables.
R.