cflow2dot.pl 显示C源码函数调用图的。
- eexpress
- 帖子: 58428
- 注册时间: 2005-08-14 21:55
- 来自: 长沙
cflow2dot.pl 显示C源码函数调用图的。
放一个tar算了。
- 附件
-
- cflow2dot.tar.gz
- cflow2dot.pl xxxx.c yyyy.c
- (84.41 KiB) 已下载 150 次
● 鸣学
-
- 帖子: 28
- 注册时间: 2007-03-07 19:07
Re: cflow2dot.pl
出来一堆错误,生成的图根本不准确。
- eexpress
- 帖子: 58428
- 注册时间: 2005-08-14 21:55
- 来自: 长沙
Re: cflow2dot.pl
加了3句。分支带不同颜色。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(/>:$/){
嘛错误?
☛ cflow2dot.pl habak.c xcore.c |dot -Tpng -o ~/x.png
● 鸣学
- eexpress
- 帖子: 58428
- 注册时间: 2005-08-14 21:55
- 来自: 长沙
Re: cflow2dot.pl
代码: 全选
☛ 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"}
● 鸣学
- ChenFengyuan
- 帖子: 770
- 注册时间: 2008-03-23 0:39
- eexpress
- 帖子: 58428
- 注册时间: 2005-08-14 21:55
- 来自: 长沙
- leeaman
- 帖子: 30702
- 注册时间: 2007-02-02 18:14
- 系统: debian sid
Re: cflow2dot.pl 显示C源码函数调用图的。
呵呵,这个倒是超赞的东西,有空写个hello world试试效果哈
醉了星星,醉月亮●●●●●The Long Way To Go(*^_^*)
- eexpress
- 帖子: 58428
- 注册时间: 2005-08-14 21:55
- 来自: 长沙
Re: cflow2dot.pl 显示C源码函数调用图的。
去掉冗余的线
dot图,干净很多。
还是perl强啊。一行处理,搞定去掉重复的关系行,并跳过dot设置语法。
btw: 需要c++的,可以自己写一个cppflow。反正cflow的输出格式,很简单的。
dot图,干净很多。
还是perl强啊。一行处理,搞定去掉重复的关系行,并跳过dot设置语法。
代码: 全选
open FILE,'<',$tmpdot; @in=<FILE>;close FILE;
my @unique=grep {! $count{$_}++ || ! /->/ } @in;
open FILE,'>',$tmpdot; print FILE @unique;close FILE;
● 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) 已下载 109 次
● 鸣学
- eexpress
- 帖子: 58428
- 注册时间: 2005-08-14 21:55
- 来自: 长沙
- eexpress
- 帖子: 58428
- 注册时间: 2005-08-14 21:55
- 来自: 长沙
Re: cflow2dot.pl 显示C源码函数调用图的。
脚本居然马上被维护者发现了。
现在对方给出了补丁,谁愿意测试的。猴急的第一个补丁。
现在对方给出了补丁,谁愿意测试的。猴急的第一个补丁。
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) 已下载 122 次
● 鸣学
- BigSnake.NET
- 帖子: 12522
- 注册时间: 2006-07-02 11:16
- 来自: 廣州
- 联系:
Re: cflow2dot.pl 显示C源码函数调用图的。
doxygen 用的那个叫什么来着
^_^ ~~~
要理解递归,首先要理解递归。
地球人都知道,理论上,理论跟实际是没有差别的,但实际上,理论跟实际的差别是相当大滴。
要理解递归,首先要理解递归。
地球人都知道,理论上,理论跟实际是没有差别的,但实际上,理论跟实际的差别是相当大滴。
- eexpress
- 帖子: 58428
- 注册时间: 2005-08-14 21:55
- 来自: 长沙
- xiooli
- 帖子: 6956
- 注册时间: 2007-11-19 21:51
- 来自: 成都
- 联系:
Re: cflow2dot.pl 显示C源码函数调用图的。
pic?BigSnake.NET 写了:doxygen 用的那个叫什么来着
- eexpress
- 帖子: 58428
- 注册时间: 2005-08-14 21:55
- 来自: 长沙