How to retrieve the caller information from call stack
Ramana Radhakrishnan
ramana.radhakrishnan@celunite.com
Mon Jan 8 05:06:00 GMT 2007
On Mon, 2007-01-08 at 09:16 +0900, Hyun Seop Bae wrote:
> Hi there,
>
> I'm looking for a way to retrieve caller information during run-time.
> Of course, I can find the name of caller function if I use gdb and set breakpoint.
>
> But, how can I know the name of caller function without gdb?
You can use __builtin_return_address if you were using gcc to get to the
address of the calling function . Getting to the name is a simple matter
of using a script to identify the function in which the address is
located, you can use an intelligent script using objdump / readelf to
get to it. Ofcourse you'll have to do some more hackery if this were in
a shared library :) .
cheers
Ramana
--
cheers
Ramana
Ramana Radhakrishnan
GNU Tools
Celunite Inc (www.celunite.com)
3rd Floor, Business Avenue
Lane 6 North Main Road
Koregaon Park
Pune 411001
Phone (work) - +912026051367
(mobile) - +919890040009
More information about the Gdb
mailing list