How to find caller address in i386?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
samueldotj
Member
Member
Posts: 32
Joined: Mon Nov 13, 2006 12:24 am

How to find caller address in i386?

Post 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
xyzzy
Member
Member
Posts: 391
Joined: Wed Jul 25, 2007 8:45 am
Libera.chat IRC: aejsmith
Location: London, UK
Contact:

Re: How to find caller address in i386?

Post 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()
User avatar
samueldotj
Member
Member
Posts: 32
Joined: Mon Nov 13, 2006 12:24 am

Re: How to find caller address in i386?

Post by samueldotj »

Thanks
Post Reply