This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to implement a function which will give the address of the calling function during runtime.

I am working on a complex project written in C for 8051 arhitecture with Keil C. And unfortunately no real debugger. There are many functions called from various c files. Some times hundereds of different c file. I want to implement a function which will give me the address of the calling function during runtime. Is there a way to read the call stack to exctract the callig function address? If a can get the adress a can check it from .m51 file and can understand which function call is active.

func1(void)
{ func_test();
};

func2(void)
{ func_test();
};

func3(void)
{ func_test();
};

func_test(void)
{ int get_call_func_address;

get_call_func_address = ???????; printf("Calling function adress is %d", get_call_func_address);

//Do other things...

}

main()
{ func1(); func2(); func3();
}

Best regards
Saltuk Alakus

0