Reading a Function's Return Address
Theodore A. Camus
tac at cs.brown.edu
Tue Jul 24 05:14:41 AEST 1990
>Has anyone attempted and succeeded in coding a 'C' fragment which can be
>used on a SPARC to determine a function's caller's return address from
>within the function?
Just put the following in 'file.s' :
.seg "text"
.global _getaddr
_getaddr:
retl
add %i7,8,%o0
and link in file.s (just pretend it's a C source file). Now you can just
say : this_functions_return_address_is = getaddr(); in the callee. This
will give you the point in the caller where the callee will return to.
This value minus 8 is the address of the statement which actually called
the function you're in.
- Ted
More information about the Comp.sys.sun
mailing list