c++: generate function call tree

删除回忆录丶 提交于 2019-12-07 05:20:49

问题


I want to parse current c++ files in a project and list out all the methods/functions in it and then generate the function call and caller trees. F.g. you can refer how doxygen generates the call tree.

I have checked gccxml but it doesn't list the functions called from another function.

Please suggest me some lightweight tools (open source) which I can use it.

thanks!


回答1:


The static call tree isn't necessarily the runtime call tree. Callbacks and virtual functions muddy the water. So static analysis can only give you part of the answer.

The only way I've ever been able to get a reliable call tree was to run gprof on the compiled executable. The output can be massaged into a very accurate call tree.




回答2:


gccxml, currently, essentially ignores function bodies (including calls to other functions). A good overview of C++ parsing options currently available is here -- not necessarily a bearer of good news, but recommended reading.




回答3:


You mention Doxygen. Why not use that?




回答4:


I probably misunderstood , but visual studio have something similar. Right Click a function and select Call Browser.




回答5:


It's impossible to provide a full call tree analysis for an application that's dependent on asynchronous event reception. This is way we have test. Even in the simplest cases where the application is fully deterministic this could be a relatively daunting task and I would argue provide marginal value. Then how would you analyze the results? To what effect?



来源:https://stackoverflow.com/questions/1727471/c-generate-function-call-tree

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!