Control Flow Graph

albino aiello ultimanota@libero.it
Wed Nov 15 15:21:00 GMT 2006


Thanks,
but i want to use the .cfg file to construct directly a tree_cfg  in C 
language using the TREE SSA libraries of gcc. The doc-page is the follow 
http://people.redhat.com/dnovillo/pub/tree-ssa/doc/html/files.html. I'm 
not understand how to use this libraries to contstruct a tree-cfg to 
manipulate.
Can you help me?

Thanks to all,

lastnote

Diego Novillo ha scritto:

> ultimanota@libero.it wrote on 11/15/06 06:06:
>
>> Hi all,
>> i must use cfg library to build and manipulate a control flow graph. 
>> I have read more but i have not found an answer to my question: It is 
>> possible to build a cfg structure directly from a file .cfg ?? How i 
>> can building a cfg from a file??
>> Thanks to all,
>>
> Ask for a dump using the -blocks switch and post-process the dump file 
> with the attached script.
>
> $ gcc -fdump-tree-all-blocks file.c
> $ dump2dot file.c.XXXt.yyy
>
> It generates a graphviz file with the flow graph of the function.  The 
> script is fairly simplistic and will not handle more than one function 
> too gracefully, but that should be easy to change.
>
>------------------------------------------------------------------------
>
>#!/bin/sh
>#
># (C) 2005 Free Software Foundation
># Contributed by Diego Novillo <dnovillo@redhat.com>.
>#
># This script is Free Software, and it can be copied, distributed and
># modified as defined in the GNU General Public License.  A copy of
># its license can be downloaded from http://www.gnu.org/copyleft/gpl.html
>
>if [ "$1" = "" ] ; then
>    echo "usage: $0 file"
>    echo
>    echo "Generates a GraphViz .dot graph file from 'file'."
>    echo "It assumes that 'file' has been generated with -fdump-tree-...-blocks"
>    echo
>    exit 1
>fi
>
>file=$1
>out=$file.dot
>echo "digraph cfg {"		> $out
>echo "	node [shape=box]"	>>$out
>echo '	size="11,8.5"'		>>$out
>echo 				>>$out
>(grep -E '# BLOCK|# PRED:|# SUCC:' $file |				\
>	sed -e 's:\[\([0-9\.%]*\)*\]::g;s:([a-z_,]*)::g' |		\
>	awk '{	#print $0;						\
>		if ($2 == "BLOCK")					\
>		    {							\
>			bb = $3;					\
>			print "\t", bb, "[label=\"", bb, "\", style=filled, color=gray]";		\
>		    }							\
>		else if ($2 == "PRED:")					\
>		    {							\
>			for (i = 3; i <= NF; i++)			\
>			    print "\t", $i, "->", bb, ";";		\
>		    }							\
>	    }')			>> $out
>echo "}"			>> $out
>  
>



More information about the Gcc mailing list