Uwe Kleine-König wrote: > currently[1] __builtin_return_address for ARM only works with level == 0. > > For ftrace in the linux kernel it would be great to implement that for > level > 0 (provided that framepointers or unwind information are > available of course). On the linux-arm-kernel ML Mikael Pettersson[2] > said that "__builtin_return_address(N) where N>0 should never have been > introduced into gcc.". Is that the general view for > __builtin_return_address or would a patch be accepted?
The old APCS, if I recall correctly, required a frame pointer, so __builtin_return_address(N) was easy. > Up to now I only had a quick glance at gcc sources and after that I'm > not sure if I even find the place where to put an implementation, so any > help is welcome. In userland ARM EABI doesn't have a frame pointer chain, so what you suggest isn't possible. However, we do need to unwind the stack so we use the unwinder info. For this you have to call _Unwind_Backtrace directly. 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. Andrew.