I know gcc has built in __function__
and related macros, but from an outside function, if I'm being passed a function pointer, is there a way to get the name of that function out of the symbol table at compile time?
Basically:
void* foo(){
profile_func(foo);
do_something();
}
profile_func(void* func){
printf("function is %s\n", NAME_OF(foo));
}
Of course, I know the symbol table is not an exact representation of the function, but it's enough to get the information I need.
I'm using -finstrument_functions
, and this is going to be going in the related __cyg_profile_func_enter()
function. I'm surprised that I can't find this already done by someone (unless my google-fu is lacking)