diff options
author | Richard Biener <rguenther@suse.de> | 2016-02-22 10:31:41 +0000 |
---|---|---|
committer | Tom de Vries <vries@gcc.gnu.org> | 2016-02-22 10:31:41 +0000 |
commit | bddb7adb4411ec4c9653e61accb3db25e3b2c405 (patch) | |
tree | 0325e4200547ba999678e700113902517c36175c /gcc/graph.c | |
parent | b6e5b400c3253134d0c7dd71c7976bdd0be55391 (diff) | |
download | gcc-bddb7adb4411ec4c9653e61accb3db25e3b2c405.zip gcc-bddb7adb4411ec4c9653e61accb3db25e3b2c405.tar.gz gcc-bddb7adb4411ec4c9653e61accb3db25e3b2c405.tar.bz2 |
Add dot-fn to gdbhooks.py
2016-02-22 Richard Biener <rguenther@suse.de>
Tom de Vries <tom@codesourcery.com>
* graph.c: Include dumpfile.h.
(print_graph_cfg): Split into three overloads.
* gdbhooks.py (class DotFn): Add and instantiate, adding command dot-fn.
Co-Authored-By: Tom de Vries <tom@codesourcery.com>
From-SVN: r233600
Diffstat (limited to 'gcc/graph.c')
-rw-r--r-- | gcc/graph.c | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/gcc/graph.c b/gcc/graph.c index 1b28c67..dd5bc4e 100644 --- a/gcc/graph.c +++ b/gcc/graph.c @@ -29,6 +29,7 @@ along with GCC; see the file COPYING3. If not see #include "cfganal.h" #include "cfgloop.h" #include "graph.h" +#include "dumpfile.h" /* DOT files with the .dot extension are recognized as document templates by a well-known piece of word processing software out of Redmond, WA. @@ -272,14 +273,13 @@ draw_cfg_edges (pretty_printer *pp, struct function *fun) subgraphs right for GraphViz, which requires nodes to be defined before edges to cluster nodes properly. */ -void -print_graph_cfg (const char *base, struct function *fun) +void DEBUG_FUNCTION +print_graph_cfg (FILE *fp, struct function *fun) { - const char *funcname = function_name (fun); - FILE *fp = open_graph_file (base, "a"); pretty_printer graph_slim_pp; graph_slim_pp.buffer->stream = fp; pretty_printer *const pp = &graph_slim_pp; + const char *funcname = function_name (fun); pp_printf (pp, "subgraph \"cluster_%s\" {\n" "\tstyle=\"dashed\";\n" "\tcolor=\"black\";\n" @@ -289,6 +289,30 @@ print_graph_cfg (const char *base, struct function *fun) draw_cfg_edges (pp, fun); pp_printf (pp, "}\n"); pp_flush (pp); +} + +/* Overload with additional flag argument. */ + +void DEBUG_FUNCTION +print_graph_cfg (FILE *fp, struct function *fun, int flags) +{ + int saved_dump_flags = dump_flags; + dump_flags = flags; + print_graph_cfg (fp, fun); + dump_flags = saved_dump_flags; +} + + +/* Print a graphical representation of the CFG of function FUN. + First print all basic blocks. Draw all edges at the end to get + subgraphs right for GraphViz, which requires nodes to be defined + before edges to cluster nodes properly. */ + +void +print_graph_cfg (const char *base, struct function *fun) +{ + FILE *fp = open_graph_file (base, "a"); + print_graph_cfg (fp, fun); fclose (fp); } |