Hi,
GCC has a nice feature about instrumentation which let you call a routine every time a function is called, or every time a function returns.
Now, I want to create my own system to make it portable to other compilers, and also to allow to instrumentalize the functions I want, so I was thinking in two macro for both situations. I am thinking in making some kind of profile that it is activated only with a define clausule.
Code:
#define FUNCT(t,function_name,...) \
(t) function_name(...) { \
(void) *func_pointer = &(function_name); \
start_data(func_pointer, myclock());
#define RETURN(x) {stop_data(func_pointer, myclock()); return (x);}
FUNCT(BOOL, LMP, const int prof, const int nmo))
ASSERT(prof > 0);
ASSERT(nmo >= 0);
if (nmo <= 5 ||
prof > (prof_l / 3)) {
RETURN(FALSE);
}
RETURN(TRUE);
}
but I cann't get it to work. Can someone help me with this? or is this a difficult task to accomplish?
Other alternative that comes to my mind is let the function declare without a macro, and if it is anyway to know the function pointer without knowing its name, something like in VB when you call a Form with Me, with it is a generic alias. is it possible?
Thanks
Fermin