Well here is a hack that might help you, it wont identify the calling function but will identify the calling line of code.
Lets assume that you function is defined like so
-
int aFunction(int param)
-
{
-
...
-
}
-
Declared in a header like so
-
extern int aFunction(int param);
-
and called like so
-
int result;
-
int param;
-
-
// initialise param
-
-
...
-
-
result = aFunction(param);
-
-
...
-
-
// use result
-
You make use of the __LINE__ and __FILE__ predefine macros in C that resolve to the current line number and current file name. You can use these along with the C/C++ preprocessor to crowbar some debuging into your code by making the following modifications
Cahnge the function definition to
-
int aFunctionWithDebug(int param, const char *file, int line)
-
{
-
printf("%s(%d): Called aFunction\n", file, line);
-
...
-
}
-
Change the declaration in the header file to
-
extern int aFunctionWithDebug(int param);
-
#define aFunction(param) aFunctionWithDebug(param)
-
and don't change the call to the function at all.
-
int result;
-
int param;
-
-
// initialise param
-
-
...
-
-
result = aFunction(param);
-
-
...
-
-
// use result
-
You will need to recompile your entire source (which sounds like it could take a while) and if you get the macro or any calls to the function wrong you will get not entirely intuitive compiler diagnostics but the printf would output something like
/home/user/source/file.c(45): called a function
which would allow you to locate the function call.
If you are using a C99 compiler (gcc for instance) then you could use the __FUNCTION__ in a similar manor. This actually resolves to the current function name. gcc has an extension of this __PRETTY_FUNCTION__ which outputs the function declaration.