Here is a sample code to give an idea of ββwhat I want.
int regular_function(void)
{
int x,y,z;
my_api_call();
return x;
}
...
void my_api_call(void)
{
char* caller = get_caller_file();
int line = get_caller_line();
printf("I was called from %s:%d\n", caller, line);
}
Is there a way to implement get_caller_file()and get_caller_line()? I saw / used #defineing type tricks my_api_callas a function call passing in macros __FILE__and __LINE__. I was wondering if there is a way to access this information (provided it is present) at runtime instead of compile time? Shouldn't something like Valgrind do something like this to get the information it returns?
source
share