This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
__builtin_return_address question
- From: Andrew Haley <aph at cambridge dot redhat dot com>
- To: nbecker at hns dot com (Neal D. Becker)
- Cc: gcc at gcc dot gnu dot org
- Date: Wed, 21 Aug 2002 15:22:48 +0100 (BST)
- Subject: __builtin_return_address question
- References: <x8865y4gx58.fsf@rpppc1.md.hns.com>
Neal D. Becker writes:
> I'm trying to make a stack trace function. Use of
> __builtin_return_address looks promising, but the arg has to be a
> constant expression. Because the arg can't be a variable, I don't see
> how I can traceback more than one level of the stack. Any ideas?
It depends on the architecture. With some ABIs unwinding is trivial
pointer chasing, but with others it can be very difficult. See
backtrace() in the glibc source.
For IA-64 see
http://sources.redhat.com/ml/libc-hacker/2002-01/msg00034.html. This
is the way of the future...
Andrew.