Page 1 of 1

How to find caller address in i386?

Posted: Tue Jul 22, 2008 11:02 pm
by samueldotj
Hi,

Inside a kernel function I want to find which function called that function at run time.
For example: If function x() calls y(), I want to get x's address inside y.

Is there any way without back tracing the stack?

Thanks
Sam

Re: How to find caller address in i386?

Posted: Wed Jul 23, 2008 12:28 am
by xyzzy
If you're using GCC, you can use the builtin function __builtin_return_address() to get the address of the instruction after the call in x()

Re: How to find caller address in i386?

Posted: Wed Jul 23, 2008 2:41 am
by samueldotj
Thanks