LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   how to kno parent function's name ? (https://www.linuxquestions.org/questions/programming-9/how-to-kno-parent-functions-name-689750/)

vdx 12-11-2008 01:01 AM

how to kno parent function's name ?
 
hello friends,

Suppose I have 2 functions, fun_A() and fun_B().

Now fun_B is calling fun_A. So In fun_B how can i know tht "fun_A" has called me ?

I wanna make a C prog for the same....

elprawn 12-11-2008 08:15 AM

Pass the name of the caller as an argument.

jcookeman 12-11-2008 08:44 AM

Not so sure how much relevant this is, but looks interesting.

dmail 12-11-2008 08:45 AM

One method is to walk the call stack yet as how to do this is dependant on the system you are using. glibc gives you a backtrace, windows has StackWalk64, then there is __builtin_return_address and __builtin_frame_address.

edit:
What are you trying to achieve here is this for debugging information of say the allocation point or is this something completely different?

arunmathew1984 12-14-2008 01:51 AM

Pass the fun_b() as an argument the name of the calling function.
[ So it will now become - fun_b(String caller) ]

Linux Archive


All times are GMT -5. The time now is 12:51 PM.