The function of counting functions by name or signature. Gcc, C ++

I have a C ++ written package. Linux, gcc. I can change the compilation process (change the Makefile, flags, etc.), but may not change the source code in C ++.

One launches a package with different parameters, performs a task, and exits.

How to count :
1) The number of function calls with a specific name?
2) The number of function calls with a specific signature?
3) The number of function calls when one of the parameters has a particular type ie std :: string (the type is specified by the signature)?
4) and an additional number of function calls to STL objects, i.e. std :: string copy constructor?

(I mean counting the number of calls during the run.)

I thought about doing it with GDB, but it was very difficult for me to do it (1) and did not find how to do it (2) - (4) in general.


All acceptable answers I will write here for humanity.

+3
source share
2 answers

You can try running DTRACE on Linux. This is definitely a great tool for what you are trying to accomplish.

+4
source

Have you checked Valgrind callgrind ?

If you don't use streams (or want to experiment a bit), gprof is pretty easy for some cases. However, there is a workaround for streaming.

+2
source

Source: https://habr.com/ru/post/1792956/


All Articles