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
Saltuk, what you are trying to do is something extraordinary: you want to be able to log just about any possible call tree in your program. The point is that this is not required if your software is organized properly: for example, if you have state machines in your program, you can simplify your requirement significantly because knowing the state of the state machine and the signal that it received, yields knowledge of the executed function! what you want to do is going to have, even if it works, such a huge impact on performance that it might distort the value of the data your acquire itself!