可视化代码流的工具 (C/C++)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/153074/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Tool to visualise code flow (C/C++)
提问by Dprado
Do you have any sugestions of tools to ease the task of understanding C/C++ code? We just inherited a large piece of software written by others and we need to quickly get up to speed on it. Any advice on tools that might simplify this task?
您是否有任何工具可以简化理解 C/C++ 代码的任务?我们刚刚继承了别人编写的一大块软件,我们需要快速上手。关于可以简化此任务的工具的任何建议?
采纳答案by aku
SourceInsightand Understand for C++are the best tools you can get for c/c++ code analysis including flow charts.
SourceInsight和Understanding for C++是您可以获得的用于包括流程图在内的 c/c++ 代码分析的最佳工具。
回答by Thorsten79
Profiling software gives you an idea of which functions have been called.
分析软件让您了解调用了哪些函数。
If you can use Linux, try KCachegrind
如果您可以使用 Linux,请尝试KCachegrind
回答by Andy Dent
Doxygenis very good at generating diagrams from code without applying markup, if you turn on the EXTRACT_ALL option. You need GraphVizinstalled to get diagrams generated with the HAVE_DOT setting. I find having it installed and leaving the DOT_PATH blank works fine on Windows but on OS/X keep having to point directly to the dot tool location.
如果您打开 EXTRACT_ALL 选项,Doxygen非常擅长从代码生成图表而无需应用标记。您需要安装GraphViz才能使用 HAVE_DOT 设置生成图表。我发现安装它并将 DOT_PATH 留空在 Windows 上工作正常,但在 OS/X 上必须直接指向点工具位置。
There's an excellent Code Spelunkingarticle in ACM Queue which talks more about using doxygen and DTrace.
ACM Queue 中有一篇出色的Code Spelunking文章,其中详细介绍了使用 doxygen 和 DTrace。
回答by gbjbaanb
Personally, I use the debugger. Run through the code and see what its doing, and where its going is the only way.
就个人而言,我使用调试器。运行代码,看看它在做什么,它的去向是唯一的方法。
However, you can run it through some documentation-generators which (sometimes) help. A good example is doxygen.
但是,您可以通过一些(有时)帮助的文档生成器来运行它。一个很好的例子是doxygen。
回答by gbjbaanb
KScope, built upon the cscope utility, if you're on linux (KDE). The best thing I ever used (and use all the time) to deleve into some huge piece of unfamiliar code which I have to modify somehow or which API I'm to employ for my needs. Among its features are the cross-reference database, which can be searched in a plenty of ways: you can find all references of a symbol, its global definition, find callers/callees of a function and much more. It even has a built-in IDE and an ability to show a call-graph.
KScope,基于 cscope 实用程序构建,如果您使用的是 linux (KDE)。我曾经使用过的最好的东西(并且一直使用)来深入研究一些我必须以某种方式修改的大量陌生代码,或者我将使用哪些 API 来满足我的需求。它的功能之一是交叉引用数据库,可以通过多种方式进行搜索:您可以找到符号的所有引用、其全局定义、查找函数的调用者/被调用者等等。它甚至有一个内置的 IDE 和显示调用图的能力。
回答by Douglas Mayle
回答by OldMan
There are some tools like Egypt http://www.gson.org/egypt/egypt.htmlthat work, but only if you match the expected GCC version used to compile the code and the exact version of the callgraph generator. The same can be said about codeviz http://www.csn.ul.ie/~mel/projects/codeviz/
有一些工具,如埃及http://www.gson.org/egypt/egypt.html可以工作,但前提是您匹配用于编译代码的预期 GCC 版本和调用图生成器的确切版本。关于 codeviz 也可以这样说http://www.csn.ul.ie/~mel/projects/codeviz/
Other option is valgrind used in cachegrind mode (it generates a type of callgraph that you can follow from kcachegrind program.
另一个选项是在 cachegrind 模式下使用的 valgrind(它生成一种调用图,您可以从 kcachegrind 程序中遵循该调用图。
回答by Craig Tyler
I used Borland Togethera while back and it did a decent job of generating models from code. I believe it will even generate sequence diagrams from code. Keep in mind if your code is a mess your model will be too. And as I recall it isn't cheap but sometimes you can catch a special.
不久前我使用了Borland Together,它在从代码生成模型方面做得很好。我相信它甚至可以从代码生成序列图。请记住,如果您的代码一团糟,您的模型也会一团糟。我记得它并不便宜,但有时你可以抓住一个特别的。
回答by QBziZ
Rational Quantify also presents a nice call graph.
Rational Quantify 还提供了一个很好的调用图。
回答by rjdthegreat
i tried a tool named Visustin which is not very great graphically but does what it says: Flowchart from Code. http://www.aivosto.com/visustin.html
我尝试了一个名为 Visustin 的工具,它在图形上不是很好,但它的功能是:代码流程图。 http://www.aivosto.com/visustin.html