This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: __builtin_return_address for ARM
Paul Brook wrote:
>>>> As I understand it, the ARM kernel can now do something similar. So,
>>>> the only use for a __builtin_return_address(N) that used the frame
>>>> pointer chain would be if the code were compiled with nonstandard
>>>> options.
>>> Correct.
>> Well, but wouldn't it still be nice if __builtin_return_address(N) was
>> implemented for N>0 by libcalling into the unwinder for you? Obviously
>> this would still have to return NULL at runtime when you're running on a
>> DW2 target without any EH frame data present in memory (and I guess it
>> wouldn't work on SjLj targets either), but wouldn't it still be a nice
>> convenience feature for users?
>
> There are sufficiently many caveats and system specific bits of weirdness that
> you probably just have to know what you're doing (or rely on backtrace(3) to
> do it for you).
>
> IMHO builtins are for things that you can't do in normal C. So
> __builtin_return_address(0) makes a lot of sense. Having it start guessing
> how to do N>0 much less so.
I suggest we could contribute a version of backtrace.c for ARM to glibc.
An example to follow is libc/sysdeps/ia64/backtrace.c.
Andrew.