This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Is there a (somewhat) portable way to get the return address of a function?
- To: gcc at gcc dot gnu dot org, george at moberg dot com
- Subject: Re: Is there a (somewhat) portable way to get the return address of a function?
- From: Mike Stump <mrs at windriver dot com>
- Date: Tue, 6 Jun 2000 19:20:18 -0700 (PDT)
> Date: Tue, 06 Jun 2000 18:50:33 -0400
> From: "George T. Talbot" <george@moberg.com>
> [ Is there a (somewhat) portable way to get the return address of a function? ]
What part of the manual that describes how to do this was unclear:
@node Return Address
@section Getting the Return or Frame Address of a Function
These functions may be used to get information about the callers of a
function.
@table @code
@findex __builtin_return_address
@item __builtin_return_address (@var{level})
This function returns the return address of the current function, or of
one of its callers. The @var{level} argument is number of frames to
scan up the call stack. A value of @code{0} yields the return address
of the current function, a value of @code{1} yields the return address
of the caller of the current function, and so forth.
The @var{level} argument must be a constant integer.
On some machines it may be impossible to determine the return address of
any function other than the current one; in such cases, or when the top
of the stack has been reached, this function will return @code{0}.
This function should only be used with a non-zero argument for debugging
purposes.
? I'm just curious. Also, this is the wrong list. gcc-help would
have been better. Further, on glibc platforms, there may be (I could
be wrong) additional functionality in glibc, check out the glibc for
details, I can't recall them now.