当前时区为 UTC + 8 小时



发表新帖 回复这个主题  [ 14 篇帖子 ] 
作者 内容
1 楼 
 文章标题 : cflow2dot.pl 显示C源码函数调用图的。
帖子发表于 : 2010-10-18 16:52 
头像

注册: 2005-08-14 21:55
帖子: 58428
地址: 长沙
送出感谢: 4
接收感谢: 274
放一个tar算了。


附件:
文件注释: cflow2dot.pl xxxx.c yyyy.c
cflow2dot.tar.gz [84.41 KiB]
被下载 71 次
cflow2dot.png
cflow2dot.png [ 83.99 KiB | 被浏览 2295 次 ]

x.png
x.png [ 1.3 MiB | 被浏览 2337 次 ]



_________________
● 鸣学
页首
 用户资料  
 
2 楼 
 文章标题 : Re: cflow2dot.pl
帖子发表于 : 2010-10-18 17:00 

注册: 2007-03-07 19:07
帖子: 28
送出感谢: 0 次
接收感谢: 0 次
出来一堆错误,生成的图根本不准确。


页首
 用户资料  
 
3 楼 
 文章标题 : Re: cflow2dot.pl
帖子发表于 : 2010-10-18 18:20 
头像

注册: 2005-08-14 21:55
帖子: 58428
地址: 长沙
送出感谢: 4
接收感谢: 274
引用:
my @color=qw(#eecc80 #ccee80 #80ccee #eecc80 #80eecc);
print "digraph G {\n";
print "node [peripheries=2 style=filled color=\"#eecc80\" fontname=\"Vera Sans YuanTi Mono\"];\nrankdir=LR;\nmain[shape=box];\nedge [color=\"sienna\" fontcolor=\"green\"];\n";
foreach (@in){
chomp;
/^ */;my $n=length($&)/4;
s/^ *//; s/\(\)\s*//;
print "node [color=\"$color[$n-1]\"];\n";
print "edge [color=\"$color[$n-1]\"];\n";

if(/>:$/){


加了3句。分支带不同颜色。

嘛错误?
☛ cflow2dot.pl habak.c xcore.c |dot -Tpng -o ~/x.png


附件:
Screenshot-3.png
Screenshot-3.png [ 142.74 KiB | 被浏览 2326 次 ]



_________________
● 鸣学
页首
 用户资料  
 
4 楼 
 文章标题 : Re: cflow2dot.pl
帖子发表于 : 2010-10-18 18:59 
头像

注册: 2005-08-14 21:55
帖子: 58428
地址: 长沙
送出感谢: 4
接收感谢: 274
代码:
☛ dog cflow2dot.pl
if(! -x "/usr/bin/cflow"){print "\'cflow\' not installed.\n"; exit;}
$_=join " ",@ARGV;
my @in=`/usr/bin/cflow $_`;
my @index;
my @commet;
my @color=qw(#eecc80 #ccee80 #80ccee #eecc80 #80eecc);
my $tmpdot="/tmp/cflow.dot";
my $tmppng="/tmp/cflow.png";
open FILE,'>',$tmpdot;  select FILE;
print "digraph G {\n";
print "node [peripheries=2 style=filled color=\"#eecc80\" fontname=\"Vera Sans YuanTi Mono\"];\nrankdir=LR;\nmain[shape=box];\nedge [color=\"sienna\" fontcolor=\"green\"];\n";
foreach (@in){
chomp;
/^ */;my $n=length($&)/4;
s/^ *//; s/\(\)\s*//;
print "node [color=\"$color[$n-1]\"];\nedge [color=\"$color[$n-1]\"];\n";
if(/>:$/){
s/(<.*>).*$//; push @commet,$1;
push @index,$_;
if($n ne 0){
print "$index[$n-1]->$_;\n";
}
}
else{
print "$index[$n-1]->$_;\n";
}
}
print "}\n";
select STDOUT; print "dot output to $tmpdot.\n";
if(-x "/usr/bin/dot"){
`dot -Tpng $tmpdot -o $tmppng`;
print "png output to $tmppng";
if(-x "/usr/bin/eog"){`eog $tmppng`;}
}
else{print "\'dot\' not installed.\n"}


_________________
● 鸣学


页首
 用户资料  
 
5 楼 
 文章标题 : Re: cflow2dot.pl 显示C源码函数调用图的。
帖子发表于 : 2010-10-18 20:56 
头像

注册: 2008-03-23 0:39
帖子: 770
送出感谢: 0 次
接收感谢: 4
mark :em11


页首
 用户资料  
 
6 楼 
 文章标题 : Re: cflow2dot.pl 显示C源码函数调用图的。
帖子发表于 : 2010-10-19 8:59 
头像

注册: 2005-08-14 21:55
帖子: 58428
地址: 长沙
送出感谢: 4
接收感谢: 274
睡觉冥想,发现逻辑错误。马上修改。

代码:
#push @index,$_;
$index[$n]=$_;


_________________
● 鸣学


页首
 用户资料  
 
7 楼 
 文章标题 : Re: cflow2dot.pl 显示C源码函数调用图的。
帖子发表于 : 2010-10-19 9:51 
头像

注册: 2007-02-02 18:14
帖子: 30702
系统: debian sid
送出感谢: 1
接收感谢: 34
呵呵,这个倒是超赞的东西,有空写个hello world试试效果哈


_________________
醉了星星,醉月亮●●●●●The Long Way To Go(*^_^*)


页首
 用户资料  
 
8 楼 
 文章标题 : Re: cflow2dot.pl 显示C源码函数调用图的。
帖子发表于 : 2010-10-19 10:20 
头像

注册: 2005-08-14 21:55
帖子: 58428
地址: 长沙
送出感谢: 4
接收感谢: 274
去掉冗余的线
dot图,干净很多。
还是perl强啊。一行处理,搞定去掉重复的关系行,并跳过dot设置语法。
代码:
open FILE,'<',$tmpdot; @in=<FILE>;close FILE;
my @unique=grep {! $count{$_}++ || ! /->/ } @in;
open FILE,'>',$tmpdot; print FILE @unique;close FILE;



附件:
cflow2dot.pl.去掉冗余的线.tar.xz [772 Bytes]
被下载 36 次


btw: 需要c++的,可以自己写一个cppflow。反正cflow的输出格式,很简单的。
引用:
● cflow habak.c
main() <int main (int argc,char *argv[]) at habak.c:166>:
srand()
time()
initXconnection()
getenv()
malloc()
strlen()
strcpy()
strcat()
print_help() <void print_help (int rc) at habak.c:99>:
printf()
exit()
strcmp()
.....


附件:
文件注释: 颜色和形状分类版本。程序结构更好。
cflow2dot.pl.tar.xz [776 Bytes]
被下载 35 次


_________________
● 鸣学
页首
 用户资料  
 
9 楼 
 文章标题 : Re: cflow2dot.pl 显示C源码函数调用图的。
帖子发表于 : 2010-10-21 15:34 
头像

注册: 2005-08-14 21:55
帖子: 58428
地址: 长沙
送出感谢: 4
接收感谢: 274
更短了。

http://code.google.com/p/cflow2dot/


附件:
cflow2dot.1.0.pl.tar [10 KiB]
被下载 53 次


_________________
● 鸣学
页首
 用户资料  
 
10 楼 
 文章标题 : Re: cflow2dot.pl 显示C源码函数调用图的。
帖子发表于 : 2010-11-05 9:16 
头像

注册: 2005-08-14 21:55
帖子: 58428
地址: 长沙
送出感谢: 4
接收感谢: 274
脚本居然马上被维护者发现了。

现在对方给出了补丁,谁愿意测试的。猴急的第一个补丁。

引用:
This should give a first draft. You can apply this to the latest release with:

frans@linux-u4jm:~/Projects/cflow-1.3> patch -p1 < cflow.patch

when I do it I get an error in src/cflow.h but you can easily add that patch by hand just add this function prototype somewhere in the file.

int dot_output_handler(cflow_output_command cmd,
FILE *outfile, int line,
void *data, void *handler_data);


This will give you an new option '-f dot'. you can test it with

frans@linux-u4jm:~/Projects/cflow-1.3> ./src/cflow -f dot src/*.c | dot -Tpng -o cflow.png

or what ever you found funny to run it on.


/Frans


附件:
cflow.patch.tar.xz [1.82 KiB]
被下载 46 次


_________________
● 鸣学
页首
 用户资料  
 
11 楼 
 文章标题 : Re: cflow2dot.pl 显示C源码函数调用图的。
帖子发表于 : 2010-11-05 20:55 
头像

注册: 2006-07-02 11:16
帖子: 12522
地址: 廣州
送出感谢: 0 次
接收感谢: 8
doxygen 用的那个叫什么来着


_________________
^_^ ~~~
要理解递归,首先要理解递归。

地球人都知道,理论上,理论跟实际是没有差别的,但实际上,理论跟实际的差别是相当大滴。


页首
 用户资料  
 
12 楼 
 文章标题 : Re: cflow2dot.pl 显示C源码函数调用图的。
帖子发表于 : 2010-11-05 21:08 
头像

注册: 2005-08-14 21:55
帖子: 58428
地址: 长沙
送出感谢: 4
接收感谢: 274
doxygen 没试过。要那么麻烦的写注释,不爽。


_________________
● 鸣学


页首
 用户资料  
 
13 楼 
 文章标题 : Re: cflow2dot.pl 显示C源码函数调用图的。
帖子发表于 : 2010-11-05 21:40 
头像

注册: 2007-11-19 21:51
帖子: 6956
地址: 成都
送出感谢: 0 次
接收感谢: 4
BigSnake.NET 写道:
doxygen 用的那个叫什么来着

pic?


页首
 用户资料  
 
14 楼 
 文章标题 : Re: cflow2dot.pl 显示C源码函数调用图的。
帖子发表于 : 2012-04-29 19:22 
头像

注册: 2005-08-14 21:55
帖子: 58428
地址: 长沙
送出感谢: 4
接收感谢: 274
发表于 : 2010-10-18 16:52

回顾下。Perl多强壮。没再动过,今天刚好又用到。


_________________
● 鸣学


页首
 用户资料  
 
显示帖子 :  排序  
发表新帖 回复这个主题  [ 14 篇帖子 ] 

当前时区为 UTC + 8 小时


在线用户

正在浏览此版面的用户:没有注册用户 和 1 位游客


不能 在这个版面发表主题
不能 在这个版面回复主题
不能 在这个版面编辑帖子
不能 在这个版面删除帖子
不能 在这个版面提交附件

前往 :  
本站点为公益性站点,用于推广开源自由软件,由 DiaHosting VPSBudgetVM VPS 提供服务。
我们认为:软件应可免费取得,软件工具在各种语言环境下皆可使用,且不会有任何功能上的差异;
人们应有定制和修改软件的自由,且方式不受限制,只要他们自认为合适。

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
简体中文语系由 王笑宇 翻译