如何可视化包含/点到另一个C结构的图? [英] How to visualise a graph of C structs that contain / point to one another?

查看:298
本文介绍了如何可视化包含/点到另一个C结构的图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Ubuntu 10.04,并研究内核对象的编程。

I am using Ubuntu 10.04, and studying programming of kernel objects.

我也碰到过,我有困难,读一些相当复杂的结构,所以我想我会尝试找到一些工具,可以帮助我想像他们。

I have come across some rather complicated structs which I have difficulties reading, so I thought I'd try to find some tool that can help me visualise them.

我唯一能找到到目前为止 VCG ,其中有一个 C结构可视化例子,它看起来像这样的:

Only thing I could find so far is VCG, which has a C Struct Visualization Example, which looks like this:


这看起来像我想使用。

which looks like something I'd like to use.

第一件事,就是打包为Ubuntu的最后一个VCG是 VCG(1.30debian-6)在h​​ardy < /一> - 但.deb包可以被下载并安装在Ubuntu清醒没有问题。

First thing, is that the last VCG packaged for Ubuntu is vcg (1.30debian-6) in hardy - but the .deb package can be downloaded and installed in Ubuntu Lucid without problems.

但是,似乎这个包只是一个VCG的浏览器的(类似的 vcgviewer ,我猜)。该 vcgviewer 页注:

However, it seems this package is only a VCG viewer (similar to vcgviewer, I'd guess). The vcgviewer page notes:

To generate compiler graph data with newest gcc compilers use:
gcc -g -da -dv -fdump-tree-original-raw -fdump-tree-all-all 

所以,显然我不得不使用这些开关与 GCC沿在编译,生成从C源.vcg图形文件。

So, apparently I'd have to use those switches along with gcc while compiling, to generate .vcg graph files from the C source.

但问题是,我要建一个内核模块,只引用了Linux头 - 因为我尽量避免像我可以整个内核的重新编译。而现在看来,只要我尝试使用 -fdump树-... 这方面(内核模块)的交换机, GCC 要开始编译内核的休息呢​​! (,显然失败了,在这两个编辑和生成.vcg图形 - 因为我没有内核源代码,只有头文件的)

The problem, however, is that I'm building a kernel module, which only references the Linux headers - as I try to avoid as much as I can the recompilation of entire kernel. And it seems, as soon as I try to use -fdump-tree-... switches in that context (kernel module), gcc wants to start compiling the rest of the kernel too! (and obviously fails, in both compilation and generation of .vcg graphs - as I don't have the kernel sources, only headers)

所以,我的问题是 - 是有一个工具,这将产生.vcg结构或.DOT图 - 简单地用一个纯文本的头文件作为输入? (那就不必解决所有的依赖关系 - 不仅仅是那些在同一个目录中的头文件的)

So my question is - is there a tool, that would produce .vcg or .dot graphs of structs - simply using a plain text header file as input? (it would not have to resolve all dependencies - simply those in header files in same directory)

编辑:它实际上是不适合我,重要的是,后端特别.vcg或.DOT,我提到他们只是因为我发现他们为止;任何形式的软件,将允许类似的结构可视化,无论后台的,我们都是欢迎的

it is actually not that important for me that the backend is .vcg or .dot in particular, I mentioned them just because I've found them so far; any sort of software that would allow similar struct visualization, regardless of backend, is welcome :)

PS:需要注意的是,如果你不希望使用VCG观众观看.vcg图表,您可以将.vcg格式转换为.DOT格式,并使用的graphviz 而不是为可视化。什么工作对我来说是使用图易 - search.cpan.org perl的 - 这第一次拿到打包在Ubuntu与小牛版,为的 libgraph易-perl的然而,.deb文件可以 - 再 - 是清醒<下载并安装没有问题/ em>的)。 libgraph易-perl的安装了图易脚本,然后允许做的东西,如:

PS: Note that if you do not want to use VCG viewers for viewing .vcg graphs, you can convert the .vcg format to a .dot format, and use graphviz instead for the visualisation. What worked for me is to use graph-easy - search.cpan.org for perl - which first got packaged in Ubuntu with Maverick edition, as libgraph-easy-perl (however, the .deb file can - again - be downloaded and installed without problems in Lucid). libgraph-easy-perl installs a graph-easy script, which then allows to do stuff like:

graph-easy test.vcg --as_dot | dot -Tpng -o test.vcg.png 

另请参阅 [graphviz的利益] VCG文件迭戈Novillo - 回复:找不到VCG观众另一VCG-来点脚本(,不幸的是,没有为我<工作/ EM>)。

See also "[graphviz-interest] VCG files" and "Diego Novillo - Re: can't find VCG viewer" for another vcg-to-dot script (which, unfortunately, didn't work for me).

推荐答案

我有好经验用的该任务doxygen的。它的目的是创造出来的文档注释的源文件,但它已经可以给你很多东西不注释,包括各种图表。
Doxygen的使用点的图形创建。

I have had good experiences with using doxygen for that task. It is designed to create documentation out of annotated source files, but it can already give you a lot of things without the annotations, including various graphs. Doxygen uses dot for the graph creation.

这篇关于如何可视化包含/点到另一个C结构的图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆