cflow の出力を graphviz で可視化するためのスクリプトを作ってみた.
#!/usr/bin/awk -f function parse(parent, nest) { if (getline == 0) return -1; N=2; while ($N == "") N++; while (N>nest) { FUNC=gensub(/^(.+) {(.*)}$/, "\\1", "g", $N); print parent " -> " FUNC; N = parse(FUNC, nest+1); } return N; } BEGIN{ FS="\t"; print "digraph G {"; print "node [shape=box]"; while (0 < parse("global", 1)) ; print "}"; }
実行
$ cflow a.c |./cflow2dot.awk | dot -Tpng | display