开发者

How can I find out what functions have been called from what classes?

I'm using a Physics Toolkit (Geant4) which consists of several thousand C++ header and class files. In order to use the toolkit, you have to write a series of your own class files, that give the toolkit some basic information about what you are trying to model. You then write a main() file which registers these files with the toolkit, 'make' it and then execute the final program. I am using Ubuntu 10.10 as the platform to do this.

I'd like to better understand how the toolkit operates. Specifically, I'd like to find out what functions in what class files, throughout the 开发者_如何学JAVAtoolkit, are called and in what order, when the program runs.

One, somewhat brute-force method would be to label each function in each file e.g. insert cout << "File Name, Function Name" << endl as the first statement in each function body and have this all output to a textfile. However, there are some 3000 files I'd need to go through, which would be somewhat... time-consuming.

Is there an easier way of finding out what functions have been called? I've searched through the toolkits manual and, unless I have missed something, I see no way there of doing this via the toolkit. I guess I would need some command at the terminal or an external program?!?

Any help, suggestions or advice would be greatly appreciated!


On ubuntu you'll have a choice of profilers.

I personally love

valgrind --tool=callgrind ./myprogram
kcachegrind

For this because it creates very good callgraphs and statistics (tree map visualizations).

The big FAQ profiler topic is here: How can I profile C++ code running in Linux?

Off the top off my head: gprof (needs instrumentation), oprofile and perf record -g are easy to get started with as well

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜