This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: How to retrieve the caller information from call stack


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


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