* howto graphically view .cfg file produced by -fdump-tree-cfg
@ 2009-11-08 23:09 Larry Evans
2009-11-14 19:30 ` Diego Novillo
0 siblings, 1 reply; 2+ messages in thread
From: Larry Evans @ 2009-11-08 23:09 UTC (permalink / raw)
To: gcc
http://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html#Debugging-Options
describes -fdump-tree-SWITCH
where SWITCH may be one of a number of "switches" including:
cfg
vcg
I tried the vcg switch; however, it looks like that's just the control
flow for basic block. The cfg switch looks similar except it
prefixes the control flow for each function with the function
name. In addition, calls in the function appear as the actual
function name called with possibly some generated variable
names as argument and result. For example, the output from
compile of cp/pt.c with -fdump-tree-cfg contains:
instantiate_class_template (type)
{
...
}
and within the ..., there's:
union tree_node * D.76307;
union tree_node * type.1598;
...
type.1598 = type;
D.76307 = most_specialized_class (type.1598, templ);
which I think corresponds to the obvious line in:
/* Figure out which template is being instantiated. */
templ = most_general_template (CLASSTYPE_TI_TEMPLATE (type));
gcc_assert (TREE_CODE (templ) == TEMPLATE_DECL);
/* Determine what specialization of the original template to
instantiate. */
t = most_specialized_class (type, templ);
if (t == error_mark_node)
of pt.c around line 7371 (viewable here:
http://gcc.gnu.org/viewcvs/trunk/gcc/cp/pt.c?revision=153977&view=markup
)
Does someone know of a way to view this in a graphical way,
somewhat like what xvcg does for its cfg's?
TIA.
-Larry
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: howto graphically view .cfg file produced by -fdump-tree-cfg
2009-11-08 23:09 howto graphically view .cfg file produced by -fdump-tree-cfg Larry Evans
@ 2009-11-14 19:30 ` Diego Novillo
0 siblings, 0 replies; 2+ messages in thread
From: Diego Novillo @ 2009-11-14 19:30 UTC (permalink / raw)
To: Larry Evans; +Cc: gcc
[-- Attachment #1: Type: text/plain, Size: 413 bytes --]
On Sun, Nov 8, 2009 at 19:10, Larry Evans <cppljevans@suddenlink.net> wrote:
> Does someone know of a way to view this in a graphical way,
> somewhat like what xvcg does for its cfg's?
When I've needed to visualize a CFG, I just used a very simplistic
script to paw through the dump file to produce graphviz output
(attached). It probably needs tweaking as it's been a long time since
I last used it.
Diego.
[-- Attachment #2: dump2dot --]
[-- Type: application/octet-stream, Size: 1125 bytes --]
#!/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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-11-14 19:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-08 23:09 howto graphically view .cfg file produced by -fdump-tree-cfg Larry Evans
2009-11-14 19:30 ` Diego Novillo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).