This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: How to retrieve the caller information from call stack
- From: Ramana Radhakrishnan <ramana dot radhakrishnan at celunite dot com>
- To: Hyun Seop Bae <hsbae at suresofttech dot com>
- Cc: gdb at sourceware dot org
- Date: Mon, 08 Jan 2007 10:35:08 +0530
- Subject: Re: How to retrieve the caller information from call stack
- References: <008801c732ba$502534f0$aae074d3@black>
- Reply-to: ramana dot radhakrishnan at celunite dot com
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