I'm not to familiar with the x86 architecture but for an ARM architecture you can just look at the link register, R14. This will give you the address of the function that called you. It is used to store where the code goes to upon 'return' and therefore will contain the address you want. I would be pretty sure that there is something similar in x86, have a look through the register definitions.
http://en.wikipedia.org/wiki/Link_register Thanks, Ste On Thu, Mar 5, 2009 at 4:09 PM, Ravi Sankar <ravisanka...@gmail.com> wrote: > Thanks thats good starting point for me. > > On Thu, Mar 5, 2009 at 4:49 PM, Manish Katiyar <mkati...@gmail.com> wrote: > >> On Thu, Mar 5, 2009 at 12:49 PM, Ravi Sankar <ravisanka...@gmail.com> >> wrote: >> > Hi, >> > >> > I would like to know how can I get the function name of the caller in >> c?. >> >> I don't know how to get the function name, but you can get the return >> address in the caller function using "__builtin_return_address()". >> Google for it and you would get some idea. Inorder to get function >> name from address, probably you will have to do some translation, just >> like debuggers do. >> >> Thanks - >> Manish >> >> >> > >> > Like >> > // c code >> > >> > void foo(void) >> > { >> > >> > bar(); >> > } >> > >> > void bar(void) >> > { >> > // who is my caller? >> > } >> > >> > I don't want to change the caller function code to add arguments etc. >> > Even I don't have access to the caller function source code. >> > >> > Thanks for your help. >> > >> > -- >> > --, >> > BR, >> > Ravi Sankar Guntur. >> > >> > > > > -- > --, > BR, > Ravi Sankar Guntur. >