I have almost the same question, how to add code when entering each function? but for C :
Since I am supporting some other large undocumented project, I want to have code similar to
static C0UNT_identifier_not_used_anywhere_else = 0; printf("%s%s:%d#%d", __func__, strrchr(__FILE__,'/'), __LINE__, ++C0UNT_identifier_not_used_anywhere_else);
to run when you enter each function, so I
- there is a journal of what causes that, and
- may indicate by which n th calls the function that it breaks.
Existing code contains hundreds of source files, so it is impossible to put a macro, for example.
#define ENTRY_CODE ... ... int function() { ENTRY_CODE ... }
in every function. I also do not use DevStudio, Visual Studio or another compiler providing __cyg_profile_func_enter or such extensions.
Optionally, I would like to print the return value of each function when exiting in a similar style. Can I do it?
source share