Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!rice!sun-spots-request From: tac@cs.brown.edu (Theodore A. Camus) Newsgroups: comp.sys.sun Subject: Re: Reading a Function's Return Address Keywords: Miscellaneous Message-ID: <10158@brazos.Rice.edu> Date: 23 Jul 90 19:14:41 GMT Sender: root@rice.edu Organization: Sun-Spots Lines: 19 Approved: Sun-Spots@rice.edu X-Refs: Original: v9n268 X-Sun-Spots-Digest: Volume 9, Issue 277, message 5 Originator: spots@titan.rice.edu >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