This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Is there a (somewhat) portable way to get the return address of a function?


> 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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]