C/C++ 源代码可视化?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27857/
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
C/C++ source code visualization?
提问by Avinash
Basically I want tools which generate source code visualization like:
基本上我想要生成源代码可视化的工具,例如:
- function call graph
- dependency graph
- ...
- 函数调用图
- 依赖图
- ...
回答by Andrew Wilkinson
Doxygenis really excellent for this, although you will need to install GraphVizto get the the graphs to draw.
Doxygen在这方面非常出色,尽管您需要安装GraphViz才能绘制图形。
Once you've got everything installed, it's really rather simple to draw the graphs. Make sure you set EXTRACT_ALLand CALL_GRAPHto true and you should be good to go.
一旦你安装了所有东西,绘制图形就非常简单了。确保将EXTRACT_ALL和CALL_GRAPH设置为 true,这样就可以了。
The full documentation on this function for doxygen is here.
有关 doxygen 的此功能的完整文档在此处。
回答by Andrew Wilkinson
I strongly recommend BOUML. It's a free UML modelling application, which:
我强烈推荐BOUML。这是一个免费的 UML 建模应用程序,它:
- is extremely fast (fastest UML tool ever created, check out benchmarks),
- has rock solid C++ import support,
- has great SVG export support, which is important, because viewing large graphs in vector format, which scales fast in e.g. Firefox, is very convenient (you can quickly switch between "birds eye" view and class detail view),
- is full featured, impressively intensively developed (look at development history, it's hard to believe that so fast progress is possible).
- 非常快(有史以来最快的 UML 工具,请查看基准测试),
- 具有坚如磐石的 C++ 导入支持,
- 具有强大的 SVG 导出支持,这一点很重要,因为以矢量格式查看大图,在例如 Firefox 中可以快速缩放,非常方便(您可以在“鸟瞰”视图和类详细信息视图之间快速切换),
- 功能齐全,开发密集程度令人印象深刻(看看开发历史,很难相信这么快的进展是可能的)。
So: import your code into BOUML and view it there, or export to SVG and view it in Firefox.
所以:将您的代码导入 BOUML 并在那里查看,或导出到 SVG 并在 Firefox 中查看。
For the free version:
对于免费版本:
- source is on Github as DoUML
- Installers can be downloaded from http://www.bouml.fr/download.html
- 源在 Github 上为 DoUML
- 安装程序可以从http://www.bouml.fr/download.html下载
回答by AndreyBark
You can look at different tools for software design and modelling (Rational Rose, Sparx Enterprise Architect, Umbrello, etc). Majority of them have some functionality to reverse modeling by source code, and getting UML class diagrams, and sometimes even sequence diagrams (and this is very close to functions call graph).
您可以查看用于软件设计和建模的不同工具(Rational Rose、Sparx Enterprise Architect、Umbrello等)。它们中的大多数具有通过源代码反向建模的功能,并获得 UML 类图,有时甚至是序列图(这与函数调用图非常接近)。
But after you get some pictures on really big project code base you could realise that such graphs are rather hard to read and understand. Unfortunally visualization capabilities of complexity are very limited.
但是当你在非常大的项目代码库上得到一些图片后,你会意识到这样的图表很难阅读和理解。不幸的是,复杂性的可视化能力非常有限。
As for me, using a "divide and rule" idiom is more convinient approach. You can extract different functionality blocks or layers from your some code base (just sorting cpp-files by different folders sometimes enough). Another way is to use some scripts (bash, python) to create simple csv tables with interested parameters of files, classes or functions like "number of dependencies" etc).
对我来说,使用“分而治之”的成语是更方便的方法。您可以从一些代码库中提取不同的功能块或层(有时只需按不同的文件夹对 cpp 文件进行排序就足够了)。另一种方法是使用一些脚本(bash、python)来创建简单的 csv 表,其中包含感兴趣的文件、类或函数参数,例如“依赖项数”等)。
回答by Esther Fan - MSFT
If you use Visual Studio, the 2010 Ultimate release lets you generate sequence diagrams and dependency graphs. However, the release currently supports only .NET application projects.
如果您使用 Visual Studio,2010 Ultimate 版本允许您生成序列图和依赖关系图。但是,该版本目前仅支持 .NET 应用程序项目。
The team has gotten lots of interest in supporting C++ in a future release, so you might want stay tuned. In the meantime, you can post in the VS 2010 Architectural Discovery & Modeling Toolsforum at http://social.msdn.microsoft.com/Forums/en-US/vsarch/threadsto request an update. I know the product team loves hearing customer feedback about the tools.
该团队对在未来版本中支持 C++ 产生了浓厚的兴趣,因此您可能需要继续关注。同时,您可以在位于http://social.msdn.microsoft.com/Forums/en-US/vsarch/threads的VS 2010 Architectural Discovery & Modeling Tools论坛中发帖请求更新。我知道产品团队喜欢听取客户对这些工具的反馈。
In the meantime, you can learn more about creating sequence diagrams and dependency diagrams from .NET code in the following topics:
同时,您可以在以下主题中了解有关从 .NET 代码创建序列图和依赖关系图的更多信息:
How to: Find Code Using Architecture Explorer: http://msdn.microsoft.com/en-us/library/dd409431%28VS.100%29.aspx
如何:使用架构资源管理器查找代码:http: //msdn.microsoft.com/en-us/library/dd409431%28VS.100%29.aspx
How to: Generate Graph Documents from Code: http://msdn.microsoft.com/en-us/library/dd409453%28VS.100%29.aspx#SeeSpecificSource
如何:从代码生成图形文档:http: //msdn.microsoft.com/en-us/library/dd409453%28VS.100%29.aspx#SeeSpecificSource
How to: Explore Code with Sequence Diagrams: http://msdn.microsoft.com/en-us/library/ee317485%28VS.100%29.aspx
如何:使用序列图探索代码:http: //msdn.microsoft.com/en-us/library/ee317485%28VS.100%29.aspx
To try the RC release and provide feedback, download it at http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=457bab91-5eb2-4b36-b0f4-d6f34683c62a
要试用 RC 版本并提供反馈,请在http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=457bab91-5eb2-4b36-b0f4-d6f34683c62a下载
回答by baris.aydinoz
In addition to written tools above, you may try understand. But, it is not free.
除了上面的书面工具,你可以尝试理解。但是,它不是免费的。
回答by epotter
回答by Steve M
Might be a duplication, but check out ollydbg, IDA Pro and this websitehas a whole bunch of resources with some very sexy images.
可能是重复的,但请查看 ollydbg、IDA Pro 和这个网站有一大堆资源和一些非常性感的图像。