for a C++ project, I am looking for a way to count all function calls to mathematical functions (sin, cos, tan, ...). Counting function calls is one thing that can be done by gprof by using the -pg compiler/linker option. The problem is that the functions in libraries have to be compiled with this option as well. It is obvious that for performance reasons, this option is not used in general.
My question is now: what is the easiest way to get a math-lib with profiling support? Is it enough to install the glibc-debuginfo package? Do I have to build the glibc-package from the sources? If so, how is this done to get the -pg option (I think it may not be as easy as using rpmbuild)? Is there any way to get this done without interfering with the normal packages/libraries? I mean, I don't want to have the profiling support in general, but I'd like to have a way to specify another library, maybe something like -lm_p, to get the profiling support. This would also have the advantage of an easy integration into Eclipse, which I am using as my IDE.
If there are other ways of achieving this, please don't hesitate to enlighten me. Adding profiling capabilities to the math-lib was just the first thing I thought of...
I know that I could add some 'global' variables that are 'manually' incremented whenever a call to sin oder cosine happens, but this wouldn't be 'professional'.
The profiler seems to be the easiest option, because it is just one flag that needs to be added and in Eclipse, this can be done for the Debug target, leaving the Release target untouched.
If there is no way to achieve a co-existence of normal and profiling-capable libraries, I could set up a virtual machine.
Additional informations, if necessary/summary: System is a Fedora 9 based, development is done in Eclipse/CDT and the project is a C++ one. Counting function calls (math functions, basic arithmetics are less important) is the only objective.
I hope that someone can help me or at least guide me somewhere, where I can find a solution...
Thanks in advance,