开发者

Count function calls by name or signature. Gcc, C++

I have some c++ written package. Linux, gcc. I can modify compilation process (change Makefile, flags, etc.), but can not change C++ source code.

One runs the package with different parameters, it does a 开发者_StackOverflow社区job and exits.

How to count:

1) Number of calls of function with specific name?

2) Number of calls of functions with specific signature?

3) Number of calls of functions where one of the parameters is of specific type i.e. std::string (type is specified by signature)?

4) and extra Number of calls of functions of STL objects, i.e. std::string copy constructor?

(I mean count a number of calls during the run. )

I thought to do it with GDB, but I found it very tough to do (1) and have not found how to do (2)-(4) at all.


All acceptable answers I will write here for humanity.


You can try running DTRACE under linux. It's definitely a great tool for what you are trying to accomplish.


Have you checked Valgrind's callgrind?

If you are not using threading (or are willing to experiment a bit), gprof is quite easy for some cases. However, there is a workaround for threading.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜